summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorSean Fertile <sfertile@ca.ibm.com>2019-08-20 22:03:18 +0000
committerSean Fertile <sfertile@ca.ibm.com>2019-08-20 22:03:18 +0000
commit1e46d4cec535588dec8653757894d890e38942cb (patch)
treec3d86ba516175b1fd96499269022ef638f51d2b9 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent27a313ebde156f2db5f071a10444c9df8c332fc6 (diff)
downloadbcm5719-llvm-1e46d4cec535588dec8653757894d890e38942cb.tar.gz
bcm5719-llvm-1e46d4cec535588dec8653757894d890e38942cb.zip
Adds support for writing the .bss section for XCOFF object files.
Adds Wrapper classes for MCSymbol and MCSection into the XCOFF target object writer. Also adds a class to represent the top-level sections, which we materialize in the ObjectWriter. executePostLayoutBinding will map all csects into the appropriate container depending on its storage mapping class, and map all symbols into their containing csect. Once all symbols have been processed we - Assign addresses and symbol table indices. - Calaculte section sizes. - Build the section header table. - Assign the sections raw-pointer value for non-virtual sections. Since the .bss section is virtual, writing the header table is enough to add support. Writing of a sections raw data, or of any relocations is not included in this patch. Testing is done by dumping the section header table, but it needs to be extended to include dumping the symbol table once readobj support for dumping auxiallary entries lands. Differential Revision: https://reviews.llvm.org/D65159 llvm-svn: 369454
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 9c1eee0f8fc..7abc86dfde7 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1840,9 +1840,11 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal(
if (Kind.isBSSLocal() || Kind.isCommon()) {
SmallString<128> Name;
getNameWithPrefix(Name, GO, TM);
+ XCOFF::StorageClass SC =
+ TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GO);
return getContext().getXCOFFSection(
Name, Kind.isBSSLocal() ? XCOFF::XMC_BS : XCOFF::XMC_RW, XCOFF::XTY_CM,
- Kind, /* BeginSymbolName */ nullptr);
+ SC, Kind, /* BeginSymbolName */ nullptr);
}
if (Kind.isText())
@@ -1879,3 +1881,19 @@ const MCExpr *TargetLoweringObjectFileXCOFF::lowerRelativeReference(
const TargetMachine &TM) const {
report_fatal_error("XCOFF not yet implemented.");
}
+
+XCOFF::StorageClass TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(
+ const GlobalObject *GO) {
+ switch (GO->getLinkage()) {
+ case GlobalValue::InternalLinkage:
+ return XCOFF::C_HIDEXT;
+ case GlobalValue::ExternalLinkage:
+ case GlobalValue::CommonLinkage:
+ return XCOFF::C_EXT;
+ case GlobalValue::ExternalWeakLinkage:
+ return XCOFF::C_WEAKEXT;
+ default:
+ report_fatal_error(
+ "Unhandled linkage when mapping linkage to StorageClass.");
+ }
+}
OpenPOWER on IntegriCloud