Skip to content

Commit 8bd0c97

Browse files
committed
[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
1 parent 3137fe4 commit 8bd0c97

File tree

3 files changed

+468
-225
lines changed

3 files changed

+468
-225
lines changed

llvm/lib/MC/XCOFFObjectWriter.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,17 @@ class XCOFFObjectWriter : public MCObjectWriter {
158158
// the sections. Should have one for each set of csects that get mapped into
159159
// the same section and get handled in a 'similar' way.
160160
CsectGroup ProgramCodeCsects{CsectGroup::LabelDefSupported, {}};
161+
CsectGroup DataCsects{CsectGroup::LabelDefSupported, {}};
161162
CsectGroup BSSCsects{CsectGroup::LabelDefUnsupported, {}};
162163

163164
// The Predefined sections.
164165
Section Text;
166+
Section Data;
165167
Section BSS;
166168

167169
// All the XCOFF sections, in the order they will appear in the section header
168170
// table.
169-
std::array<Section *const, 2> Sections{{&Text, &BSS}};
171+
std::array<Section *const, 3> Sections{{&Text, &Data, &BSS}};
170172

171173
CsectGroup &getCsectGroup(const MCSectionXCOFF *MCSec);
172174

@@ -224,6 +226,8 @@ XCOFFObjectWriter::XCOFFObjectWriter(
224226
Strings(StringTableBuilder::XCOFF),
225227
Text(".text", XCOFF::STYP_TEXT, /* IsVirtual */ false,
226228
CsectGroups{&ProgramCodeCsects}),
229+
Data(".data", XCOFF::STYP_DATA, /* IsVirtual */ false,
230+
CsectGroups{&DataCsects}),
227231
BSS(".bss", XCOFF::STYP_BSS, /* IsVirtual */ true,
228232
CsectGroups{&BSSCsects}) {}
229233

@@ -251,6 +255,9 @@ CsectGroup &XCOFFObjectWriter::getCsectGroup(const MCSectionXCOFF *MCSec) {
251255
if (XCOFF::XTY_CM == MCSec->getCSectType())
252256
return BSSCsects;
253257

258+
if (XCOFF::XTY_SD == MCSec->getCSectType())
259+
return DataCsects;
260+
254261
report_fatal_error("Unhandled mapping of read-write csect to section.");
255262
case XCOFF::XMC_BS:
256263
assert(XCOFF::XTY_CM == MCSec->getCSectType() &&

llvm/test/CodeGen/PowerPC/aix-xcoff-common.ll

-221
This file was deleted.

0 commit comments

Comments
 (0)