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

Unified Diff: src/IceELFSection.h

Issue 1559243002: Suzero. X8664. NaCl Sandboxing. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: make format 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/IceELFSection.h
diff --git a/src/IceELFSection.h b/src/IceELFSection.h
index ef1b299f68d1e8275175a9d61baa3f2d44979350..fcaa9d577e802ad2bc41c86e69259c6fab5109fa 100644
--- a/src/IceELFSection.h
+++ b/src/IceELFSection.h
@@ -356,17 +356,24 @@ void ELFRelocationSection::writeData(const GlobalContext &Ctx, ELFStreamer &Str,
Symbol = SymTab->getNullSymbol();
} else {
constexpr Assembler *Asm = nullptr;
+ IceString Name = Fixup.symbol(&Ctx, Asm);
Jim Stichnoth 2016/01/13 18:28:26 Can you move this into the "if (!Symbol) { ... }"
John 2016/01/13 20:48:03 Having this here allows for a better error-message
Symbol = SymTab->findSymbol(Fixup.symbol(&Ctx, Asm));
+ if (!Symbol)
+ llvm::report_fatal_error(Name + ": Missing symbol mentioned in reloc");
}
- if (!Symbol)
- llvm::report_fatal_error("Missing symbol mentioned in reloc");
if (IsELF64) {
- // TODO(jpp): check that Fixup.offset() is correct even for pc-rel.
Elf64_Rela Rela;
Rela.r_offset = Fixup.position();
Rela.setSymbolAndType(Symbol->getNumber(), Fixup.kind());
Rela.r_addend = Fixup.offset();
+ if (Fixup.kind() == llvm::ELF::R_X86_64_PC32) {
+ // In ELF64, PC-relative relocations' addend need to account for
Jim Stichnoth 2016/01/13 18:28:26 "addends" (for agreement)
Jim Stichnoth 2016/01/13 18:28:26 reflow comment to 80-col
John 2016/01/13 20:48:03 Done.
John 2016/01/13 20:48:03 Done.
+ // the immediate size. For now, this is always 4 (because x86-64
+ // sandboxed is the only ELF64 target currently implemented.)
+ constexpr int32_t RelocImmediateSize = 4;
+ Rela.r_addend -= RelocImmediateSize;
+ }
Str.writeAddrOrOffset<IsELF64>(Rela.r_offset);
Str.writeELFXword<IsELF64>(Rela.r_info);
Str.writeELFXword<IsELF64>(Rela.r_addend);

Powered by Google App Engine
This is Rietveld 408576698