[PATCH] D17269: [ELF] - Implemented linkerscript sections padding.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 24 17:20:37 PST 2016
ruiu added inline comments.
================
Comment at: ELF/LinkerScript.cpp:63-66
@@ +62,6 @@
+ArrayRef<uint8_t> LinkerScript::getFiller(StringRef Name) {
+ auto I = std::find_if(OutSections.begin(), OutSections.end(), FindSec{Name});
+ if (I == OutSections.end() || I->Filler.empty())
+ return ArrayRef<uint8_t>();
+ return ArrayRef<uint8_t>(&I->Filler[0], I->Filler.size());
+}
----------------
Why don't you just do
for (OutSection &C : OutSections)
if (C.Name == Name)
return C.Filler;
return {};
?
================
Comment at: ELF/LinkerScript.cpp:74-75
@@ -64,1 +73,4 @@
+ auto E = OutSections.end();
+ auto I = std::find_if(OutSections.begin(), E, FindSec{A});
+ auto J = std::find_if(OutSections.begin(), E, FindSec{B});
if (I == E || J == E)
----------------
This is a bit odd way of doing it because we can use lambdas.
auto I = std::find_if(Begin, End, [](OutSection &C) { return C.Name == A; });
auto J = std::find_if(Begin, End, [](OutSection &C) { return C.Name == B; });
================
Comment at: ELF/LinkerScript.cpp:446-453
@@ +445,10 @@
+ while (!Tok.empty()) {
+ StringRef B = Tok.substr(0, 2);
+ Tok = Tok.slice(2, Tok.size());
+ uint8_t Hex;
+ if (B.getAsInteger(16, Hex)) {
+ setError("Filler should be a HEX value");
+ return;
+ }
+ OutSec.Filler.push_back(Hex);
+ }
----------------
Define this piece of code as a separate function, say,
std::vector<uint8_t> readHex(StringRef S);
and replace this code with
OutSec.Filler = readHex(Tok);
http://reviews.llvm.org/D17269
More information about the llvm-commits
mailing list