What functions does gcc add to the linux ELF?

Most of these are various methods to execute code before or after the “main” program itself and most live in crtstuff.c ( https://github.com/gcc-mirror/gcc/blob/master/libgcc/crtstuff.c ). They exist to support features of various C-like programming languages, but they can be accessed in C as well. It perhaps seems over complicated because some of these represent legacy baggage … Read more

Why does the PLT exist in addition to the GOT, instead of just using the GOT?

The problem is that replacing call printf@PLT with call [printf@GOTPLT] requires that the compiler knows that the function printf exists in a shared library and not a static library (or even in just a plain object file). The linker can change call printf into call printf@PLT, jmp printf into jmp printf@PLT or even mov eax, … Read more

How can I get the architecture of a ‘.a’ file?

You can also skip the ar command and use readelf, via something like: readelf -h <archive>.a | grep ‘Class\|File\|Machine’ [00:32:15] /usr/lib $ readelf -h libxslt.a | grep ‘Class\|File\|Machine’ File: libxslt.a(attrvt.o) Class: ELF32 Machine: Intel 80386 File: libxslt.a(xslt.o) Class: ELF32 Machine: Intel 80386 … #Trimmed this, it goes on a bit File: libxslt.a(transform.o) Class: ELF32 Machine: … Read more

What does exactly the warning mean about hidden symbol being referenced by DSO?

What is a DSO? A DSO is a Dynamic Shared Object, or less formally a shared library. What is a hidden symbol? A hidden symbol is a symbol (i.e. name of function or data object) that has been compiled with hidden linkage, e.g. as per the (GCC specific) declaration: int x __attribute__ ((visibility (“hidden”))); If … Read more

What do R_X86_64_32S and R_X86_64_64 relocation mean?

The R_X86_64_32S and R_X86_64_64 are names of relocation types, for code compiled for the amd64 architecture. You can look all of them up in the amd64 ABI. According to it, R_X86_64_64 is broken down to: R_X86_64 – all names are prefixed with this 64 – Direct 64 bit relocation and R_X86_64_32S to: R_X86_64 – prefix … Read more

tech