diff options
author | jasonliu <jasonliu.development@gmail.com> | 2019-11-19 15:09:07 +0000 |
---|---|---|
committer | jasonliu <jasonliu.development@gmail.com> | 2019-11-19 16:11:00 +0000 |
commit | c9edaa828eb84a62af2042a1a64168e32ea32924 (patch) | |
tree | 91dc4e3127f46db52f4251a06ec8fa59a1abaa4f | |
parent | 980653621ef563df41f1d09a1ac8c58708f79930 (diff) | |
download | bcm5719-llvm-c9edaa828eb84a62af2042a1a64168e32ea32924.tar.gz bcm5719-llvm-c9edaa828eb84a62af2042a1a64168e32ea32924.zip |
[AIX][XCOFF] Write Function descriptors and TOC base to data section
This patch implements writing function descriptors and TOC base into
data section, and also add function descriptors(both csect and label)
and TOC base symbols to the symbol table.
-rw-r--r-- | llvm/lib/MC/XCOFFObjectWriter.cpp | 19 | ||||
-rw-r--r-- | llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll | 112 |
2 files changed, 125 insertions, 6 deletions
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp index cec74ee76c3..34f75e2ccdf 100644 --- a/llvm/lib/MC/XCOFFObjectWriter.cpp +++ b/llvm/lib/MC/XCOFFObjectWriter.cpp @@ -151,6 +151,8 @@ class XCOFFObjectWriter : public MCObjectWriter { // the same section and get handled in a 'similar' way. CsectGroup ProgramCodeCsects; CsectGroup DataCsects; + CsectGroup FuncDSCsects; + CsectGroup TOCCsects; CsectGroup BSSCsects; // The Predefined sections. @@ -219,7 +221,7 @@ XCOFFObjectWriter::XCOFFObjectWriter( Text(".text", XCOFF::STYP_TEXT, /* IsVirtual */ false, CsectGroups{&ProgramCodeCsects}), Data(".data", XCOFF::STYP_DATA, /* IsVirtual */ false, - CsectGroups{&DataCsects}), + CsectGroups{&DataCsects, &FuncDSCsects, &TOCCsects}), BSS(".bss", XCOFF::STYP_BSS, /* IsVirtual */ true, CsectGroups{&BSSCsects}) {} @@ -251,11 +253,20 @@ CsectGroup &XCOFFObjectWriter::getCsectGroup(const MCSectionXCOFF *MCSec) { return DataCsects; report_fatal_error("Unhandled mapping of read-write csect to section."); + case XCOFF::XMC_DS: + return FuncDSCsects; case XCOFF::XMC_BS: assert(XCOFF::XTY_CM == MCSec->getCSectType() && "Mapping invalid csect. CSECT with bss storage class must be " "common type."); return BSSCsects; + case XCOFF::XMC_TC0: + assert(XCOFF::XTY_SD == MCSec->getCSectType() && + "Only an initialized csect can contain TOC-base."); + assert(TOCCsects.empty() && + "We should have only one TOC-base, and it should be the first csect " + "in this CsectGroup."); + return TOCCsects; default: report_fatal_error("Unhandled mapping of csect to section."); } @@ -281,10 +292,6 @@ void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm, if (nameShouldBeInStringTable(MCSec->getSectionName())) Strings.add(MCSec->getSectionName()); - // TODO FIXME Handle emiting the TOC base. - if (MCSec->getMappingClass() == XCOFF::XMC_TC0) - continue; - CsectGroup &Group = getCsectGroup(MCSec); Group.emplace_back(MCSec); WrapperMap[MCSec] = &Group.back(); @@ -322,7 +329,7 @@ void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm, void XCOFFObjectWriter::recordRelocation(MCAssembler &, const MCAsmLayout &, const MCFragment *, const MCFixup &, MCValue, uint64_t &) { - report_fatal_error("XCOFF relocations not supported."); + // TODO: recordRelocation is not yet implemented. } void XCOFFObjectWriter::writeSections(const MCAssembler &Asm, diff --git a/llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll b/llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll new file mode 100644 index 00000000000..217f687e8b0 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll @@ -0,0 +1,112 @@ +; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s +; RUN: llvm-readobj --symbols %t.o | FileCheck %s + +define void @foo() { +entry: + ret void +} + +; CHECK: File: {{.*}}aix-func-dsc-gen.ll.tmp.o +; CHECK-NEXT: Format: aixcoff-rs6000 +; CHECK-NEXT: Arch: powerpc +; CHECK-NEXT: AddressSize: 32bit +; CHECK: Symbol { +; CHECK-NEXT: Index: [[#Index:]] +; CHECK-NEXT: Name: .text +; CHECK-NEXT: Value (RelocatableAddress): 0x0 +; CHECK-NEXT: Section: .text +; CHECK-NEXT: Type: 0x0 +; CHECK-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECK-NEXT: NumberOfAuxEntries: 1 +; CHECK-NEXT: CSECT Auxiliary Entry { +; CHECK-NEXT: Index: [[#Index+1]] +; CHECK-NEXT: SectionLen: 4 +; CHECK-NEXT: ParameterHashIndex: 0x0 +; CHECK-NEXT: TypeChkSectNum: 0x0 +; CHECK-NEXT: SymbolAlignmentLog2: 4 +; CHECK-NEXT: SymbolType: XTY_SD (0x1) +; CHECK-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECK-NEXT: StabInfoIndex: 0x0 +; CHECK-NEXT: StabSectNum: 0x0 +; CHECK-NEXT: } +; CHECK-NEXT: } +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Index: [[#Index+2]] +; CHECK-NEXT: Name: .foo +; CHECK-NEXT: Value (RelocatableAddress): 0x0 +; CHECK-NEXT: Section: .text +; CHECK-NEXT: Type: 0x0 +; CHECK-NEXT: StorageClass: C_EXT (0x2) +; CHECK-NEXT: NumberOfAuxEntries: 1 +; CHECK-NEXT: CSECT Auxiliary Entry { +; CHECK-NEXT: Index: [[#Index+3]] +; CHECK-NEXT: ContainingCsectSymbolIndex: [[#Index]] +; CHECK-NEXT: ParameterHashIndex: 0x0 +; CHECK-NEXT: TypeChkSectNum: 0x0 +; CHECK-NEXT: SymbolAlignmentLog2: 0 +; CHECK-NEXT: SymbolType: XTY_LD (0x2) +; CHECK-NEXT: StorageMappingClass: XMC_PR (0x0) +; CHECK-NEXT: StabInfoIndex: 0x0 +; CHECK-NEXT: StabSectNum: 0x0 +; CHECK-NEXT: } +; CHECK-NEXT: } +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Index: [[#Index+4]] +; CHECK-NEXT: Name: foo +; CHECK-NEXT: Value (RelocatableAddress): 0x4 +; CHECK-NEXT: Section: .data +; CHECK-NEXT: Type: 0x0 +; CHECK-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECK-NEXT: NumberOfAuxEntries: 1 +; CHECK-NEXT: CSECT Auxiliary Entry { +; CHECK-NEXT: Index: [[#Index+5]] +; CHECK-NEXT: SectionLen: 12 +; CHECK-NEXT: ParameterHashIndex: 0x0 +; CHECK-NEXT: TypeChkSectNum: 0x0 +; CHECK-NEXT: SymbolAlignmentLog2: 0 +; CHECK-NEXT: SymbolType: XTY_SD (0x1) +; CHECK-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECK-NEXT: StabInfoIndex: 0x0 +; CHECK-NEXT: StabSectNum: 0x0 +; CHECK-NEXT: } +; CHECK-NEXT: } +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Index: [[#Index+6]] +; CHECK-NEXT: Name: foo +; CHECK-NEXT: Value (RelocatableAddress): 0x4 +; CHECK-NEXT: Section: .data +; CHECK-NEXT: Type: 0x0 +; CHECK-NEXT: StorageClass: C_EXT (0x2) +; CHECK-NEXT: NumberOfAuxEntries: 1 +; CHECK-NEXT: CSECT Auxiliary Entry { +; CHECK-NEXT: Index: [[#Index+7]] +; CHECK-NEXT: ContainingCsectSymbolIndex: [[#Index+4]] +; CHECK-NEXT: ParameterHashIndex: 0x0 +; CHECK-NEXT: TypeChkSectNum: 0x0 +; CHECK-NEXT: SymbolAlignmentLog2: 0 +; CHECK-NEXT: SymbolType: XTY_LD (0x2) +; CHECK-NEXT: StorageMappingClass: XMC_DS (0xA) +; CHECK-NEXT: StabInfoIndex: 0x0 +; CHECK-NEXT: StabSectNum: 0x0 +; CHECK-NEXT: } +; CHECK-NEXT: } +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Index: [[#Index+8]] +; CHECK-NEXT: Name: TOC +; CHECK-NEXT: Value (RelocatableAddress): 0x10 +; CHECK-NEXT: Section: .data +; CHECK-NEXT: Type: 0x0 +; CHECK-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECK-NEXT: NumberOfAuxEntries: 1 +; CHECK-NEXT: CSECT Auxiliary Entry { +; CHECK-NEXT: Index: [[#Index+9]] +; CHECK-NEXT: SectionLen: 0 +; CHECK-NEXT: ParameterHashIndex: 0x0 +; CHECK-NEXT: TypeChkSectNum: 0x0 +; CHECK-NEXT: SymbolAlignmentLog2: 0 +; CHECK-NEXT: SymbolType: XTY_SD (0x1) +; CHECK-NEXT: StorageMappingClass: XMC_TC0 (0xF) +; CHECK-NEXT: StabInfoIndex: 0x0 +; CHECK-NEXT: StabSectNum: 0x0 +; CHECK-NEXT: } +; CHECK-NEXT: } |