1*7304104dSAndroid Build Coastguard Worker#! /bin/sh 2*7304104dSAndroid Build Coastguard Worker# Copyright (C) 2020 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# void *SYM1; 21*7304104dSAndroid Build Coastguard Worker# void *SYM2 = 0; 22*7304104dSAndroid Build Coastguard Worker# extern void *SYM3; 23*7304104dSAndroid Build Coastguard Worker# static void *SYM4; 24*7304104dSAndroid Build Coastguard Worker# 25*7304104dSAndroid Build Coastguard Worker# void *SYM6 = &SYM3; 26*7304104dSAndroid Build Coastguard Worker# static void *SYM7 = &SYM3; 27*7304104dSAndroid Build Coastguard Worker# 28*7304104dSAndroid Build Coastguard Worker# void *SYM8 __attribute__((__weak__)); 29*7304104dSAndroid Build Coastguard Worker# 30*7304104dSAndroid Build Coastguard Worker# void FUN1 (void) { } 31*7304104dSAndroid Build Coastguard Worker# static void FUN2 (void) { } 32*7304104dSAndroid Build Coastguard Worker# extern void FUN3 (void); 33*7304104dSAndroid Build Coastguard Worker# 34*7304104dSAndroid Build Coastguard Worker# void *FREF = FUN3; 35*7304104dSAndroid Build Coastguard Worker# 36*7304104dSAndroid Build Coastguard Worker# void __attribute__((__weak__)) FUN4 (void) { }; 37*7304104dSAndroid Build Coastguard Worker# 38*7304104dSAndroid Build Coastguard Worker# int NUM0 = 0; __asm__(".type NUM0,%gnu_unique_object"); 39*7304104dSAndroid Build Coastguard Worker# int __thread NUM1 = 1; 40*7304104dSAndroid Build Coastguard Worker# 41*7304104dSAndroid Build Coastguard Worker# gcc -m64 -c syms.c -o testfilesyms64 42*7304104dSAndroid Build Coastguard Worker# gcc -m32 -c syms.c -o testfilesyms32 43*7304104dSAndroid Build Coastguard Worker 44*7304104dSAndroid Build Coastguard Workertestfiles testfilesyms32 testfilesyms64 45*7304104dSAndroid Build Coastguard Worker 46*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/nm --format=bsd testfilesyms32 <<\EOF 47*7304104dSAndroid Build Coastguard Worker00000008 D FREF 48*7304104dSAndroid Build Coastguard Worker00000000 T FUN1 49*7304104dSAndroid Build Coastguard Worker00000010 t FUN2 50*7304104dSAndroid Build Coastguard Worker U FUN3 51*7304104dSAndroid Build Coastguard Worker00000020 W FUN4 52*7304104dSAndroid Build Coastguard Worker00000008 u NUM0 53*7304104dSAndroid Build Coastguard Worker00000000 D NUM1 54*7304104dSAndroid Build Coastguard Worker00000004 C SYM1 55*7304104dSAndroid Build Coastguard Worker00000000 B SYM2 56*7304104dSAndroid Build Coastguard Worker U SYM3 57*7304104dSAndroid Build Coastguard Worker0000000c b SYM4 58*7304104dSAndroid Build Coastguard Worker00000000 D SYM6 59*7304104dSAndroid Build Coastguard Worker00000004 d SYM7 60*7304104dSAndroid Build Coastguard Worker00000004 V SYM8 61*7304104dSAndroid Build Coastguard Worker U _GLOBAL_OFFSET_TABLE_ 62*7304104dSAndroid Build Coastguard Worker00000000 T __x86.get_pc_thunk.ax 63*7304104dSAndroid Build Coastguard WorkerEOF 64*7304104dSAndroid Build Coastguard Worker 65*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/nm --format=posix testfilesyms32 <<\EOF 66*7304104dSAndroid Build Coastguard WorkerFREF D 00000008 00000004 67*7304104dSAndroid Build Coastguard WorkerFUN1 T 00000000 00000010 68*7304104dSAndroid Build Coastguard WorkerFUN2 t 00000010 00000010 69*7304104dSAndroid Build Coastguard WorkerFUN3 U 70*7304104dSAndroid Build Coastguard WorkerFUN4 W 00000020 00000010 71*7304104dSAndroid Build Coastguard WorkerNUM0 u 00000008 00000004 72*7304104dSAndroid Build Coastguard WorkerNUM1 D 00000000 00000004 73*7304104dSAndroid Build Coastguard WorkerSYM1 C 00000004 00000004 74*7304104dSAndroid Build Coastguard WorkerSYM2 B 00000000 00000004 75*7304104dSAndroid Build Coastguard WorkerSYM3 U 76*7304104dSAndroid Build Coastguard WorkerSYM4 b 0000000c 00000004 77*7304104dSAndroid Build Coastguard WorkerSYM6 D 00000000 00000004 78*7304104dSAndroid Build Coastguard WorkerSYM7 d 00000004 00000004 79*7304104dSAndroid Build Coastguard WorkerSYM8 V 00000004 00000004 80*7304104dSAndroid Build Coastguard Worker_GLOBAL_OFFSET_TABLE_ U 81*7304104dSAndroid Build Coastguard Worker__x86.get_pc_thunk.ax T 00000000 00000000 82*7304104dSAndroid Build Coastguard WorkerEOF 83*7304104dSAndroid Build Coastguard Worker 84*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/nm --format=sysv testfilesyms32 <<\EOF 85*7304104dSAndroid Build Coastguard Worker 86*7304104dSAndroid Build Coastguard Worker 87*7304104dSAndroid Build Coastguard WorkerSymbols from testfilesyms32: 88*7304104dSAndroid Build Coastguard Worker 89*7304104dSAndroid Build Coastguard WorkerName Value Class Type Size Line Section 90*7304104dSAndroid Build Coastguard Worker 91*7304104dSAndroid Build Coastguard WorkerFREF |00000008|GLOBAL|OBJECT |00000004| |.data.rel 92*7304104dSAndroid Build Coastguard WorkerFUN1 |00000000|GLOBAL|FUNC |00000010| |.text 93*7304104dSAndroid Build Coastguard WorkerFUN2 |00000010|LOCAL |FUNC |00000010| |.text 94*7304104dSAndroid Build Coastguard WorkerFUN3 | |GLOBAL|NOTYPE | | |UNDEF 95*7304104dSAndroid Build Coastguard WorkerFUN4 |00000020|WEAK |FUNC |00000010| |.text 96*7304104dSAndroid Build Coastguard WorkerNUM0 |00000008|UNIQUE|OBJECT |00000004| |.bss 97*7304104dSAndroid Build Coastguard WorkerNUM1 |00000000|GLOBAL|TLS |00000004| |.tdata 98*7304104dSAndroid Build Coastguard WorkerSYM1 |00000004|GLOBAL|OBJECT |00000004| |COMMON 99*7304104dSAndroid Build Coastguard WorkerSYM2 |00000000|GLOBAL|OBJECT |00000004| |.bss 100*7304104dSAndroid Build Coastguard WorkerSYM3 | |GLOBAL|NOTYPE | | |UNDEF 101*7304104dSAndroid Build Coastguard WorkerSYM4 |0000000c|LOCAL |OBJECT |00000004| |.bss 102*7304104dSAndroid Build Coastguard WorkerSYM6 |00000000|GLOBAL|OBJECT |00000004| |.data.rel 103*7304104dSAndroid Build Coastguard WorkerSYM7 |00000004|LOCAL |OBJECT |00000004| |.data.rel 104*7304104dSAndroid Build Coastguard WorkerSYM8 |00000004|WEAK |OBJECT |00000004| |.bss 105*7304104dSAndroid Build Coastguard Worker_GLOBAL_OFFSET_TABLE_| |GLOBAL|NOTYPE | | |UNDEF 106*7304104dSAndroid Build Coastguard Worker__x86.get_pc_thunk.ax|00000000|GLOBAL|FUNC |00000000| |.text.__x86.get_pc_thunk.ax 107*7304104dSAndroid Build Coastguard WorkerEOF 108*7304104dSAndroid Build Coastguard Worker 109*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/nm --format=bsd testfilesyms64 <<\EOF 110*7304104dSAndroid Build Coastguard Worker0000000000000010 D FREF 111*7304104dSAndroid Build Coastguard Worker0000000000000000 T FUN1 112*7304104dSAndroid Build Coastguard Worker0000000000000007 t FUN2 113*7304104dSAndroid Build Coastguard Worker U FUN3 114*7304104dSAndroid Build Coastguard Worker000000000000000e W FUN4 115*7304104dSAndroid Build Coastguard Worker0000000000000010 u NUM0 116*7304104dSAndroid Build Coastguard Worker0000000000000000 D NUM1 117*7304104dSAndroid Build Coastguard Worker0000000000000008 C SYM1 118*7304104dSAndroid Build Coastguard Worker0000000000000000 B SYM2 119*7304104dSAndroid Build Coastguard Worker U SYM3 120*7304104dSAndroid Build Coastguard Worker0000000000000018 b SYM4 121*7304104dSAndroid Build Coastguard Worker0000000000000000 D SYM6 122*7304104dSAndroid Build Coastguard Worker0000000000000008 d SYM7 123*7304104dSAndroid Build Coastguard Worker0000000000000008 V SYM8 124*7304104dSAndroid Build Coastguard WorkerEOF 125*7304104dSAndroid Build Coastguard Worker 126*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/nm --format=posix testfilesyms64 <<\EOF 127*7304104dSAndroid Build Coastguard WorkerFREF D 0000000000000010 0000000000000008 128*7304104dSAndroid Build Coastguard WorkerFUN1 T 0000000000000000 0000000000000007 129*7304104dSAndroid Build Coastguard WorkerFUN2 t 0000000000000007 0000000000000007 130*7304104dSAndroid Build Coastguard WorkerFUN3 U 131*7304104dSAndroid Build Coastguard WorkerFUN4 W 000000000000000e 0000000000000007 132*7304104dSAndroid Build Coastguard WorkerNUM0 u 0000000000000010 0000000000000004 133*7304104dSAndroid Build Coastguard WorkerNUM1 D 0000000000000000 0000000000000004 134*7304104dSAndroid Build Coastguard WorkerSYM1 C 0000000000000008 0000000000000008 135*7304104dSAndroid Build Coastguard WorkerSYM2 B 0000000000000000 0000000000000008 136*7304104dSAndroid Build Coastguard WorkerSYM3 U 137*7304104dSAndroid Build Coastguard WorkerSYM4 b 0000000000000018 0000000000000008 138*7304104dSAndroid Build Coastguard WorkerSYM6 D 0000000000000000 0000000000000008 139*7304104dSAndroid Build Coastguard WorkerSYM7 d 0000000000000008 0000000000000008 140*7304104dSAndroid Build Coastguard WorkerSYM8 V 0000000000000008 0000000000000008 141*7304104dSAndroid Build Coastguard WorkerEOF 142*7304104dSAndroid Build Coastguard Worker 143*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_top_builddir}/src/nm --format=sysv testfilesyms64 <<\EOF 144*7304104dSAndroid Build Coastguard Worker 145*7304104dSAndroid Build Coastguard Worker 146*7304104dSAndroid Build Coastguard WorkerSymbols from testfilesyms64: 147*7304104dSAndroid Build Coastguard Worker 148*7304104dSAndroid Build Coastguard WorkerName Value Class Type Size Line Section 149*7304104dSAndroid Build Coastguard Worker 150*7304104dSAndroid Build Coastguard WorkerFREF |0000000000000010|GLOBAL|OBJECT |0000000000000008| |.data.rel 151*7304104dSAndroid Build Coastguard WorkerFUN1 |0000000000000000|GLOBAL|FUNC |0000000000000007| |.text 152*7304104dSAndroid Build Coastguard WorkerFUN2 |0000000000000007|LOCAL |FUNC |0000000000000007| |.text 153*7304104dSAndroid Build Coastguard WorkerFUN3 | |GLOBAL|NOTYPE | | |UNDEF 154*7304104dSAndroid Build Coastguard WorkerFUN4 |000000000000000e|WEAK |FUNC |0000000000000007| |.text 155*7304104dSAndroid Build Coastguard WorkerNUM0 |0000000000000010|UNIQUE|OBJECT |0000000000000004| |.bss 156*7304104dSAndroid Build Coastguard WorkerNUM1 |0000000000000000|GLOBAL|TLS |0000000000000004| |.tdata 157*7304104dSAndroid Build Coastguard WorkerSYM1 |0000000000000008|GLOBAL|OBJECT |0000000000000008| |COMMON 158*7304104dSAndroid Build Coastguard WorkerSYM2 |0000000000000000|GLOBAL|OBJECT |0000000000000008| |.bss 159*7304104dSAndroid Build Coastguard WorkerSYM3 | |GLOBAL|NOTYPE | | |UNDEF 160*7304104dSAndroid Build Coastguard WorkerSYM4 |0000000000000018|LOCAL |OBJECT |0000000000000008| |.bss 161*7304104dSAndroid Build Coastguard WorkerSYM6 |0000000000000000|GLOBAL|OBJECT |0000000000000008| |.data.rel 162*7304104dSAndroid Build Coastguard WorkerSYM7 |0000000000000008|LOCAL |OBJECT |0000000000000008| |.data.rel 163*7304104dSAndroid Build Coastguard WorkerSYM8 |0000000000000008|WEAK |OBJECT |0000000000000008| |.bss 164*7304104dSAndroid Build Coastguard WorkerEOF 165*7304104dSAndroid Build Coastguard Worker 166*7304104dSAndroid Build Coastguard Workerexit 0 167