Skip to content

Commit 4c9110a

Browse files
atanasyantstellar
authored andcommitted
[MIPS] Recognize DT_MIPS_XHASH dynamic table tag
LLVM tools do not emit `DT_MIPS_XHASH` dynamic table tag. But now `llvm-objdump` and `llvm-readelf` recognize this tag and print it. Fixes #53996 (cherry picked from commit 3c840e3)
1 parent ce3d57a commit 4c9110a

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

llvm/include/llvm/BinaryFormat/DynamicTags.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ MIPS_DYNAMIC_TAG(MIPS_RWPLT, 0x70000034) // Points to the base
209209
// of a writable PLT.
210210
MIPS_DYNAMIC_TAG(MIPS_RLD_MAP_REL, 0x70000035) // Relative offset of run time loader
211211
// map, used for debugging.
212+
MIPS_DYNAMIC_TAG(MIPS_XHASH, 0x70000036) // GNU-style hash table with xlat.
212213

213214
// PPC specific dynamic table entries.
214215
PPC_DYNAMIC_TAG(PPC_GOT, 0x70000000) // Uses Secure PLT ABI.

llvm/test/tools/llvm-objdump/ELF/dynamic-section-machine-specific.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ ProgramHeaders:
8686
# MIPS-NEXT: MIPS_PLTGOT 0x0000000000001000
8787
# MIPS-NEXT: MIPS_RWPLT 0x0000000000001000
8888
# MIPS-NEXT: MIPS_RLD_MAP_REL 0x0000000000001000
89+
# MIPS-NEXT: MIPS_XHASH 0x0000000000002000
8990

9091
--- !ELF
9192
FileHeader:
@@ -187,6 +188,8 @@ Sections:
187188
Value: 0x1000
188189
- Tag: DT_MIPS_RLD_MAP_REL
189190
Value: 0x1000
191+
- Tag: DT_MIPS_XHASH
192+
Value: 0x2000
190193
- Tag: DT_NULL
191194
Value: 0
192195
ProgramHeaders:

llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ProgramHeaders:
5353
# RUN: llvm-readelf --dynamic-table %t.mips \
5454
# RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix=GNU-MIPS
5555

56-
# LLVM-MIPS:DynamicSection [ (47 entries)
56+
# LLVM-MIPS:DynamicSection [ (48 entries)
5757
# LLVM-MIPS-NEXT: Tag Type Name/Value
5858
# LLVM-MIPS-NEXT: 0x0000000000000004 HASH 0x1000
5959
# LLVM-MIPS-NEXT: 0x0000000070000001 MIPS_RLD_VERSION 305419896
@@ -101,10 +101,11 @@ ProgramHeaders:
101101
# LLVM-MIPS-NEXT: 0x0000000070000032 MIPS_PLTGOT 0x1000
102102
# LLVM-MIPS-NEXT: 0x0000000070000034 MIPS_RWPLT 0x1000
103103
# LLVM-MIPS-NEXT: 0x0000000070000035 MIPS_RLD_MAP_REL 0x1000
104+
# LLVM-MIPS-NEXT: 0x0000000070000036 MIPS_XHASH 0x2000
104105
# LLVM-MIPS-NEXT: 0x0000000000000000 NULL 0x0
105106
# LLVM-MIPS-NEXT:]
106107

107-
# GNU-MIPS:Dynamic section at offset {{.*}} contains 47 entries:
108+
# GNU-MIPS:Dynamic section at offset {{.*}} contains 48 entries:
108109
# GNU-MIPS-NEXT: Tag Type Name/Value
109110
# GNU-MIPS-NEXT: 0x0000000000000004 (HASH) 0x1000
110111
# GNU-MIPS-NEXT: 0x0000000070000001 (MIPS_RLD_VERSION) 305419896
@@ -152,6 +153,7 @@ ProgramHeaders:
152153
# GNU-MIPS-NEXT: 0x0000000070000032 (MIPS_PLTGOT) 0x1000
153154
# GNU-MIPS-NEXT: 0x0000000070000034 (MIPS_RWPLT) 0x1000
154155
# GNU-MIPS-NEXT: 0x0000000070000035 (MIPS_RLD_MAP_REL) 0x1000
156+
# GNU-MIPS-NEXT: 0x0000000070000036 (MIPS_XHASH) 0x2000
155157
# GNU-MIPS-NEXT: 0x0000000000000000 (NULL) 0x0
156158

157159
--- !ELF
@@ -256,6 +258,8 @@ Sections:
256258
Value: 0x1000
257259
- Tag: DT_MIPS_RLD_MAP_REL
258260
Value: 0x1000
261+
- Tag: DT_MIPS_XHASH
262+
Value: 0x2000
259263
- Tag: DT_NULL
260264
Value: 0
261265
ProgramHeaders:

llvm/test/tools/obj2yaml/ELF/dynamic-section-arch-tags.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
# MIPS-NEXT: Value: 0x2D
9898
# MIPS-NEXT: - Tag: DT_MIPS_RLD_MAP_REL
9999
# MIPS-NEXT: Value: 0x2E
100+
# MIPS-NEXT: - Tag: DT_MIPS_XHASH
101+
# MIPS-NEXT: Value: 0x2F
100102

101103
--- !ELF
102104
FileHeader:
@@ -200,6 +202,8 @@ Sections:
200202
Value: 0x000000000000002D
201203
- Tag: DT_MIPS_RLD_MAP_REL
202204
Value: 0x000000000000002E
205+
- Tag: DT_MIPS_XHASH
206+
Value: 0x000000000000002F
203207

204208
## Check we can handle Hexagon specific tags.
205209
# RUN: yaml2obj --docnum=2 %s -o %t2

llvm/tools/llvm-readobj/ELFDumper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,7 @@ std::string ELFDumper<ELFT>::getDynamicEntry(uint64_t Type,
22652265
case DT_MIPS_PLTGOT:
22662266
case DT_MIPS_RWPLT:
22672267
case DT_MIPS_RLD_MAP_REL:
2268+
case DT_MIPS_XHASH:
22682269
return FormatHexValue(Value);
22692270
case DT_MIPS_FLAGS:
22702271
return FormatFlags(Value, makeArrayRef(ElfDynamicDTMipsFlags));

0 commit comments

Comments
 (0)