1#! /bin/sh
2# Copyright (C) 2014 Red Hat, Inc.
3# This file is part of elfutils.
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# elfutils is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18. $srcdir/test-subr.sh
19
20# char c;
21# int i;
22# long l;
23#
24# void *v;
25#
26# struct s
27# {
28#   char *a;
29#   int i;
30# } s;
31#
32# char ca[16];
33# int ia[32];
34# void *va[64];
35# struct s sa[8];
36
37# On x86_64 (LP64):
38# gcc -g -c -o testfile-sizes1.o sizes.c
39# clang -g -c -o testfile-sizes2.o sizes.c
40
41# const char c;
42# volatile int i;
43# const volatile long l;
44#
45# void * restrict v;
46#
47# struct s
48# {
49#   const char *a;
50#   volatile int i;
51# } s;
52#
53# const char ca[16];
54# volatile int ia[32];
55# const volatile void * const volatile restrict va[64];
56# struct s sa[8];
57#
58# typedef const int foo;
59# typedef volatile foo bar;
60# foo f;
61# bar b;
62#
63# gcc -std=c99 -g -c -o testfile-sizes3.o sizes.c
64
65testfiles testfile-sizes1.o testfile-sizes2.o testfile-sizes3.o
66
67testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes1.o <<\EOF
68c size 1
69i size 4
70l size 8
71v size 8
72s size 16
73ca size 16
74ia size 128
75va size 512
76sa size 128
77EOF
78
79testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes2.o <<\EOF
80c size 1
81i size 4
82l size 8
83v size 8
84s size 16
85ca size 16
86ia size 128
87va size 512
88sa size 128
89EOF
90
91testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes3.o <<\EOF
92c size 1
93i size 4
94l size 8
95v size 8
96s size 16
97ca size 16
98ia size 128
99va size 512
100sa size 128
101f size 4
102b size 4
103EOF
104
105exit 0
106