Chromium Code Reviews| Index: src/IceELFSection.cpp |
| diff --git a/src/IceELFSection.cpp b/src/IceELFSection.cpp |
| index 5dcc206df8d61849ba2cd529ceed6967fa366a23..00289e6e3c755120ad80af725a4562f733bcbf21 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" |
| @@ -19,6 +21,19 @@ using namespace llvm::ELF; |
| namespace Ice { |
| +void ELFSection::padToAlignment(ELFStreamer &Str, bool WritePadding, |
| + Elf64_Xword Align) { |
| + assert(llvm::isPowerOf2_32(Align)); |
| + Elf64_Xword Mod = Header.sh_size & (Align - 1); |
| + if (Mod == 0) |
| + return; |
| + Elf64_Xword AlignDiff = Align - Mod; |
| + if (WritePadding) |
| + Str.writeZeroPadding(AlignDiff); |
| + Header.sh_size += AlignDiff; |
| + assert((Header.sh_size & (Align - 1)) == 0); |
| +} |
| + |
| // Text sections. |
| void ELFTextSection::appendData(ELFStreamer &Str, |
| @@ -35,6 +50,21 @@ 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; |
| + } |
| + Str.writeLE32(RelocOffset); |
| + Header.sh_size += RelocAddrSize; |
| +} |
| + |
| // Relocation sections. |
| void ELFRelocationSection::addRelocations(RelocOffsetT BaseOff, |
| @@ -73,7 +103,7 @@ void ELFSymbolTableSection::createDefinedSym(const IceString &Name, |
| NewSymbol.Section = Section; |
| NewSymbol.Number = ELFSym::UnknownNumber; |
| bool Unique; |
| - if (Type == STB_LOCAL) |
| + if (Binding == STB_LOCAL) |
|
jvoung (off chromium)
2015/01/27 01:46:28
oops
Jim Stichnoth
2015/01/27 16:44:55
Hmm. Too bad LLVM didn't name the enums that defi
jvoung (off chromium)
2015/01/28 17:46:21
Yeah, and unfortunately LLVM doesn't have a second
|
| Unique = LocalSymbols.insert(std::make_pair(Name, NewSymbol)).second; |
| else |
| Unique = GlobalSymbols.insert(std::make_pair(Name, NewSymbol)).second; |