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

Unified Diff: src/IceELFSection.cpp

Issue 874353006: Write out global initializers and data rel directly to ELF file. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: tweak comment Created 5 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.cpp
diff --git a/src/IceELFSection.cpp b/src/IceELFSection.cpp
index 5dcc206df8d61849ba2cd529ceed6967fa366a23..f6fb526a2dcab01fa91639ae09e9d33a42a577b8 100644
--- a/src/IceELFSection.cpp
+++ b/src/IceELFSection.cpp
@@ -11,6 +11,8 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/MathExtras.h"
+
#include "IceDefs.h"
#include "IceELFSection.h"
#include "IceELFStreamer.h"
@@ -35,6 +37,32 @@ void ELFDataSection::appendData(ELFStreamer &Str,
Header.sh_size += MoreData.size();
}
+void ELFDataSection::appendZeros(ELFStreamer &Str, SizeT NumBytes) {
+ Str.writeZeroPadding(NumBytes);
+ Header.sh_size += NumBytes;
+}
+
+void ELFDataSection::appendRelocationOffset(ELFStreamer &Str, bool IsRela,
+ RelocOffsetT RelocOffset) {
+ if (IsRela) {
+ appendZeros(Str, RelocAddrSize);
+ return;
+ }
+ static_assert(RelocAddrSize == 4, " writeLE32 assumes RelocAddrSize is 4");
+ Str.writeLE32(RelocOffset);
+ Header.sh_size += RelocAddrSize;
+}
+
+void ELFDataSection::padToAlignment(ELFStreamer &Str, Elf64_Xword Align) {
+ assert(llvm::isPowerOf2_32(Align));
+ Elf64_Xword AlignDiff = Utils::OffsetToAlignment(Header.sh_size, Align);
+ if (AlignDiff == 0)
+ return;
+ if (Header.sh_type != llvm::ELF::SHT_NOBITS)
+ Str.writeZeroPadding(AlignDiff);
+ Header.sh_size += AlignDiff;
+}
+
// Relocation sections.
void ELFRelocationSection::addRelocations(RelocOffsetT BaseOff,
@@ -73,7 +101,7 @@ void ELFSymbolTableSection::createDefinedSym(const IceString &Name,
NewSymbol.Section = Section;
NewSymbol.Number = ELFSym::UnknownNumber;
bool Unique;
- if (Type == STB_LOCAL)
+ if (Binding == STB_LOCAL)
Unique = LocalSymbols.insert(std::make_pair(Name, NewSymbol)).second;
else
Unique = GlobalSymbols.insert(std::make_pair(Name, NewSymbol)).second;
« src/IceELFObjectWriter.cpp ('K') | « src/IceELFSection.h ('k') | src/IceGlobalInits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698