[PATCH] D87381: [LLD][PowerPC][test] Update thunk range error report for PPC64PCRelLongBranchThunk
Victor Huang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 08:46:34 PDT 2020
NeHuang updated this revision to Diff 293188.
NeHuang added a comment.
Move up the comment in the test case.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87381/new/
https://reviews.llvm.org/D87381
Files:
lld/ELF/Thunks.cpp
lld/test/ELF/ppc64-pcrel-call-to-toc-error.s
lld/test/ELF/ppc64-pcrel-long-branch-error.s
Index: lld/test/ELF/ppc64-pcrel-long-branch-error.s
===================================================================
--- lld/test/ELF/ppc64-pcrel-long-branch-error.s
+++ lld/test/ELF/ppc64-pcrel-long-branch-error.s
@@ -16,10 +16,13 @@
# RUN: llvm-mc -filetype=obj -triple=ppc64 %s -o %t.o
# RUN: not ld.lld -T %t.script %t.o -o %t 2>&1 | FileCheck %s
+# RUN: ld.lld -T %t.script %t.o -o %t --noinhibit-exec
# RUN: llvm-mc -filetype=obj -triple=ppc64 -defsym HIDDEN=1 %s -o %t.o
# RUN: not ld.lld -shared -T %t.script %t.o -o %t 2>&1 | FileCheck %s
+# RUN: ld.lld -shared -T %t.script %t.o -o %t --noinhibit-exec
-# CHECK: error: offset overflow 34 bits, please compile using the large code model
+# CHECK: error: PC-relative long branch stub offset is out of range: 8589934592 is not in [-8589934592, 8589934591]; references high
+# CHECK-NEXT: >>> defined in {{.*}}.o
.section .text_low, "ax", %progbits
.globl _start
Index: lld/test/ELF/ppc64-pcrel-call-to-toc-error.s
===================================================================
--- /dev/null
+++ lld/test/ELF/ppc64-pcrel-call-to-toc-error.s
@@ -0,0 +1,42 @@
+# REQUIRES: ppc, system-linux
+## The test is enabled only for ppc linux since writing to an allocated
+## file will cause time out error for this case on FreeBSD. The issue can
+## be avoided on FreeBSD by writting out to /dev/null. However, that causes a
+## different problem on systems that limit virtual memory - the OS won't
+## allow the process to allocate a memory buffer that size. Therefore we
+## decided to write to a file and limit this to ppc linux.
+
+# RUN: echo 'SECTIONS { \
+# RUN: .text_low 0x2000: { *(.text_low) } \
+# RUN: .text_high 0x200002010 : { *(.text_high) } \
+# RUN: }' > %t.script
+
+# RUN: llvm-mc -filetype=obj -triple=ppc64le %s -o %t.o
+# RUN: not ld.lld -T %t.script %t.o -o %t 2>&1 | FileCheck %s
+
+# RUN: llvm-mc -filetype=obj -triple=ppc64 %s -o %t.o
+# RUN: not ld.lld -T %t.script %t.o -o %t 2>&1 | FileCheck %s
+
+# CHECK: error: R12 setup stub offset is out of range: 8589934592 is not in [-8589934592, 8589934591]; references callee
+# CHECK-NEXT: >>> defined in {{.*}}.o
+
+# RUN: ld.lld -T %t.script %t.o -o %t --noinhibit-exec
+
+.section .text_high, "ax", %progbits
+callee:
+ .Lfunc_gep1:
+ addis 2, 12, .TOC.-.Lfunc_gep1 at ha
+ addi 2, 2, .TOC.-.Lfunc_gep1 at l
+ .Lfunc_lep1:
+ .localentry callee, .Lfunc_lep1-.Lfunc_gep1
+ addis 4, 2, global at toc@ha
+ lwz 4, global at toc@l(4)
+ blr
+
+.section .text_low, "ax", %progbits
+caller:
+ .localentry caller, 1
+ bl callee at notoc
+ blr
+global:
+ .long 0
Index: lld/ELF/Thunks.cpp
===================================================================
--- lld/ELF/Thunks.cpp
+++ lld/ELF/Thunks.cpp
@@ -966,7 +966,8 @@
void PPC64PCRelLongBranchThunk::writeTo(uint8_t *buf) {
int64_t offset = destination.getVA() - getThunkTargetSym()->getVA();
if (!isInt<34>(offset))
- fatal("offset overflow 34 bits, please compile using the large code model");
+ reportRangeError(buf, offset, 34, destination,
+ "PC-relative long branch stub offset");
uint64_t paddi = PADDI_R12_NO_DISP | (((offset >> 16) & 0x3ffff) << 32) |
(offset & 0xffff);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87381.293188.patch
Type: text/x-patch
Size: 3241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200921/4de6e0d2/attachment.bin>
More information about the llvm-commits
mailing list