summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ld/ChangeLog17
-rw-r--r--ld/emulparams/i386pe.sh1
-rw-r--r--ld/emulparams/i386pe_posix.sh1
-rw-r--r--ld/emulparams/i386pep.sh1
-rw-r--r--ld/emultempl/pe.em4
-rw-r--r--ld/emultempl/pep.em4
-rwxr-xr-xld/genscripts.sh11
-rw-r--r--ld/ld.texinfo16
-rw-r--r--ld/ldint.texinfo9
-rw-r--r--ld/scripttempl/pe.sc15
-rw-r--r--ld/scripttempl/pep.sc15
11 files changed, 80 insertions, 14 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 13402db43e..da5de5c6da 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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.
diff --git a/ld/emulparams/i386pe.sh b/ld/emulparams/i386pe.sh
index 879379f9c5..ecafd698e0 100644
--- a/ld/emulparams/i386pe.sh
+++ b/ld/emulparams/i386pe.sh
@@ -7,3 +7,4 @@ ENTRY="_mainCRTStartup"
SUBSYSTEM=PE_DEF_SUBSYSTEM
INITIAL_SYMBOL_CHAR=\"_\"
TARGET_PAGE_SIZE=0x1000
+GENERATE_AUTO_IMPORT_SCRIPT=1
diff --git a/ld/emulparams/i386pe_posix.sh b/ld/emulparams/i386pe_posix.sh
index afa00de0cd..9348e648c7 100644
--- a/ld/emulparams/i386pe_posix.sh
+++ b/ld/emulparams/i386pe_posix.sh
@@ -8,3 +8,4 @@ SUBSYSTEM=7
EXECUTABLE_NAME=a.out
INITIAL_SYMBOL_CHAR=\"_\"
TARGET_PAGE_SIZE=0x1000
+GENERATE_AUTO_IMPORT_SCRIPT=1
diff --git a/ld/emulparams/i386pep.sh b/ld/emulparams/i386pep.sh
index d20f3aba5f..7145f35539 100644
--- a/ld/emulparams/i386pep.sh
+++ b/ld/emulparams/i386pep.sh
@@ -7,3 +7,4 @@ ENTRY="_mainCRTStartup"
SUBSYSTEM=PE_DEF_SUBSYSTEM
INITIAL_SYMBOL_CHAR=\"_\"
TARGET_PAGE_SIZE=0x1000
+GENERATE_AUTO_IMPORT_SCRIPT=1
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index e7bcacfdc1..43ce8e91d2 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -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
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index a78435b957..9e27e15f12 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -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
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
index d78ffce3c2..10623ecba5 100755
--- a/ld/genscripts.sh
+++ b/ld/genscripts.sh
@@ -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
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 4f4cb0bae9..4d687e2626 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -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:
diff --git a/ld/ldint.texinfo b/ld/ldint.texinfo
index 81a5adab7f..f6007d498b 100644
--- a/ld/ldint.texinfo
+++ b/ld/ldint.texinfo
@@ -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
diff --git a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc
index c9eb16f6dc..8561446054 100644
--- a/ld/scripttempl/pe.sc
+++ b/ld/scripttempl/pe.sc
@@ -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__ = .;}
diff --git a/ld/scripttempl/pep.sc b/ld/scripttempl/pep.sc
index b7f0c1b200..e571bd3509 100644
--- a/ld/scripttempl/pep.sc
+++ b/ld/scripttempl/pep.sc
@@ -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__ = .;}