Skip to content

patchelf.cc: add comment explaining calculation for DT_MIPS_RLD_MAP_REL #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Jun 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/patchelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,16 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress)
pointer, relative to the address of the tag */
auto shdr = tryFindSectionHeader(".rld_map");
if (shdr) {
/*
* "When correct, (DT_MIPS_RLD_MAP_REL + tag offset + executable base address) equals DT_MIPS_RLD_MAP"
* -- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820334#5
*
* Equivalently,
*
* DT_MIPS_RLD_MAP_REL + tag offset + executable base address == DT_MIPS_RLD_MAP
* DT_MIPS_RLD_MAP_REL + executable base address == DT_MIPS_RLD_MAP - tag_offset
* DT_MIPS_RLD_MAP_REL == DT_MIPS_RLD_MAP - tag_offset - executable base address
*/
auto rld_map_addr = findSectionHeader(".rld_map").sh_addr;
auto dyn_offset = ((char*)dyn) - ((char*)dyn_table);
dyn->d_un.d_ptr = rld_map_addr - dyn_offset - (*shdrDynamic).get().sh_addr;
Expand Down