[lld] r284197 - [ELF/AMDGPU]: Add support for new relocations
Konstantin Zhuravlyov via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 13 21:51:43 PDT 2016
Author: kzhuravl
Date: Thu Oct 13 23:51:43 2016
New Revision: 284197
URL: http://llvm.org/viewvc/llvm-project?rev=284197&view=rev
Log:
[ELF/AMDGPU]: Add support for new relocations
Differential Revision: https://reviews.llvm.org/D25563
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/test/ELF/amdgpu-relocs.s
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=284197&r1=284196&r2=284197&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Oct 13 23:51:43 2016
@@ -1479,9 +1479,15 @@ void AMDGPUTargetInfo::relocateOne(uint8
switch (Type) {
case R_AMDGPU_ABS32:
case R_AMDGPU_GOTPCREL:
+ case R_AMDGPU_GOTPCREL32_LO:
case R_AMDGPU_REL32:
+ case R_AMDGPU_REL32_LO:
write32le(Loc, Val);
break;
+ case R_AMDGPU_GOTPCREL32_HI:
+ case R_AMDGPU_REL32_HI:
+ write32le(Loc, Val >> 32);
+ break;
default:
fatal("unrecognized reloc " + Twine(Type));
}
@@ -1492,8 +1498,12 @@ RelExpr AMDGPUTargetInfo::getRelExpr(uin
case R_AMDGPU_ABS32:
return R_ABS;
case R_AMDGPU_REL32:
+ case R_AMDGPU_REL32_LO:
+ case R_AMDGPU_REL32_HI:
return R_PC;
case R_AMDGPU_GOTPCREL:
+ case R_AMDGPU_GOTPCREL32_LO:
+ case R_AMDGPU_GOTPCREL32_HI:
return R_GOT_PC;
default:
fatal("do not know how to handle relocation " + Twine(Type));
Modified: lld/trunk/test/ELF/amdgpu-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/amdgpu-relocs.s?rev=284197&r1=284196&r2=284197&view=diff
==============================================================================
--- lld/trunk/test/ELF/amdgpu-relocs.s (original)
+++ lld/trunk/test/ELF/amdgpu-relocs.s Thu Oct 13 23:51:43 2016
@@ -8,33 +8,75 @@
.text
kernel0:
- s_mov_b32 s0, common_var at GOTPCREL+4
- s_mov_b32 s0, extern_var at GOTPCREL+4
- s_mov_b32 s0, local_var+4
- s_mov_b32 s0, global_var at GOTPCREL+4
- s_mov_b32 s0, weak_var at GOTPCREL+4
- s_mov_b32 s0, weakref_var at GOTPCREL+4
+ s_mov_b32 s0, common_var0 at GOTPCREL+4
+ s_mov_b32 s0, common_var1 at gotpcrel32@lo+4
+ s_mov_b32 s0, common_var2 at gotpcrel32@hi+4
+
+ s_mov_b32 s0, global_var0 at GOTPCREL+4
+ s_mov_b32 s0, global_var1 at gotpcrel32@lo+4
+ s_mov_b32 s0, global_var2 at gotpcrel32@hi+4
+
+ s_mov_b32 s0, extern_var0 at GOTPCREL+4
+ s_mov_b32 s0, extern_var1 at gotpcrel32@lo+4
+ s_mov_b32 s0, extern_var2 at gotpcrel32@hi+4
+
+ s_mov_b32 s0, weak_var0 at GOTPCREL+4
+ s_mov_b32 s0, weak_var1 at gotpcrel32@lo+4
+ s_mov_b32 s0, weak_var2 at gotpcrel32@hi+4
+
+ s_mov_b32 s0, weakref_var0 at GOTPCREL+4
+ s_mov_b32 s0, weakref_var1 at gotpcrel32@lo+4
+ s_mov_b32 s0, weakref_var2 at gotpcrel32@hi+4
+
+ s_mov_b32 s0, local_var0+4
+ s_mov_b32 s0, local_var1 at rel32@lo+4
+ s_mov_b32 s0, local_var2 at rel32@hi+4
+
s_endpgm
- .comm common_var,1024,4
- .globl global_var
- .local local_var
- .weak weak_var
- .weakref weakref_var, weakref_alias_var
+ .comm common_var0,1024,4
+ .comm common_var1,1024,4
+ .comm common_var2,1024,4
+ .globl global_var0
+ .globl global_var1
+ .globl global_var1
+ .weak weak_var0
+ .weak weak_var1
+ .weak weak_var2
+ .weakref weakref_var0, weakref_alias_var0
+ .weakref weakref_var1, weakref_alias_var1
+ .weakref weakref_var2, weakref_alias_var2
+ .local local_var0
+ .local local_var1
+ .local local_var2
.section nonalloc, "w", @progbits
- .long var, common_var
+ .long var0, common_var2+4
+ .long var1, common_var1+8
+ .long var2, common_var0+12
-# The relocation for local_var and var should be resolved by the linker.
+# The relocation for local_var{0, 1, 2} and var should be resolved by the
+# linker.
# CHECK: Relocations [
# CHECK: .rela.dyn {
-# CHECK-NEXT: R_AMDGPU_ABS64 common_var 0x0
-# CHECK-NEXT: R_AMDGPU_ABS64 extern_var 0x0
-# CHECK-NEXT: R_AMDGPU_ABS64 global_var 0x0
-# CHECK-NEXT: R_AMDGPU_ABS64 weak_var 0x0
-# CHECK-NEXT: R_AMDGPU_ABS64 weakref_alias_var 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 common_var0 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 common_var1 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 common_var2 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 extern_var0 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 extern_var1 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 extern_var2 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 global_var0 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 global_var1 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 global_var2 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 weak_var0 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 weak_var1 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 weak_var2 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 weakref_alias_var0 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 weakref_alias_var1 0x0
+# CHECK-NEXT: R_AMDGPU_ABS64 weakref_alias_var2 0x0
# CHECK-NEXT: }
# CHECK-NEXT: ]
# OBJDUMP: Contents of section nonalloc:
-# OBJDUMP-NEXT: 0000 00000000 00300000
+# OBJDUMP-NEXT: 0000 00000000 04380000 00000000 08340000
+# OBJDUMP-NEXT: 00000000 0c300000
More information about the llvm-commits
mailing list