Skip to content

Commit

Permalink
Merge pull request #380 from amjoseph-nixpkgs/pr/close/368
Browse files Browse the repository at this point in the history
patchelf.cc: handle DT_MIPS_XHASH and .MIPS.xhash
  • Loading branch information
Mic92 authored Jun 29, 2022
2 parents a8dcbc9 + 7b155fd commit 734daa3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,7 @@ typedef struct
#define SHT_MIPS_EH_REGION 0x70000027
#define SHT_MIPS_XLATE_OLD 0x70000028
#define SHT_MIPS_PDR_EXCEPTION 0x70000029
#define SHT_MIPS_XHASH 0x7000002b

/* Legal values for sh_flags field of Elf32_Shdr. */

Expand Down Expand Up @@ -1647,7 +1648,9 @@ typedef struct
in a PIE as it stores a relative offset from the address of the tag
rather than an absolute address. */
#define DT_MIPS_RLD_MAP_REL 0x70000035
#define DT_MIPS_NUM 0x36
/* GNU-style hash table with xlat. */
#define DT_MIPS_XHASH 0x70000036
#define DT_MIPS_NUM 0x37

/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */

Expand Down
4 changes: 4 additions & 0 deletions src/patchelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,10 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress)
// some binaries might this section stripped
// in which case we just ignore the value.
if (shdr) dyn->d_un.d_ptr = (*shdr).get().sh_addr;
} else if (d_tag == DT_MIPS_XHASH) {
// the .MIPS.xhash section was added to the glibc-ABI
// in commit 23c1c256ae7b0f010d0fcaff60682b620887b164
dyn->d_un.d_ptr = findSectionHeader(".MIPS.xhash").sh_addr;
} else if (d_tag == DT_JMPREL) {
auto shdr = tryFindSectionHeader(".rel.plt");
if (!shdr) shdr = tryFindSectionHeader(".rela.plt");
Expand Down

0 comments on commit 734daa3

Please sign in to comment.