From e87b950c8e6dd1bbbe7dc78a82a0abd089665230 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 30 Jan 1997 16:33:36 +0000 Subject: * emultempl/sunos.em: Include . (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. --- ld/ChangeLog | 8 ++++ ld/emultempl/sunos.em | 108 +++++++++++++++++++++++++++++++++++--------------- 2 files changed, 84 insertions(+), 32 deletions(-) (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index 720fea6..6aeb727 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +Thu Jan 30 11:31:52 1997 Ian Lance Taylor + + * emultempl/sunos.em: Include . + (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. + Wed Jan 29 18:15:00 1997 Geoffrey Noer * scripttempl/pe.sc: 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 < SunOS shared library support by Ian Lance Taylor @@ -26,12 +26,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define TARGET_IS_${EMULATION_NAME} +#include #include #include #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 <>e${EMULATION_NAME}.c <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 <>e${EMULATION_NAME}.c <