forked from OSchip/llvm-project
[llvm-objdump/llvm-readobj/obj2yaml/yaml2obj] Support DT_PPC_GOT and DT_PPC_OPT
In glibc, DT_PPC_GOT indicates that PowerPC32 Secure PLT ABI is used. I plan to use it in D62464. DT_PPC_OPT currently indicates if a TLSDESC inspired TLS optimization is enabled. Reviewed By: grimar, jhenderson, rupprecht Differential Revision: https://reviews.llvm.org/D62851 llvm-svn: 362569
This commit is contained in:
parent
fe97754acf
commit
f090e6f7b6
|
@ -21,6 +21,11 @@
|
|||
#define MIPS_DYNAMIC_TAG_DEFINED
|
||||
#endif
|
||||
|
||||
#ifndef PPC_DYNAMIC_TAG
|
||||
#define PPC_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
|
||||
#define PPC_DYNAMIC_TAG_DEFINED
|
||||
#endif
|
||||
|
||||
#ifndef PPC64_DYNAMIC_TAG
|
||||
#define PPC64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
|
||||
#define PPC64_DYNAMIC_TAG_DEFINED
|
||||
|
@ -199,6 +204,10 @@ MIPS_DYNAMIC_TAG(MIPS_RWPLT, 0x70000034) // Points to the base
|
|||
MIPS_DYNAMIC_TAG(MIPS_RLD_MAP_REL, 0x70000035) // Relative offset of run time loader
|
||||
// map, used for debugging.
|
||||
|
||||
// PPC specific dynamic table entries.
|
||||
PPC_DYNAMIC_TAG(PPC_GOT, 0x70000000) // Uses Secure PLT ABI.
|
||||
PPC_DYNAMIC_TAG(PPC_OPT, 0x70000001) // Has TLS optimization.
|
||||
|
||||
// PPC64 specific dynamic table entries.
|
||||
PPC64_DYNAMIC_TAG(PPC64_GLINK, 0x70000000) // Address of 32 bytes before the
|
||||
// first glink lazy resolver stub.
|
||||
|
@ -225,6 +234,10 @@ DYNAMIC_TAG(FILTER, 0x7FFFFFFF) // Shared object to get values from
|
|||
#undef HEXAGON_DYNAMIC_TAG
|
||||
#undef HEXAGON_DYNAMIC_TAG_DEFINED
|
||||
#endif
|
||||
#ifdef PPC_DYNAMIC_TAG_DEFINED
|
||||
#undef PPC_DYNAMIC_TAG
|
||||
#undef PPC_DYNAMIC_TAG_DEFINED
|
||||
#endif
|
||||
#ifdef PPC64_DYNAMIC_TAG_DEFINED
|
||||
#undef PPC64_DYNAMIC_TAG
|
||||
#undef PPC64_DYNAMIC_TAG_DEFINED
|
||||
|
|
|
@ -683,6 +683,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG>::enumeration(
|
|||
#define AARCH64_DYNAMIC_TAG(name, value)
|
||||
#define MIPS_DYNAMIC_TAG(name, value)
|
||||
#define HEXAGON_DYNAMIC_TAG(name, value)
|
||||
#define PPC_DYNAMIC_TAG(name, value)
|
||||
#define PPC64_DYNAMIC_TAG(name, value)
|
||||
// Ignore marker tags such as DT_HIOS (maps to DT_VERNEEDNUM), etc.
|
||||
#define DYNAMIC_TAG_MARKER(name, value)
|
||||
|
@ -711,6 +712,13 @@ void ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG>::enumeration(
|
|||
#undef HEXAGON_DYNAMIC_TAG
|
||||
#define HEXAGON_DYNAMIC_TAG(name, value)
|
||||
break;
|
||||
case ELF::EM_PPC:
|
||||
#undef PPC_DYNAMIC_TAG
|
||||
#define PPC_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
|
||||
#include "llvm/BinaryFormat/DynamicTags.def"
|
||||
#undef PPC_DYNAMIC_TAG
|
||||
#define PPC_DYNAMIC_TAG(name, value)
|
||||
break;
|
||||
case ELF::EM_PPC64:
|
||||
#undef PPC64_DYNAMIC_TAG
|
||||
#define PPC64_DYNAMIC_TAG(name, value) DYNAMIC_TAG(name, value)
|
||||
|
@ -725,6 +733,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_DYNTAG>::enumeration(
|
|||
#undef AARCH64_DYNAMIC_TAG
|
||||
#undef MIPS_DYNAMIC_TAG
|
||||
#undef HEXAGON_DYNAMIC_TAG
|
||||
#undef PPC_DYNAMIC_TAG
|
||||
#undef PPC64_DYNAMIC_TAG
|
||||
#undef DYNAMIC_TAG_MARKER
|
||||
#undef STRINGIFY
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Test that hexagon machine-specific tags can be dumped.
|
||||
## Test that hexagon machine-specific tags can be dumped.
|
||||
# RUN: yaml2obj --docnum=1 -o %t.hex \
|
||||
# RUN: %S/../llvm-readobj/Inputs/elf-dynamic-tags-machine-specific.yaml
|
||||
# RUN: llvm-objdump -p %t.hex | FileCheck %s --check-prefix=HEXAGON
|
||||
|
@ -11,7 +11,7 @@
|
|||
# HEXAGON-NEXT: <unknown:>0x1234abcd 0x0000000000000001
|
||||
|
||||
|
||||
# Test that MIPS machine-specific tags can be dumped.
|
||||
## Test that MIPS machine-specific tags can be dumped.
|
||||
# RUN: yaml2obj --docnum=2 -o %t.mips \
|
||||
# RUN: %S/../llvm-readobj/Inputs/elf-dynamic-tags-machine-specific.yaml
|
||||
# RUN: llvm-objdump -p %t.mips | FileCheck %s --check-prefix=MIPS
|
||||
|
@ -66,12 +66,23 @@
|
|||
# MIPS-NEXT: <unknown:>0x1234abcd 0x0000000000000001
|
||||
|
||||
|
||||
# Test that PPC64 machine-specific tags can be dumped.
|
||||
## Test that PPC machine-specific tags can be dumped.
|
||||
# RUN: yaml2obj --docnum=3 -o %t.ppc \
|
||||
# RUN: %S/../llvm-readobj/Inputs/elf-dynamic-tags-machine-specific.yaml
|
||||
# RUN: llvm-objdump -p %t.ppc | FileCheck %s --check-prefix=PPC
|
||||
|
||||
# PPC: Dynamic Section:
|
||||
# PPC-NEXT: HASH 0x0000000000001000
|
||||
# PPC-NEXT: PPC64_GLINK 0x0000000000001000
|
||||
# PPC-NEXT: <unknown:>0x1234abcd 0x0000000000000001
|
||||
# PPC-NEXT: PPC_GOT 0x000200c0
|
||||
# PPC-NEXT: PPC_OPT 0x00000001
|
||||
# PPC-NEXT: <unknown:>0x1234abcd 0x00000001
|
||||
|
||||
|
||||
## Test that PPC64 machine-specific tags can be dumped.
|
||||
# RUN: yaml2obj --docnum=4 -o %t.ppc64 \
|
||||
# RUN: %S/../llvm-readobj/Inputs/elf-dynamic-tags-machine-specific.yaml
|
||||
# RUN: llvm-objdump -p %t.ppc64 | FileCheck %s --check-prefix=PPC64
|
||||
|
||||
# PPC64: Dynamic Section:
|
||||
# PPC64-NEXT: HASH 0x0000000000001000
|
||||
# PPC64-NEXT: PPC64_GLINK 0x0000000000001000
|
||||
# PPC64-NEXT: <unknown:>0x1234abcd 0x0000000000000001
|
||||
|
|
|
@ -165,7 +165,43 @@ ProgramHeaders:
|
|||
Sections:
|
||||
- Section: .dynamic
|
||||
|
||||
# Third document: PPC64
|
||||
# Third document: PPC
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS32
|
||||
Data: ELFDATA2MSB
|
||||
Type: ET_EXEC
|
||||
Machine: EM_PPC
|
||||
Sections:
|
||||
- Name: .dynstr
|
||||
Type: SHT_STRTAB
|
||||
Address: 0x200
|
||||
Size: 0x10
|
||||
Content: "004400550066007700"
|
||||
- Name: .dynamic
|
||||
Type: SHT_DYNAMIC
|
||||
Address: 0x20000
|
||||
Entries:
|
||||
- Tag: DT_PPC_GOT
|
||||
Value: 0x200c0
|
||||
- Tag: DT_PPC_OPT
|
||||
Value: 1
|
||||
- Tag: 0x1234abcd
|
||||
Value: 0x1
|
||||
- Tag: DT_NULL
|
||||
Value: 0
|
||||
ProgramHeaders:
|
||||
- Type: PT_LOAD
|
||||
VAddr: 0x1000
|
||||
Sections:
|
||||
- Section: .dynstr
|
||||
- Section: .dynamic
|
||||
- Type: PT_DYNAMIC
|
||||
VAddr: 0x20000
|
||||
Sections:
|
||||
- Section: .dynamic
|
||||
|
||||
# Fourth document: PPC64
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS64
|
||||
|
|
|
@ -132,28 +132,49 @@
|
|||
# GNU-MIPS-NEXT: 0x0000000000000000 (NULL) 0x0
|
||||
|
||||
|
||||
# Test that PPC64 machine-specific tags can be dumped.
|
||||
# Test that PPC machine-specific tags can be dumped.
|
||||
# RUN: yaml2obj --docnum=3 %S/Inputs/elf-dynamic-tags-machine-specific.yaml -o %t.ppc
|
||||
# RUN: llvm-readobj --dynamic-table %t.ppc | FileCheck %s --check-prefix=LLVM-PPC
|
||||
# RUN: llvm-readelf --dynamic-table %t.ppc | FileCheck %s --check-prefix=GNU-PPC
|
||||
|
||||
# LLVM-PPC: DynamicSection [ (4 entries)
|
||||
# LLVM-PPC-NEXT: Tag Type Name/Value
|
||||
# LLVM-PPC-NEXT: 0x0000000000000004 HASH 0x1000
|
||||
# LLVM-PPC-NEXT: 0x0000000070000000 PPC64_GLINK 0x1000
|
||||
# LLVM-PPC-NEXT: 0x000000001234ABCD unknown 0x1
|
||||
# LLVM-PPC-NEXT: 0x0000000000000000 NULL 0x0
|
||||
# LLVM-PPC-NEXT: 0x70000000 PPC_GOT 0x200C0
|
||||
# LLVM-PPC-NEXT: 0x70000001 PPC_OPT 0x1
|
||||
# LLVM-PPC-NEXT: 0x1234ABCD unknown 0x1
|
||||
# LLVM-PPC-NEXT: 0x00000000 NULL 0x0
|
||||
# LLVM-PPC-NEXT: ]
|
||||
|
||||
# GNU-PPC: Dynamic section at offset {{.*}} contains 4 entries:
|
||||
# GNU-PPC-NEXT: Tag Type Name/Value
|
||||
# GNU-PPC-NEXT: 0x0000000000000004 (HASH) 0x1000
|
||||
# GNU-PPC-NEXT: 0x0000000070000000 (PPC64_GLINK) 0x1000
|
||||
# GNU-PPC-NEXT: 0x000000001234abcd (unknown) 0x1
|
||||
# GNU-PPC-NEXT: 0x0000000000000000 (NULL) 0x0
|
||||
# GNU-PPC-NEXT: 0x70000000 (PPC_GOT) 0x200c0
|
||||
# GNU-PPC-NEXT: 0x70000001 (PPC_OPT) 0x1
|
||||
# GNU-PPC-NEXT: 0x1234abcd (unknown) 0x1
|
||||
# GNU-PPC-NEXT: 0x00000000 (NULL) 0x0
|
||||
|
||||
|
||||
# Test that PPC64 machine-specific tags can be dumped.
|
||||
# RUN: yaml2obj --docnum=4 %S/Inputs/elf-dynamic-tags-machine-specific.yaml -o %t.ppc64
|
||||
# RUN: llvm-readobj --dynamic-table %t.ppc64 | FileCheck %s --check-prefix=LLVM-PPC64
|
||||
# RUN: llvm-readelf --dynamic-table %t.ppc64 | FileCheck %s --check-prefix=GNU-PPC64
|
||||
|
||||
# LLVM-PPC64: DynamicSection [ (4 entries)
|
||||
# LLVM-PPC64-NEXT: Tag Type Name/Value
|
||||
# LLVM-PPC64-NEXT: 0x0000000000000004 HASH 0x1000
|
||||
# LLVM-PPC64-NEXT: 0x0000000070000000 PPC64_GLINK 0x1000
|
||||
# LLVM-PPC64-NEXT: 0x000000001234ABCD unknown 0x1
|
||||
# LLVM-PPC64-NEXT: 0x0000000000000000 NULL 0x0
|
||||
# LLVM-PPC64-NEXT: ]
|
||||
|
||||
# GNU-PPC64: Dynamic section at offset {{.*}} contains 4 entries:
|
||||
# GNU-PPC64-NEXT: Tag Type Name/Value
|
||||
# GNU-PPC64-NEXT: 0x0000000000000004 (HASH) 0x1000
|
||||
# GNU-PPC64-NEXT: 0x0000000070000000 (PPC64_GLINK) 0x1000
|
||||
# GNU-PPC64-NEXT: 0x000000001234abcd (unknown) 0x1
|
||||
# GNU-PPC64-NEXT: 0x0000000000000000 (NULL) 0x0
|
||||
|
||||
# Test that AARCH64 machine-specific tags can be dumped.
|
||||
# RUN: yaml2obj --docnum=4 %S/Inputs/elf-dynamic-tags-machine-specific.yaml -o %t.aarch64
|
||||
# RUN: yaml2obj --docnum=5 %S/Inputs/elf-dynamic-tags-machine-specific.yaml -o %t.aarch64
|
||||
# RUN: llvm-readobj --dynamic-table %t.aarch64 | FileCheck %s --check-prefix=LLVM-AARCH64
|
||||
# RUN: llvm-readelf --dynamic-table %t.aarch64 | FileCheck %s --check-prefix=GNU-AARCH64
|
||||
|
||||
|
|
|
@ -229,9 +229,33 @@ Sections:
|
|||
- Tag: DT_HEXAGON_PLT
|
||||
Value: 0x0000000000000003
|
||||
|
||||
## Check we can handle PPC64 specific tags.
|
||||
## Check we can handle PPC specific tags.
|
||||
# RUN: yaml2obj -docnum=3 %s -o %t3
|
||||
# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=EM_PPC64
|
||||
# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=EM_PPC
|
||||
|
||||
# EM_PPC: - Tag: DT_PPC_GOT
|
||||
# EM_PPC-NEXT: Value: 0x0000000000020000
|
||||
# EM_PPC-NEXT: - Tag: DT_PPC_OPT
|
||||
# EM_PPC-NEXT: Value: 0x0000000000000001
|
||||
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS32
|
||||
Data: ELFDATA2MSB
|
||||
Type: ET_REL
|
||||
Machine: EM_PPC
|
||||
Sections:
|
||||
- Name: .dynamic
|
||||
Type: SHT_DYNAMIC
|
||||
Entries:
|
||||
- Tag: DT_PPC_GOT
|
||||
Value: 0x0000000000020000
|
||||
- Tag: DT_PPC_OPT
|
||||
Value: 0x0000000000000001
|
||||
|
||||
## Check we can handle PPC64 specific tags.
|
||||
# RUN: yaml2obj -docnum=4 %s -o %t4
|
||||
# RUN: obj2yaml %t4 | FileCheck %s --check-prefix=EM_PPC64
|
||||
|
||||
# EM_PPC64: - Tag: DT_PPC64_GLINK
|
||||
# EM_PPC64-NEXT: Value: 0x0000000000000001
|
||||
|
@ -250,7 +274,7 @@ Sections:
|
|||
Value: 0x0000000000000001
|
||||
|
||||
## Check we can handle AARCH64 specific tags.
|
||||
# RUN: yaml2obj -docnum=4 %s -o %t2
|
||||
# RUN: yaml2obj -docnum=5 %s -o %t2
|
||||
# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=AARCH64
|
||||
|
||||
# AARCH64: - Tag: DT_AARCH64_BTI_PLT
|
||||
|
@ -278,7 +302,7 @@ Sections:
|
|||
## Here for EM_PPC64 we are trying to use DT_HEXAGON_SYMSZ
|
||||
## instead of DT_PPC64_GLINK. They both have value of 0x70000000.
|
||||
|
||||
# RUN: not yaml2obj -docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERR
|
||||
# RUN: not yaml2obj -docnum=6 %s 2>&1 | FileCheck %s --check-prefix=ERR
|
||||
# ERR: error: invalid hex64 number
|
||||
# ERR-NEXT: - Tag: DT_HEXAGON_SYMSZ
|
||||
|
||||
|
|
Loading…
Reference in New Issue