/* 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>
#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"
#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
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
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;
}
while ((entry = readdir (dir)) != NULL)
{
+ const char *s;
int found_maj, found_min;
if (strncmp (entry->d_name, "lib", 3) != 0
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
{
struct bfd_link_needed_list *ll;
const char *lname;
- const char *lib_path;
search_dirs_type *search;
lname = l->name;
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)
"${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