Index: include/llvm/BinaryFormat/DynamicTags.def =================================================================== --- include/llvm/BinaryFormat/DynamicTags.def +++ include/llvm/BinaryFormat/DynamicTags.def @@ -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_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 @@ #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 Index: lib/ObjectYAML/ELFYAML.cpp =================================================================== --- lib/ObjectYAML/ELFYAML.cpp +++ lib/ObjectYAML/ELFYAML.cpp @@ -683,6 +683,7 @@ #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 @@ #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 @@ #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 Index: test/tools/llvm-objdump/elf-dynamic-section-machine-specific.test =================================================================== --- test/tools/llvm-objdump/elf-dynamic-section-machine-specific.test +++ test/tools/llvm-objdump/elf-dynamic-section-machine-specific.test @@ -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: 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: 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: 0x1234abcd 0x0000000000000001 +# PPC-NEXT: PPC_GOT 0x000200c0 +# PPC-NEXT: PPC_OPT 0x00000001 +# PPC-NEXT: 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: 0x1234abcd 0x0000000000000001 Index: test/tools/llvm-readobj/Inputs/elf-dynamic-tags-machine-specific.yaml =================================================================== --- test/tools/llvm-readobj/Inputs/elf-dynamic-tags-machine-specific.yaml +++ test/tools/llvm-readobj/Inputs/elf-dynamic-tags-machine-specific.yaml @@ -165,7 +165,43 @@ 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 Index: test/tools/llvm-readobj/elf-dynamic-tags-machine-specific.test =================================================================== --- test/tools/llvm-readobj/elf-dynamic-tags-machine-specific.test +++ test/tools/llvm-readobj/elf-dynamic-tags-machine-specific.test @@ -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: Tag Type Name/Value +# 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: Tag Type Name/Value +# 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 Index: test/tools/obj2yaml/dynamic-section-arch-tags.test =================================================================== --- test/tools/obj2yaml/dynamic-section-arch-tags.test +++ test/tools/obj2yaml/dynamic-section-arch-tags.test @@ -229,9 +229,33 @@ - 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 @@ 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 @@ ## 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