PR linker/4844

* genscript.sh: Add support for generating a .xa script for use with the --auto-import option.
* ld.texinfo: Document the new behaviour of the --auto-import option.
* ldint.texinfo: Document new script generation.
* emulparams/i386pe.sh (GENERATE_AUTO_IMPORT): Define.
* emulparams/i386pe_posix.sh (GENERATE_AUTO_IMPORT): Define.
* emulparams/i386pep.sh (GENERATE_AUTO_IMPORT): Define.
* emultemp/pe.em (..._get_script): Support the use of the auto import script.
* scripttempl/pe.sc: Put the .rdata input sections into the .data output section when creating an auto import script.
* scripttempl/pep.sc: Likewise.
This commit is contained in:
Nick Clifton 2007-10-01 09:54:58 +00:00
parent 1576798ef8
commit e2a83dd0ec
11 changed files with 80 additions and 14 deletions

View File

@ -1,3 +1,20 @@
2007-10-01 Nick Clifton <nickc@redhat.com>
PR linker/4844
* genscript.sh: Add support for generating a .xa script for use
with the --auto-import option.
* ld.texinfo: Document the new behaviour of the --auto-import
option.
* ldint.texinfo: Document new script generation.
* emulparams/i386pe.sh (GENERATE_AUTO_IMPORT): Define.
* emulparams/i386pe_posix.sh (GENERATE_AUTO_IMPORT): Define.
* emulparams/i386pep.sh (GENERATE_AUTO_IMPORT): Define.
* emultemp/pe.em (..._get_script): Support the use of the auto
import script.
* scripttempl/pe.sc: Put the .rdata input sections into the .data
output section when creating an auto import script.
* scripttempl/pep.sc: Likewise.
2007-09-26 Brian Watt <bwatt@us.ibm.com>
* emultempl/spu_ovl.S: Add debug printf code.

View File

@ -7,3 +7,4 @@ ENTRY="_mainCRTStartup"
SUBSYSTEM=PE_DEF_SUBSYSTEM
INITIAL_SYMBOL_CHAR=\"_\"
TARGET_PAGE_SIZE=0x1000
GENERATE_AUTO_IMPORT_SCRIPT=1

View File

@ -8,3 +8,4 @@ SUBSYSTEM=7
EXECUTABLE_NAME=a.out
INITIAL_SYMBOL_CHAR=\"_\"
TARGET_PAGE_SIZE=0x1000
GENERATE_AUTO_IMPORT_SCRIPT=1

View File

@ -7,3 +7,4 @@ ENTRY="_mainCRTStartup"
SUBSYSTEM=PE_DEF_SUBSYSTEM
INITIAL_SYMBOL_CHAR=\"_\"
TARGET_PAGE_SIZE=0x1000
GENERATE_AUTO_IMPORT_SCRIPT=1

View File

@ -1891,6 +1891,10 @@ echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
if test -n "$GENERATE_AUTO_IMPORT_SCRIPT" ; then
echo ' ; else if (link_info.pei386_auto_import == 1) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xa >> e${EMULATION_NAME}.c
fi
echo ' ; else return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
echo '; }' >> e${EMULATION_NAME}.c

View File

@ -1659,6 +1659,10 @@ echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
if test -n "$GENERATE_AUTO_IMPORT_SCRIPT" ; then
echo ' ; else if (link_info.pei386_auto_import == 1) return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.xa >> e${EMULATION_NAME}.c
fi
echo ' ; else return' >> e${EMULATION_NAME}.c
sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
echo '; }' >> e${EMULATION_NAME}.c

View File

@ -63,6 +63,7 @@
# sun3.xc [used when the linker is invoked with "-z combreloc"]
# sun3.xsc [used when the linker is invoked with "--shared"]
# sun3.xdc [used when the linker is invoked with "-pie"]
# sun3.xa [used when the linker is invoked with "--enable-auto-import"]
#
# It also produced the C source file:
#
@ -386,6 +387,16 @@ if test -n "$GENERATE_PIE_SCRIPT"; then
unset CREATE_PIE
fi
if test -n "$GENERATE_AUTO_IMPORT_SCRIPT"; then
LD_FLAG=auto_import
DATA_ALIGNMENT=${DATA_ALIGNMENT_}
(
echo "/* Script for ld --enable-auto-import: Like the default script except read only data is placed into .data */"
. ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME}
. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xa
fi
case " $EMULATION_LIBPATH " in
*" ${EMULATION_NAME} "*) COMPILE_IN=true;;
esac

View File

@ -1568,15 +1568,15 @@ at link time. Searching @option{-rpath} in this way is only supported
by native linkers and cross linkers which have been configured with
the @option{--with-sysroot} option.
@item
On an ELF system, if the @option{-rpath} and @code{rpath-link} options
were not used, search the contents of the environment variable
@code{LD_RUN_PATH}. It is for the native linker only.
On an ELF system, for native linkers, if the @option{-rpath} and
@option{-rpath-link} options were not used, search the contents of the
environment variable @code{LD_RUN_PATH}.
@item
On SunOS, if the @option{-rpath} option was not used, search any
directories specified using @option{-L} options.
@item
For a native linker, the contents of the environment variable
@code{LD_LIBRARY_PATH}.
For a native linker, the search the contents of the environment
variable @code{LD_LIBRARY_PATH}.
@item
For a native ELF linker, the directories in @code{DT_RUNPATH} or
@code{DT_RPATH} of a shared library are searched for shared
@ -2220,6 +2220,12 @@ building the import libraries with those DATA exports. Note: Use of the
to be made writable. This does not conform to the PE-COFF format
specification published by Microsoft.
Note - use of the 'auto-import' extension will also cause read only
data which would normally be placed into the .rdata section to be
placed into the .data section instead. This is in order to work
around a problem with consts that is described here:
http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
Using 'auto-import' generally will 'just work' -- but sometimes you may
see this message:

View File

@ -237,7 +237,7 @@ If @code{SCRIPT_NAME} is set to @var{script}, @code{genscripts.sh} will
invoke @file{scripttempl/@var{script}.sc}.
The @file{genscripts.sh} script will invoke the @file{scripttempl}
script 5 to 8 times. Each time it will set the shell variable
script 5 to 9 times. Each time it will set the shell variable
@code{LD_FLAG} to a different value. When the linker is run, the
options used will direct it to select a particular script. (Script
selection is controlled by the @code{get_script} emulation entry point;
@ -292,6 +292,13 @@ this value if @code{GENERATE_COMBRELOC_SCRIPT} is defined in the
The @file{emultempl} script must arrange to use this script at the
appropriate time, normally when the linker is invoked with the @code{-shared
-z combreloc} option. The output has an extension of @file{.xsc}.
@item auto_import
The @file{scripttempl} script is only invoked with @code{LD_FLAG} set to
this value if @code{GENERATE_AUTO_IMPORT_SCRIPT} is defined in the
@file{emulparams} file. The @file{emultempl} script must arrange to
use this script at the appropriate time, normally when the linker is
invoked with the @code{--enable-auto-import} option. The output has
an extension of @file{.xa}.
@end table
Besides the shell variables set by the @file{emulparams} script, and the

View File

@ -13,8 +13,16 @@ fi
# use grouped sections instead).
if test "${RELOCATING}"; then
R_TEXT='*(SORT(.text$*))'
R_DATA='*(SORT(.data$*))'
R_RDATA='*(SORT(.rdata$*))'
if test "x$LD_FLAG" = "xauto_import" ; then
R_DATA='*(SORT(.data$*))
*(.rdata)
*(SORT(.rdata$*))'
R_RDATA=''
else
R_DATA='*(SORT(.data$*))'
R_RDATA='*(.rdata)
*(SORT(.rdata$*))'
fi
R_IDATA='
SORT(*)(.idata$2)
SORT(*)(.idata$3)
@ -37,7 +45,7 @@ if test "${RELOCATING}"; then
else
R_TEXT=
R_DATA=
R_RDATA=
R_RDATA='*(.rdata)'
R_IDATA=
R_CRT=
R_RSRC=
@ -93,7 +101,6 @@ SECTIONS
.rdata ${RELOCATING+BLOCK(__section_alignment__)} :
{
*(.rdata)
${R_RDATA}
${RELOCATING+ *(.eh_frame)}
${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;}

View File

@ -13,8 +13,16 @@ fi
# use grouped sections instead).
if test "${RELOCATING}"; then
R_TEXT='*(SORT(.text$*))'
R_DATA='*(SORT(.data$*))'
R_RDATA='*(SORT(.rdata$*))'
if test "x$LD_FLAG" = "xauto_import" ; then
R_DATA='*(SORT(.data$*))
*(.rdata)
*(SORT(.rdata$*))'
R_RDATA=''
else
R_DATA='*(SORT(.data$*))'
R_RDATA='*(.rdata)
*(SORT(.rdata$*))'
fi
R_IDATA='
SORT(*)(.idata$2)
SORT(*)(.idata$3)
@ -37,7 +45,7 @@ if test "${RELOCATING}"; then
else
R_TEXT=
R_DATA=
R_RDATA=
R_RDATA='*(.rdata)'
R_IDATA=
R_CRT=
R_RSRC=
@ -93,7 +101,6 @@ SECTIONS
.rdata ${RELOCATING+BLOCK(__section_alignment__)} :
{
*(.rdata)
${R_RDATA}
${RELOCATING+ *(.eh_frame)}
${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;}