Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -1430,17 +1430,16 @@ write32le(Loc, NewInst); } -// Implementing relocations for AMDGPU is low priority since most -// programs don't use relocations now. Thus, this function is not -// actually called (relocateOne is called for each relocation). -// That's why the AMDGPU port works without implementing this function. void AMDGPUTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const { - llvm_unreachable("not implemented"); + assert(Type == R_AMDGPU_REL32); + write32le(Loc, Val); } RelExpr AMDGPUTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { - llvm_unreachable("not implemented"); + if (Type != R_AMDGPU_REL32) + error("do not know how to handle relocation"); + return R_PC; } ARMTargetInfo::ARMTargetInfo() { Index: test/ELF/amdgpu-relocs.s =================================================================== --- /dev/null +++ test/ELF/amdgpu-relocs.s @@ -0,0 +1,27 @@ +# RUN: llvm-mc -filetype=obj -triple=amdgcn--amdhsa -mcpu=fiji %s -o %t.o +# RUN: ld.lld -shared %t.o -o %t.so +# RUN: llvm-readobj -r %t.so | FileCheck %s + +# REQUIRES: amdgpu + +# Make sure that the reloc for gdata is resolved by lld. + + .text + .globl kernel0 + .p2align 8 + .type kernel0,@function + .amdgpu_hsa_kernel kernel0 + +kernel0: + s_mov_b32 s0, gdata+4 + s_endpgm + +.Lfunc_end0: + .size kernel0, .Lfunc_end0-kernel0 + + .type gdata,@object + .local gdata + .comm gdata,1024,4 + +# CHECK: Relocations [ +# CHECK-NEXT: ]