[lld] r289827 - [ELF] - Make LLD accept Ttext-segment X/Ttext-segment=X aliases for -Ttext.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 08:12:34 PST 2016

Author: grimar
Date: Thu Dec 15 10:12:34 2016
New Revision: 289827

URL: http://llvm.org/viewvc/llvm-project?rev=289827&view=rev
[ELF] - Make LLD accept Ttext-segment X/Ttext-segment=X aliases for -Ttext.

It os used in work/emulators/qemu-user-static port.
Which tries to use -Ttext-segment and then:

# In case ld does not support -Ttext-segment, edit the default linker
# script via sed to set the .text start addr.  This is needed on FreeBSD
# at least.
<here it calls -verbose to extract and edit default bfd linker script.>

Actually now we are do not fully support -Ttext properly (see D27613),
but we also seems never will provide anything close to default script, like bfd do,
so at least this patch introduces proper alias handling.


Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=289827&r1=289826&r2=289827&view=diff
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Thu Dec 15 10:12:34 2016
@@ -283,6 +283,8 @@ def alias_Tdata: J<"Tdata=">, Alias<Tdat
 def alias_trace: Flag<["-"], "t">, Alias<trace>;
 def alias_trace_symbol_y : JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>;
 def alias_Ttext: J<"Ttext=">, Alias<Ttext>;
+def alias_Ttext_segment: S<"Ttext-segment">, Alias<Ttext>;
+def alias_Ttext_segment_eq: J<"Ttext-segment=">, Alias<Ttext>;
 def alias_undefined_eq: J<"undefined=">, Alias<undefined>;
 def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
 def alias_version_V: Flag<["-"], "V">, Alias<version>;

Modified: lld/trunk/test/ELF/sectionstart.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/sectionstart.s?rev=289827&r1=289826&r2=289827&view=diff
--- lld/trunk/test/ELF/sectionstart.s (original)
+++ lld/trunk/test/ELF/sectionstart.s Thu Dec 15 10:12:34 2016
@@ -20,6 +20,12 @@
 # RUN: ld.lld %t.o -Ttext=0x100000 -Tdata=0x110000 -Tbss=0x200000 -o %t4
 # RUN: llvm-objdump -section-headers %t4 | FileCheck %s
+## Check Ttext-segment X and Ttext-segment=X forms.
+# RUN: ld.lld %t.o -Ttext-segment=0x100000 -Tdata=0x110000 -Tbss=0x200000 -o %t4
+# RUN: llvm-objdump -section-headers %t4 | FileCheck %s
+# RUN: ld.lld %t.o -Ttext-segment 0x100000 -Tdata=0x110000 -Tbss=0x200000 -o %t4
+# RUN: llvm-objdump -section-headers %t4 | FileCheck %s
 ## The same, but dropped "0x" prefix.
 # RUN: ld.lld %t.o -Ttext=100000 -Tdata=110000 -Tbss=200000 -o %t5
 # RUN: llvm-objdump -section-headers %t5 | FileCheck %s

More information about the llvm-commits mailing list