Index: include/llvm/Object/RelocVisitor.h =================================================================== --- include/llvm/Object/RelocVisitor.h +++ include/llvm/Object/RelocVisitor.h @@ -139,6 +139,14 @@ HasError = true; return RelocToApply(); } + case Triple::amdgcn: + switch (RelocType) { + case llvm::ELF::R_AMDGPU_ABS32: + return visitELF_AMDGPU_ABS32(R, Value); + default: + HasError = true; + return RelocToApply(); + } default: HasError = true; return RelocToApply(); @@ -403,6 +411,11 @@ return RelocToApply(static_cast(Res), 4); } + RelocToApply visitELF_AMDGPU_ABS32(RelocationRef R, uint64_t Value) { + int64_t Addend = getELFAddend(R); + return RelocToApply(Value + Addend, 4); + } + /// I386 COFF RelocToApply visitCOFF_I386_SECREL(RelocationRef R, uint64_t Value) { return RelocToApply(static_cast(Value), /*Width=*/4); Index: lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp =================================================================== --- lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp +++ lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp @@ -56,6 +56,7 @@ default: break; case FK_PCRel_4: return ELF::R_AMDGPU_REL32; + case FK_Data_4: case FK_SecRel_4: return ELF::R_AMDGPU_ABS32; } Index: test/MC/AMDGPU/reloc.s =================================================================== --- test/MC/AMDGPU/reloc.s +++ test/MC/AMDGPU/reloc.s @@ -4,6 +4,7 @@ // CHECK: R_AMDGPU_ABS32_LO SCRATCH_RSRC_DWORD0 0x0 // CHECK: R_AMDGPU_ABS32_HI SCRATCH_RSRC_DWORD1 0x0 // CHECK: R_AMDGPU_GOTPCREL global_var 0x0 +// CHECK: R_AMDGPU_ABS32 var 0x0 // CHECK: ] kernel: @@ -14,3 +15,6 @@ .globl global_var .globl SCRATCH_RSRC_DWORD0 + +.section .data.foo, "w", @progbits + .long var, global_var