llvm.org GIT mirror llvm / 7624630
AMDGPU: Add ELFOSABI_AMDGPU_PAL git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314843 91177308-0d34-0410-b5e6-96231b3b80d8 Konstantin Zhuravlyov 2 years ago
10 changed file(s) with 85 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
358358 .. table:: AMDGPU ELF Header
359359 :name: amdgpu-elf-header-table
360360
361 ========================== =========================
361 ========================== ===============================
362362 Field Value
363 ========================== =========================
363 ========================== ===============================
364364 ``e_ident[EI_CLASS]`` ``ELFCLASS64``
365365 ``e_ident[EI_DATA]`` ``ELFDATA2LSB``
366 ``e_ident[EI_OSABI]`` ``ELFOSABI_AMDGPU_HSA``
367 ``e_ident[EI_ABIVERSION]`` ``ELFABIVERSION_AMDGPU_HSA``
366 ``e_ident[EI_OSABI]`` ``ELFOSABI_AMDGPU_HSA`` or
367 ``ELFOSABI_AMDGPU_PAL``
368 ``e_ident[EI_ABIVERSION]`` ``ELFABIVERSION_AMDGPU_HSA`` or
369 ``ELFABIVERSION_AMDGPU_PAL``
368370 ``e_type`` ``ET_REL`` or ``ET_DYN``
369371 ``e_machine`` ``EM_AMDGPU``
370372 ``e_entry`` 0
371373 ``e_flags`` 0
372 ========================== =========================
374 ========================== ===============================
373375
374376 ..
375377
381383 ============================ =====
382384 ``EM_AMDGPU`` 224
383385 ``ELFOSABI_AMDGPU_HSA`` 64
386 ``ELFOSABI_AMDGPU_PAL`` 65
384387 ``ELFABIVERSION_AMDGPU_HSA`` 1
388 ``ELFABIVERSION_AMDGPU_PAL`` 0
385389 ============================ =====
386390
387391 ``e_ident[EI_CLASS]``
388 The ELF class is always ``ELFCLASS64``. The AMDGPU backend only supports 64 bit
389 applications.
392 The ELF class is always ``ELFCLASS64``. The AMDGPU backend only supports 64
393 bit applications.
390394
391395 ``e_ident[EI_DATA]``
392396 All AMDGPU targets use ELFDATA2LSB for little-endian byte ordering.
393397
394398 ``e_ident[EI_OSABI]``
395 The AMD GPU architecture specific OS ABI of ``ELFOSABI_AMDGPU_HSA`` is used to
396 specify that the code object conforms to the AMD HSA runtime ABI [HSA]_.
399 One of two AMD GPU architecture specific OS ABI:
400
401 * ``ELFOSABI_AMDGPU_HSA`` is used to specify that the code object conforms to
402 the AMD HSA runtime ABI [HSA]_.
403
404 * ``ELFOSABI_AMDGPU_PAL`` is used to specify that the code object conforms to
405 the AMD PAL runtime ABI.
397406
398407 ``e_ident[EI_ABIVERSION]``
399 The AMD GPU architecture specific OS ABI version of
400 ``ELFABIVERSION_AMDGPU_HSA`` is used to specify the version of AMD HSA runtime
401 ABI to which the code object conforms.
408 The ABI version of the AMD GPU architecture specific OS ABI to which the code
409 object conforms:
410
411 * ``ELFABIVERSION_AMDGPU_HSA`` is used to specify the version of AMD HSA
412 runtime ABI.
413
414 * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
415 runtime ABI.
402416
403417 ``e_type``
404418 Can be one of the following values:
354354 ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI
355355 ELFOSABI_FIRST_ARCH = 64, // First architecture-specific OS ABI
356356 ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
357 ELFOSABI_AMDGPU_PAL = 65, // AMD PAL runtime
358 ELFOSABI_ARM = 97, // ARM
357359 ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
358360 ELFOSABI_C6000_LINUX = 65, // Linux TMS320C6000
359 ELFOSABI_ARM = 97, // ARM
360361 ELFOSABI_STANDALONE = 255, // Standalone (embedded) application
361362 ELFOSABI_LAST_ARCH = 255 // Last Architecture-specific OS ABI
362363 };
994994 case ELF::EM_WEBASSEMBLY:
995995 return "ELF64-wasm";
996996 case ELF::EM_AMDGPU:
997 return (EF.getHeader()->e_ident[ELF::EI_OSABI] == ELF::ELFOSABI_AMDGPU_HSA
998 && IsLittleEndian) ?
999 "ELF64-amdgpu-hsacobj" : "ELF64-amdgpu";
997 return "ELF64-amdgpu";
1000998 case ELF::EM_BPF:
1001999 return "ELF64-BPF";
10021000 default:
10651063 }
10661064
10671065 case ELF::EM_AMDGPU:
1068 return (EF.getHeader()->e_ident[ELF::EI_CLASS] == ELF::ELFCLASS64
1069 && EF.getHeader()->e_ident[ELF::EI_OSABI] == ELF::ELFOSABI_AMDGPU_HSA
1070 && IsLittleEndian) ?
1071 Triple::amdgcn : Triple::UnknownArch;
1066 if (EF.getHeader()->e_ident[ELF::EI_CLASS] != ELF::ELFCLASS64)
1067 return Triple::UnknownArch;
1068 if (!IsLittleEndian)
1069 return Triple::UnknownArch;
1070
1071 // TODO: Determine r600/amdgcn architecture based e_flags.
1072 return Triple::amdgcn;
10721073
10731074 case ELF::EM_BPF:
10741075 return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;
259259 ECase(ELFOSABI_AROS);
260260 ECase(ELFOSABI_FENIXOS);
261261 ECase(ELFOSABI_CLOUDABI);
262 ECase(ELFOSABI_AMDGPU_HSA);
263 ECase(ELFOSABI_AMDGPU_PAL);
264 ECase(ELFOSABI_ARM);
262265 ECase(ELFOSABI_C6000_ELFABI);
263 ECase(ELFOSABI_AMDGPU_HSA);
264266 ECase(ELFOSABI_C6000_LINUX);
265 ECase(ELFOSABI_ARM);
266267 ECase(ELFOSABI_STANDALONE);
267268 #undef ECase
268269 }
+0
-21
test/Object/AMDGPU/elf-definitions.yaml less more
None # RUN: yaml2obj %s > %t.o
1 # RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s
2
3 # CHECK: Format: ELF64-amdgpu-hsacobj
4 # CHECK: Arch: amdgcn
5 # CHECK: ElfHeader {
6 # CHECK: Ident {
7 # CHECK: OS/ABI: AMDGPU_HSA (0x40)
8 # CHECK: ABIVersion: 0
9 # CHECK: }
10 # CHECK: Machine: EM_AMDGPU (0xE0)
11 # CHECK: }
12
13 --- !ELF
14 FileHeader:
15 Class: ELFCLASS64
16 Data: ELFDATA2LSB
17 Type: ET_REL
18 Machine: EM_AMDGPU
19 OSABI: ELFOSABI_AMDGPU_HSA
20 ...
0 # RUN: yaml2obj %s > %t.o
1 # RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s
2
3 # CHECK: Format: ELF64-amdgpu
4 # CHECK: Arch: amdgcn
5 # CHECK: ElfHeader {
6 # CHECK: Ident {
7 # CHECK: OS/ABI: AMDGPU_HSA (0x40)
8 # CHECK: ABIVersion: 0
9 # CHECK: }
10 # CHECK: Machine: EM_AMDGPU (0xE0)
11 # CHECK: }
12
13 --- !ELF
14 FileHeader:
15 Class: ELFCLASS64
16 Data: ELFDATA2LSB
17 Type: ET_REL
18 Machine: EM_AMDGPU
19 OSABI: ELFOSABI_AMDGPU_HSA
20 ...
0 # RUN: yaml2obj %s > %t.o
1 # RUN: llvm-readobj -s -file-headers %t.o | FileCheck %s
2
3 # CHECK: Format: ELF64-amdgpu
4 # CHECK: Arch: amdgcn
5 # CHECK: ElfHeader {
6 # CHECK: Ident {
7 # CHECK: OS/ABI: AMDGPU_PAL (0x41)
8 # CHECK: ABIVersion: 0
9 # CHECK: }
10 # CHECK: Machine: EM_AMDGPU (0xE0)
11 # CHECK: }
12
13 --- !ELF
14 FileHeader:
15 Class: ELFCLASS64
16 Data: ELFDATA2LSB
17 Type: ET_REL
18 Machine: EM_AMDGPU
19 OSABI: ELFOSABI_AMDGPU_PAL
20 ...
4444 v_lshlrev_b32_e32 v7, 2, v7
4545 s_endpgm
4646
47 // CHECK: file format ELF64-amdgpu-hsacobj
47 // CHECK: file format ELF64-amdgpu
4848 // CHECK: Disassembly of section .text:
4949 // CHECK: hello_world:
5050 // CHECK: s_mov_b32 m0, 0x10000 // 000000000100: BEFC00FF 00010000
0 RUN: llvm-readobj -file-headers -program-headers -sections -symbols %p/Inputs/trivial.obj.elf-amdhsa-gfx803 | FileCheck %s
11
2 CHECK: Format: ELF64-amdgpu-hsacobj
2 CHECK: Format: ELF64-amdgpu
33 CHECK: Arch: amdgcn
44 CHECK: ElfHeader {
55 CHECK: Ident {
824824 };
825825
826826 static const EnumEntry AMDGPUElfOSABI[] = {
827 {"AMDGPU_HSA", "AMDGPU - HSA", ELF::ELFOSABI_AMDGPU_HSA}
827 {"AMDGPU_HSA", "AMDGPU - HSA", ELF::ELFOSABI_AMDGPU_HSA},
828 {"AMDGPU_PAL", "AMDGPU - PAL", ELF::ELFOSABI_AMDGPU_PAL}
828829 };
829830
830831 static const EnumEntry ARMElfOSABI[] = {