[PATCH] D66105: Support HEX_32 when building shared objects
Sid Manning via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 12 12:41:29 PDT 2019
sidneym created this revision.
sidneym added reviewers: ruiu, bcain, kparzysz.
sidneym added a project: lld.
Herald added subscribers: MaskRay, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
Support HEX_32 when building shared objects.
The following code:
int foo = 10;
int *b = &foo;
will create a R_HEX_32 relocation and currently will produce the following error:
"ld.lld: error: relocation R_HEX_32 cannot be used against symbol var; recompile with -fPIC"
Hexagon didn't support this when building shared objects. This patch adds the feature and updates the testcase.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D66105
Files:
lld/ELF/Arch/Hexagon.cpp
lld/test/ELF/hexagon-shared.s
Index: lld/test/ELF/hexagon-shared.s
===================================================================
--- lld/test/ELF/hexagon-shared.s
+++ lld/test/ELF/hexagon-shared.s
@@ -6,6 +6,7 @@
# RUN: llvm-objdump -d -j .plt %t4.so | FileCheck --check-prefix=PLT %s
# RUN: llvm-objdump -d -j .text %t4.so | FileCheck --check-prefix=TEXT %s
# RUN: llvm-objdump -D -j .got %t4.so | FileCheck --check-prefix=GOT %s
+# RUN: llvm-readelf -r %t4.so | FileCheck --check-prefix=RELO %s
.global foo
foo:
@@ -25,8 +26,22 @@
# R_HEX_GOT_16_X
r0 = add(r1,##bar at GOT)
+# R_HEX_32
+.data
+.global var
+.type var, at object
+.p2align 2
+var:
+ .word 10
+ .size var, 4
+.global pvar
+.type pvar, at object
+pvar:
+ .word var
+ .size pvar, 4
+
# PLT: { immext(#131008
-# PLT: r28 = add(pc,##131024) }
+# PLT: r28 = add(pc,##131032) }
# PLT: { r14 -= add(r28,#16)
# PLT: r15 = memw(r28+#8)
# PLT: r28 = memw(r28+#4) }
@@ -34,13 +49,17 @@
# PLT: jumpr r28 }
# PLT: { trap0(#219) }
# PLT: immext(#131008)
-# PLT: r14 = add(pc,##131008) }
+# PLT: r14 = add(pc,##131016) }
# PLT: r28 = memw(r14+#0) }
# PLT: jumpr r28 }
# TEXT: 10000: 00 00 01 00 00010000
# TEXT: { call 0x10050 }
-# TEXT: r0 = add(r1,##-65408) }
+# TEXT: r0 = add(r1,##-65416) }
# GOT: .got:
# GOT: 20080: 00 00 00 00 00000000 <unknown>
+
+# RELO: 00020080 00000121 R_HEX_GLOB_DAT
+# RELO: 00030004 00000406 R_HEX_32
+# RELO: 00030018 00000122 R_HEX_JMP_SLOT
Index: lld/ELF/Arch/Hexagon.cpp
===================================================================
--- lld/ELF/Arch/Hexagon.cpp
+++ lld/ELF/Arch/Hexagon.cpp
@@ -29,6 +29,7 @@
uint32_t calcEFlags() const override;
RelExpr getRelExpr(RelType type, const Symbol &s,
const uint8_t *loc) const override;
+ RelType getDynRel(RelType type) const override;
void relocateOne(uint8_t *loc, RelType type, uint64_t val) const override;
void writePltHeader(uint8_t *buf) const override;
void writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, uint64_t pltEntryAddr,
@@ -285,6 +286,12 @@
relocateOne(buf + 4, R_HEX_6_PCREL_X, gotPltEntryAddr - pltEntryAddr);
}
+RelType Hexagon::getDynRel(RelType type) const {
+ if (type == R_HEX_32)
+ return type;
+ return R_HEX_NONE;
+}
+
TargetInfo *elf::getHexagonTargetInfo() {
static Hexagon target;
return ⌖
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66105.214686.patch
Type: text/x-patch
Size: 2333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190812/0382e77d/attachment.bin>
More information about the llvm-commits
mailing list