This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
A patch for linker emulation
- To: binutils at sourceware dot cygnus dot com
- Subject: A patch for linker emulation
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Thu, 24 May 2001 21:16:10 -0700
"make check" in ld has been failing on sparc64. The problem is ld
depends on the linker script to set OUTPUT_ARCH. But some linker
scripts in ld tests don't set OUTPUT_ARCH. For sparc64, we get the
wrong default arch. This patch will initialize those default values
from OUTPUT_ARCH in the default emulation parameters. Any objections?
H.J.
----
2001-05-24 H.J. Lu <hjl@gnu.org>
* emultempl/aix.em (OUTPUT_ARCH): Defined.
(gld${EMULATION_NAME}_before_parse): Initialize
ldfile_output_architecture, ldfile_output_machine and
ldfile_output_machine_name from ${OUTPUT_ARCH} if possible.
* emultempl/beos.em: Likewise.
* emultempl/elf32.em: Likewise.
* emultempl/linux.em: Likewise.
* emultempl/mipsecoff.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/sunos.em: Likewise.
Index: emultempl/aix.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/aix.em,v
retrieving revision 1.1.1.6
diff -u -p -r1.1.1.6 aix.em
--- emultempl/aix.em 2001/05/02 21:53:21 1.1.1.6
+++ emultempl/aix.em 2001/05/25 04:04:15
@@ -1,5 +1,10 @@
# This shell script emits a C file. -*- C -*-
# It does some substitutions.
+if [ -z "$MACHINE" ]; then
+ OUTPUT_ARCH=${ARCH}
+else
+ OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
@@ -108,7 +113,15 @@ static void
gld${EMULATION_NAME}_before_parse()
{
#ifndef TARGET_ /* I.e., if not generic. */
- ldfile_output_architecture = bfd_arch_${ARCH};
+ const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
+ if (arch)
+ {
+ ldfile_output_architecture = arch->arch;
+ ldfile_output_machine = arch->mach;
+ ldfile_output_machine_name = arch->printable_name;
+ }
+ else
+ ldfile_output_architecture = bfd_arch_${ARCH};
#endif /* not TARGET_ */
config.has_shared = true;
}
Index: emultempl/beos.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/beos.em,v
retrieving revision 1.1.1.7
diff -u -p -r1.1.1.7 beos.em
--- emultempl/beos.em 2001/05/02 21:53:22 1.1.1.7
+++ emultempl/beos.em 2001/05/25 04:04:15
@@ -1,5 +1,10 @@
# This shell script emits a C file. -*- C -*-
# It does some substitutions.
+if [ -z "$MACHINE" ]; then
+ OUTPUT_ARCH=${ARCH}
+else
+ OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
cat >e${EMULATION_NAME}.c <<EOF
/* This file is part of GLD, the Gnu Linker.
Copyright 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
@@ -72,7 +77,15 @@ static void
gld_${EMULATION_NAME}_before_parse()
{
output_filename = "a.exe";
- ldfile_output_architecture = bfd_arch_${ARCH};
+ const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
+ if (arch)
+ {
+ ldfile_output_architecture = arch->arch;
+ ldfile_output_machine = arch->mach;
+ ldfile_output_machine_name = arch->printable_name;
+ }
+ else
+ ldfile_output_architecture = bfd_arch_${ARCH};
}
/* PE format extra command line options. */
Index: emultempl/elf32.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/elf32.em,v
retrieving revision 1.41
diff -u -p -r1.41 elf32.em
--- emultempl/elf32.em 2001/05/24 16:48:34 1.41
+++ emultempl/elf32.em 2001/05/25 04:04:15
@@ -3,6 +3,11 @@
# This file is now misnamed, because it supports both 32 bit and 64 bit
# ELF emulations.
test -z "${ELFSIZE}" && ELFSIZE=32
+if [ -z "$MACHINE" ]; then
+ OUTPUT_ARCH=${ARCH}
+else
+ OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
@@ -90,7 +95,15 @@ cat >>e${EMULATION_NAME}.c <<EOF
static void
gld${EMULATION_NAME}_before_parse ()
{
- ldfile_output_architecture = bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`;
+ const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
+ if (arch)
+ {
+ ldfile_output_architecture = arch->arch;
+ ldfile_output_machine = arch->mach;
+ ldfile_output_machine_name = arch->printable_name;
+ }
+ else
+ ldfile_output_architecture = bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`;
config.dynamic_link = ${DYNAMIC_LINK-true};
config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo true ; else echo false ; fi`;
}
Index: emultempl/linux.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/linux.em,v
retrieving revision 1.1.1.7
diff -u -p -r1.1.1.7 linux.em
--- emultempl/linux.em 2001/03/15 22:57:12 1.1.1.7
+++ emultempl/linux.em 2001/05/25 04:04:15
@@ -1,5 +1,10 @@
# This shell script emits a C file. -*- C -*-
# It does some substitutions.
+if [ -z "$MACHINE" ]; then
+ OUTPUT_ARCH=${ARCH}
+else
+ OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
@@ -52,7 +57,15 @@ static char *gld${EMULATION_NAME}_get_sc
static void
gld${EMULATION_NAME}_before_parse()
{
- ldfile_output_architecture = bfd_arch_${ARCH};
+ const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
+ if (arch)
+ {
+ ldfile_output_architecture = arch->arch;
+ ldfile_output_machine = arch->mach;
+ ldfile_output_machine_name = arch->printable_name;
+ }
+ else
+ ldfile_output_architecture = bfd_arch_${ARCH};
config.dynamic_link = true;
config.has_shared = true;
}
Index: emultempl/mipsecoff.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/mipsecoff.em,v
retrieving revision 1.1.1.7
diff -u -p -r1.1.1.7 mipsecoff.em
--- emultempl/mipsecoff.em 2001/03/15 22:57:12 1.1.1.7
+++ emultempl/mipsecoff.em 2001/05/25 04:04:15
@@ -1,5 +1,10 @@
# This shell script emits a C file. -*- C -*-
# It does some substitutions.
+if [ -z "$MACHINE" ]; then
+ OUTPUT_ARCH=${ARCH}
+else
+ OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
@@ -48,7 +53,15 @@ static void
gld${EMULATION_NAME}_before_parse()
{
#ifndef TARGET_ /* I.e., if not generic. */
- ldfile_output_architecture = bfd_arch_${ARCH};
+ const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
+ if (arch)
+ {
+ ldfile_output_architecture = arch->arch;
+ ldfile_output_machine = arch->mach;
+ ldfile_output_machine_name = arch->printable_name;
+ }
+ else
+ ldfile_output_architecture = bfd_arch_${ARCH};
#endif /* not TARGET_ */
}
Index: emultempl/pe.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/pe.em,v
retrieving revision 1.1.1.29
diff -u -p -r1.1.1.29 pe.em
--- emultempl/pe.em 2001/05/02 21:53:23 1.1.1.29
+++ emultempl/pe.em 2001/05/25 04:04:15
@@ -1,5 +1,10 @@
# This shell script emits a C file. -*- C -*-
# It does some substitutions.
+if [ -z "$MACHINE" ]; then
+ OUTPUT_ARCH=${ARCH}
+else
+ OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
rm -f e${EMULATION_NAME}.c
(echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
cat >>e${EMULATION_NAME}.c <<EOF
@@ -131,7 +136,15 @@ static void
gld_${EMULATION_NAME}_before_parse()
{
output_filename = "${EXECUTABLE_NAME:-a.exe}";
- ldfile_output_architecture = bfd_arch_${ARCH};
+ const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
+ if (arch)
+ {
+ ldfile_output_architecture = arch->arch;
+ ldfile_output_machine = arch->mach;
+ ldfile_output_machine_name = arch->printable_name;
+ }
+ else
+ ldfile_output_architecture = bfd_arch_${ARCH};
#ifdef DLL_SUPPORT
config.has_shared = 1;
Index: emultempl/sunos.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/sunos.em,v
retrieving revision 1.8
diff -u -p -r1.8 sunos.em
--- emultempl/sunos.em 2001/03/17 20:48:15 1.8
+++ emultempl/sunos.em 2001/05/25 04:04:15
@@ -1,5 +1,10 @@
# This shell script emits a C file. -*- C -*-
# It does some substitutions.
+if [ -z "$MACHINE" ]; then
+ OUTPUT_ARCH=${ARCH}
+else
+ OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
@@ -85,7 +90,15 @@ static char *gld${EMULATION_NAME}_get_sc
static void
gld${EMULATION_NAME}_before_parse()
{
- ldfile_output_architecture = bfd_arch_${ARCH};
+ const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
+ if (arch)
+ {
+ ldfile_output_architecture = arch->arch;
+ ldfile_output_machine = arch->mach;
+ ldfile_output_machine_name = arch->printable_name;
+ }
+ else
+ ldfile_output_architecture = bfd_arch_${ARCH};
config.dynamic_link = true;
config.has_shared = true;
}