[PATCH] D23181: Make lld actually compatible with gold in terms of filler handling.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 15:09:41 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280018: Make lld actually compatible with gold in terms of filler handling. (authored by ruiu).
Changed prior to commit:
https://reviews.llvm.org/D23181?vs=66862&id=69621#toc
Repository:
rL LLVM
https://reviews.llvm.org/D23181
Files:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/linkerscript-sections-padding.s
Index: lld/trunk/test/ELF/linkerscript/linkerscript-sections-padding.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-sections-padding.s
+++ lld/trunk/test/ELF/linkerscript/linkerscript-sections-padding.s
@@ -2,16 +2,16 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
## Check that padding value works:
-# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x112233445566778899 }" > %t.script
+# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122 }" > %t.script
# RUN: ld.lld -o %t.out --script %t.script %t
# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES %s
-# YES: 0120 66223344 55667788 99112233 44556677
+# YES: 0120 66001122 00001122 00001122 00001122
## Confirming that address was correct:
-# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x998877665544332211 }" > %t.script
+# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99887766 }" > %t.script
# RUN: ld.lld -o %t.out --script %t.script %t
# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES2 %s
-# YES2: 0120 66887766 55443322 11998877 66554433
+# YES2: 0120 66887766 99887766 99887766 99887766
## Default padding value is 0x00:
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } }" > %t.script
@@ -29,7 +29,7 @@
# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99XX }" > %t.script
# RUN: not ld.lld -o %t.out --script %t.script %t 2>&1 \
# RUN: | FileCheck --check-prefix=ERR2 %s
-# ERR2: not a hexadecimal value: XX
+# ERR2: invalid filler expression: =0x99XX
.section .mysec.1,"a"
.align 16
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -956,24 +956,24 @@
return Cmd;
}
+// Read "=<number>" where <number> is an octal/decimal/hexadecimal number.
+// https://sourceware.org/binutils/docs/ld/Output-Section-Fill.html
+//
+// ld.gold is not fully compatible with ld.bfd. ld.bfd handles
+// hexstrings as blobs of arbitrary sizes, while ld.gold handles them
+// as 32-bit big-endian values. We will do the same as ld.gold does
+// because it's simpler than what ld.bfd does.
std::vector<uint8_t> ScriptParser::readOutputSectionFiller() {
- StringRef Tok = peek();
- if (!Tok.startswith("="))
+ if (!peek().startswith("="))
return {};
- next();
- // Read a hexstring of arbitrary length.
- if (Tok.startswith("=0x"))
- return parseHex(Tok.substr(3));
-
- // Read a decimal or octal value as a big-endian 32 bit value.
- // Why do this? I don't know, but that's what gold does.
+ StringRef Tok = next();
uint32_t V;
if (Tok.substr(1).getAsInteger(0, V)) {
setError("invalid filler expression: " + Tok);
return {};
}
- return { uint8_t(V >> 24), uint8_t(V >> 16), uint8_t(V >> 8), uint8_t(V) };
+ return {uint8_t(V >> 24), uint8_t(V >> 16), uint8_t(V >> 8), uint8_t(V)};
}
SymbolAssignment *ScriptParser::readProvideHidden(bool Provide, bool Hidden) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23181.69621.patch
Type: text/x-patch
Size: 3044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160829/ee69a499/attachment.bin>
More information about the llvm-commits
mailing list