Skip to content

Commit 734daa3

Browse files
authored
Merge pull request NixOS#380 from amjoseph-nixpkgs/pr/close/368
patchelf.cc: handle DT_MIPS_XHASH and .MIPS.xhash
2 parents a8dcbc9 + 7b155fd commit 734daa3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/elf.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,7 @@ typedef struct
14001400
#define SHT_MIPS_EH_REGION 0x70000027
14011401
#define SHT_MIPS_XLATE_OLD 0x70000028
14021402
#define SHT_MIPS_PDR_EXCEPTION 0x70000029
1403+
#define SHT_MIPS_XHASH 0x7000002b
14031404

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

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

16521655
/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
16531656

src/patchelf.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,10 @@ void ElfFile<ElfFileParamNames>::rewriteHeaders(Elf_Addr phdrAddress)
996996
// some binaries might this section stripped
997997
// in which case we just ignore the value.
998998
if (shdr) dyn->d_un.d_ptr = (*shdr).get().sh_addr;
999+
} else if (d_tag == DT_MIPS_XHASH) {
1000+
// the .MIPS.xhash section was added to the glibc-ABI
1001+
// in commit 23c1c256ae7b0f010d0fcaff60682b620887b164
1002+
dyn->d_un.d_ptr = findSectionHeader(".MIPS.xhash").sh_addr;
9991003
} else if (d_tag == DT_JMPREL) {
10001004
auto shdr = tryFindSectionHeader(".rel.plt");
10011005
if (!shdr) shdr = tryFindSectionHeader(".rela.plt");

0 commit comments

Comments
 (0)