[PATCH] D81104: [XCOFF][AIX] report_fatal_error when an overflow section is needed
Jason Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 11:33:33 PDT 2020
jasonliu updated this revision to Diff 268542.
jasonliu added a comment.
Use sed to generate the test.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81104/new/
https://reviews.llvm.org/D81104
Files:
llvm/lib/MC/XCOFFObjectWriter.cpp
llvm/test/CodeGen/PowerPC/Inputs/reloc-sed.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-reloc-overflow.ll
Index: llvm/test/CodeGen/PowerPC/aix-xcoff-reloc-overflow.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-xcoff-reloc-overflow.ll
@@ -0,0 +1,18 @@
+;; This test generates more than 65535 relocation entries in a single section,
+;; which would trigger an overflow section to be generated in 32-bit mode.
+;; Since overflow section is not supported yet, we will emit an error instead of
+;; generating an invalid binary for now.
+
+; RUN: sed "s/A/ABABA/g;s/A/ABABA/g;s/A/ABABA/g;s/A/ABABA/g;s/A/ABABA/g;s/A/ABABA/g;s/A/ABABA/g;s/A/ABABA/g;s/A/ABABA/g;s/A/ABA/g;s/A/ABA/g;" \
+; RUN: %p/Inputs/reloc-sed.ll | tr B "\n" | \
+; RUN: sed "s/A/call\ void\ bitcast\ \(void (...)*\ @foo\ to\ void\ ()*)()/g" > %t.ll
+
+; RUN: not --crash llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff \
+; RUN: -mcpu=pwr4 -mattr=-altivec -filetype=obj -o %t.o %t.ll 2>&1 | \
+; RUN: FileCheck --check-prefix=XCOFF32 %s
+; XCOFF32: LLVM ERROR: relocation entries overflowed; overflow section is not implemented yet
+
+; RUN: not --crash llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff \
+; RUN: -mcpu=pwr4 -mattr=-altivec -filetype=obj -o %t.o %t.ll 2>&1 | \
+; RUN: FileCheck --check-prefix=XCOFF64 %s
+; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet.
Index: llvm/test/CodeGen/PowerPC/Inputs/reloc-sed.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/Inputs/reloc-sed.ll
@@ -0,0 +1,8 @@
+define void @bar() {
+entry:
+;; We would replace the line below in ../aix-xcoff-reloc-overflow.ll
+A
+ ret void
+}
+
+declare void @foo(...)
Index: llvm/lib/MC/XCOFFObjectWriter.cpp
===================================================================
--- llvm/lib/MC/XCOFFObjectWriter.cpp
+++ llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -740,8 +740,18 @@
if (Group->empty())
continue;
- for (auto &Csect : *Group)
+ for (auto &Csect : *Group) {
+ if (Csect.Relocations.size() >= UINT16_MAX)
+ report_fatal_error(
+ "relocation entries overflowed; overflow section is "
+ "not implemented yet");
+
Section->RelocationCount += Csect.Relocations.size();
+ if (Section->RelocationCount >= UINT16_MAX)
+ report_fatal_error(
+ "relocation entries overflowed; overflow section is "
+ "not implemented yet");
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81104.268542.patch
Type: text/x-patch
Size: 2502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200604/35e55071/attachment.bin>
More information about the llvm-commits
mailing list