summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjasonliu <jasonliu.development@gmail.com>2019-11-22 15:36:46 +0000
committerjasonliu <jasonliu.development@gmail.com>2019-11-22 15:49:37 +0000
commitaf8576ff9d5a66d30ce27176aff808b688c3ec85 (patch)
treedba4bd9ac2d9b13638930528fb4af476d2c2a379
parent26fa9e31f58a7ff693f3a5d8c2eb1b6a5a13b133 (diff)
downloadbcm5719-llvm-af8576ff9d5a66d30ce27176aff808b688c3ec85.tar.gz
bcm5719-llvm-af8576ff9d5a66d30ce27176aff808b688c3ec85.zip
[XCOFF][AIX] Read-only data section object file generation
Summary: This patch is a follow up on read-only assembly patch D70182. It intends to enable object file generation for the read-only data section on AIX. Reviewers: DiggerLin, daltenty Differential Revision: https://reviews.llvm.org/D70455
-rw-r--r--llvm/lib/MC/XCOFFObjectWriter.cpp7
-rw-r--r--llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll272
2 files changed, 278 insertions, 1 deletions
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index 34f75e2ccdf..95f950465c0 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -150,6 +150,7 @@ class XCOFFObjectWriter : public MCObjectWriter {
// the sections. Should have one for each set of csects that get mapped into
// the same section and get handled in a 'similar' way.
CsectGroup ProgramCodeCsects;
+ CsectGroup ReadOnlyCsects;
CsectGroup DataCsects;
CsectGroup FuncDSCsects;
CsectGroup TOCCsects;
@@ -219,7 +220,7 @@ XCOFFObjectWriter::XCOFFObjectWriter(
: W(OS, support::big), TargetObjectWriter(std::move(MOTW)),
Strings(StringTableBuilder::XCOFF),
Text(".text", XCOFF::STYP_TEXT, /* IsVirtual */ false,
- CsectGroups{&ProgramCodeCsects}),
+ CsectGroups{&ProgramCodeCsects, &ReadOnlyCsects}),
Data(".data", XCOFF::STYP_DATA, /* IsVirtual */ false,
CsectGroups{&DataCsects, &FuncDSCsects, &TOCCsects}),
BSS(".bss", XCOFF::STYP_BSS, /* IsVirtual */ true,
@@ -245,6 +246,10 @@ CsectGroup &XCOFFObjectWriter::getCsectGroup(const MCSectionXCOFF *MCSec) {
assert(XCOFF::XTY_SD == MCSec->getCSectType() &&
"Only an initialized csect can contain program code.");
return ProgramCodeCsects;
+ case XCOFF::XMC_RO:
+ assert(XCOFF::XTY_SD == MCSec->getCSectType() &&
+ "Only an initialized csect can contain read only data.");
+ return ReadOnlyCsects;
case XCOFF::XMC_RW:
if (XCOFF::XTY_CM == MCSec->getCSectType())
return BSSCsects;
diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
index 9dcd7e8f965..769a9c2cc46 100644
--- a/llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
@@ -1,6 +1,16 @@
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s
+; RUN: llvm-readobj --section-headers --file-header %t.o | \
+; RUN: FileCheck --check-prefix=OBJ %s
+; RUN: llvm-readobj --syms %t.o | FileCheck --check-prefix=SYMS %s
+; RUN: llvm-objdump -D %t.o | FileCheck --check-prefix=DIS %s
+
+; RUN: not llc -verify-machineinstrs -mcpu=pwr7 -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.
+
@const_ivar = constant i32 35, align 4
@const_llvar = constant i64 36, align 8
@const_svar = constant i16 37, align 2
@@ -48,3 +58,265 @@
; CHECK-NEXT: .llong 4611686018427387904
; CHECK-NEXT: .llong 4613937818241073152
; CHECK-NEXT: .llong 4616189618054758400
+
+
+; OBJ: File: {{.*}}aix-xcoff-rodata.ll.tmp.o
+; OBJ-NEXT: Format: aixcoff-rs6000
+; OBJ-NEXT: Arch: powerpc
+; OBJ-NEXT: AddressSize: 32bit
+; OBJ-NEXT: FileHeader {
+; OBJ-NEXT: Magic: 0x1DF
+; OBJ-NEXT: NumberOfSections: 1
+; OBJ-NEXT: TimeStamp: None (0x0)
+; OBJ-NEXT: SymbolTableOffset: 0x8C
+; OBJ-NEXT: SymbolTableEntries: 20
+; OBJ-NEXT: OptionalHeaderSize: 0x0
+; OBJ-NEXT: Flags: 0x0
+; OBJ-NEXT: }
+
+; OBJ: Sections [
+; OBJ: Section {
+; OBJ-NEXT: Index: 1
+; OBJ-NEXT: Name: .text
+; OBJ-NEXT: PhysicalAddress: 0x0
+; OBJ-NEXT: VirtualAddress: 0x0
+; OBJ-NEXT: Size: 0x50
+; OBJ-NEXT: RawDataOffset: 0x3C
+; OBJ-NEXT: RelocationPointer: 0x0
+; OBJ-NEXT: LineNumberPointer: 0x0
+; OBJ-NEXT: NumberOfRelocations: 0
+; OBJ-NEXT: NumberOfLineNumbers: 0
+; OBJ-NEXT: Type: STYP_TEXT (0x20)
+; OBJ-NEXT: }
+; OBJ-NEXT: ]
+
+
+; SYMS: File: {{.*}}aix-xcoff-rodata.ll.tmp.o
+; SYMS-NEXT: Format: aixcoff-rs6000
+; SYMS-NEXT: Arch: powerpc
+; SYMS-NEXT: AddressSize: 32bit
+; SYMS: Symbols [
+; SYMS: Symbol {{[{][[:space:]] *}}Index: [[#INDX:]]{{[[:space:]] *}}Name: .rodata
+; SYMS-NEXT: Value (RelocatableAddress): 0x0
+; SYMS-NEXT: Section: .text
+; SYMS-NEXT: Type: 0x0
+; SYMS-NEXT: StorageClass: C_HIDEXT (0x6B)
+; SYMS-NEXT: NumberOfAuxEntries: 1
+; SYMS-NEXT: CSECT Auxiliary Entry {
+; SYMS-NEXT: Index: [[#INDX+1]]
+; SYMS-NEXT: SectionLen: 80
+; SYMS-NEXT: ParameterHashIndex: 0x0
+; SYMS-NEXT: TypeChkSectNum: 0x0
+; SYMS-NEXT: SymbolAlignmentLog2: 5
+; SYMS-NEXT: SymbolType: XTY_SD (0x1)
+; SYMS-NEXT: StorageMappingClass: XMC_RO (0x1)
+; SYMS-NEXT: StabInfoIndex: 0x0
+; SYMS-NEXT: StabSectNum: 0x0
+; SYMS-NEXT: }
+; SYMS-NEXT: }
+
+; SYMS: Symbol {
+; SYMS-NEXT: Index: [[#INDX+2]]
+; SYMS-NEXT: Name: const_ivar
+; SYMS-NEXT: Value (RelocatableAddress): 0x0
+; SYMS-NEXT: Section: .text
+; SYMS-NEXT: Type: 0x0
+; SYMS-NEXT: StorageClass: C_EXT (0x2)
+; SYMS-NEXT: NumberOfAuxEntries: 1
+; SYMS-NEXT: CSECT Auxiliary Entry {
+; SYMS-NEXT: Index: [[#INDX+3]]
+; SYMS-NEXT: ContainingCsectSymbolIndex: 2
+; SYMS-NEXT: ParameterHashIndex: 0x0
+; SYMS-NEXT: TypeChkSectNum: 0x0
+; SYMS-NEXT: SymbolAlignmentLog2: 0
+; SYMS-NEXT: SymbolType: XTY_LD (0x2)
+; SYMS-NEXT: StorageMappingClass: XMC_RO (0x1)
+; SYMS-NEXT: StabInfoIndex: 0x0
+; SYMS-NEXT: StabSectNum: 0x0
+; SYMS-NEXT: }
+; SYMS-NEXT: }
+
+; SYMS: Symbol {
+; SYMS-NEXT: Index: [[#INDX+4]]
+; SYMS-NEXT: Name: const_llvar
+; SYMS-NEXT: Value (RelocatableAddress): 0x8
+; SYMS-NEXT: Section: .text
+; SYMS-NEXT: Type: 0x0
+; SYMS-NEXT: StorageClass: C_EXT (0x2)
+; SYMS-NEXT: NumberOfAuxEntries: 1
+; SYMS-NEXT: CSECT Auxiliary Entry {
+; SYMS-NEXT: Index: [[#INDX+5]]
+; SYMS-NEXT: ContainingCsectSymbolIndex: 2
+; SYMS-NEXT: ParameterHashIndex: 0x0
+; SYMS-NEXT: TypeChkSectNum: 0x0
+; SYMS-NEXT: SymbolAlignmentLog2: 0
+; SYMS-NEXT: SymbolType: XTY_LD (0x2)
+; SYMS-NEXT: StorageMappingClass: XMC_RO (0x1)
+; SYMS-NEXT: StabInfoIndex: 0x0
+; SYMS-NEXT: StabSectNum: 0x0
+; SYMS-NEXT: }
+; SYMS-NEXT: }
+
+; SYMS: Symbol {
+; SYMS-NEXT: Index: [[#INDX+6]]
+; SYMS-NEXT: Name: const_svar
+; SYMS-NEXT: Value (RelocatableAddress): 0x10
+; SYMS-NEXT: Section: .text
+; SYMS-NEXT: Type: 0x0
+; SYMS-NEXT: StorageClass: C_EXT (0x2)
+; SYMS-NEXT: NumberOfAuxEntries: 1
+; SYMS-NEXT: CSECT Auxiliary Entry {
+; SYMS-NEXT: Index: [[#INDX+7]]
+; SYMS-NEXT: ContainingCsectSymbolIndex: 2
+; SYMS-NEXT: ParameterHashIndex: 0x0
+; SYMS-NEXT: TypeChkSectNum: 0x0
+; SYMS-NEXT: SymbolAlignmentLog2: 0
+; SYMS-NEXT: SymbolType: XTY_LD (0x2)
+; SYMS-NEXT: StorageMappingClass: XMC_RO (0x1)
+; SYMS-NEXT: StabInfoIndex: 0x0
+; SYMS-NEXT: StabSectNum: 0x0
+; SYMS-NEXT: }
+; SYMS-NEXT: }
+
+; SYMS: Symbol {
+; SYMS-NEXT: Index: [[#INDX+8]]
+; SYMS-NEXT: Name: const_fvar
+; SYMS-NEXT: Value (RelocatableAddress): 0x14
+; SYMS-NEXT: Section: .text
+; SYMS-NEXT: Type: 0x0
+; SYMS-NEXT: StorageClass: C_EXT (0x2)
+; SYMS-NEXT: NumberOfAuxEntries: 1
+; SYMS-NEXT: CSECT Auxiliary Entry {
+; SYMS-NEXT: Index: [[#INDX+9]]
+; SYMS-NEXT: ContainingCsectSymbolIndex: 2
+; SYMS-NEXT: ParameterHashIndex: 0x0
+; SYMS-NEXT: TypeChkSectNum: 0x0
+; SYMS-NEXT: SymbolAlignmentLog2: 0
+; SYMS-NEXT: SymbolType: XTY_LD (0x2)
+; SYMS-NEXT: StorageMappingClass: XMC_RO (0x1)
+; SYMS-NEXT: StabInfoIndex: 0x0
+; SYMS-NEXT: StabSectNum: 0x0
+; SYMS-NEXT: }
+; SYMS-NEXT: }
+
+; SYMS: Symbol {
+; SYMS-NEXT: Index: [[#INDX+10]]
+; SYMS-NEXT: Name: const_dvar
+; SYMS-NEXT: Value (RelocatableAddress): 0x18
+; SYMS-NEXT: Section: .text
+; SYMS-NEXT: Type: 0x0
+; SYMS-NEXT: StorageClass: C_EXT (0x2)
+; SYMS-NEXT: NumberOfAuxEntries: 1
+; SYMS-NEXT: CSECT Auxiliary Entry {
+; SYMS-NEXT: Index: [[#INDX+11]]
+; SYMS-NEXT: ContainingCsectSymbolIndex: 2
+; SYMS-NEXT: ParameterHashIndex: 0x0
+; SYMS-NEXT: TypeChkSectNum: 0x0
+; SYMS-NEXT: SymbolAlignmentLog2: 0
+; SYMS-NEXT: SymbolType: XTY_LD (0x2)
+; SYMS-NEXT: StorageMappingClass: XMC_RO (0x1)
+; SYMS-NEXT: StabInfoIndex: 0x0
+; SYMS-NEXT: StabSectNum: 0x0
+; SYMS-NEXT: }
+; SYMS-NEXT: }
+
+; SYMS: Symbol {
+; SYMS-NEXT: Index: [[#INDX+12]]
+; SYMS-NEXT: Name: const_over_aligned
+; SYMS-NEXT: Value (RelocatableAddress): 0x20
+; SYMS-NEXT: Section: .text
+; SYMS-NEXT: Type: 0x0
+; SYMS-NEXT: StorageClass: C_EXT (0x2)
+; SYMS-NEXT: NumberOfAuxEntries: 1
+; SYMS-NEXT: CSECT Auxiliary Entry {
+; SYMS-NEXT: Index: [[#INDX+13]]
+; SYMS-NEXT: ContainingCsectSymbolIndex: 2
+; SYMS-NEXT: ParameterHashIndex: 0x0
+; SYMS-NEXT: TypeChkSectNum: 0x0
+; SYMS-NEXT: SymbolAlignmentLog2: 0
+; SYMS-NEXT: SymbolType: XTY_LD (0x2)
+; SYMS-NEXT: StorageMappingClass: XMC_RO (0x1)
+; SYMS-NEXT: StabInfoIndex: 0x0
+; SYMS-NEXT: StabSectNum: 0x0
+; SYMS-NEXT: }
+; SYMS-NEXT: }
+
+; SYMS: Symbol {
+; SYMS-NEXT: Index: [[#INDX+14]]
+; SYMS-NEXT: Name: const_chrarray
+; SYMS-NEXT: Value (RelocatableAddress): 0x28
+; SYMS-NEXT: Section: .text
+; SYMS-NEXT: Type: 0x0
+; SYMS-NEXT: StorageClass: C_EXT (0x2)
+; SYMS-NEXT: NumberOfAuxEntries: 1
+; SYMS-NEXT: CSECT Auxiliary Entry {
+; SYMS-NEXT: Index: [[#INDX+15]]
+; SYMS-NEXT: ContainingCsectSymbolIndex: 2
+; SYMS-NEXT: ParameterHashIndex: 0x0
+; SYMS-NEXT: TypeChkSectNum: 0x0
+; SYMS-NEXT: SymbolAlignmentLog2: 0
+; SYMS-NEXT: SymbolType: XTY_LD (0x2)
+; SYMS-NEXT: StorageMappingClass: XMC_RO (0x1)
+; SYMS-NEXT: StabInfoIndex: 0x0
+; SYMS-NEXT: StabSectNum: 0x0
+; SYMS-NEXT: }
+; SYMS-NEXT: }
+
+; SYMS: Symbol {
+; SYMS-NEXT: Index: [[#INDX+16]]
+; SYMS-NEXT: Name: const_dblarr
+; SYMS-NEXT: Value (RelocatableAddress): 0x30
+; SYMS-NEXT: Section: .text
+; SYMS-NEXT: Type: 0x0
+; SYMS-NEXT: StorageClass: C_EXT (0x2)
+; SYMS-NEXT: NumberOfAuxEntries: 1
+; SYMS-NEXT: CSECT Auxiliary Entry {
+; SYMS-NEXT: Index: [[#INDX+17]]
+; SYMS-NEXT: ContainingCsectSymbolIndex: 2
+; SYMS-NEXT: ParameterHashIndex: 0x0
+; SYMS-NEXT: TypeChkSectNum: 0x0
+; SYMS-NEXT: SymbolAlignmentLog2: 0
+; SYMS-NEXT: SymbolType: XTY_LD (0x2)
+; SYMS-NEXT: StorageMappingClass: XMC_RO (0x1)
+; SYMS-NEXT: StabInfoIndex: 0x0
+; SYMS-NEXT: StabSectNum: 0x0
+; SYMS-NEXT: }
+; SYMS-NEXT: }
+; SYMS: ]
+
+; DIS: Disassembly of section .text:
+; DIS: 00000000 const_ivar:
+; DIS-NEXT: 0: 00 00 00 23
+; DIS-NEXT: 4: 00 00 00 00
+
+; DIS: 00000008 const_llvar:
+; DIS-NEXT: 8: 00 00 00 00
+; DIS-NEXT: c: 00 00 00 24
+
+; DIS: 00000010 const_svar:
+; DIS-NEXT: 10: 00 25 00 00
+
+; DIS: 00000014 const_fvar:
+; DIS-NEXT: 14: 44 48 00 00
+
+; DIS: 00000018 const_dvar:
+; DIS-NEXT: 18: 40 8c 20 00
+; DIS-NEXT: 1c: 00 00 00 00
+
+; DIS: 00000020 const_over_aligned:
+; DIS-NEXT: 20: 40 8c 20 00
+; DIS-NEXT: 24: 00 00 00 00
+
+; DIS: 00000028 const_chrarray:
+; DIS-NEXT: 28: 61 62 63 64
+; DIS-NEXT: 2c: 00 00 00 00
+
+; DIS: 00000030 const_dblarr:
+; DIS-NEXT: 30: 3f f0 00 00
+; DIS-NEXT: 34: 00 00 00 00
+; DIS-NEXT: 38: 40 00 00 00
+; DIS-NEXT: 3c: 00 00 00 00
+; DIS-NEXT: 40: 40 08 00 00
+; DIS-NEXT: 44: 00 00 00 00
+; DIS-NEXT: 48: 40 10 00 00
+; DIS-NEXT: 4c: 00 00 00 00
OpenPOWER on IntegriCloud