[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 https://github.com/llvm/llvm-project/issues/53996
This commit is contained in:
Simon Atanasyan 2022-02-23 15:53:41 +03:00
parent 8ad6d5e465
commit 3c840e3c00
5 changed files with 15 additions and 2 deletions

View File

@ -209,6 +209,7 @@ MIPS_DYNAMIC_TAG(MIPS_RWPLT, 0x70000034) // Points to the base
// of a writable PLT.
MIPS_DYNAMIC_TAG(MIPS_RLD_MAP_REL, 0x70000035) // Relative offset of run time loader
// map, used for debugging.
MIPS_DYNAMIC_TAG(MIPS_XHASH, 0x70000036) // GNU-style hash table with xlat.
// PPC specific dynamic table entries.
PPC_DYNAMIC_TAG(PPC_GOT, 0x70000000) // Uses Secure PLT ABI.

View File

@ -86,6 +86,7 @@ ProgramHeaders:
# MIPS-NEXT: MIPS_PLTGOT 0x0000000000001000
# MIPS-NEXT: MIPS_RWPLT 0x0000000000001000
# MIPS-NEXT: MIPS_RLD_MAP_REL 0x0000000000001000
# MIPS-NEXT: MIPS_XHASH 0x0000000000002000
--- !ELF
FileHeader:
@ -187,6 +188,8 @@ Sections:
Value: 0x1000
- Tag: DT_MIPS_RLD_MAP_REL
Value: 0x1000
- Tag: DT_MIPS_XHASH
Value: 0x2000
- Tag: DT_NULL
Value: 0
ProgramHeaders:

View File

@ -53,7 +53,7 @@ ProgramHeaders:
# RUN: llvm-readelf --dynamic-table %t.mips \
# RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix=GNU-MIPS
# LLVM-MIPS:DynamicSection [ (47 entries)
# LLVM-MIPS:DynamicSection [ (48 entries)
# LLVM-MIPS-NEXT: Tag Type Name/Value
# LLVM-MIPS-NEXT: 0x0000000000000004 HASH 0x1000
# LLVM-MIPS-NEXT: 0x0000000070000001 MIPS_RLD_VERSION 305419896
@ -101,10 +101,11 @@ ProgramHeaders:
# LLVM-MIPS-NEXT: 0x0000000070000032 MIPS_PLTGOT 0x1000
# LLVM-MIPS-NEXT: 0x0000000070000034 MIPS_RWPLT 0x1000
# LLVM-MIPS-NEXT: 0x0000000070000035 MIPS_RLD_MAP_REL 0x1000
# LLVM-MIPS-NEXT: 0x0000000070000036 MIPS_XHASH 0x2000
# LLVM-MIPS-NEXT: 0x0000000000000000 NULL 0x0
# LLVM-MIPS-NEXT:]
# GNU-MIPS:Dynamic section at offset {{.*}} contains 47 entries:
# GNU-MIPS:Dynamic section at offset {{.*}} contains 48 entries:
# GNU-MIPS-NEXT: Tag Type Name/Value
# GNU-MIPS-NEXT: 0x0000000000000004 (HASH) 0x1000
# GNU-MIPS-NEXT: 0x0000000070000001 (MIPS_RLD_VERSION) 305419896
@ -152,6 +153,7 @@ ProgramHeaders:
# GNU-MIPS-NEXT: 0x0000000070000032 (MIPS_PLTGOT) 0x1000
# GNU-MIPS-NEXT: 0x0000000070000034 (MIPS_RWPLT) 0x1000
# GNU-MIPS-NEXT: 0x0000000070000035 (MIPS_RLD_MAP_REL) 0x1000
# GNU-MIPS-NEXT: 0x0000000070000036 (MIPS_XHASH) 0x2000
# GNU-MIPS-NEXT: 0x0000000000000000 (NULL) 0x0
--- !ELF
@ -256,6 +258,8 @@ Sections:
Value: 0x1000
- Tag: DT_MIPS_RLD_MAP_REL
Value: 0x1000
- Tag: DT_MIPS_XHASH
Value: 0x2000
- Tag: DT_NULL
Value: 0
ProgramHeaders:

View File

@ -97,6 +97,8 @@
# MIPS-NEXT: Value: 0x2D
# MIPS-NEXT: - Tag: DT_MIPS_RLD_MAP_REL
# MIPS-NEXT: Value: 0x2E
# MIPS-NEXT: - Tag: DT_MIPS_XHASH
# MIPS-NEXT: Value: 0x2F
--- !ELF
FileHeader:
@ -200,6 +202,8 @@ Sections:
Value: 0x000000000000002D
- Tag: DT_MIPS_RLD_MAP_REL
Value: 0x000000000000002E
- Tag: DT_MIPS_XHASH
Value: 0x000000000000002F
## Check we can handle Hexagon specific tags.
# RUN: yaml2obj --docnum=2 %s -o %t2

View File

@ -2266,6 +2266,7 @@ std::string ELFDumper<ELFT>::getDynamicEntry(uint64_t Type,
case DT_MIPS_PLTGOT:
case DT_MIPS_RWPLT:
case DT_MIPS_RLD_MAP_REL:
case DT_MIPS_XHASH:
return FormatHexValue(Value);
case DT_MIPS_FLAGS:
return FormatFlags(Value, makeArrayRef(ElfDynamicDTMipsFlags));