SHF_MIPS_ADDR = 0x40000000,
// Section data is string data by default.
- SHF_MIPS_STRING = 0x80000000
+ SHF_MIPS_STRING = 0x80000000,
+
+ SHF_AMDGPU_HSA_GLOBAL = 0x00100000,
+ SHF_AMDGPU_HSA_READONLY = 0x00200000,
+ SHF_AMDGPU_HSA_CODE = 0x00400000,
+ SHF_AMDGPU_HSA_AGENT = 0x00800000
};
// Section Group Flags
STT_LOOS = 10, // Lowest operating system-specific symbol type
STT_HIOS = 12, // Highest operating system-specific symbol type
STT_LOPROC = 13, // Lowest processor-specific symbol type
- STT_HIPROC = 15 // Highest processor-specific symbol type
+ STT_HIPROC = 15, // Highest processor-specific symbol type
+
+ // AMDGPU symbol types
+ STT_AMDGPU_HSA_KERNEL = 10,
+ STT_AMDGPU_HSA_INDIRECT_FUNCTION = 11,
+ STT_AMDGPU_HSA_METADATA = 12
};
enum {
PT_MIPS_REGINFO = 0x70000000, // Register usage information.
PT_MIPS_RTPROC = 0x70000001, // Runtime procedure table.
PT_MIPS_OPTIONS = 0x70000002, // Options segment.
- PT_MIPS_ABIFLAGS = 0x70000003 // Abiflags segment.
+ PT_MIPS_ABIFLAGS = 0x70000003, // Abiflags segment.
+
+ // AMDGPU program header types.
+ PT_AMDGPU_HSA_LOAD_GLOBAL_PROGRAM = 0x60000000,
+ PT_AMDGPU_HSA_LOAD_GLOBAL_AGENT = 0x60000001,
+ PT_AMDGPU_HSA_LOAD_READONLY_AGENT = 0x60000002,
+ PT_AMDGPU_HSA_LOAD_CODE_AGENT = 0x60000003
};
// Segment flag bits.
--- /dev/null
+RUN: llvm-readobj -program-headers -sections -symbols -file-headers \
+RUN: %p/Inputs/trivial.elf-amdhsa-kaveri | FileCheck %s
+
+CHECK: ElfHeader {
+CHECK: Ident {
+CHECK: Class: 64-bit (0x2)
+CHECK: DataEncoding: LittleEndian (0x1)
+CHECK: Machine: EM_AMDGPU (0xE0)
+
+
+CHECK: Section {
+CHECK: Name: .text
+CHECK: Type: SHT_PROGBITS (0x1)
+CHECK: Flags [ (0xC00007
+CHECK: SHF_ALLOC (0x2)
+CHECK: SHF_AMDGPU_HSA_AGENT (0x800000)
+CHECK: SHF_AMDGPU_HSA_CODE (0x400000)
+CHECK: SHF_EXECINSTR (0x4)
+CHECK: SHF_WRITE (0x1)
+
+CHECK: Symbol {
+CHECK: Name: hello_world
+CHECK: Value: 0x0
+CHECK: Binding: Local (0x0)
+CHECK: Type: AMDGPU_HSA_KERNEL (0xA)
+
+CHECK: ProgramHeader {
+CHECK: Type: PT_AMDGPU_HSA_LOAD_CODE_AGENT (0x60000003)
{ "GNU_IFunc", ELF::STT_GNU_IFUNC }
};
+static const EnumEntry<unsigned> AMDGPUSymbolTypes[] = {
+ { "AMDGPU_HSA_KERNEL", ELF::STT_AMDGPU_HSA_KERNEL },
+ { "AMDGPU_HSA_INDIRECT_FUNCTION", ELF::STT_AMDGPU_HSA_INDIRECT_FUNCTION },
+ { "AMDGPU_HSA_METADATA", ELF::STT_AMDGPU_HSA_METADATA }
+};
+
static const char *getElfSectionType(unsigned Arch, unsigned Type) {
switch (Arch) {
case ELF::EM_ARM:
LLVM_READOBJ_ENUM_ENT(ELF, SHF_TLS ),
LLVM_READOBJ_ENUM_ENT(ELF, XCORE_SHF_CP_SECTION),
LLVM_READOBJ_ENUM_ENT(ELF, XCORE_SHF_DP_SECTION),
- LLVM_READOBJ_ENUM_ENT(ELF, SHF_MIPS_NOSTRIP )
+ LLVM_READOBJ_ENUM_ENT(ELF, SHF_MIPS_NOSTRIP ),
+ LLVM_READOBJ_ENUM_ENT(ELF, SHF_AMDGPU_HSA_GLOBAL),
+ LLVM_READOBJ_ENUM_ENT(ELF, SHF_AMDGPU_HSA_READONLY),
+ LLVM_READOBJ_ENUM_ENT(ELF, SHF_AMDGPU_HSA_CODE),
+ LLVM_READOBJ_ENUM_ENT(ELF, SHF_AMDGPU_HSA_AGENT)
};
static const char *getElfSegmentType(unsigned Arch, unsigned Type) {
// Check potentially overlapped processor-specific
// program header type.
switch (Arch) {
+ case ELF::EM_AMDGPU:
+ switch (Type) {
+ LLVM_READOBJ_ENUM_CASE(ELF, PT_AMDGPU_HSA_LOAD_GLOBAL_PROGRAM);
+ LLVM_READOBJ_ENUM_CASE(ELF, PT_AMDGPU_HSA_LOAD_GLOBAL_AGENT);
+ LLVM_READOBJ_ENUM_CASE(ELF, PT_AMDGPU_HSA_LOAD_READONLY_AGENT);
+ LLVM_READOBJ_ENUM_CASE(ELF, PT_AMDGPU_HSA_LOAD_CODE_AGENT);
+ }
case ELF::EM_ARM:
switch (Type) {
LLVM_READOBJ_ENUM_CASE(ELF, PT_ARM_EXIDX);
StringRef SectionName;
getSectionNameIndex(*Obj, Symbol, SectionName, SectionIndex);
std::string FullSymbolName = getFullSymbolName(Symbol, StrTable, IsDynamic);
+ unsigned char SymbolType = Symbol->getType();
DictScope D(W, "Symbol");
W.printNumber("Name", FullSymbolName, Symbol->st_name);
W.printNumber("Size", Symbol->st_size);
W.printEnum ("Binding", Symbol->getBinding(),
makeArrayRef(ElfSymbolBindings));
- W.printEnum ("Type", Symbol->getType(), makeArrayRef(ElfSymbolTypes));
+ if (Obj->getHeader()->e_machine == ELF::EM_AMDGPU &&
+ SymbolType >= ELF::STT_LOOS && SymbolType < ELF::STT_HIOS)
+ W.printEnum ("Type", SymbolType, makeArrayRef(AMDGPUSymbolTypes));
+ else
+ W.printEnum ("Type", SymbolType, makeArrayRef(ElfSymbolTypes));
W.printNumber("Other", Symbol->st_other);
W.printHex("Section", SectionName, SectionIndex);
}