Skip to content

Commit

Permalink
ELF/AMDGPU: Add support for R_AMDGPU_ABS32
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D21654

llvm-svn: 276295
  • Loading branch information
kzhuravl committed Jul 21, 2016
1 parent 1556262 commit 667e245
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lld/ELF/Target.cpp
Expand Up @@ -1461,6 +1461,7 @@ AMDGPUTargetInfo::AMDGPUTargetInfo() {
void AMDGPUTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
uint64_t Val) const {
switch (Type) {
case R_AMDGPU_ABS32:
case R_AMDGPU_GOTPCREL:
case R_AMDGPU_REL32:
write32le(Loc, Val);
Expand All @@ -1472,6 +1473,8 @@ void AMDGPUTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,

RelExpr AMDGPUTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
switch (Type) {
case R_AMDGPU_ABS32:
return R_ABS;
case R_AMDGPU_REL32:
return R_PC;
case R_AMDGPU_GOTPCREL:
Expand Down
9 changes: 8 additions & 1 deletion lld/test/ELF/amdgpu-relocs.s
@@ -1,6 +1,7 @@
# 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
# RUN: llvm-objdump -s %t.so | FileCheck %s --check-prefix=OBJDUMP

# REQUIRES: amdgpu

Expand All @@ -21,7 +22,10 @@ kernel0:
.weak weak_var
.weakref weakref_var, weakref_alias_var

# The relocation for local_var should be resolved by the linker.
.section nonalloc, "w", @progbits
.long var, common_var

# The relocation for local_var and var should be resolved by the linker.
# CHECK: Relocations [
# CHECK: .rela.dyn {
# CHECK-NEXT: R_AMDGPU_ABS64 common_var 0x0
Expand All @@ -31,3 +35,6 @@ kernel0:
# CHECK-NEXT: R_AMDGPU_ABS64 weakref_alias_var 0x0
# CHECK-NEXT: }
# CHECK-NEXT: ]

# OBJDUMP: Contents of section nonalloc:
# OBJDUMP-NEXT: 0000 00000000 00300000

0 comments on commit 667e245

Please sign in to comment.