How is .gnu.version resolved?
Fangrui Song
i@maskray.me
Sat May 1 02:01:27 GMT 2021
On 2021-04-30, Peng Yu via Binutils wrote:
>$ readelf -W -a puts_helloworld.exe
>...
>Version symbols section '.gnu.version' contains 7 entries:
> Addr: 0x000000000000045a Offset: 0x00045a Link: 5 (.dynsym)
> 000: 0 (*local*) 0 (*local*) 2 (GLIBC_2.2.5) 2 (GLIBC_2.2.5)
> 004: 0 (*local*) 0 (*local*) 2 (GLIBC_2.2.5)
>...
>
>I see the .gnu.version above. Which contains 7 numbers 0, 0, 2, 2, 0,
>0 and 2. The 2's seems to be the numbers in the numbers in () below.
>Is it so? What do these 2's mean?
>
>$ readelf -W --dyn-syms puts_helloworld.exe
>
>Symbol table '.dynsym' contains 7 entries:
> Num: Value Size Type Bind Vis Ndx Name
> 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
> 1: 0000000000000000 0 NOTYPE WEAK DEFAULT UND
>_ITM_deregisterTMCloneTable
> 2: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@GLIBC_2.2.5 (2)
> 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND
>__libc_start_main@GLIBC_2.2.5 (2)
> 4: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
> 5: 0000000000000000 0 NOTYPE WEAK DEFAULT UND
>_ITM_registerTMCloneTable
> 6: 0000000000000000 0 FUNC WEAK DEFAULT UND
>__cxa_finalize@GLIBC_2.2.5 (2)
>
>The raw data in .gnu.version is just a bunch of uint16_t if I
>understand it correctly. How these numbers are resolved to "*local*"
>and GLIBC_2.2.5?
>
>$ readelf -x .gnu.version puts_helloworld.exe
>
>Hex dump of section '.gnu.version':
> 0x0000045a 00000000 02000200 00000000 0200 ..............
>
>
>The input file is generated as below.
>
>$ cat puts_helloworld.c
>#include <stdio.h>
>int main() {
> puts("Hello World!");
> return 0;
>}
>$ gcc -o puts_helloworld.exe puts_helloworld.c
>$ gcc --version
>gcc (Debian 10.2.1-6) 10.2.1 20210110
>Copyright (C) 2020 Free Software Foundation, Inc.
>This is free software; see the source for copying conditions. There is NO
>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
>--
>Regards,
>Peng
https://maskray.me/blog/2020-11-26-all-about-symbol-versioning#example
readelf -V
More information about the Binutils
mailing list