aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2009-01-16 14:14:07 +0000
committerH.J. Lu <hjl.tools@gmail.com>2009-01-16 14:14:07 +0000
commit258795f524fca9d5b98441b81684c331c4d721b1 (patch)
tree365c275b1bbaade138d48bf73fb98ddbd26f7a70 /ld
parent3493e7b072fcca9911dd102bbcb6a1fc61012f95 (diff)
downloadgdb-258795f524fca9d5b98441b81684c331c4d721b1.zip
gdb-258795f524fca9d5b98441b81684c331c4d721b1.tar.gz
gdb-258795f524fca9d5b98441b81684c331c4d721b1.tar.bz2
ld/
2009-01-16 H.J. Lu <hongjiu.lu@intel.com> * lexsup.c (option_values): Add OPTION_TTEXT_SEGMENT. (ld_options): Add -Ttext-segment. (parse_args): Handle OPTION_TTEXT_SEGMENT. * ld.texinfo: Document -Ttext-segment. * NEWS: Mention -Ttext-segment. * scripttempl/elf.sc (TEXT_START_ADDR): Use SEGMENT_START. (SHLIB_TEXT_START_ADDR): Likewise. ld/testsuite/ 2009-01-16 H.J. Lu <hongjiu.lu@intel.com> * ld-elf/textaddr1.d: New. * ld-elf/textaddr2.d: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog13
-rw-r--r--ld/NEWS3
-rw-r--r--ld/ld.texinfo6
-rw-r--r--ld/lexsup.c6
-rw-r--r--ld/scripttempl/elf.sc7
-rw-r--r--ld/testsuite/ChangeLog5
-rw-r--r--ld/testsuite/ld-elf/textaddr1.d8
-rw-r--r--ld/testsuite/ld-elf/textaddr2.d8
8 files changed, 54 insertions, 2 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index c9069cf..a73efc5 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,16 @@
+2009-01-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ * lexsup.c (option_values): Add OPTION_TTEXT_SEGMENT.
+ (ld_options): Add -Ttext-segment.
+ (parse_args): Handle OPTION_TTEXT_SEGMENT.
+
+ * ld.texinfo: Document -Ttext-segment.
+
+ * NEWS: Mention -Ttext-segment.
+
+ * scripttempl/elf.sc (TEXT_START_ADDR): Use SEGMENT_START.
+ (SHLIB_TEXT_START_ADDR): Likewise.
+
2009-01-13 Alan Modra <amodra@bigpond.net.au>
* emultempl/spu_icache.o_c: Regenerate.
diff --git a/ld/NEWS b/ld/NEWS
index 9e56775..790cab3 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,5 +1,8 @@
-*- text -*-
+* Add a new command line option, -Ttext-segment ADDR, for ELF targets
+ to set the address of the first byte of the text segment.
+
* Add new option --use-nul-prefixed-import-tables to ld for PE targets to
allow fallback to old import table generation with null element prefix.
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 3f16546..3543505 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -1723,6 +1723,12 @@ sign (``@key{=}''), and @var{org}.
Same as --section-start, with @code{.bss}, @code{.data} or
@code{.text} as the @var{sectionname}.
+@kindex -Ttext-segment @var{org}
+@itemx -Ttext-segment @var{org}
+@cindex text segment origin, cmd line
+When creating an ELF executable or shared object, it will set the address
+of the first byte of the text segment.
+
@kindex --unresolved-symbols
@item --unresolved-symbols=@var{method}
Determine how to handle unresolved symbols. There are four possible
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 60a8167..f9e6b1f 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -103,6 +103,7 @@ enum option_values
OPTION_TBSS,
OPTION_TDATA,
OPTION_TTEXT,
+ OPTION_TTEXT_SEGMENT,
OPTION_TRADITIONAL_FORMAT,
OPTION_UR,
OPTION_VERBOSE,
@@ -512,6 +513,8 @@ static const struct ld_option ld_options[] =
'\0', N_("ADDRESS"), N_("Set address of .data section"), ONE_DASH },
{ {"Ttext", required_argument, NULL, OPTION_TTEXT},
'\0', N_("ADDRESS"), N_("Set address of .text section"), ONE_DASH },
+ { {"Ttext-segment", required_argument, NULL, OPTION_TTEXT_SEGMENT},
+ '\0', N_("ADDRESS"), N_("Set address of text segment"), ONE_DASH },
{ {"unresolved-symbols=<method>", required_argument, NULL,
OPTION_UNRESOLVED_SYMBOLS},
'\0', NULL, N_("How to handle unresolved symbols. <method> is:\n"
@@ -1231,6 +1234,9 @@ parse_args (unsigned argc, char **argv)
case OPTION_TTEXT:
set_segment_start (".text", optarg);
break;
+ case OPTION_TTEXT_SEGMENT:
+ set_segment_start (".text-segment", optarg);
+ break;
case OPTION_TRADITIONAL_FORMAT:
link_info.traditional_format = TRUE;
break;
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index bb8c808..123a989 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -242,6 +242,9 @@ STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
*(.stack)
}"
+TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
+SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
+
# if this is for an embedded system, don't add SIZEOF_HEADERS.
if [ -z "$EMBEDDED" ]; then
test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
@@ -267,8 +270,8 @@ SECTIONS
{
/* Read-only sections, merged into text segment: */
${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
- ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
- ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
+ ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
+ ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}}
${INITIAL_READONLY_SECTIONS}
.note.gnu.build-id : { *(.note.gnu.build-id) }
EOF
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index fe0d802..128e5e1 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ld-elf/textaddr1.d: New.
+ * ld-elf/textaddr2.d: Likewise.
+
2009-01-14 H.J. Lu <hongjiu.lu@intel.com>
PR ld/9727
diff --git a/ld/testsuite/ld-elf/textaddr1.d b/ld/testsuite/ld-elf/textaddr1.d
new file mode 100644
index 0000000..f7a3ad9
--- /dev/null
+++ b/ld/testsuite/ld-elf/textaddr1.d
@@ -0,0 +1,8 @@
+#source: maxpage1.s
+#ld: -Ttext-segment 0x7000000 -z max-page-size=0x200000
+#readelf: -l --wide
+#target: *-*-linux-gnu
+
+#...
+ LOAD +0x0+ 0x0*7000000 0x0*7000000 0x0*[0-9a-f][0-9a-f][0-9a-f] 0x0*[0-9a-f][0-9a-f][0-9a-f] R E 0x200000
+#pass
diff --git a/ld/testsuite/ld-elf/textaddr2.d b/ld/testsuite/ld-elf/textaddr2.d
new file mode 100644
index 0000000..9d1b0e5
--- /dev/null
+++ b/ld/testsuite/ld-elf/textaddr2.d
@@ -0,0 +1,8 @@
+#source: maxpage1.s
+#ld: -shared -Ttext-segment 0x7000000 -z max-page-size=0x200000
+#readelf: -l --wide
+#target: *-*-linux-gnu
+
+#...
+ LOAD +0x0+ 0x0*7000000 0x0*7000000 0x0*[0-9a-f][0-9a-f][0-9a-f] 0x0*[0-9a-f][0-9a-f][0-9a-f] R E 0x200000
+#pass