Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: src/IceELFObjectWriter.cpp

Issue 1179313004: Fix a bug that would cause subzero to fail when --threads=0. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Removes (newly introduces) unused parameter warning. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceELFObjectWriter.cpp
diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp
index edb46fae0af2f2406b5e5e3bcbeca0cd993a9a29..8587ed9a3fd9a31070fe081b189a2c9e10ec24b6 100644
--- a/src/IceELFObjectWriter.cpp
+++ b/src/IceELFObjectWriter.cpp
@@ -11,6 +11,8 @@
//
//===----------------------------------------------------------------------===//
+#include <sstream>
+
#include "llvm/Support/MathExtras.h"
#include "IceAssembler.h"
@@ -285,7 +287,8 @@ void partitionGlobalsBySection(const VariableDeclarationList &Vars,
} // end of anonymous namespace
void ELFObjectWriter::writeDataSection(const VariableDeclarationList &Vars,
- FixupKind RelocationKind) {
+ FixupKind RelocationKind,
+ const IceString &SectionSuffix) {
assert(!SectionNumbersAssigned);
VariableDeclarationList VarsBySection[ELFObjectWriter::NumSectionTypes];
for (auto &SectionList : VarsBySection)
@@ -294,18 +297,28 @@ void ELFObjectWriter::writeDataSection(const VariableDeclarationList &Vars,
Ctx.getFlags().getTranslateOnly());
size_t I = 0;
for (auto &SectionList : VarsBySection) {
- writeDataOfType(static_cast<SectionType>(I++), SectionList, RelocationKind);
+ writeDataOfType(static_cast<SectionType>(I++), SectionList, RelocationKind,
+ SectionSuffix);
}
}
+namespace {
+IceString MangleSectionName(const char Base[], const IceString &Suffix) {
+ if (Suffix.empty())
+ return Base;
+ return (std::ostringstream() << Base << "." << Suffix).str();
+}
+} // end of anonymous namespace
+
+// TODO(jvoung): Handle fdata-sections.
void ELFObjectWriter::writeDataOfType(SectionType ST,
const VariableDeclarationList &Vars,
- FixupKind RelocationKind) {
+ FixupKind RelocationKind,
+ const IceString &SectionSuffix) {
if (Vars.empty())
return;
ELFDataSection *Section;
ELFRelocationSection *RelSection;
- // TODO(jvoung): Handle fdata-sections.
IceString SectionName;
Elf64_Xword ShAddralign = 1;
for (VariableDeclaration *Var : Vars) {
@@ -316,9 +329,7 @@ void ELFObjectWriter::writeDataOfType(SectionType ST,
// Lift this out, so it can be re-used if we do fdata-sections?
switch (ST) {
case ROData: {
- SectionName = ".rodata";
- // Only expecting to write the data sections all in one shot for now.
- assert(RODataSections.empty());
+ const IceString SectionName = MangleSectionName(".rodata", SectionSuffix);
const Elf64_Xword ShFlags = SHF_ALLOC;
Section = createSection<ELFDataSection>(SectionName, SHT_PROGBITS, ShFlags,
ShAddralign, ShEntsize);
@@ -329,8 +340,7 @@ void ELFObjectWriter::writeDataOfType(SectionType ST,
break;
}
case Data: {
- SectionName = ".data";
- assert(DataSections.empty());
+ const IceString SectionName = MangleSectionName(".data", SectionSuffix);
const Elf64_Xword ShFlags = SHF_ALLOC | SHF_WRITE;
Section = createSection<ELFDataSection>(SectionName, SHT_PROGBITS, ShFlags,
ShAddralign, ShEntsize);
@@ -341,8 +351,7 @@ void ELFObjectWriter::writeDataOfType(SectionType ST,
break;
}
case BSS: {
- SectionName = ".bss";
- assert(BSSSections.empty());
+ const IceString SectionName = MangleSectionName(".bss", SectionSuffix);
const Elf64_Xword ShFlags = SHF_ALLOC | SHF_WRITE;
Section = createSection<ELFDataSection>(SectionName, SHT_NOBITS, ShFlags,
ShAddralign, ShEntsize);
@@ -383,9 +392,8 @@ void ELFObjectWriter::writeDataOfType(SectionType ST,
for (VariableDeclaration::Initializer *Init : Var->getInitializers()) {
switch (Init->getKind()) {
case VariableDeclaration::Initializer::DataInitializerKind: {
- const auto Data =
- llvm::cast<VariableDeclaration::DataInitializer>(Init)
- ->getContents();
+ const auto Data = llvm::cast<VariableDeclaration::DataInitializer>(
+ Init)->getContents();
Section->appendData(Str, llvm::StringRef(Data.data(), Data.size()));
break;
}

Powered by Google App Engine
This is Rietveld 408576698