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

Unified Diff: src/IceELFObjectWriter.cpp

Issue 1506653002: Subzero: Add Non-SFI support for x86-32. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 12 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
« no previous file with comments | « src/IceELFObjectWriter.h ('k') | src/IceELFSection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceELFObjectWriter.cpp
diff --git a/src/IceELFObjectWriter.cpp b/src/IceELFObjectWriter.cpp
index 5d816359dfa266ea7611a4703c76289a93daf790..cb36e3d92a0cf7aa68fdce4af2db63d859677a85 100644
--- a/src/IceELFObjectWriter.cpp
+++ b/src/IceELFObjectWriter.cpp
@@ -285,7 +285,8 @@ void partitionGlobalsBySection(const VariableDeclarationList &Vars,
void ELFObjectWriter::writeDataSection(const VariableDeclarationList &Vars,
FixupKind RelocationKind,
- const IceString &SectionSuffix) {
+ const IceString &SectionSuffix,
+ bool IsPIC) {
assert(!SectionNumbersAssigned);
VariableDeclarationList VarsBySection[ELFObjectWriter::NumSectionTypes];
for (auto &SectionList : VarsBySection)
@@ -295,7 +296,7 @@ void ELFObjectWriter::writeDataSection(const VariableDeclarationList &Vars,
size_t I = 0;
for (auto &SectionList : VarsBySection) {
writeDataOfType(static_cast<SectionType>(I++), SectionList, RelocationKind,
- SectionSuffix);
+ SectionSuffix, IsPIC);
}
}
@@ -311,7 +312,8 @@ IceString MangleSectionName(const char Base[], const IceString &Suffix) {
void ELFObjectWriter::writeDataOfType(SectionType ST,
const VariableDeclarationList &Vars,
FixupKind RelocationKind,
- const IceString &SectionSuffix) {
+ const IceString &SectionSuffix,
+ bool IsPIC) {
if (Vars.empty())
return;
ELFDataSection *Section;
@@ -326,8 +328,9 @@ void ELFObjectWriter::writeDataOfType(SectionType ST,
// Lift this out, so it can be re-used if we do fdata-sections?
switch (ST) {
case ROData: {
- const IceString SectionName = MangleSectionName(".rodata", SectionSuffix);
- constexpr Elf64_Xword ShFlags = SHF_ALLOC;
+ const IceString SectionName =
+ MangleSectionName(IsPIC ? ".data.rel.ro" : ".rodata", SectionSuffix);
+ const Elf64_Xword ShFlags = SHF_ALLOC | (IsPIC ? SHF_WRITE : 0);
Section = createSection<ELFDataSection>(SectionName, SHT_PROGBITS, ShFlags,
ShAddralign, ShEntsize);
Section->setFileOffset(alignFileOffset(ShAddralign));
@@ -557,14 +560,14 @@ void ELFObjectWriter::writeAllRelocationSections() {
}
void ELFObjectWriter::writeJumpTable(const JumpTableData &JT,
- FixupKind RelocationKind) {
+ FixupKind RelocationKind, bool IsPIC) {
ELFDataSection *Section;
ELFRelocationSection *RelSection;
const Elf64_Xword PointerSize = typeWidthInBytes(getPointerType());
const Elf64_Xword ShAddralign = PointerSize;
const Elf64_Xword ShEntsize = PointerSize;
- const IceString SectionName =
- MangleSectionName(".rodata", JT.getFunctionName() + "$jumptable");
+ const IceString SectionName = MangleSectionName(
+ IsPIC ? ".data.rel.ro" : ".rodata", JT.getFunctionName() + "$jumptable");
Section = createSection<ELFDataSection>(SectionName, SHT_PROGBITS, SHF_ALLOC,
ShAddralign, ShEntsize);
Section->setFileOffset(alignFileOffset(ShAddralign));
« no previous file with comments | « src/IceELFObjectWriter.h ('k') | src/IceELFSection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698