[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 18:46:35 PDT 2020


jasonliu updated this revision to Diff 268634.
jasonliu added a comment.

Remove input files and use `grep -v`


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/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,27 @@
+;; 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: grep -v sed  %s | \
+; 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;" | 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.
+
+define void @bar() {
+entry:
+;; The line below will get transformed.
+  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.268634.patch
Type: text/x-patch
Size: 2269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/2dd5cbbb/attachment.bin>


More information about the llvm-commits mailing list