# This shell script emits a C file. -*- C -*-
# It does some substitutions.
+if [ -z "$MACHINE" ]; then
+ OUTPUT_ARCH=${ARCH}
+else
+ OUTPUT_ARCH=${ARCH}:${MACHINE}
+fi
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, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+ 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 "safe-ctype.h"
#include "ld.h"
#include "ldmain.h"
-#include "ldemul.h"
-#include "ldfile.h"
#include "ldmisc.h"
#include "ldexp.h"
#include "ldlang.h"
+#include "ldfile.h"
+#include "ldemul.h"
#ifdef HAVE_DIRENT_H
# include <dirent.h>
static void
gld${EMULATION_NAME}_before_parse()
{
- ldfile_output_architecture = bfd_arch_${ARCH};
+ const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
+ if (arch)
+ {
+ ldfile_output_architecture = arch->arch;
+ ldfile_output_machine = arch->mach;
+ ldfile_output_machine_name = arch->printable_name;
+ }
+ else
+ ldfile_output_architecture = bfd_arch_${ARCH};
config.dynamic_link = true;
+ config.has_shared = true;
}
/* This is called after the command line arguments have been parsed,
{
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
const char *env;
}
}
EOF
- fi
+ ;;
+ esac
fi
cat >>e${EMULATION_NAME}.c <<EOF
}
lang_input_statement_type *inp;
{
search_dirs_type *search;
- char *found;
+ char *found = NULL;
char *alc;
struct stat st;
found, add it to the list of input files. */
alc = (char *) xmalloc (strlen (inp->filename) + 1);
strcpy (alc, inp->filename);
- strstr (alc + strlen (search->name), ".so.")[2] = 'a';
+ strstr (alc + strlen (search->name), ".so")[2] = 'a';
if (stat (alc, &st) != 0)
free (alc);
else
int max_maj, max_min;
DIR *dir;
struct dirent *entry;
+ unsigned int dirnamelen;
+ char *full_path;
+ int statval;
+ struct stat st;
*found_static = false;
dir = opendir (dirname);
if (dir == NULL)
return NULL;
+ dirnamelen = strlen (dirname);
while ((entry = readdir (dir)) != NULL)
{
continue;
}
- if (strncmp (entry->d_name + 3 + len, ".so.", 4) != 0
- || ! isdigit (entry->d_name[7 + len]))
+ /* We accept libfoo.so without a version number, even though the
+ native linker does not. This is more convenient for packages
+ which just generate .so files for shared libraries, as on ELF
+ systems. */
+ if (strncmp (entry->d_name + 3 + len, ".so", 3) != 0)
+ continue;
+ if (entry->d_name[6 + len] == '\0')
+ ;
+ else if (entry->d_name[6 + len] == '.'
+ && ISDIGIT (entry->d_name[7 + len]))
+ ;
+ else
continue;
- for (s = entry->d_name + 7 + len; *s != '\0'; s++)
- if (*s != '.' && ! isdigit (*s))
+ for (s = entry->d_name + 6 + len; *s != '\0'; s++)
+ if (*s != '.' && ! ISDIGIT (*s))
break;
if (*s != '\0')
continue;
|| (force_min != -1 && force_min != found_min))
continue;
+ /* Make sure the file really exists (ignore broken symlinks). */
+ full_path = xmalloc (dirnamelen + 1 + strlen (entry->d_name) + 1);
+ sprintf (full_path, "%s/%s", dirname, entry->d_name);
+ statval = stat (full_path, &st);
+ free (full_path);
+ if (statval != 0)
+ continue;
+
/* We've found a match for the name we are searching for. See
if this is the version we should use. If the major and minor
versions match, we use the last entry in alphabetical order;
}
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
{
const char *lib_path;
continue;
}
EOF
- fi
+ ;;
+ esac
fi
cat >>e${EMULATION_NAME}.c <<EOF
if (command_line.rpath != NULL)
# 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
- 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
+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.
gld${EMULATION_NAME}_get_script,
"${EMULATION_NAME}",
"${OUTPUT_FORMAT}",
- NULL, /* finish */
+ NULL, /* finish */
gld${EMULATION_NAME}_create_output_section_statements,
- NULL, /* open_dynamic_library */
- NULL, /* place_orphan */
- gld${EMULATION_NAME}_set_symbols
+ NULL, /* open dynamic archive */
+ NULL, /* place orphan */
+ gld${EMULATION_NAME}_set_symbols,
+ NULL, /* parse args */
+ NULL, /* unrecognized file */
+ NULL, /* list options */
+ NULL, /* recognized file */
+ NULL /* find_potential_libraries */
};
EOF