summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils/ld/emultempl
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2001-04-18 18:35:25 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2001-04-18 18:35:25 +0000
commitb89dfcbe8bed684181e331f97901faa648408242 (patch)
tree5b447b827a294c84027270c94eb90deef67b8771 /gnu/usr.bin/binutils/ld/emultempl
parentdff338c028fdab2f0d7e4cc6cdc96395e079ba14 (diff)
date: 2001/04/18 18:33:13; author: drahn; state: Exp; lines: +41 -0
Use the /var/run/ld.so.hints for looking up transitive dependancies on shared libraries in ld, this is done in linux with ld.so.conf, but the string is stored in ld.so.hints for openbsd. Fixes some "-rpath" compilation errors. as with the linux case, this is only for the native ld. Ok'd by espie@.
Diffstat (limited to 'gnu/usr.bin/binutils/ld/emultempl')
-rw-r--r--gnu/usr.bin/binutils/ld/emultempl/elf32.em41
1 files changed, 41 insertions, 0 deletions
diff --git a/gnu/usr.bin/binutils/ld/emultempl/elf32.em b/gnu/usr.bin/binutils/ld/emultempl/elf32.em
index d629d9a245b..3698885e23d 100644
--- a/gnu/usr.bin/binutils/ld/emultempl/elf32.em
+++ b/gnu/usr.bin/binutils/ld/emultempl/elf32.em
@@ -325,6 +325,14 @@ EOF
if [ "x${host}" = "x${target}" ] ; then
case " ${EMULATION_LIBPATH} " in
*" ${EMULATION_NAME} "*)
+ case ${target} in
+ *-*-openbsd*)
+cat >>e${EMULATION_NAME}.c <<EOF
+#include <fcntl.h>
+#include <link.h>
+EOF
+ ;;
+ esac
cat >>e${EMULATION_NAME}.c <<EOF
/* For a native linker, check the file /etc/ld.so.conf for directories
@@ -345,8 +353,41 @@ gld${EMULATION_NAME}_check_ld_so_conf (name, force)
if (! initialized)
{
FILE *f;
+EOF
+ case ${target} in
+ *-*-openbsd*)
+ cat >>e${EMULATION_NAME}.c <<EOF
+ struct hints_header hdr;
+ off_t diroff;
+ int fd;
+ char *buf;
+
+ f = fopen(_PATH_LD_HINTS, FOPEN_RT);
+ if (f != NULL)
+ {
+ if ( fread (&hdr, sizeof (struct hints_header), 1, f) == 1) {
+ if (!HH_BADMAG(hdr)) {
+ diroff = (hdr.hh_strtab + hdr.hh_dirlist);
+ fseek(f, diroff, SEEK_SET);
+ } else {
+ fclose(f);
+ f = NULL;
+ }
+ } else {
+ fclose(f);
+ f = NULL;
+ }
+ }
+EOF
+ ;;
+ *)
+cat >>e${EMULATION_NAME}.c <<EOF
f = fopen ("/etc/ld.so.conf", FOPEN_RT);
+EOF
+ ;;
+ esac
+cat >>e${EMULATION_NAME}.c <<EOF
if (f != NULL)
{
char *b;