* 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-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.
SUBSYSTEM=PE_DEF_SUBSYSTEM
INITIAL_SYMBOL_CHAR=\"_\"
TARGET_PAGE_SIZE=0x1000
+GENERATE_AUTO_IMPORT_SCRIPT=1
EXECUTABLE_NAME=a.out
INITIAL_SYMBOL_CHAR=\"_\"
TARGET_PAGE_SIZE=0x1000
+GENERATE_AUTO_IMPORT_SCRIPT=1
SUBSYSTEM=PE_DEF_SUBSYSTEM
INITIAL_SYMBOL_CHAR=\"_\"
TARGET_PAGE_SIZE=0x1000
+GENERATE_AUTO_IMPORT_SCRIPT=1
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
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
# 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:
#
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
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
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:
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;
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
# 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)
else
R_TEXT=
R_DATA=
- R_RDATA=
+ R_RDATA='*(.rdata)'
R_IDATA=
R_CRT=
R_RSRC=
.rdata ${RELOCATING+BLOCK(__section_alignment__)} :
{
- *(.rdata)
${R_RDATA}
${RELOCATING+ *(.eh_frame)}
${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;}
# 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)
else
R_TEXT=
R_DATA=
- R_RDATA=
+ R_RDATA='*(.rdata)'
R_IDATA=
R_CRT=
R_RSRC=
.rdata ${RELOCATING+BLOCK(__section_alignment__)} :
{
- *(.rdata)
${R_RDATA}
${RELOCATING+ *(.eh_frame)}
${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;}