Skip to main content

Module elf

Module elf 

Source
Expand description

Minimal ELF shared-object rewriter (little-endian, 32/64-bit) for andysu pack.

Renaming libfoo.so to libfoo.<hash8>.so makes the string longer, so the dynamic string table cannot be edited in place. Instead we append, at the end of the file, a new read-only PT_LOAD segment that holds a copy of the program header table (now one or two entries longer) followed by the old .dynstr plus the new names, and repoint DT_STRTAB/DT_STRSZ, DT_SONAME, DT_NEEDED, verneed vn_file, PT_PHDR and the .dynstr section header. Old string offsets stay valid because the new table starts with the old one.

Structs§

Info
Phdr

Constants§

PT_DYNAMIC
PT_LOAD
PT_PHDR

Functions§

info
rewrite
Rewrite SONAME (if soname is set) and every DT_NEEDED found in needed. Returns the input unchanged when there is nothing to do.