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

Unified Diff: src/IceELFObjectWriter.cpp

Issue 1669443002: Subzero. Uses fixups to calculate addend to relocations. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. Created 4 years, 11 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 b701f2af123aff39f926b604646ad5d25e62fc60..f370d873cd9fe3b5f5cb06ed9f653f9a13bfc87a 100644
--- a/src/IceELFObjectWriter.cpp
+++ b/src/IceELFObjectWriter.cpp
@@ -217,7 +217,7 @@ Elf64_Off ELFObjectWriter::alignFileOffset(Elf64_Xword Align) {
}
void ELFObjectWriter::writeFunctionCode(const IceString &FuncName,
- bool IsInternal, const Assembler *Asm) {
+ bool IsInternal, Assembler *Asm) {
assert(!SectionNumbersAssigned);
ELFTextSection *Section = nullptr;
ELFRelocationSection *RelSection = nullptr;
@@ -243,7 +243,6 @@ void ELFObjectWriter::writeFunctionCode(const IceString &FuncName,
// Function symbols are set to 0 size in the symbol table, in contrast to
// data symbols which have a proper size.
constexpr SizeT SymbolSize = 0;
- Section->appendData(Str, Asm->getBufferView());
uint8_t SymbolType;
uint8_t SymbolBinding;
if (IsInternal && !Ctx.getFlags().getDisableInternal()) {
@@ -259,9 +258,18 @@ void ELFObjectWriter::writeFunctionCode(const IceString &FuncName,
// Copy the fixup information from per-function Assembler memory to the
// object writer's memory, for writing later.
- if (!Asm->fixups().empty()) {
+ const auto &Fixups = Asm->fixups();
+ if (!Fixups.empty()) {
+ if (!RelSection->isRela()) {
+ // This is a non-rela section, so we need to update the instruction stream
+ // with the relocation addends.
+ for (const auto *Fixup : Fixups) {
Jim Stichnoth 2016/02/03 23:18:27 const AssemblerFixup *Fixup
John 2016/02/04 18:28:50 Discussed offline. Leaving as is.
+ Fixup->emitOffset(Asm);
+ }
+ }
RelSection->addRelocations(OffsetInSection, Asm->fixups());
}
+ Section->appendData(Str, Asm->getBufferView());
}
namespace {

Powered by Google App Engine
This is Rietveld 408576698