llvm.org GIT mirror llvm / 9baa291
ELF: Add AMDGPU specific defintions Reviewers: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11458 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244303 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 5 years ago
4 changed file(s) with 71 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
746746 SHF_MIPS_ADDR = 0x40000000,
747747
748748 // Section data is string data by default.
749 SHF_MIPS_STRING = 0x80000000
749 SHF_MIPS_STRING = 0x80000000,
750
751 SHF_AMDGPU_HSA_GLOBAL = 0x00100000,
752 SHF_AMDGPU_HSA_READONLY = 0x00200000,
753 SHF_AMDGPU_HSA_CODE = 0x00400000,
754 SHF_AMDGPU_HSA_AGENT = 0x00800000
750755 };
751756
752757 // Section Group Flags
827832 STT_LOOS = 10, // Lowest operating system-specific symbol type
828833 STT_HIOS = 12, // Highest operating system-specific symbol type
829834 STT_LOPROC = 13, // Lowest processor-specific symbol type
830 STT_HIPROC = 15 // Highest processor-specific symbol type
835 STT_HIPROC = 15, // Highest processor-specific symbol type
836
837 // AMDGPU symbol types
838 STT_AMDGPU_HSA_KERNEL = 10,
839 STT_AMDGPU_HSA_INDIRECT_FUNCTION = 11,
840 STT_AMDGPU_HSA_METADATA = 12
831841 };
832842
833843 enum {
978988 PT_MIPS_REGINFO = 0x70000000, // Register usage information.
979989 PT_MIPS_RTPROC = 0x70000001, // Runtime procedure table.
980990 PT_MIPS_OPTIONS = 0x70000002, // Options segment.
981 PT_MIPS_ABIFLAGS = 0x70000003 // Abiflags segment.
991 PT_MIPS_ABIFLAGS = 0x70000003, // Abiflags segment.
992
993 // AMDGPU program header types.
994 PT_AMDGPU_HSA_LOAD_GLOBAL_PROGRAM = 0x60000000,
995 PT_AMDGPU_HSA_LOAD_GLOBAL_AGENT = 0x60000001,
996 PT_AMDGPU_HSA_LOAD_READONLY_AGENT = 0x60000002,
997 PT_AMDGPU_HSA_LOAD_CODE_AGENT = 0x60000003
982998 };
983999
9841000 // Segment flag bits.
0 RUN: llvm-readobj -program-headers -sections -symbols -file-headers \
1 RUN: %p/Inputs/trivial.elf-amdhsa-kaveri | FileCheck %s
2
3 CHECK: ElfHeader {
4 CHECK: Ident {
5 CHECK: Class: 64-bit (0x2)
6 CHECK: DataEncoding: LittleEndian (0x1)
7 CHECK: Machine: EM_AMDGPU (0xE0)
8
9
10 CHECK: Section {
11 CHECK: Name: .text
12 CHECK: Type: SHT_PROGBITS (0x1)
13 CHECK: Flags [ (0xC00007
14 CHECK: SHF_ALLOC (0x2)
15 CHECK: SHF_AMDGPU_HSA_AGENT (0x800000)
16 CHECK: SHF_AMDGPU_HSA_CODE (0x400000)
17 CHECK: SHF_EXECINSTR (0x4)
18 CHECK: SHF_WRITE (0x1)
19
20 CHECK: Symbol {
21 CHECK: Name: hello_world
22 CHECK: Value: 0x0
23 CHECK: Binding: Local (0x0)
24 CHECK: Type: AMDGPU_HSA_KERNEL (0xA)
25
26 CHECK: ProgramHeader {
27 CHECK: Type: PT_AMDGPU_HSA_LOAD_CODE_AGENT (0x60000003)
617617 { "GNU_IFunc", ELF::STT_GNU_IFUNC }
618618 };
619619
620 static const EnumEntry AMDGPUSymbolTypes[] = {
621 { "AMDGPU_HSA_KERNEL", ELF::STT_AMDGPU_HSA_KERNEL },
622 { "AMDGPU_HSA_INDIRECT_FUNCTION", ELF::STT_AMDGPU_HSA_INDIRECT_FUNCTION },
623 { "AMDGPU_HSA_METADATA", ELF::STT_AMDGPU_HSA_METADATA }
624 };
625
620626 static const char *getElfSectionType(unsigned Arch, unsigned Type) {
621627 switch (Arch) {
622628 case ELF::EM_ARM:
681687 LLVM_READOBJ_ENUM_ENT(ELF, SHF_TLS ),
682688 LLVM_READOBJ_ENUM_ENT(ELF, XCORE_SHF_CP_SECTION),
683689 LLVM_READOBJ_ENUM_ENT(ELF, XCORE_SHF_DP_SECTION),
684 LLVM_READOBJ_ENUM_ENT(ELF, SHF_MIPS_NOSTRIP )
690 LLVM_READOBJ_ENUM_ENT(ELF, SHF_MIPS_NOSTRIP ),
691 LLVM_READOBJ_ENUM_ENT(ELF, SHF_AMDGPU_HSA_GLOBAL),
692 LLVM_READOBJ_ENUM_ENT(ELF, SHF_AMDGPU_HSA_READONLY),
693 LLVM_READOBJ_ENUM_ENT(ELF, SHF_AMDGPU_HSA_CODE),
694 LLVM_READOBJ_ENUM_ENT(ELF, SHF_AMDGPU_HSA_AGENT)
685695 };
686696
687697 static const char *getElfSegmentType(unsigned Arch, unsigned Type) {
688698 // Check potentially overlapped processor-specific
689699 // program header type.
690700 switch (Arch) {
701 case ELF::EM_AMDGPU:
702 switch (Type) {
703 LLVM_READOBJ_ENUM_CASE(ELF, PT_AMDGPU_HSA_LOAD_GLOBAL_PROGRAM);
704 LLVM_READOBJ_ENUM_CASE(ELF, PT_AMDGPU_HSA_LOAD_GLOBAL_AGENT);
705 LLVM_READOBJ_ENUM_CASE(ELF, PT_AMDGPU_HSA_LOAD_READONLY_AGENT);
706 LLVM_READOBJ_ENUM_CASE(ELF, PT_AMDGPU_HSA_LOAD_CODE_AGENT);
707 }
691708 case ELF::EM_ARM:
692709 switch (Type) {
693710 LLVM_READOBJ_ENUM_CASE(ELF, PT_ARM_EXIDX);
11381155 StringRef SectionName;
11391156 getSectionNameIndex(*Obj, Symbol, SectionName, SectionIndex);
11401157 std::string FullSymbolName = getFullSymbolName(Symbol, StrTable, IsDynamic);
1158 unsigned char SymbolType = Symbol->getType();
11411159
11421160 DictScope D(W, "Symbol");
11431161 W.printNumber("Name", FullSymbolName, Symbol->st_name);
11451163 W.printNumber("Size", Symbol->st_size);
11461164 W.printEnum ("Binding", Symbol->getBinding(),
11471165 makeArrayRef(ElfSymbolBindings));
1148 W.printEnum ("Type", Symbol->getType(), makeArrayRef(ElfSymbolTypes));
1166 if (Obj->getHeader()->e_machine == ELF::EM_AMDGPU &&
1167 SymbolType >= ELF::STT_LOOS && SymbolType < ELF::STT_HIOS)
1168 W.printEnum ("Type", SymbolType, makeArrayRef(AMDGPUSymbolTypes));
1169 else
1170 W.printEnum ("Type", SymbolType, makeArrayRef(ElfSymbolTypes));
11491171 W.printNumber("Other", Symbol->st_other);
11501172 W.printHex("Section", SectionName, SectionIndex);
11511173 }