* emultempl/ppc32elf.em: New file.
[deliverable/binutils-gdb.git] / ld / ldmain.c
index c90cb6653742425ddac26062fadc9abe46596c65..3aaef5d8bb01af689af6ef4397ece418286a9d06 100644 (file)
@@ -1,6 +1,6 @@
 /* Main program of GNU linker.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002
+   2002, 2003
    Free Software Foundation, Inc.
    Written by Steve Chamberlain steve@cygnus.com
 
@@ -55,6 +55,10 @@ extern PTR sbrk ();
 #endif
 #endif
 
+#ifndef TARGET_SYSTEM_ROOT
+#define TARGET_SYSTEM_ROOT ""
+#endif
+
 int main PARAMS ((int, char **));
 
 static char *get_emulation PARAMS ((int, char **));
@@ -68,6 +72,9 @@ const char *output_filename = "a.out";
 /* Name this program was invoked by.  */
 char *program_name;
 
+/* The prefix for system library directories.  */
+char *ld_sysroot;
+
 /* The file that we're creating.  */
 bfd *output_bfd = 0;
 
@@ -189,6 +196,25 @@ main (argc, argv)
 
   xatexit (remove_output);
 
+#ifdef TARGET_SYSTEM_ROOT_RELOCATABLE
+  ld_sysroot = make_relative_prefix (program_name, BINDIR,
+                                    TARGET_SYSTEM_ROOT);
+  if (ld_sysroot)
+    {
+      struct stat s;
+      int res = stat (ld_sysroot, &s) == 0 && S_ISDIR (s.st_mode);
+      if (!res)
+       {
+         free (ld_sysroot);
+         ld_sysroot = TARGET_SYSTEM_ROOT;
+       }
+    }
+  else
+    ld_sysroot = TARGET_SYSTEM_ROOT;
+#else
+  ld_sysroot = TARGET_SYSTEM_ROOT;
+#endif
+
   /* Set the default BFD target based on the configured target.  Doing
      this permits the linker to be configured for a particular target,
      and linked against a shared BFD library which was configured for
@@ -239,7 +265,7 @@ main (argc, argv)
   link_info.traditional_format = FALSE;
   link_info.optimize = FALSE;
   link_info.no_undefined = FALSE;
-  link_info.allow_shlib_undefined = FALSE;
+  link_info.allow_shlib_undefined = TRUE;
   link_info.allow_multiple_definition = FALSE;
   link_info.allow_undefined_version = TRUE;
   link_info.keep_memory = TRUE;
@@ -552,10 +578,11 @@ get_emulation (argc, argv)
          else if (strcmp (argv[i], "-mips1") == 0
                   || strcmp (argv[i], "-mips2") == 0
                   || strcmp (argv[i], "-mips3") == 0
-                  || strcmp (argv[i], "-mips32") == 0
-                  || strcmp (argv[i], "-mips64") == 0
                   || strcmp (argv[i], "-mips4") == 0
-                  || strcmp (argv[i], "-mips5") == 0)
+                  || strcmp (argv[i], "-mips5") == 0
+                  || strcmp (argv[i], "-mips32") == 0
+                  || strcmp (argv[i], "-mips32r2") == 0
+                  || strcmp (argv[i], "-mips64") == 0)
            {
              /* FIXME: The arguments -mips1, -mips2, -mips3, etc. are
                 passed to the linker by some MIPS compilers.  They
@@ -611,9 +638,12 @@ check_for_scripts_dir (dir)
    Libraries will be searched for here too, but that's ok.
    We look for the "ldscripts" directory in:
 
+   SCRIPTDIR (passed from Makefile)
+            (adjusted according to the current location of the binary)
    SCRIPTDIR (passed from Makefile)
    the dir where this program is (for using it from the build tree)
-   the dir where this program is/../lib (for installing the tool suite elsewhere) */
+   the dir where this program is/../lib
+            (for installing the tool suite elsewhere)  */
 
 static void
 set_scripts_dir ()
@@ -621,6 +651,14 @@ set_scripts_dir ()
   char *end, *dir;
   size_t dirlen;
 
+  dir = make_relative_prefix (program_name, BINDIR, SCRIPTDIR);
+  if (dir && check_for_scripts_dir (dir))
+    /* Success.  Don't free dir.  */
+    return;
+
+  if (dir)
+    free (dir);
+
   if (check_for_scripts_dir (SCRIPTDIR))
     /* We've been installed normally.  */
     return;
This page took 0.023694 seconds and 4 git commands to generate.