Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linker changes symbol names when those symbols are part of glibc

I compiled code(in linux) that make use of printf and I saw that during compile (gcc -c) the symbol stays printf but when I compile and link it (gcc -o) I see that the symbol changes to [email protected]. It also happens with other symbols that are part of glibc.

Does the linker change the symbol so it will only work when linking with one version of glibc and not others?

like image 539
roy cabouly Avatar asked Oct 14 '25 18:10

roy cabouly


1 Answers

Does the linker change the symbol so it will only work when linking with one version of glibc and not others?

No.

To understand what's happening here, you need to know about GNU versioned symbols.

With very rare exceptions, GLIBC maintains backward compatibility (older programs continue to run when the version of GLIBC at runtime is the same or newer then the version against which the program was linked).

In case of [email protected], the printf ABI changed some time before 2002 (GLIBC-2.2.5 was released on 2002-01-20), and hasn't changed since. Your binary will work with any version of GLIBC released since then (for this specific symbol; you may be using other symbols that require newer GLIBC).

like image 173
Employed Russian Avatar answered Oct 17 '25 09:10

Employed Russian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!