[lld] r282818 - Start linker scripts at 0.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 29 17:16:12 PDT 2016
Author: rafael
Date: Thu Sep 29 19:16:11 2016
New Revision: 282818
URL: http://llvm.org/viewvc/llvm-project?rev=282818&view=rev
Log:
Start linker scripts at 0.
We were implicitly creating space for the headers. That is not the
behaviour of bfd, which requires the script to use SIZEOF_HEADERS. The
difference is important for scripts that don't use SIZEOF_HEADERS and
expect the first section to be at 0.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/no-space.s
lld/trunk/test/ELF/linkerscript/va.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=282818&r1=282817&r2=282818&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Sep 29 19:16:11 2016
@@ -595,7 +595,7 @@ void LinkerScript<ELFT>::assignAddresses
}
// Assign addresses as instructed by linker script SECTIONS sub-commands.
- Dot = getHeaderSize();
+ Dot = 0;
for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands) {
if (auto *Cmd = dyn_cast<SymbolAssignment>(Base.get())) {
Modified: lld/trunk/test/ELF/linkerscript/no-space.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/no-space.s?rev=282818&r1=282817&r2=282818&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/no-space.s (original)
+++ lld/trunk/test/ELF/linkerscript/no-space.s Thu Sep 29 19:16:11 2016
@@ -5,6 +5,10 @@
# RUN: ld.lld -o %t --script %t.script %t.o -shared
# RUN: llvm-readobj -elf-output-style=GNU -l %t | FileCheck %s
+# RUN: echo "SECTIONS {foo : {*(foo*)} }" > %t.script
+# RUN: ld.lld -o %t --script %t.script %t.o -shared
+# RUN: llvm-readobj -elf-output-style=GNU -l %t | FileCheck %s
+
# There is not enough address space available for the header, so just start the PT_LOAD
# after it.
Modified: lld/trunk/test/ELF/linkerscript/va.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/va.s?rev=282818&r1=282817&r2=282818&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/va.s (original)
+++ lld/trunk/test/ELF/linkerscript/va.s Thu Sep 29 19:16:11 2016
@@ -7,9 +7,9 @@
# CHECK: Sections:
# CHECK-NEXT: Idx Name Size Address Type
# CHECK-NEXT: 0 00000000 0000000000000000
-# CHECK-NEXT: 1 .text 00000001 00000000000000e8 TEXT DATA
-# CHECK-NEXT: 2 .foo 00000004 00000000000000e9 DATA
-# CHECK-NEXT: 3 .boo 00000004 00000000000000ed DATA
+# CHECK-NEXT: 1 .text 00000001 0000000000000000 TEXT DATA
+# CHECK-NEXT: 2 .foo 00000004 0000000000000001 DATA
+# CHECK-NEXT: 3 .boo 00000004 0000000000000005 DATA
.global _start
_start:
More information about the llvm-commits
mailing list