summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/XCOFFObjectWriter.cpp
diff options
context:
space:
mode:
authorjasonliu <jasonliu.development@gmail.com>2019-10-30 18:31:31 +0000
committerjasonliu <jasonliu.development@gmail.com>2019-10-30 18:44:35 +0000
commit8bd0c9781001f66e86e77ee076b20522efb92c9d (patch)
tree6f2b7866de17e451064ceb2044c2bd73ca243be5 /llvm/lib/MC/XCOFFObjectWriter.cpp
parent3137fe4d23eeb8df08c03e9111465325eeafe08e (diff)
downloadbcm5719-llvm-8bd0c9781001f66e86e77ee076b20522efb92c9d.tar.gz
bcm5719-llvm-8bd0c9781001f66e86e77ee076b20522efb92c9d.zip
[PowerPC][AIX] Adds support for writing the data section in object files
Adds support for generating the XCOFF data section in object files for global variables with initialization. Merged aix-xcoff-common.ll into aix-xcoff-data.ll. Changed variable name charr to chrarray in the test case to test if readobj works with 8-character names. Authored by: xingxue Reviewers: hubert.reinterptrtcast, sfertile, jasonliu, daltenty, Xiangling_L. Reviewed by: hubert.reinterpretcast, sfertile, daltenty. Subscribers: DiggerLin, Wuzish, nemanjai, hiraditya, MaskRay, jsji, shchenz, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67125
Diffstat (limited to 'llvm/lib/MC/XCOFFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/XCOFFObjectWriter.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index 05f3f769e5b..d8f9e0b593b 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -158,15 +158,17 @@ 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::LabelDefSupported, {}};
+ CsectGroup DataCsects{CsectGroup::LabelDefSupported, {}};
CsectGroup BSSCsects{CsectGroup::LabelDefUnsupported, {}};
// The Predefined sections.
Section Text;
+ Section Data;
Section BSS;
// All the XCOFF sections, in the order they will appear in the section header
// table.
- std::array<Section *const, 2> Sections{{&Text, &BSS}};
+ std::array<Section *const, 3> Sections{{&Text, &Data, &BSS}};
CsectGroup &getCsectGroup(const MCSectionXCOFF *MCSec);
@@ -224,6 +226,8 @@ XCOFFObjectWriter::XCOFFObjectWriter(
Strings(StringTableBuilder::XCOFF),
Text(".text", XCOFF::STYP_TEXT, /* IsVirtual */ false,
CsectGroups{&ProgramCodeCsects}),
+ Data(".data", XCOFF::STYP_DATA, /* IsVirtual */ false,
+ CsectGroups{&DataCsects}),
BSS(".bss", XCOFF::STYP_BSS, /* IsVirtual */ true,
CsectGroups{&BSSCsects}) {}
@@ -251,6 +255,9 @@ CsectGroup &XCOFFObjectWriter::getCsectGroup(const MCSectionXCOFF *MCSec) {
if (XCOFF::XTY_CM == MCSec->getCSectType())
return BSSCsects;
+ if (XCOFF::XTY_SD == MCSec->getCSectType())
+ return DataCsects;
+
report_fatal_error("Unhandled mapping of read-write csect to section.");
case XCOFF::XMC_BS:
assert(XCOFF::XTY_CM == MCSec->getCSectType() &&
OpenPOWER on IntegriCloud