(ld_sysroot): Try to set from TOOLBINDIR too.
This commit is contained in:
parent
4fabe71ea9
commit
0125cdf20c
4 changed files with 96 additions and 79 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2003-02-25 Alexandre Oliva <aoliva@redhat.com>
|
||||||
|
|
||||||
|
* Makefile.am (ldmain.o): Define TOOLBINDIR.
|
||||||
|
* Makefile.in: Rebuilt.
|
||||||
|
* ldmain.c (ld_sysroot): Try to set from TOOLBINDIR too.
|
||||||
|
|
||||||
2003-02-21 Bob Wilson <bob.wilson@acm.org>
|
2003-02-21 Bob Wilson <bob.wilson@acm.org>
|
||||||
|
|
||||||
* ldlang.c (lang_size_sections_1): Add CHECK_REGIONS argument and only
|
* ldlang.c (lang_size_sections_1): Add CHECK_REGIONS argument and only
|
||||||
|
|
|
@ -397,6 +397,7 @@ po/POTFILES.in: @MAINT@ Makefile
|
||||||
ldmain.o: ldmain.c config.status
|
ldmain.o: ldmain.c config.status
|
||||||
$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
|
$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
|
||||||
-DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
|
-DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
|
||||||
|
-DTOOLBINDIR='"$(tooldir)/bin"' \
|
||||||
-DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
|
-DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
|
||||||
$(srcdir)/ldmain.c
|
$(srcdir)/ldmain.c
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
|
# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
|
||||||
|
|
||||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
||||||
# This Makefile.in is free software; the Free Software Foundation
|
# This Makefile.in is free software; the Free Software Foundation
|
||||||
|
@ -583,7 +583,7 @@ deffilep.c ldgram.c ldlex.c
|
||||||
|
|
||||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
|
|
||||||
TAR = tar
|
TAR = gtar
|
||||||
GZIP_ENV = --best
|
GZIP_ENV = --best
|
||||||
SOURCES = $(ld_new_SOURCES) $(EXTRA_ld_new_SOURCES)
|
SOURCES = $(ld_new_SOURCES) $(EXTRA_ld_new_SOURCES)
|
||||||
OBJECTS = $(ld_new_OBJECTS)
|
OBJECTS = $(ld_new_OBJECTS)
|
||||||
|
@ -1065,7 +1065,7 @@ distclean-generic:
|
||||||
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
||||||
|
|
||||||
maintainer-clean-generic:
|
maintainer-clean-generic:
|
||||||
-test -z "ldlex.cdeffilep.hdeffilep.cldgram.hldgram.c$(MAINTAINERCLEANFILES)" || rm -f ldlex.c deffilep.h deffilep.c ldgram.h ldgram.c $(MAINTAINERCLEANFILES)
|
-test -z "ldlexldeffilephdeffilepcldgramhldgramc$(MAINTAINERCLEANFILES)" || rm -f ldlexl deffileph deffilepc ldgramh ldgramc $(MAINTAINERCLEANFILES)
|
||||||
mostlyclean-am: mostlyclean-hdr mostlyclean-noinstPROGRAMS \
|
mostlyclean-am: mostlyclean-hdr mostlyclean-noinstPROGRAMS \
|
||||||
mostlyclean-compile mostlyclean-libtool \
|
mostlyclean-compile mostlyclean-libtool \
|
||||||
mostlyclean-aminfo mostlyclean-tags mostlyclean-generic \
|
mostlyclean-aminfo mostlyclean-tags mostlyclean-generic \
|
||||||
|
@ -1128,6 +1128,7 @@ po/POTFILES.in: @MAINT@ Makefile
|
||||||
ldmain.o: ldmain.c config.status
|
ldmain.o: ldmain.c config.status
|
||||||
$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
|
$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
|
||||||
-DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
|
-DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
|
||||||
|
-DTOOLBINDIR='"$(tooldir)/bin"' \
|
||||||
-DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
|
-DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
|
||||||
$(srcdir)/ldmain.c
|
$(srcdir)/ldmain.c
|
||||||
|
|
||||||
|
|
161
ld/ldmain.c
161
ld/ldmain.c
|
@ -42,7 +42,7 @@
|
||||||
#include "ldemul.h"
|
#include "ldemul.h"
|
||||||
#include "ldctor.h"
|
#include "ldctor.h"
|
||||||
|
|
||||||
/* Somewhere above, sys/stat.h got included . . . . */
|
/* Somewhere above, sys/stat.h got included. */
|
||||||
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
||||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,9 +61,6 @@ extern PTR sbrk ();
|
||||||
|
|
||||||
int main PARAMS ((int, char **));
|
int main PARAMS ((int, char **));
|
||||||
|
|
||||||
static char *get_emulation PARAMS ((int, char **));
|
|
||||||
static void set_scripts_dir PARAMS ((void));
|
|
||||||
|
|
||||||
/* EXPORTS */
|
/* EXPORTS */
|
||||||
|
|
||||||
char *default_target;
|
char *default_target;
|
||||||
|
@ -101,46 +98,49 @@ args_type command_line;
|
||||||
|
|
||||||
ld_config_type config;
|
ld_config_type config;
|
||||||
|
|
||||||
static void remove_output PARAMS ((void));
|
static char *get_emulation
|
||||||
static bfd_boolean check_for_scripts_dir PARAMS ((char *dir));
|
PARAMS ((int, char **));
|
||||||
static bfd_boolean add_archive_element PARAMS ((struct bfd_link_info *, bfd *,
|
static void set_scripts_dir
|
||||||
const char *));
|
PARAMS ((void));
|
||||||
static bfd_boolean multiple_definition PARAMS ((struct bfd_link_info *,
|
static void remove_output
|
||||||
const char *,
|
PARAMS ((void));
|
||||||
bfd *, asection *, bfd_vma,
|
static bfd_boolean check_for_scripts_dir
|
||||||
bfd *, asection *, bfd_vma));
|
PARAMS ((char *));
|
||||||
static bfd_boolean multiple_common PARAMS ((struct bfd_link_info *,
|
static bfd_boolean add_archive_element
|
||||||
const char *, bfd *,
|
PARAMS ((struct bfd_link_info *, bfd *, const char *));
|
||||||
enum bfd_link_hash_type, bfd_vma,
|
static bfd_boolean multiple_definition
|
||||||
bfd *, enum bfd_link_hash_type,
|
PARAMS ((struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma,
|
||||||
bfd_vma));
|
bfd *, asection *, bfd_vma));
|
||||||
static bfd_boolean add_to_set PARAMS ((struct bfd_link_info *,
|
static bfd_boolean multiple_common
|
||||||
struct bfd_link_hash_entry *,
|
PARAMS ((struct bfd_link_info *, const char *, bfd *,
|
||||||
bfd_reloc_code_real_type,
|
enum bfd_link_hash_type, bfd_vma, bfd *, enum bfd_link_hash_type,
|
||||||
bfd *, asection *, bfd_vma));
|
bfd_vma));
|
||||||
static bfd_boolean constructor_callback PARAMS ((struct bfd_link_info *,
|
static bfd_boolean add_to_set
|
||||||
bfd_boolean constructor,
|
PARAMS ((struct bfd_link_info *, struct bfd_link_hash_entry *,
|
||||||
const char *name,
|
bfd_reloc_code_real_type, bfd *, asection *, bfd_vma));
|
||||||
bfd *, asection *, bfd_vma));
|
static bfd_boolean constructor_callback
|
||||||
static bfd_boolean warning_callback PARAMS ((struct bfd_link_info *,
|
PARAMS ((struct bfd_link_info *, bfd_boolean, const char *, bfd *,
|
||||||
const char *, const char *, bfd *,
|
asection *, bfd_vma));
|
||||||
asection *, bfd_vma));
|
static bfd_boolean warning_callback
|
||||||
static void warning_find_reloc PARAMS ((bfd *, asection *, PTR));
|
PARAMS ((struct bfd_link_info *, const char *, const char *, bfd *,
|
||||||
static bfd_boolean undefined_symbol PARAMS ((struct bfd_link_info *,
|
asection *, bfd_vma));
|
||||||
const char *, bfd *,
|
static void warning_find_reloc
|
||||||
asection *, bfd_vma, bfd_boolean));
|
PARAMS ((bfd *, asection *, PTR));
|
||||||
static bfd_boolean reloc_overflow PARAMS ((struct bfd_link_info *, const char *,
|
static bfd_boolean undefined_symbol
|
||||||
const char *, bfd_vma,
|
PARAMS ((struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma,
|
||||||
bfd *, asection *, bfd_vma));
|
bfd_boolean));
|
||||||
static bfd_boolean reloc_dangerous PARAMS ((struct bfd_link_info *, const char *,
|
static bfd_boolean reloc_overflow
|
||||||
bfd *, asection *, bfd_vma));
|
PARAMS ((struct bfd_link_info *, const char *, const char *, bfd_vma,
|
||||||
static bfd_boolean unattached_reloc PARAMS ((struct bfd_link_info *,
|
bfd *, asection *, bfd_vma));
|
||||||
const char *, bfd *, asection *,
|
static bfd_boolean reloc_dangerous
|
||||||
bfd_vma));
|
PARAMS ((struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma));
|
||||||
static bfd_boolean notice PARAMS ((struct bfd_link_info *, const char *,
|
static bfd_boolean unattached_reloc
|
||||||
bfd *, asection *, bfd_vma));
|
PARAMS ((struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma));
|
||||||
|
static bfd_boolean notice
|
||||||
|
PARAMS ((struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma));
|
||||||
|
|
||||||
static struct bfd_link_callbacks link_callbacks = {
|
static struct bfd_link_callbacks link_callbacks =
|
||||||
|
{
|
||||||
add_archive_element,
|
add_archive_element,
|
||||||
multiple_definition,
|
multiple_definition,
|
||||||
multiple_common,
|
multiple_common,
|
||||||
|
@ -199,21 +199,40 @@ main (argc, argv)
|
||||||
#ifdef TARGET_SYSTEM_ROOT_RELOCATABLE
|
#ifdef TARGET_SYSTEM_ROOT_RELOCATABLE
|
||||||
ld_sysroot = make_relative_prefix (program_name, BINDIR,
|
ld_sysroot = make_relative_prefix (program_name, BINDIR,
|
||||||
TARGET_SYSTEM_ROOT);
|
TARGET_SYSTEM_ROOT);
|
||||||
|
|
||||||
if (ld_sysroot)
|
if (ld_sysroot)
|
||||||
{
|
{
|
||||||
struct stat s;
|
struct stat s;
|
||||||
int res = stat (ld_sysroot, &s) == 0 && S_ISDIR (s.st_mode);
|
int res = stat (ld_sysroot, &s) == 0 && S_ISDIR (s.st_mode);
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
free (ld_sysroot);
|
free (ld_sysroot);
|
||||||
ld_sysroot = TARGET_SYSTEM_ROOT;
|
ld_sysroot = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
ld_sysroot = TARGET_SYSTEM_ROOT;
|
if (! ld_sysroot)
|
||||||
#else
|
{
|
||||||
ld_sysroot = TARGET_SYSTEM_ROOT;
|
ld_sysroot = make_relative_prefix (program_name, TOOLBINDIR,
|
||||||
|
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 = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! ld_sysroot)
|
||||||
#endif
|
#endif
|
||||||
|
ld_sysroot = TARGET_SYSTEM_ROOT;
|
||||||
|
|
||||||
/* Set the default BFD target based on the configured target. Doing
|
/* Set the default BFD target based on the configured target. Doing
|
||||||
this permits the linker to be configured for a particular target,
|
this permits the linker to be configured for a particular target,
|
||||||
|
@ -411,9 +430,7 @@ main (argc, argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trace_files)
|
if (trace_files)
|
||||||
{
|
info_msg (_("%P: mode %s\n"), emulation);
|
||||||
info_msg (_("%P: mode %s\n"), emulation);
|
|
||||||
}
|
|
||||||
|
|
||||||
ldemul_after_parse ();
|
ldemul_after_parse ();
|
||||||
|
|
||||||
|
@ -439,7 +456,6 @@ main (argc, argv)
|
||||||
|
|
||||||
/* Print error messages for any missing symbols, for any warning
|
/* Print error messages for any missing symbols, for any warning
|
||||||
symbols, and possibly multiple definitions. */
|
symbols, and possibly multiple definitions. */
|
||||||
|
|
||||||
if (link_info.relocateable)
|
if (link_info.relocateable)
|
||||||
output_bfd->flags &= ~EXEC_P;
|
output_bfd->flags &= ~EXEC_P;
|
||||||
else
|
else
|
||||||
|
@ -457,17 +473,13 @@ main (argc, argv)
|
||||||
/* Even if we're producing relocateable output, some non-fatal errors should
|
/* Even if we're producing relocateable output, some non-fatal errors should
|
||||||
be reported in the exit status. (What non-fatal errors, if any, do we
|
be reported in the exit status. (What non-fatal errors, if any, do we
|
||||||
want to ignore for relocateable output?) */
|
want to ignore for relocateable output?) */
|
||||||
|
|
||||||
if (!config.make_executable && !force_make_executable)
|
if (!config.make_executable && !force_make_executable)
|
||||||
{
|
{
|
||||||
if (trace_files)
|
if (trace_files)
|
||||||
{
|
einfo (_("%P: link errors found, deleting executable `%s'\n"),
|
||||||
einfo (_("%P: link errors found, deleting executable `%s'\n"),
|
output_filename);
|
||||||
output_filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The file will be removed by remove_output. */
|
/* The file will be removed by remove_output. */
|
||||||
|
|
||||||
xexit (1);
|
xexit (1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -481,6 +493,7 @@ main (argc, argv)
|
||||||
if (! link_info.relocateable && command_line.force_exe_suffix)
|
if (! link_info.relocateable && command_line.force_exe_suffix)
|
||||||
{
|
{
|
||||||
int len = strlen (output_filename);
|
int len = strlen (output_filename);
|
||||||
|
|
||||||
if (len < 4
|
if (len < 4
|
||||||
|| (strcasecmp (output_filename + len - 4, ".exe") != 0
|
|| (strcasecmp (output_filename + len - 4, ".exe") != 0
|
||||||
&& strcasecmp (output_filename + len - 4, ".dll") != 0))
|
&& strcasecmp (output_filename + len - 4, ".dll") != 0))
|
||||||
|
@ -491,6 +504,7 @@ main (argc, argv)
|
||||||
char *buf = xmalloc (bsize);
|
char *buf = xmalloc (bsize);
|
||||||
int l;
|
int l;
|
||||||
char *dst_name = xmalloc (len + 5);
|
char *dst_name = xmalloc (len + 5);
|
||||||
|
|
||||||
strcpy (dst_name, output_filename);
|
strcpy (dst_name, output_filename);
|
||||||
strcat (dst_name, ".exe");
|
strcat (dst_name, ".exe");
|
||||||
src = fopen (output_filename, FOPEN_RB);
|
src = fopen (output_filename, FOPEN_RB);
|
||||||
|
@ -503,16 +517,14 @@ main (argc, argv)
|
||||||
while ((l = fread (buf, 1, bsize, src)) > 0)
|
while ((l = fread (buf, 1, bsize, src)) > 0)
|
||||||
{
|
{
|
||||||
int done = fwrite (buf, 1, l, dst);
|
int done = fwrite (buf, 1, l, dst);
|
||||||
|
|
||||||
if (done != l)
|
if (done != l)
|
||||||
{
|
einfo (_("%P: Error writing file `%s'\n"), dst_name);
|
||||||
einfo (_("%P: Error writing file `%s'\n"), dst_name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (src);
|
fclose (src);
|
||||||
if (fclose (dst) == EOF)
|
if (fclose (dst) == EOF)
|
||||||
{
|
einfo (_("%P: Error closing file `%s'\n"), dst_name);
|
||||||
einfo (_("%P: Error closing file `%s'\n"), dst_name);
|
|
||||||
}
|
|
||||||
free (dst_name);
|
free (dst_name);
|
||||||
free (buf);
|
free (buf);
|
||||||
}
|
}
|
||||||
|
@ -571,9 +583,7 @@ get_emulation (argc, argv)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
einfo (_("%P%F: missing argument to -m\n"));
|
||||||
einfo (_("%P%F: missing argument to -m\n"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (strcmp (argv[i], "-mips1") == 0
|
else if (strcmp (argv[i], "-mips1") == 0
|
||||||
|| strcmp (argv[i], "-mips2") == 0
|
|| strcmp (argv[i], "-mips2") == 0
|
||||||
|
@ -643,7 +653,7 @@ check_for_scripts_dir (dir)
|
||||||
SCRIPTDIR (passed from Makefile)
|
SCRIPTDIR (passed from Makefile)
|
||||||
the dir where this program is (for using it from the build tree)
|
the dir where this program is (for using it from the build tree)
|
||||||
the dir where this program is/../lib
|
the dir where this program is/../lib
|
||||||
(for installing the tool suite elsewhere) */
|
(for installing the tool suite elsewhere). */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_scripts_dir ()
|
set_scripts_dir ()
|
||||||
|
@ -669,17 +679,16 @@ set_scripts_dir ()
|
||||||
{
|
{
|
||||||
/* We could have \foo\bar, or /foo\bar. */
|
/* We could have \foo\bar, or /foo\bar. */
|
||||||
char *bslash = strrchr (program_name, '\\');
|
char *bslash = strrchr (program_name, '\\');
|
||||||
|
|
||||||
if (end == NULL || (bslash != NULL && bslash > end))
|
if (end == NULL || (bslash != NULL && bslash > end))
|
||||||
end = bslash;
|
end = bslash;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (end == NULL)
|
if (end == NULL)
|
||||||
{
|
/* Don't look for ldscripts in the current directory. There is
|
||||||
/* Don't look for ldscripts in the current directory. There is
|
too much potential for confusion. */
|
||||||
too much potential for confusion. */
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dirlen = end - program_name;
|
dirlen = end - program_name;
|
||||||
/* Make a copy of program_name in dir.
|
/* Make a copy of program_name in dir.
|
||||||
|
@ -735,6 +744,7 @@ add_wrap (name)
|
||||||
61))
|
61))
|
||||||
einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
|
einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bfd_hash_lookup (link_info.wrap_hash, name, TRUE, TRUE) == NULL)
|
if (bfd_hash_lookup (link_info.wrap_hash, name, TRUE, TRUE) == NULL)
|
||||||
einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
|
einfo (_("%P%F: bfd_hash_lookup failed: %E\n"));
|
||||||
}
|
}
|
||||||
|
@ -1120,7 +1130,8 @@ constructor_callback (info, constructor, name, abfd, section, value)
|
||||||
/* A structure used by warning_callback to pass information through
|
/* A structure used by warning_callback to pass information through
|
||||||
bfd_map_over_sections. */
|
bfd_map_over_sections. */
|
||||||
|
|
||||||
struct warning_callback_info {
|
struct warning_callback_info
|
||||||
|
{
|
||||||
bfd_boolean found;
|
bfd_boolean found;
|
||||||
const char *warning;
|
const char *warning;
|
||||||
const char *symbol;
|
const char *symbol;
|
||||||
|
@ -1158,7 +1169,6 @@ warning_callback (info, warning, symbol, abfd, section, address)
|
||||||
|
|
||||||
/* Look through the relocs to see if we can find a plausible
|
/* Look through the relocs to see if we can find a plausible
|
||||||
address. */
|
address. */
|
||||||
|
|
||||||
entry = (lang_input_statement_type *) abfd->usrdata;
|
entry = (lang_input_statement_type *) abfd->usrdata;
|
||||||
if (entry != NULL && entry->asymbols != NULL)
|
if (entry != NULL && entry->asymbols != NULL)
|
||||||
asymbols = entry->asymbols;
|
asymbols = entry->asymbols;
|
||||||
|
@ -1269,7 +1279,6 @@ undefined_symbol (info, name, abfd, section, address, fatal)
|
||||||
static struct bfd_hash_table *hash;
|
static struct bfd_hash_table *hash;
|
||||||
|
|
||||||
/* Only warn once about a particular undefined symbol. */
|
/* Only warn once about a particular undefined symbol. */
|
||||||
|
|
||||||
if (hash == NULL)
|
if (hash == NULL)
|
||||||
{
|
{
|
||||||
hash = ((struct bfd_hash_table *)
|
hash = ((struct bfd_hash_table *)
|
||||||
|
|
Loading…
Reference in a new issue