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# double d3d[3][4][5];
58#
59# typedef const int foo;
60# typedef volatile foo bar;
61# foo f;
62# bar b;
63#
64# gcc -std=c99 -g -c -o testfile-sizes3.o sizes.c
65
66# The file testfile-size4.o is hand-crafted.
67
68testfiles testfile-sizes1.o testfile-sizes2.o testfile-sizes3.o testfile-sizes4.o
69
70testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes1.o <<\EOF
71c size 1
72i size 4
73l size 8
74v size 8
75s size 16
76ca size 16
77ia size 128
78va size 512
79sa size 128
80EOF
81
82testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes2.o <<\EOF
83c size 1
84i size 4
85l size 8
86v size 8
87s size 16
88ca size 16
89ia size 128
90va size 512
91sa size 128
92EOF
93
94testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes3.o <<\EOF
95c size 1
96i size 4
97l size 8
98v size 8
99s size 16
100ca size 16
101ia size 128
102va size 512
103sa size 128
104d3d size 480
105f size 4
106b size 4
107EOF
108
109testrun_compare ${abs_builddir}/aggregate_size -e testfile-sizes4.o <<\EOF
110v size 257
111EOF
112
113exit 0
114