summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-04-11 22:45:57 +0000
committerRui Ueyama <ruiu@google.com>2017-04-11 22:45:57 +0000
commitb58079d4e23b933ce8ddd004feb344bb8a9e9e71 (patch)
tree8a16a3bf34bcce00ce786dcddd836320e861d496
parent8f8c2f9599ece0e9dea382e34ff04dbda1a8ee9b (diff)
downloadbcm5719-llvm-b58079d4e23b933ce8ddd004feb344bb8a9e9e71.tar.gz
bcm5719-llvm-b58079d4e23b933ce8ddd004feb344bb8a9e9e71.zip
Remove big-endianness from =<fillexp> code.
llvm-svn: 300005
-rw-r--r--lld/ELF/OutputSections.cpp10
-rw-r--r--lld/ELF/ScriptParser.cpp13
2 files changed, 12 insertions, 11 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 18a20fe7eb0..a7bfa61192a 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -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() {
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 6c115fb9e51..bdc733d0082 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -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::readOutputSectionDescription(StringRef OutSec) {
// 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) {
OpenPOWER on IntegriCloud