diff options
Diffstat (limited to 'ld/ldmain.c')
-rw-r--r-- | ld/ldmain.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ld/ldmain.c b/ld/ldmain.c index 3185bef..0117b1c 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -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,23 @@ 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; +#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 |