[lld] r300005 - Remove big-endianness from =<fillexp> code.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 11 15:45:58 PDT 2017
Author: ruiu
Date: Tue Apr 11 17:45:57 2017
New Revision: 300005
URL: http://llvm.org/viewvc/llvm-project?rev=300005&view=rev
Log:
Remove big-endianness from =<fillexp> code.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/ScriptParser.cpp
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=300005&r1=300004&r2=300005&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Apr 11 17:45:57 2017
@@ -221,15 +221,13 @@ void OutputSection::sortCtorsDtors() {
std::stable_sort(Sections.begin(), Sections.end(), compCtors);
}
-// Fill [Buf, Buf + Size) with Filler. Filler is written in big
-// endian order. This is used for linker script "=fillexp" command.
+// Fill [Buf, Buf + Size) with Filler.
+// This is used for linker script "=fillexp" command.
static void fill(uint8_t *Buf, size_t Size, uint32_t Filler) {
- uint8_t V[4];
- write32be(V, Filler);
size_t I = 0;
for (; I + 4 < Size; I += 4)
- memcpy(Buf + I, V, 4);
- memcpy(Buf + I, V, Size - I);
+ memcpy(Buf + I, &Filler, 4);
+ memcpy(Buf + I, &Filler, Size - I);
}
uint32_t OutputSection::getFiller() {
Modified: lld/trunk/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.cpp?rev=300005&r1=300004&r2=300005&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.cpp (original)
+++ lld/trunk/ELF/ScriptParser.cpp Tue Apr 11 17:45:57 2017
@@ -36,6 +36,7 @@
using namespace llvm;
using namespace llvm::ELF;
+using namespace llvm::support::endian;
using namespace lld;
using namespace lld::elf;
@@ -637,11 +638,13 @@ ScriptParser::readOutputSectionDescripti
// as 32-bit big-endian values. We will do the same as ld.gold does
// because it's simpler than what ld.bfd does.
uint32_t ScriptParser::readOutputSectionFiller(StringRef Tok) {
- uint32_t V;
- if (!Tok.getAsInteger(0, V))
- return V;
- setError("invalid filler expression: " + Tok);
- return 0;
+ uint32_t V = 0;
+ if (Tok.getAsInteger(0, V))
+ setError("invalid filler expression: " + Tok);
+
+ uint32_t Buf;
+ write32be(&Buf, V);
+ return Buf;
}
SymbolAssignment *ScriptParser::readProvideHidden(bool Provide, bool Hidden) {
More information about the llvm-commits
mailing list