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