| 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;
|
|
|