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.
This commit is contained in:
H.J. Lu 2009-01-16 14:14:07 +00:00
parent 3493e7b072
commit 258795f524
8 changed files with 54 additions and 2 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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