This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Wrong dynamic-linker used on Solaris 7/x86
On May 20, 2001, Philip Blundell <philb@gnu.org> wrote:
> You might do better to create a new linker emulation, have it
> override the contents of the .interp section, and make that the
> default for Solaris. That way the hackery is localised inside ld,
> rather than involving BFD itself.
I like this. It's the least pervasive change of all proposed so far.
Here's the patch that implements it. Tested on
GNU/Linux-x-Solaris/x86. Ok to install?
Index: ld/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* emulparams/elf_i386_ldso.sh: New, copied from elf_i386.sh.
(ELF_INTERPRETER_NAME): Define it.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Use
it.
* configure.tgt (targ_emul, targ_extra_emuls)
[i[3456]86-*-solaris2*, i[3456]86-*-solaris*]: Use elf_i386_ldso
as primary, elf_i386 as extra.
* Makefile.am (ALL_EMULATIONS): Added eelf_i386_ldso.o.
(eelf_i386_ldso.c): New rule.
* Makefile.in: Rebuilt.
Index: ld/configure.tgt
===================================================================
RCS file: /cvs/src/src/ld/configure.tgt,v
retrieving revision 1.53
diff -u -p -r1.53 configure.tgt
--- ld/configure.tgt 2001/05/02 18:14:30 1.53
+++ ld/configure.tgt 2001/05/20 19:50:34
@@ -144,9 +144,13 @@ x86_64-*-linux-gnu*) targ_emul=elf_x86_6
tdir_i386linux=${targ_alias}aout
;;
i[3456]86-*-sysv[45]*) targ_emul=elf_i386 ;;
-i[3456]86-*-solaris2*) targ_emul=elf_i386 ;;
+i[3456]86-*-solaris2*) targ_emul=elf_i386_ldso
+ targ_extra_emuls="elf_i386"
+ ;;
i[3456]86-*-unixware) targ_emul=elf_i386 ;;
-i[3456]86-*-solaris*) targ_emul=elf_i386 ;;
+i[3456]86-*-solaris*) targ_emul=elf_i386_ldso
+ targ_extra_emuls="elf_i386"
+ ;;
i[3456]86-*-netbsd*) targ_emul=i386nbsd ;;
i[3456]86-*-netware) targ_emul=i386nw ;;
i[3456]86-*-elf*) targ_emul=elf_i386 ;;
Index: ld/Makefile.am
===================================================================
RCS file: /cvs/src/src/ld/Makefile.am,v
retrieving revision 1.59
diff -u -p -r1.59 Makefile.am
--- ld/Makefile.am 2001/05/14 16:55:23 1.59
+++ ld/Makefile.am 2001/05/20 19:50:34
@@ -162,6 +162,7 @@ ALL_EMULATIONS = \
eelf_i386.o \
eelf_i386_be.o \
eelf_i386_chaos.o \
+ eelf_i386_ldso.o \
eelf_s390.o \
egld960.o \
egld960coff.o \
@@ -537,6 +538,9 @@ eelf_i386_be.c: $(srcdir)/emulparams/elf
eelf_i386_chaos.c: $(srcdir)/emulparams/elf_i386_chaos.sh \
$(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf_i386_chaos "$(tdir_elf_i386_chaos)"
+eelf_i386_ldso.c: $(srcdir)/emulparams/elf_i386_ldso.sh \
+ $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+ ${GENSCRIPTS} elf_i386_ldso "$(tdir_elf_i386_ldso)"
eelf_s390.c: $(srcdir)/emulparams/elf_s390.sh \
$(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf_s390 "$(tdir_elf_s390)"
Index: ld/emulparams/elf_i386_ldso.sh
===================================================================
RCS file: elf_i386_ldso.sh
diff -N elf_i386_ldso.sh
--- /dev/null Tue May 5 13:32:27 1998
+++ ld/emulparams/elf_i386_ldso.sh Sun May 20 12:50:34 2001
@@ -0,0 +1,11 @@
+SCRIPT_NAME=elf
+OUTPUT_FORMAT="elf32-i386"
+TEXT_START_ADDR=0x08048000
+MAXPAGESIZE=0x1000
+NONPAGED_TEXT_START_ADDR=0x08048000
+ARCH=i386
+MACHINE=
+NOP=0x9090
+TEMPLATE_NAME=elf32
+GENERATE_SHLIB_SCRIPT=yes
+ELF_INTERPRETER_NAME=\"/usr/lib/ld.so.1\"
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.45
diff -u -p -r1.45 elf32.em
--- ld/emultempl/elf32.em 2001/05/03 06:26:26 1.45
+++ ld/emultempl/elf32.em 2001/05/20 19:50:35
@@ -817,6 +817,14 @@ gld${EMULATION_NAME}_before_allocation (
&link_info, &sinterp, lang_elf_version_info)))
einfo ("%P%F: failed to set dynamic section sizes: %E\n");
+${ELF_INTERPRETER_NAME+"
+ if (sinterp != NULL)
+ {
+ sinterp->contents = ${ELF_INTERPRETER_NAME};
+ sinterp->_raw_size = strlen (sinterp->contents) + 1;
+ }
+
+"}
/* Let the user override the dynamic linker we are using. */
if (command_line.interpreter != NULL
&& sinterp != NULL)
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me