Merge in rev 1.2 (ld was kinly looking up the Linux /etc/ld.so.conf so teach
it about the FreeBSD equivalent) This version of that patch selects the Linux code only if the case is Linux. This puts the Linux code on par with the FreeBSD code.
This commit is contained in:
parent
7277157f24
commit
c6404fdf02
@ -1,3 +1,4 @@
|
||||
# $FreeBSD$
|
||||
# This shell script emits a C file. -*- C -*-
|
||||
# It does some substitutions.
|
||||
# This file is now misnamed, because it supports both 32 bit and 64 bit
|
||||
@ -7,7 +8,8 @@ cat >e${EMULATION_NAME}.c <<EOF
|
||||
/* This file is is generated by a shell script. DO NOT EDIT! */
|
||||
|
||||
/* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
|
||||
Copyright (C) 1991, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 93, 94, 95, 96, 97, 98, 1999
|
||||
Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain <sac@cygnus.com>
|
||||
ELF support by Ian Lance Taylor <ian@cygnus.com>
|
||||
|
||||
@ -73,10 +75,12 @@ gld${EMULATION_NAME}_before_parse()
|
||||
{
|
||||
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`;
|
||||
}
|
||||
|
||||
/* Try to open a dynamic archive. This is where we know that ELF
|
||||
dynamic libraries have an extension of .so. */
|
||||
dynamic libraries have an extension of .so (or .sl on oddball systems
|
||||
like hpux). */
|
||||
|
||||
static boolean
|
||||
gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
|
||||
@ -92,13 +96,27 @@ gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
|
||||
|
||||
filename = entry->filename;
|
||||
|
||||
/* This allocates a few bytes too many when EXTRA_SHLIB_EXTENSION
|
||||
is defined, but it does not seem worth the headache to optimize
|
||||
away those two bytes of space. */
|
||||
string = (char *) xmalloc (strlen (search->name)
|
||||
+ strlen (filename)
|
||||
+ strlen (arch)
|
||||
#ifdef EXTRA_SHLIB_EXTENSION
|
||||
+ strlen (EXTRA_SHLIB_EXTENSION)
|
||||
#endif
|
||||
+ sizeof "/lib.so");
|
||||
|
||||
sprintf (string, "%s/lib%s%s.so", search->name, filename, arch);
|
||||
|
||||
#ifdef EXTRA_SHLIB_EXTENSION
|
||||
/* Try the .so extension first. If that fails build a new filename
|
||||
using EXTRA_SHLIB_EXTENSION. */
|
||||
if (! ldfile_try_open_bfd (string, entry))
|
||||
sprintf (string, "%s/lib%s%s%s", search->name,
|
||||
filename, arch, EXTRA_SHLIB_EXTENSION);
|
||||
#endif
|
||||
|
||||
if (! ldfile_try_open_bfd (string, entry))
|
||||
{
|
||||
free (string);
|
||||
@ -126,10 +144,16 @@ gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
|
||||
char *needed_name;
|
||||
|
||||
ASSERT (entry->is_archive && entry->search_dirs_flag);
|
||||
needed_name = (char *) xmalloc (strlen (filename)
|
||||
+ strlen (arch)
|
||||
+ sizeof "lib.so");
|
||||
sprintf (needed_name, "lib%s%s.so", filename, arch);
|
||||
|
||||
/* Rather than duplicating the logic above. Just use the
|
||||
filename we recorded earlier.
|
||||
|
||||
First strip off everything before the last '/'. */
|
||||
filename = strrchr (entry->filename, '/');
|
||||
filename++;
|
||||
|
||||
needed_name = (char *) xmalloc (strlen (filename) + 1);
|
||||
strcpy (needed_name, filename);
|
||||
bfd_elf_set_dt_needed_name (entry->the_bfd, needed_name);
|
||||
}
|
||||
|
||||
@ -138,7 +162,8 @@ gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry)
|
||||
|
||||
EOF
|
||||
if [ "x${host}" = "x${target}" ] ; then
|
||||
if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
|
||||
case " ${EMULATION_LIBPATH} " in
|
||||
*" ${EMULATION_NAME} "*)
|
||||
case ${target} in
|
||||
*-*-freebsd*)
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
@ -200,11 +225,13 @@ gld${EMULATION_NAME}_check_ld_elf_hints (name, force)
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
|
||||
*linux*|*Linux*|*LINUX*)
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
|
||||
/* For a native linker, check the file /etc/ld.so.conf for directories
|
||||
in which we may find shared libraries. /etc/ld.so.conf is really
|
||||
only meaningful on Linux, but we check it on other systems anyhow. */
|
||||
only meaningful on Linux. */
|
||||
|
||||
static boolean gld${EMULATION_NAME}_check_ld_so_conf
|
||||
PARAMS ((const char *, int));
|
||||
@ -282,9 +309,11 @@ gld${EMULATION_NAME}_check_ld_so_conf (name, force)
|
||||
|
||||
return gld${EMULATION_NAME}_search_needed (ld_so_conf, name, force);
|
||||
}
|
||||
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
esac
|
||||
fi
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
|
||||
@ -369,13 +398,15 @@ gld${EMULATION_NAME}_after_open ()
|
||||
}
|
||||
EOF
|
||||
if [ "x${host}" = "x${target}" ] ; then
|
||||
if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
|
||||
case " ${EMULATION_LIBPATH} " in
|
||||
*" ${EMULATION_NAME} "*)
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
|
||||
if (gld${EMULATION_NAME}_search_needed (lib_path, l->name, force))
|
||||
break;
|
||||
EOF
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
len = strlen (l->name);
|
||||
@ -395,7 +426,8 @@ cat >>e${EMULATION_NAME}.c <<EOF
|
||||
break;
|
||||
EOF
|
||||
if [ "x${host}" = "x${target}" ] ; then
|
||||
if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
|
||||
case " ${EMULATION_LIBPATH} " in
|
||||
*" ${EMULATION_NAME} "*)
|
||||
case ${target} in
|
||||
*-*-freebsd*)
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
@ -403,14 +435,15 @@ if [ "x${host}" = "x${target}" ] ; then
|
||||
break;
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
*linux*|*Linux*|*LINUX*)
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force))
|
||||
break;
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
}
|
||||
@ -832,37 +865,6 @@ gld${EMULATION_NAME}_before_allocation ()
|
||||
s->_raw_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (TARGET_IS_elf32bmip) || defined (TARGET_IS_elf32lmip)
|
||||
/* For MIPS ELF the .reginfo section requires special handling.
|
||||
Each input section is 24 bytes, and the final output section must
|
||||
also be 24 bytes. We handle this by clobbering all but the first
|
||||
input section size to 0. The .reginfo section is handled
|
||||
specially by the backend code anyhow. */
|
||||
{
|
||||
boolean found = false;
|
||||
LANG_FOR_EACH_INPUT_STATEMENT (is)
|
||||
{
|
||||
asection *s;
|
||||
|
||||
if (is->just_syms_flag)
|
||||
continue;
|
||||
|
||||
s = bfd_get_section_by_name (is->the_bfd, ".reginfo");
|
||||
if (s == NULL)
|
||||
continue;
|
||||
|
||||
if (! found)
|
||||
{
|
||||
found = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
s->_raw_size = 0;
|
||||
s->_cooked_size = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This is called by the before_allocation routine via
|
||||
@ -996,7 +998,9 @@ gld${EMULATION_NAME}_place_orphan (file, s)
|
||||
stored right after the program headers where the OS can read it
|
||||
in the first page. */
|
||||
place = NULL;
|
||||
if ((s->flags & SEC_LOAD) != 0
|
||||
if (s->flags & SEC_EXCLUDE)
|
||||
return false;
|
||||
else if ((s->flags & SEC_LOAD) != 0
|
||||
&& strncmp (secname, ".note", 4) == 0
|
||||
&& hold_interp != NULL)
|
||||
place = hold_interp;
|
||||
@ -1095,7 +1099,8 @@ gld${EMULATION_NAME}_place_orphan (file, s)
|
||||
wild_doit (&os->children, s, os, file);
|
||||
|
||||
lang_leave_output_section_statement
|
||||
((bfd_vma) 0, "*default*", (struct lang_output_section_phdr_list *) NULL);
|
||||
((bfd_vma) 0, "*default*", (struct lang_output_section_phdr_list *) NULL,
|
||||
"*default*");
|
||||
stat_ptr = &add;
|
||||
|
||||
if (*ps == '\0' && config.build_constructors)
|
||||
@ -1161,30 +1166,31 @@ then
|
||||
# Scripts compiled in.
|
||||
|
||||
# sed commands to quote an ld script as a C string.
|
||||
sc='s/["\\]/\\&/g
|
||||
s/$/\\n\\/
|
||||
1s/^/"/
|
||||
$s/$/n"/
|
||||
'
|
||||
sc="-f stringify.sed"
|
||||
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
{
|
||||
*isfile = 0;
|
||||
|
||||
if (link_info.relocateable == true && config.build_constructors == true)
|
||||
return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
|
||||
else if (link_info.relocateable == true)
|
||||
return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
|
||||
else if (!config.text_read_only)
|
||||
return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
|
||||
else if (!config.magic_demand_paged)
|
||||
return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
|
||||
else if (link_info.shared)
|
||||
return `sed "$sc" ldscripts/${EMULATION_NAME}.xs`;
|
||||
else
|
||||
return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
|
||||
}
|
||||
return
|
||||
EOF
|
||||
sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
|
||||
echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
|
||||
sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
|
||||
echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
|
||||
sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
|
||||
echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
|
||||
sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
|
||||
|
||||
if test -n "$GENERATE_SHLIB_SCRIPT" ; then
|
||||
echo ' ; else if (link_info.shared) return' >> e${EMULATION_NAME}.c
|
||||
sed $sc ldscripts/${EMULATION_NAME}.xs >> e${EMULATION_NAME}.c
|
||||
fi
|
||||
|
||||
echo ' ; else return' >> e${EMULATION_NAME}.c
|
||||
sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
|
||||
echo '; }' >> e${EMULATION_NAME}.c
|
||||
|
||||
else
|
||||
# Scripts read from the filesystem.
|
||||
@ -1210,6 +1216,22 @@ EOF
|
||||
|
||||
fi
|
||||
|
||||
if test -n "$PARSE_AND_LIST_ARGS" ; then
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
static int gld_${EMULATION_NAME}_parse_args PARAMS ((int, char **));
|
||||
static void gld_${EMULATION_NAME}_list_options PARAMS ((FILE * file));
|
||||
|
||||
$PARSE_AND_LIST_ARGS
|
||||
EOF
|
||||
else
|
||||
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
#define gld_${EMULATION_NAME}_parse_args NULL
|
||||
#define gld_${EMULATION_NAME}_list_options NULL
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
|
||||
struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
|
||||
@ -1226,9 +1248,15 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
|
||||
gld${EMULATION_NAME}_get_script,
|
||||
"${EMULATION_NAME}",
|
||||
"${OUTPUT_FORMAT}",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, /* finish */
|
||||
NULL, /* create output section statements */
|
||||
gld${EMULATION_NAME}_open_dynamic_archive,
|
||||
gld${EMULATION_NAME}_place_orphan
|
||||
gld${EMULATION_NAME}_place_orphan,
|
||||
NULL, /* set_symbols */
|
||||
gld_${EMULATION_NAME}_parse_args,
|
||||
NULL, /* unrecognized_file */
|
||||
gld_${EMULATION_NAME}_list_options,
|
||||
NULL, /* recognized_file */
|
||||
NULL /* find_potential_libraries */
|
||||
};
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user