[PATCH] D64130: [LLD][ELF] - Linkerscript: add a support for expressions for section's filling
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 3 07:48:52 PDT 2019
peter.smith added a comment.
It looks like gold and bfd disagree on whether a symbol is allowed in practice.
foo = 0x12345678;
SECTIONS {
.text : { *(.text) } = foo
}
With ld.bfd I get an error, even if I use ABSOLUTE(foo)
ld.bfd fill.o -T fill.lds
fill.lds:4: nonconstant expression for fill value
With gold the link succeeds
ld.gold fill.o -T fill.lds
The ld.bfd I used was quite old 2.26.1 so this may have changed in later versions. Trying a later version lead to a ld.bfd segfault in one case.
As I think that this is an improvement and I agree that a symbol is unlikely to be encountered in practice so I think this is worth doing.
================
Comment at: ELF/ScriptParser.cpp:884
// We are compatible with ld.gold because it's easier to implement.
-std::array<uint8_t, 4> ScriptParser::parseFill(StringRef Tok) {
- uint32_t V = 0;
- if (!to_integer(Tok, V))
- setError("invalid filler expression: " + Tok);
+std::array<uint8_t, 4> ScriptParser::readFill() {
+ uint64_t Value = readExpr()().Val;
----------------
It is worth a comment or FIXME: saying we don't support symbols in fill expressions?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64130/new/
https://reviews.llvm.org/D64130
More information about the llvm-commits
mailing list