This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RFC: automagic soname generation for ibm TPF-OS
- From: Eric Christopher <echristo at redhat dot com>
- To: binutils at sources dot redhat dot com
- Cc: uweigand at de dot ibm dot com
- Date: Thu, 14 Jul 2005 18:09:28 -0700
- Subject: RFC: automagic soname generation for ibm TPF-OS
OK, I'm not particularly happy with this hack, but can't think of
another way to do it offhand so I figured I'd post what I've got and see
what people say.
Basically the TPF-OS requires that each executable have an soname of the
first 4 characters, uppercase, of the name of the executable. They've
got other restrictions after that, but that's not something I want to
try to solve today. :)
Basically I took a page out of the irix notebook on this which has
something similar for shared libraries. Irix uses basename () instead of
a custom function, but the right idea is there. The problem comes in the
emulations - I'd prefer not to add a new custom emulation for this.
Any ideas?
Current patch attached.
-eric
Index: ld/Makefile.am
===================================================================
RCS file: /cvs/src/src/ld/Makefile.am,v
retrieving revision 1.186
diff -u -p -w -r1.186 Makefile.am
--- ld/Makefile.am 14 Jul 2005 22:52:17 -0000 1.186
+++ ld/Makefile.am 15 Jul 2005 01:06:05 -0000
@@ -826,6 +826,11 @@ eelf64_ia64_fbsd.c: $(srcdir)/emulparams
eelf64_s390.c: $(srcdir)/emulparams/elf64_s390.sh \
$(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf64_s390 "$(tdir_elf64_s390)"
+eelf64_s390_tpf.c: $(srcdir)/emulparams/elf64_s390_tpf.sh \
+ $(srcdir)/emulparams/elf64_s390.sh \
+ $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/tpf.em \
+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+ ${GENSCRIPTS} elf64_s390_tpf "$(tdir_elf64_s390)"
eelf64_sparc.c: $(srcdir)/emulparams/elf64_sparc.sh \
$(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf64_sparc "$(tdir_elf64_sparc)"
Index: ld/configure.tgt
===================================================================
RCS file: /cvs/src/src/ld/configure.tgt,v
retrieving revision 1.173
diff -u -p -w -r1.173 configure.tgt
--- ld/configure.tgt 14 Jul 2005 22:52:19 -0000 1.173
+++ ld/configure.tgt 15 Jul 2005 01:06:05 -0000
@@ -571,7 +571,7 @@ s390x-*-linux*) targ_emul=elf64_
targ_extra_emuls=elf_s390
targ_extra_libpath=$targ_extra_emuls
tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'` ;;
-s390x-*-tpf*) targ_emul=elf64_s390
+s390x-*-tpf*) targ_emul=elf64_s390_tpf
tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'` ;;
s390-*-linux*) targ_emul=elf_s390
if test "${want64}" = "true"; then
Index: ld/emulparams/elf64_s390_tpf.sh
===================================================================
RCS file: ld/emulparams/elf64_s390_tpf.sh
diff -N ld/emulparams/elf64_s390_tpf.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/emulparams/elf64_s390_tpf.sh 15 Jul 2005 01:06:05 -0000
@@ -0,0 +1,36 @@
+SCRIPT_NAME=elf
+EXTRA_EM_FILE=tpf
+ELFSIZE=64
+OUTPUT_FORMAT="elf64-s390"
+TEXT_START_ADDR=0x80000000
+MAXPAGESIZE=0x1000
+COMMONPAGESIZE=0x1000
+NONPAGED_TEXT_START_ADDR=0x80000000
+ARCH="s390:64-bit"
+MACHINE=
+NOP=0x07070707
+TEMPLATE_NAME=elf32
+GENERATE_SHLIB_SCRIPT=yes
+GENERATE_PIE_SCRIPT=yes
+NO_SMALL_DATA=yes
+
+# Treat a host that matches the target with the possible exception of "x"
+# in the name as if it were native.
+if test `echo "$host" | sed -e s/390x/390/` \
+ = `echo "$target" | sed -e s/390x/390/`; then
+ case " $EMULATION_LIBPATH " in
+ *" ${EMULATION_NAME} "*)
+ NATIVE=yes
+ esac
+fi
+
+# Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first
+# on Linux.
+case "$target" in
+ s390*-linux*)
+ case "$EMULATION_NAME" in
+ *64*)
+ LIBPATH_SUFFIX=64 ;;
+ esac
+ ;;
+esac
Index: ld/emultempl/tpf.em
===================================================================
RCS file: ld/emultempl/tpf.em
diff -N ld/emultempl/tpf.em
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/emultempl/tpf.em 15 Jul 2005 01:06:05 -0000
@@ -0,0 +1,64 @@
+# This shell script emits a C file. -*- C -*-
+# Copyright 2005 Free Software Foundation, Inc.
+#
+# This file is part of GLD, the Gnu Linker.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+cat >>e${EMULATION_NAME}.c <<EOF
+
+#include "ld.h"
+#include "ldmain.h"
+#include "libiberty.h"
+
+static char tpfsoname[5];
+
+/* Mangle the soname for the TPF OS system. We only want the first
+ 4 characters of the base output .so name only, all upper case.
+ This runs into problems when the filename is < 4 characters. You
+ will likely get garbage. */
+static char *
+tpf_soname (char *name)
+{
+ int i;
+ char *p;
+
+ for (i = 0, p = name; i < 4; i++, p++)
+ {
+ if (ISLOWER (*p))
+ tpfsoname[i] = TOUPPER (*p);
+ else
+ tpfsoname[i] = *p;
+ }
+
+ return strdup (tpfsoname);
+}
+
+/* The TPF loader needs a soname equal to the basename of the object
+ file being written. */
+
+static void
+tpf_after_open (void)
+{
+ if (link_info.shared && command_line.soname == 0)
+ command_line.soname = tpf_soname (basename
+ (bfd_get_filename (output_bfd)));
+
+ gld${EMULATION_NAME}_after_open ();
+}
+EOF
+
+LDEMUL_AFTER_OPEN=tpf_after_open