[AMDGPU] Handle R_AMDGPU_ABS64 relocation
This is needed for the following case (OpenCL example): __global int Var = 0; __global int* Ptr[] = {&Var}; ... Differential Revision: https://reviews.llvm.org/D25815 llvm-svn: 284764
This commit is contained in:
parent
6e2c89b54a
commit
b625d17db8
|
@ -1487,6 +1487,9 @@ void AMDGPUTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
|
||||||
case R_AMDGPU_REL32_LO:
|
case R_AMDGPU_REL32_LO:
|
||||||
write32le(Loc, Val);
|
write32le(Loc, Val);
|
||||||
break;
|
break;
|
||||||
|
case R_AMDGPU_ABS64:
|
||||||
|
write64le(Loc, Val);
|
||||||
|
break;
|
||||||
case R_AMDGPU_GOTPCREL32_HI:
|
case R_AMDGPU_GOTPCREL32_HI:
|
||||||
case R_AMDGPU_REL32_HI:
|
case R_AMDGPU_REL32_HI:
|
||||||
write32le(Loc, Val >> 32);
|
write32le(Loc, Val >> 32);
|
||||||
|
@ -1499,6 +1502,7 @@ void AMDGPUTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
|
||||||
RelExpr AMDGPUTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
|
RelExpr AMDGPUTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
|
||||||
switch (Type) {
|
switch (Type) {
|
||||||
case R_AMDGPU_ABS32:
|
case R_AMDGPU_ABS32:
|
||||||
|
case R_AMDGPU_ABS64:
|
||||||
return R_ABS;
|
return R_ABS;
|
||||||
case R_AMDGPU_REL32:
|
case R_AMDGPU_REL32:
|
||||||
case R_AMDGPU_REL32_LO:
|
case R_AMDGPU_REL32_LO:
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
# REQUIRES: amdgpu
|
# REQUIRES: amdgpu
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
||||||
kernel0:
|
kernel0:
|
||||||
s_mov_b32 s0, common_var0@GOTPCREL+4
|
s_mov_b32 s0, common_var0@GOTPCREL+4
|
||||||
|
@ -50,11 +50,21 @@ kernel0:
|
||||||
.local local_var1
|
.local local_var1
|
||||||
.local local_var2
|
.local local_var2
|
||||||
|
|
||||||
|
# R_AMDGPU_ABS32:
|
||||||
.section nonalloc, "w", @progbits
|
.section nonalloc, "w", @progbits
|
||||||
.long var0, common_var2+4
|
.long var0, common_var2+4
|
||||||
.long var1, common_var1+8
|
.long var1, common_var1+8
|
||||||
.long var2, common_var0+12
|
.long var2, common_var0+12
|
||||||
|
|
||||||
|
# R_AMDGPU_ABS64:
|
||||||
|
.type ptr, @object
|
||||||
|
.data
|
||||||
|
.globl ptr
|
||||||
|
.p2align 3
|
||||||
|
ptr:
|
||||||
|
.quad temp
|
||||||
|
.size ptr, 8
|
||||||
|
|
||||||
# The relocation for local_var{0, 1, 2} and var should be resolved by the
|
# The relocation for local_var{0, 1, 2} and var should be resolved by the
|
||||||
# linker.
|
# linker.
|
||||||
# CHECK: Relocations [
|
# CHECK: Relocations [
|
||||||
|
@ -68,6 +78,7 @@ kernel0:
|
||||||
# CHECK-NEXT: R_AMDGPU_ABS64 global_var0 0x0
|
# CHECK-NEXT: R_AMDGPU_ABS64 global_var0 0x0
|
||||||
# CHECK-NEXT: R_AMDGPU_ABS64 global_var1 0x0
|
# CHECK-NEXT: R_AMDGPU_ABS64 global_var1 0x0
|
||||||
# CHECK-NEXT: R_AMDGPU_ABS64 global_var2 0x0
|
# CHECK-NEXT: R_AMDGPU_ABS64 global_var2 0x0
|
||||||
|
# CHECK-NEXT: R_AMDGPU_ABS64 temp 0x0
|
||||||
# CHECK-NEXT: R_AMDGPU_ABS64 weak_var0 0x0
|
# CHECK-NEXT: R_AMDGPU_ABS64 weak_var0 0x0
|
||||||
# CHECK-NEXT: R_AMDGPU_ABS64 weak_var1 0x0
|
# CHECK-NEXT: R_AMDGPU_ABS64 weak_var1 0x0
|
||||||
# CHECK-NEXT: R_AMDGPU_ABS64 weak_var2 0x0
|
# CHECK-NEXT: R_AMDGPU_ABS64 weak_var2 0x0
|
||||||
|
@ -78,5 +89,5 @@ kernel0:
|
||||||
# CHECK-NEXT: ]
|
# CHECK-NEXT: ]
|
||||||
|
|
||||||
# OBJDUMP: Contents of section nonalloc:
|
# OBJDUMP: Contents of section nonalloc:
|
||||||
# OBJDUMP-NEXT: 0000 00000000 04380000 00000000 08340000
|
# OBJDUMP-NEXT: 0000 00000000 14380000 00000000 18340000
|
||||||
# OBJDUMP-NEXT: 00000000 0c300000
|
# OBJDUMP-NEXT: 00000000 1c300000
|
||||||
|
|
Loading…
Reference in New Issue