aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1997-01-30 16:33:36 +0000
committerIan Lance Taylor <ian@airs.com>1997-01-30 16:33:36 +0000
commite87b950c8e6dd1bbbe7dc78a82a0abd089665230 (patch)
treec902ffd8dc4023948cd0bcdde0eb2a8ef38e3544 /ld/emultempl
parent0fc327a3fb649fa1e9dac000eee14955195249dd (diff)
downloadgdb-e87b950c8e6dd1bbbe7dc78a82a0abd089665230.zip
gdb-e87b950c8e6dd1bbbe7dc78a82a0abd089665230.tar.gz
gdb-e87b950c8e6dd1bbbe7dc78a82a0abd089665230.tar.bz2
* emultempl/sunos.em: Include <ctype.h>.
(gld${EMULATION_NAME}_find_so): Skip the directory name when searching for ".so.". (gld${EMULATION_NAME}_search_dir): Make sure that the library name has a version number, and that only version numbers follow .so.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/sunos.em108
1 files changed, 76 insertions, 32 deletions
diff --git a/ld/emultempl/sunos.em b/ld/emultempl/sunos.em
index e1c6983..5907362 100644
--- a/ld/emultempl/sunos.em
+++ b/ld/emultempl/sunos.em
@@ -4,7 +4,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
/* SunOS emulation code for ${EMULATION_NAME}
- Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc.
+ Copyright (C) 1991, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
SunOS shared library support by Ian Lance Taylor <ian@cygnus.com>
@@ -26,12 +26,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define TARGET_IS_${EMULATION_NAME}
+#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "bfd.h"
#include "sysdep.h"
#include "bfdlink.h"
+#include "libiberty.h"
#include "ld.h"
#include "ldmain.h"
@@ -57,6 +59,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#endif
static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
+static void gld${EMULATION_NAME}_set_symbols PARAMS ((void));
static void gld${EMULATION_NAME}_create_output_section_statements
PARAMS ((void));
static void gld${EMULATION_NAME}_find_so
@@ -87,6 +90,46 @@ gld${EMULATION_NAME}_before_parse()
config.dynamic_link = true;
}
+/* This is called after the command line arguments have been parsed,
+ but before the linker script has been read. If this is a native
+ linker, we add the directories in LD_LIBRARY_PATH to the search
+ list. */
+
+static void
+gld${EMULATION_NAME}_set_symbols ()
+{
+EOF
+if [ "x${host}" = "x${target}" ] ; then
+ if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
+cat >>e${EMULATION_NAME}.c <<EOF
+ const char *env;
+
+ env = (const char *) getenv ("LD_LIBRARY_PATH");
+ if (env != NULL)
+ {
+ char *l;
+
+ l = xstrdup (env);
+ while (1)
+ {
+ char *c;
+
+ c = strchr (l, ':');
+ if (c != NULL)
+ *c++ = '\0';
+ if (*l != '\0')
+ ldfile_add_library_path (l, false);
+ if (c == NULL)
+ break;
+ l = c;
+ }
+ }
+EOF
+ fi
+fi
+cat >>e${EMULATION_NAME}.c <<EOF
+}
+
/* Despite the name, we use this routine to search for dynamic
libraries. On SunOS this requires a directory search. We need to
find the .so file with the highest version number. The user may
@@ -153,36 +196,22 @@ gld${EMULATION_NAME}_find_so (inp)
found, add it to the list of input files. */
alc = (char *) xmalloc (strlen (inp->filename) + 1);
strcpy (alc, inp->filename);
- strstr (alc, ".so.")[2] = 'a';
- if (stat (alc, &st) == 0)
+ strstr (alc + strlen (search->name), ".so.")[2] = 'a';
+ if (stat (alc, &st) != 0)
+ free (alc);
+ else
{
lang_input_statement_type *sa;
- char *a;
- /* Add the .sa file to the statement list just after the .so
+ /* Add the .sa file to the statement list just before the .so
file. This is really a hack. */
sa = ((lang_input_statement_type *)
xmalloc (sizeof (lang_input_statement_type)));
- sa->header.next = inp->header.next;
- sa->header.type = lang_input_statement_enum;
- a = (char *) xmalloc (strlen (alc) + 1);
- strcpy (a, alc);
- sa->filename = a;
- sa->local_sym_name = a;
- sa->the_bfd = NULL;
- sa->asymbols = NULL;
- sa->symbol_count = 0;
- sa->next = NULL;
- sa->next_real_file = inp->next_real_file;
- sa->is_archive = false;
- sa->search_dirs_flag = false;
- sa->just_syms_flag = false;
- sa->loaded = false;
- sa->real = true;
- sa->complained = false;
-
- /* Put the new statement next on the list of statements and next
- on the list of input files. */
+ *sa = *inp;
+
+ inp->filename = alc;
+ inp->local_sym_name = alc;
+
inp->header.next = (lang_statement_union_type *) sa;
inp->next_real_file = (lang_statement_union_type *) sa;
}
@@ -239,6 +268,7 @@ gld${EMULATION_NAME}_search_dir (dirname, filename, found_static)
while ((entry = readdir (dir)) != NULL)
{
+ const char *s;
int found_maj, found_min;
if (strncmp (entry->d_name, "lib", 3) != 0
@@ -252,7 +282,14 @@ gld${EMULATION_NAME}_search_dir (dirname, filename, found_static)
continue;
}
- if (strncmp (entry->d_name + 3 + len, ".so", 3) != 0)
+ if (strncmp (entry->d_name + 3 + len, ".so.", 4) != 0
+ || ! isdigit (entry->d_name[7 + len]))
+ continue;
+
+ for (s = entry->d_name + 7 + len; *s != '\0'; s++)
+ if (*s != '.' && ! isdigit (*s))
+ break;
+ if (*s != '\0')
continue;
/* We've found a .so file. Work out the major and minor
@@ -325,7 +362,6 @@ gld${EMULATION_NAME}_after_open ()
{
struct bfd_link_needed_list *ll;
const char *lname;
- const char *lib_path;
search_dirs_type *search;
lname = l->name;
@@ -404,12 +440,18 @@ gld${EMULATION_NAME}_after_open ()
continue;
}
EOF
-if [ "x${host_alias}" = "x${target_alias}" ] ; then
+if [ "x${host}" = "x${target}" ] ; then
+ if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then
cat >>e${EMULATION_NAME}.c <<EOF
- lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
- if (gld${EMULATION_NAME}_search_needed (lib_path, lname))
- continue;
+ {
+ const char *lib_path;
+
+ lib_path = (const char *) getenv ("LD_LIBRARY_PATH");
+ if (gld${EMULATION_NAME}_search_needed (lib_path, lname))
+ continue;
+ }
EOF
+ fi
fi
cat >>e${EMULATION_NAME}.c <<EOF
if (command_line.rpath != NULL)
@@ -965,6 +1007,8 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
"${OUTPUT_FORMAT}",
NULL, /* finish */
gld${EMULATION_NAME}_create_output_section_statements,
- NULL /* open_dynamic_library */
+ NULL, /* open_dynamic_library */
+ NULL, /* place_orphan */
+ gld${EMULATION_NAME}_set_symbols
};
EOF