[llvm] f989643 - [AIX][XCOFF] Fix XCOFFObjectWriter assertion failure with alignment-related gap and improve text section output testing
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 07:03:08 PST 2020
Author: diggerlin
Date: 2020-03-03T10:02:40-05:00
New Revision: f9896435c99b3288e1eba2b9226b56f603329cf1
URL: https://github.com/llvm/llvm-project/commit/f9896435c99b3288e1eba2b9226b56f603329cf1
DIFF: https://github.com/llvm/llvm-project/commit/f9896435c99b3288e1eba2b9226b56f603329cf1.diff
LOG: [AIX][XCOFF] Fix XCOFFObjectWriter assertion failure with alignment-related gap and improve text section output testing
SUMMARY:
1.if there is a gap between the end virtual address of one section and the beginning virtual address of the next section, the XCOFFObjectWriter.cpp will hit a assert.
2.as discussed in the patch https://reviews.llvm.org/D66969,
since implemented the function description. We can output the raw object data for function.
we need to create a test for raw text section content and test section header for xcoff object file.
Reviewer: daltenty,hubert.reinterpretcast,jasonliu
Differential Revision: https://reviews.llvm.org/D71845
Added:
Modified:
llvm/lib/MC/XCOFFObjectWriter.cpp
llvm/test/CodeGen/PowerPC/aix-return55.ll
Removed:
################################################################################
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index bd9229d0d0e3..2c054426fa2a 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -439,8 +439,14 @@ void XCOFFObjectWriter::writeSections(const MCAssembler &Asm,
if (Section->Index == Section::UninitializedIndex || Section->IsVirtual)
continue;
- assert(CurrentAddressLocation == Section->Address &&
- "Sections should be written consecutively.");
+ // There could be a gap (without corresponding zero padding) between
+ // sections.
+ assert(CurrentAddressLocation <= Section->Address &&
+ "CurrentAddressLocation should be less than or equal to section "
+ "address.");
+
+ CurrentAddressLocation = Section->Address;
+
for (const auto *Group : Section->Groups) {
for (const auto &Csect : *Group) {
if (uint32_t PaddingSize = Csect.Address - CurrentAddressLocation)
diff --git a/llvm/test/CodeGen/PowerPC/aix-return55.ll b/llvm/test/CodeGen/PowerPC/aix-return55.ll
index b16f2fa66e72..e1a74f0989a5 100644
--- a/llvm/test/CodeGen/PowerPC/aix-return55.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-return55.ll
@@ -1,5 +1,15 @@
-; RUN: llc -mcpu=pwr9 -mtriple=powerpc-ibm-aix-xcoff -verify-machineinstrs < %s | FileCheck %s
+; RUN: llc -mcpu=pwr4 -mtriple=powerpc-ibm-aix-xcoff -verify-machineinstrs < %s | FileCheck %s
+; RUN: llc -mcpu=pwr4 -mtriple=powerpc-ibm-aix-xcoff -verify-machineinstrs -filetype=obj -o %t.o < %s
+; RUN: llvm-objdump -D %t.o | FileCheck --check-prefix=CHECKOBJ %s
+; RUN: llvm-readobj -sections %t.o | FileCheck --check-prefix=CHECKSECT %s
+; RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff -filetype=obj < %s 2>&1 | \
+; RUN: FileCheck --check-prefix=XCOFF64 %s
+; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet.
+
+ at a = global i64 320255973571806, align 8
+ at d = global double 5.000000e+00, align 8
+ at strA = private unnamed_addr constant [10 x i8] c"hellowor\0A\00", align 1
define dso_local signext i32 @foo() {
entry:
@@ -9,3 +19,50 @@ entry:
; CHECK: blr
}
+;CHECKOBJ: 00000000 .text:
+;CHECKOBJ-NEXT: 0: 38 60 00 37 li 3, 55
+;CHECKOBJ-NEXT: 4: 4e 80 00 20 blr{{[[:space:]] *}}
+;CHECKOBJ-NEXT: 00000008 .rodata.str1.1:
+;CHECKOBJ-NEXT: 8: 68 65 6c 6c xori 5, 3, 27756
+;CHECKOBJ-NEXT: c: 6f 77 6f 72 xoris 23, 27, 28530
+;CHECKOBJ-NEXT: 10: 0a 00 00 00 tdlti 0, 0{{[[:space:]] *}}
+;CHECKOBJ-NEXT: Disassembly of section .data:{{[[:space:]] *}}
+;CHECKOBJ-NEXT: 00000018 a:
+;CHECKOBJ-NEXT: 18: 00 01 23 45 <unknown>
+;CHECKOBJ-NEXT: 1c: 67 8a bc de oris 10, 28, 48350{{[[:space:]] *}}
+;CHECKOBJ-NEXT: 00000020 d:
+;CHECKOBJ-NEXT: 20: 40 14 00 00 bdnzf 20, .+0
+;CHECKOBJ-NEXT: 24: 00 00 00 00 <unknown>{{[[:space:]] *}}
+;CHECKOBJ-NEXT: 00000028 foo:
+;CHECKOBJ-NEXT: 28: 00 00 00 00 <unknown>
+;CHECKOBJ-NEXT: 2c: 00 00 00 34 <unknown>
+;CHECKOBJ-NEXT: 30: 00 00 00 00 <unknown>
+
+;CHECKSECT: Sections [
+;CHECKSECT-NEXT: Section {
+;CHECKSECT-NEXT: Index: 1
+;CHECKSECT-NEXT: Name: .text
+;CHECKSECT-NEXT: PhysicalAddress: 0x0
+;CHECKSECT-NEXT: VirtualAddress: 0x0
+;CHECKSECT-NEXT: Size: 0x14
+;CHECKSECT-NEXT: RawDataOffset: 0x64
+;CHECKSECT-NEXT: RelocationPointer: 0x0
+;CHECKSECT-NEXT: LineNumberPointer: 0x0
+;CHECKSECT-NEXT: NumberOfRelocations: 0
+;CHECKSECT-NEXT: NumberOfLineNumbers: 0
+;CHECKSECT-NEXT: Type: STYP_TEXT (0x20)
+;CHECKSECT-NEXT: }
+;CHECKSECT-NEXT: Section {
+;CHECKSECT-NEXT: Index: 2
+;CHECKSECT-NEXT: Name: .data
+;CHECKSECT-NEXT: PhysicalAddress: 0x18
+;CHECKSECT-NEXT: VirtualAddress: 0x18
+;CHECKSECT-NEXT: Size: 0x1C
+;CHECKSECT-NEXT: RawDataOffset: 0x78
+;CHECKSECT-NEXT: RelocationPointer: 0x94
+;CHECKSECT-NEXT: LineNumberPointer: 0x0
+;CHECKSECT-NEXT: NumberOfRelocations: 2
+;CHECKSECT-NEXT: NumberOfLineNumbers: 0
+;CHECKSECT-NEXT: Type: STYP_DATA (0x40)
+;CHECKSECT-NEXT: }
+;CHECKSECT-NEXT: ]
More information about the llvm-commits
mailing list