News for hackers. Stuff that matters.
Re:ELF files on Linux by vectorEQ on Thursday May 16, 2019 @11:13AM (#19929744)
nice article but wish people would elaborate more on relocations instead of always skipping that. it's a very important part of understanding how ELF works when it's executed.
Re:ELF files on Linux by jcranmer on Thursday May 16, 2019 @02:33PM (#19931581)
Relocations boil down to this:

A relocation entry contains a location of the patch, the symbol to use in relocation, an optional addend, and a type. The type tells you how to compute the relocation and is completely defined by the processor-specific ABI.

The simple relocations boil down to "add the addend to the address of the symbol, subtract the address of the relocation, and store it as signed N-bit number". There are more complex relocations that involve things such as symbol sizes, TLS relocations, or the GOT and the PLT.

Re:ELF files on Linux by cmrdporcupine on Thursday May 16, 2019 @12:13PM (#19930293)
Absolutely, I once wrote an ELF loader for the Atari ST (never finished, but almost), and the documentation on relocation was absolutely arcane.