forked from OSchip/llvm-project
LLD/ELF/AMDGPU: Process AMDGPU-specific e_flags
Differential Revision: https://reviews.llvm.org/D39140 llvm-svn: 316483
This commit is contained in:
parent
80db37ec25
commit
b71d1b8a54
|
@ -25,6 +25,7 @@ namespace {
|
|||
class AMDGPU final : public TargetInfo {
|
||||
public:
|
||||
AMDGPU();
|
||||
uint32_t calcEFlags() const override;
|
||||
void relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const override;
|
||||
RelExpr getRelExpr(RelType Type, const SymbolBody &S,
|
||||
const uint8_t *Loc) const override;
|
||||
|
@ -37,6 +38,24 @@ AMDGPU::AMDGPU() {
|
|||
GotEntrySize = 8;
|
||||
}
|
||||
|
||||
uint32_t AMDGPU::calcEFlags() const {
|
||||
if (ObjectFiles.empty())
|
||||
return 0;
|
||||
|
||||
uint32_t Ret =
|
||||
cast<ObjFile<ELF64LE>>(ObjectFiles.front())->getObj().getHeader()->e_flags;
|
||||
|
||||
// Verify that all input files have the same e_flags.
|
||||
for (InputFile *F : ArrayRef<InputFile*>(ObjectFiles).slice(1)) {
|
||||
if (Ret != cast<ObjFile<ELF64LE>>(F)->getObj().getHeader()->e_flags) {
|
||||
error("incompatible e_flags: " + toString(F));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
void AMDGPU::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
|
||||
switch (Type) {
|
||||
case R_AMDGPU_ABS32:
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
.text
|
||||
.globl kernel_0
|
||||
.align 64
|
||||
.amdgpu_hsa_kernel kernel_0
|
||||
kernel_0:
|
||||
s_endpgm
|
|
@ -0,0 +1,6 @@
|
|||
.text
|
||||
.globl kernel_1
|
||||
.align 64
|
||||
.amdgpu_hsa_kernel kernel_1
|
||||
kernel_1:
|
||||
s_endpgm
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
|
||||
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
|
||||
# RUN: not ld.lld -shared %t-0.o %t-1.o %S/Inputs/amdgpu-kernel-2.o -o %t.so 2>&1 | FileCheck %s
|
||||
|
||||
# REQUIRES: amdgpu
|
||||
|
||||
# CHECK: error: incompatible e_flags: {{.*}}amdgpu-kernel-2.o
|
|
@ -0,0 +1,10 @@
|
|||
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o
|
||||
# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o
|
||||
# RUN: ld.lld -shared %t-0.o %t-1.o -o %t.so
|
||||
# RUN: llvm-readobj -file-headers %t.so | FileCheck %s
|
||||
|
||||
# REQUIRES: amdgpu
|
||||
|
||||
# CHECK: Flags [ (0x2)
|
||||
# CHECK: EF_AMDGPU_ARCH_GCN (0x2)
|
||||
# CHECK: ]
|
Loading…
Reference in New Issue