简体   繁体   中英

what's .rela.plt section in executable object files?

I use static linking to produce the executable object files and I use readelf to check the file and found there is one section called: .rela.plt

the keyword 'rela' indicates that this is related to relocation. but since I use static linking, not using any shared library, so the output executable file should be a fully linked executable file, so why this file still contain relocation information?

There are two ways run-time relocations can end up in statically-linked programs.

  • The GNU toolchain supports selecting different function implementations at run time using the IFUNC mechanism . On x86-64, these show up as R_X86_64_IRELATIVE relocations.
  • Some targets support statically linked position independent executables (via -static-pie in the GNU toolchain). Since the the load address differs from program run to program due to address-space layout randomization, any global data object that contains a pointer needs to be relocated at run time. On x86-64, these relocations show up as R_X86_64_RELATIVE .

(There might be other things that need relocations in statically linked programs on more obscure targets.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM