tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
re: 32 bit & 64 bit libraries.
so, i finally have done a lot of this work. much, much later
than i had originally intended to work on this.
I also don't like /usr/lib64 and /usr/lib32. Since most newer ELF specs
talk about /usr/lib/<arch>, I'd propose:
* For NetBSD binaries, if the loader is "/usr/libexec/ld.elf_so",
have the kernel look at <loader>-<arch> first, and if this
doesn't exist it uses <loader>. I.e. in the standard case it
tries /usr/libexec/ld.elf_so-sparcv9 first for a 64 bit binary,
if this doesn't exist it uses /usr/libexec/ld.elf_so. <arch>
here is the architecture that
matches the type in the ELF header (i.e. sparc or sparcv9 or
ia64 or i386 etc)
for now i've made it only do this for netbsd32_exec_elf32.c. on
amd64 or sparc64 i have it using /{usr/,}libexec/ld.elf_so-<arch>
where <arch> is always "i386" or "sparc".
* ld.elf_so looks in /usr/lib/<arch> before /usr/lib (where <arch>
is the type of binaries it's supposed to handle, not the
system that it runs on).
again, i have this some what hard coded to "i386" and "sparc" but
working. i don't really like my change to ld.elf_so very much --
i am just inserting the necessary path in _rtld_init() for the
i386 & sparc ld.elf_so binaries. i would rather put the smarts
into ld.so.conf somehow but i don't see a nice way to extend it
to handle this case. i'd like something like
<mumble> machdep.machine_arch sparc:/usr/lib/sparc
or something, i think. i'm open to other suggestions and ideas.
the simple solution i've thought of is to build a 32 bit version
of ld.elf_so in the 64 bit builds, with this option enabled and
have it installed in the correct place. that doesn't really
handle the advanced features eeh was asking for, but i think we
can figure that out with something more like my ld.so.conf.
as well as this i have "cc -m32" working on amd64 and sparc64
given that /usr/lib/{i386,sparc} exists and is (correctly)
populated. i say correctly because at first i just copied my 32
bit /usr/lib there, but then i ended up with
/usr/lib/i386/libc.so -> /lib/libc.so, which didn't work so well.
the GCC and other changes for this are fairly minimal. a small
patch implements almost everything. one missing thing here is
binutils patch to install sparc ldscripts, but that should be
fairly simple. patch is here, does not include the new files
that are mostly multilib.h's that look the same as the old
checked in one.
i think the GCC portions are safe to commit for 5.0 but i'm
hesitant on any of the other stuff. there are a bunch of small
issues i think we should work out for the kernel & ld.elf_so
portions before they are in HEAD before 5.0 or pulled up to
5.0 branch. opinions?
.mrg.
Index: gnu/dist/gcc4/gcc/config.gcc
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc4/gcc/config.gcc,v
retrieving revision 1.18
diff -p -r1.18 config.gcc
*** gnu/dist/gcc4/gcc/config.gcc 24 Aug 2008 08:38:14 -0000 1.18
--- gnu/dist/gcc4/gcc/config.gcc 10 Oct 2008 06:38:50 -0000
*************** i[34567]86-*-netbsd*)
*** 1036,1041 ****
--- 1036,1042 ----
;;
x86_64-*-netbsd*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h
netbsd-elf.h i386/x86-64.h i386/netbsd64.h"
+ tmake_file="${tmake_file} i386/t-netbsd64"
;;
i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123])
tm_file="i386/i386.h i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h
openbsd-oldgas.h openbsd.h i386/openbsd.h"
Index: gnu/dist/gcc4/gcc/config/sparc/t-netbsd64
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc4/gcc/config/sparc/t-netbsd64,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 t-netbsd64
*** gnu/dist/gcc4/gcc/config/sparc/t-netbsd64 20 Apr 2006 09:45:12 -0000
1.1.1.1
--- gnu/dist/gcc4/gcc/config/sparc/t-netbsd64 10 Oct 2008 06:38:50 -0000
***************
*** 1,8 ****
! # Disable multilib fow now, as NetBSD/sparc64 does not ship with
! # a 32-bit environment.
! #MULTILIB_OPTIONS = m32/m64
! #MULTILIB_DIRNAMES = 32 64
! #MULTILIB_MATCHES =
! #LIBGCC = stmp-multilib
! #INSTALL_LIBGCC = install-multilib
--- 1,9 ----
! # NetBSD has (will have) "non-native" libraries in /usr/lib/<arch>.
! # For NetBSD/sparc64 we thus have /usr/lib and /usr/lib/sparc.
! MULTILIB_OPTIONS = m64/m32
! MULTILIB_DIRNAMES = 64 32
! MULTILIB_OSDIRNAMES = . ../lib/sparc
!
! LIBGCC = stmp-multilib
! INSTALL_LIBGCC = install-multilib
Index: gnu/usr.bin/gcc4/frontend/Makefile
===================================================================
RCS file: /cvsroot/src/gnu/usr.bin/gcc4/frontend/Makefile,v
retrieving revision 1.3
diff -p -r1.3 Makefile
*** gnu/usr.bin/gcc4/frontend/Makefile 3 May 2008 14:48:30 -0000 1.3
--- gnu/usr.bin/gcc4/frontend/Makefile 10 Oct 2008 06:38:53 -0000
*************** LIB= frontend
*** 9,22 ****
SRCS= gcc.c version.c intl.c prefix.c
! CPPFLAGS+= -I${.CURDIR} -I${GCCARCH} -I${BACKENDOBJ} -I. \
${G_ALL_CFLAGS:M-D*} ${G_INCLUDES:M-I*:N-I.*} \
-DPREFIX=\"/usr\" \
-DDEFAULT_TARGET_VERSION=\"${G_version}\" \
-DDEFAULT_TARGET_MACHINE=\"${MACHINE_GNU_PLATFORM}\"
HOST_CPPFLAGS+= -I${GCCARCH} ${G_ALL_CFLAGS:M-D*}
${G_INCLUDES:M-I*:N-I.*}
! DPSRCS+= multilib.h specs.h
MKPIC:= no
MKPICLIB:= no
--- 9,22 ----
SRCS= gcc.c version.c intl.c prefix.c
! CPPFLAGS+= -I${GCCARCH} -I${BACKENDOBJ} -I. \
${G_ALL_CFLAGS:M-D*} ${G_INCLUDES:M-I*:N-I.*} \
-DPREFIX=\"/usr\" \
-DDEFAULT_TARGET_VERSION=\"${G_version}\" \
-DDEFAULT_TARGET_MACHINE=\"${MACHINE_GNU_PLATFORM}\"
HOST_CPPFLAGS+= -I${GCCARCH} ${G_ALL_CFLAGS:M-D*}
${G_INCLUDES:M-I*:N-I.*}
! DPSRCS+= specs.h
MKPIC:= no
MKPICLIB:= no
Index: libexec/ld.elf_so/rtld.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/rtld.c,v
retrieving revision 1.122
diff -p -r1.122 rtld.c
*** libexec/ld.elf_so/rtld.c 4 Oct 2008 09:37:12 -0000 1.122
--- libexec/ld.elf_so/rtld.c 10 Oct 2008 06:38:53 -0000
*************** _rtld_init(caddr_t mapbase, caddr_t relo
*** 256,261 ****
--- 256,266 ----
_rtld_add_paths(execname, &_rtld_default_paths,
RTLD_DEFAULT_LIBRARY_PATH);
+ #ifdef RTLD_ARCH_SUBDIR
+ _rtld_add_paths(execname, &_rtld_default_paths,
+ RTLD_DEFAULT_LIBRARY_PATH "/" RTLD_ARCH_SUBDIR);
+ #endif
+
/*
* Set up the _rtld_objlist pointer, so that rtld symbols can be found.
*/
Index: libexec/ld.elf_so/arch/i386/Makefile.inc
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/arch/i386/Makefile.inc,v
retrieving revision 1.10
diff -p -r1.10 Makefile.inc
*** libexec/ld.elf_so/arch/i386/Makefile.inc 4 Jun 2005 16:17:17 -0000
1.10
--- libexec/ld.elf_so/arch/i386/Makefile.inc 10 Oct 2008 06:38:53 -0000
*************** SRCS+= rtld_start.S mdreloc.c
*** 6,10 ****
--- 6,11 ----
CPPFLAGS+= -fpic
CPPFLAGS+= -DELFSIZE=32
+ CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"i386\"
LDFLAGS+= -Wl,-e,.rtld_start
Index: libexec/ld.elf_so/arch/sparc/Makefile.inc
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/arch/sparc/Makefile.inc,v
retrieving revision 1.10
diff -p -r1.10 Makefile.inc
*** libexec/ld.elf_so/arch/sparc/Makefile.inc 4 Jun 2005 16:17:17 -0000
1.10
--- libexec/ld.elf_so/arch/sparc/Makefile.inc 10 Oct 2008 06:38:53 -0000
*************** SRCS+= rtld_start.S mdreloc.c
*** 6,10 ****
--- 6,11 ----
CPPFLAGS+= -fpic
CPPFLAGS+= -DELFSIZE=32
+ CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"sparc\"
LDFLAGS+= -Wl,-e,_rtld_start
Index: tools/gcc/Makefile
===================================================================
RCS file: /cvsroot/src/tools/gcc/Makefile,v
retrieving revision 1.27
diff -p -r1.27 Makefile
*** tools/gcc/Makefile 20 Sep 2007 12:26:51 -0000 1.27
--- tools/gcc/Makefile 10 Oct 2008 06:38:53 -0000
*************** BINENV= /usr/bin/env -i
*** 10,18 ****
VAX_CONFIGURE_ARGS=
CONFIGURE_ARGS= --target=${MACHINE_GNU_PLATFORM} --disable-nls \
--enable-long-long \
! --disable-multilib \
--enable-threads \
${VAX_CONFIGURE_ARGS} \
--program-transform-name="s,^,${MACHINE_GNU_PLATFORM}-," \
--- 10,24 ----
VAX_CONFIGURE_ARGS=
+ .if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "sparc64"
+ MULTILIB_ARGS= --enable-multilib
+ .else
+ MULTILIB_ARGS= --disable-multilib
+ .endif
+
CONFIGURE_ARGS= --target=${MACHINE_GNU_PLATFORM} --disable-nls \
--enable-long-long \
! ${MULTILIB_ARGS} \
--enable-threads \
${VAX_CONFIGURE_ARGS} \
--program-transform-name="s,^,${MACHINE_GNU_PLATFORM}-," \
*************** MKNATIVE_ENV= ${BINENV} ${CONFIGURE_ENV:
*** 39,44 ****
--- 45,51 ----
ac_cv_prog_cc_cross=yes \
ac_cv_func_strcoll_works=yes \
gcc_cv_func_printf_ptr=yes \
+ gcc_cv_libc_provides_ssp=yes \
gdb_cv_printf_has_long_double=yes \
gdb_cv_printf_has_long_long=yes \
gdb_cv_scanf_has_long_double=yes
*************** native-gcc: .native/.configure_done
*** 87,93 ****
# edit Makefile so that maybe-all-gcc does not depend on all-gcc any
more.
(cd .native && mv Makefile Makefile.config && \
sed -e 's/\(maybe-all-gcc:\) all-gcc/\1/' <
Makefile.config > Makefile) && \
! (cd .native/gcc && ${MKNATIVE_ENV} ${BUILD_MAKE} -e
tree-check.h config.h)
.else
PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
(cd .native && ${MKNATIVE_ENV} ${BUILD_MAKE} all-libiberty) && \
--- 94,100 ----
# edit Makefile so that maybe-all-gcc does not depend on all-gcc any
more.
(cd .native && mv Makefile Makefile.config && \
sed -e 's/\(maybe-all-gcc:\) all-gcc/\1/' <
Makefile.config > Makefile) && \
! (cd .native/gcc && ${MKNATIVE_ENV} ${BUILD_MAKE} -e
tree-check.h config.h multilib.h gcov-iov.h)
.else
PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
(cd .native && ${MKNATIVE_ENV} ${BUILD_MAKE} all-libiberty) && \
Index: tools/gcc/mknative-gcc
===================================================================
RCS file: /cvsroot/src/tools/gcc/mknative-gcc,v
retrieving revision 1.24
diff -p -r1.24 mknative-gcc
*** tools/gcc/mknative-gcc 19 Sep 2008 13:18:28 -0000 1.24
--- tools/gcc/mknative-gcc 10 Oct 2008 06:38:53 -0000
*************** get_gcc () {
*** 289,295 ****
;;
gcc4)
write_c gnu/usr.bin/$_subdir/libcpp/arch/$MACHINE_ARCH/config.h
<$_TMPDIR/libcpp/config.h
! hfiles='auto-host configargs gencheck gthr-default tm bconfig
config'
;;
esac
for f in $hfiles; do
--- 289,295 ----
;;
gcc4)
write_c gnu/usr.bin/$_subdir/libcpp/arch/$MACHINE_ARCH/config.h
<$_TMPDIR/libcpp/config.h
! hfiles='auto-host configargs gencheck gthr-default tm bconfig
config multilib'
;;
esac
for f in $hfiles; do
Index: sys/compat/netbsd32/netbsd32_exec_elf32.c
===================================================================
RCS file: /cvsroot/src/sys/compat/netbsd32/netbsd32_exec_elf32.c,v
retrieving revision 1.28
diff -p -r1.28 netbsd32_exec_elf32.c
*** sys/compat/netbsd32/netbsd32_exec_elf32.c 29 May 2008 14:51:26 -0000
1.28
--- sys/compat/netbsd32/netbsd32_exec_elf32.c 10 Oct 2008 06:38:53 -0000
*************** __KERNEL_RCSID(0, "$NetBSD: netbsd32_exe
*** 72,77 ****
--- 72,78 ----
#include <sys/signal.h>
#include <sys/signalvar.h>
#include <sys/kauth.h>
+ #include <sys/namei.h>
#include <compat/netbsd32/netbsd32.h>
#include <compat/netbsd32/netbsd32_exec.h>
*************** ELFNAME2(netbsd32,probe_noteless)(struct
*** 105,112 ****
int error;
if (itp) {
/* Translate interpreter name if needed */
! if ((error = emul_find_interp(l, epp, itp)) != 0)
return error;
}
epp->ep_flags |= EXEC_32;
--- 106,144 ----
int error;
if (itp) {
+ /*
+ * If the path is exactly "/usr/libexec/ld.elf_so", first
+ * try to see if "/usr/libexec/ld.elf_so-<arch>" exists
+ * and if so, use that instead.
+ * XXX maybe move this into compat/common
+ */
+ error = 0;
+ if (strcmp(itp, "/usr/libexec/ld.elf_so") == 0 ||
+ strcmp(itp, "/libexec/ld.elf_so") == 0) {
+ extern const char machine32[];
+ struct nameidata nd;
+ char *path;
+
+ if (epp->ep_interp != NULL)
+ vrele(epp->ep_interp);
+
+ path = PNBUF_GET();
+ snprintf(path, MAXPATHLEN, "%s-%s", itp, machine32);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path);
+ error = namei(&nd);
+ /*
+ * If that worked, save interpreter in case we
+ * actually need to load it
+ */
+ if (error != 0)
+ epp->ep_interp = NULL;
+ else
+ epp->ep_interp = nd.ni_vp;
+ PNBUF_PUT(path);
+ }
+
/* Translate interpreter name if needed */
! if (error && (error = emul_find_interp(l, epp, itp)) != 0)
return error;
}
epp->ep_flags |= EXEC_32;
Home |
Main Index |
Thread Index |
Old Index