aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2002-12-23 10:45:03 +0000
committerNick Clifton <nickc@redhat.com>2002-12-23 10:45:03 +0000
commit312b768e2f1579346e7ffe978202fda06cb37224 (patch)
tree3322c12eef2b97a147b0754f4d65aba2483f77a9 /ld
parent8745eafadc9d43dbd9f9a0d2cc33e12f11ca1cd6 (diff)
downloadgdb-312b768e2f1579346e7ffe978202fda06cb37224.zip
gdb-312b768e2f1579346e7ffe978202fda06cb37224.tar.gz
gdb-312b768e2f1579346e7ffe978202fda06cb37224.tar.bz2
Change linker's default behaviour - it will now reject binary files whoes
architecture it does not recognise, unless it has explicitly told to accept them.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog15
-rw-r--r--ld/NEWS4
-rw-r--r--ld/ld.h6
-rw-r--r--ld/ldfile.c5
-rw-r--r--ld/ldlang.c3
-rw-r--r--ld/ldmain.c1
-rw-r--r--ld/lexsup.c12
7 files changed, 43 insertions, 3 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index f4ede57..cc43cea 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,18 @@
+2002-12-23 Nick Clifton <nickc@redhat.com>
+
+ * ld.h (struct args_type): Add new field
+ 'accept_unknown_input_architecture'.
+ * ldmain.c (main): Initialise 'accept_unknown_input_architecture'
+ to false.
+ * ldlang.c (lang_check): Pass accept_unknown_input_architecture to
+ bfd_arch_get_compatible.
+ * ldfile.c (ldfile_try_open_bfd): Likewise.
+ * lexsup.c (ld_options): Add new command line switch
+ --accept-unknown-input-architecture and its inverse.
+ (parse_args): Handle --accept-unknown-input-architecture.
+ * ld.texinfo: Document new linker option.
+ * NEWS: Mention new linker option.
+
2002-12-20 Alan Modra <amodra@bigpond.net.au>
* ldmain.c (main): Re-order link_info initialization. Init all
diff --git a/ld/NEWS b/ld/NEWS
index 790b263..0ed91b1 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,5 +1,9 @@
-*- text -*-
+* Added --accept-unknown-linker-format to restore old linker behaviour (pre
+ 2.14) of silently accepting and linking in any files in an unknown binary
+ file format.
+
* Added --no-omagic to undo the effects of the -N option.
* Support for Texas Instruments TMS320C4x and TMS320C3x series of
diff --git a/ld/ld.h b/ld/ld.h
index 4a2aac7..75c054e 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -148,6 +148,12 @@ typedef struct {
fpor overlaps. */
bfd_boolean check_section_addresses;
+ /* If TRUE allow the linking of input files in an unknown architecture
+ assuming that the user knows what they are doing. This was the old
+ behaviour of the linker. The new default behaviour is to reject such
+ input files. */
+ bfd_boolean accept_unknown_input_arch;
+
} args_type;
extern args_type command_line;
diff --git a/ld/ldfile.c b/ld/ldfile.c
index 34a25fa..b30fbe2 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -225,8 +225,9 @@ ldfile_try_open_bfd (attempt, entry)
return TRUE;
}
- if ((bfd_arch_get_compatible (check, output_bfd) == NULL)
- /* XCOFF archives can have 32 and 64 bit objects */
+ if ((bfd_arch_get_compatible (check, output_bfd,
+ command_line.accept_unknown_input_arch) == NULL)
+ /* XCOFF archives can have 32 and 64 bit objects. */
&& ! (bfd_get_flavour (check) == bfd_target_xcoff_flavour
&& bfd_get_flavour (output_bfd) == bfd_target_xcoff_flavour
&& bfd_check_format (entry->the_bfd, bfd_archive)))
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 66b4b13..9565a63 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -3699,7 +3699,8 @@ lang_check ()
file = file->input_statement.next)
{
input_bfd = file->input_statement.the_bfd;
- compatible = bfd_arch_get_compatible (input_bfd, output_bfd);
+ compatible = bfd_arch_get_compatible (input_bfd, output_bfd,
+ command_line.accept_unknown_input_arch);
/* In general it is not possible to perform a relocatable
link between differing object formats when the input
diff --git a/ld/ldmain.c b/ld/ldmain.c
index ef84e87..03a5c5a 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -220,6 +220,7 @@ main (argc, argv)
command_line.rpath = NULL;
command_line.warn_mismatch = TRUE;
command_line.check_section_addresses = TRUE;
+ command_line.accept_unknown_input_arch = FALSE;
/* We initialize DEMANGLING based on the environment variable
COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 8ce8f18..ce4cf30 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -133,6 +133,8 @@ int parsing_defsym = 0;
#define OPTION_NO_DEFINE_COMMON (OPTION_SPARE_DYNAMIC_TAGS + 1)
#define OPTION_NOSTDLIB (OPTION_NO_DEFINE_COMMON + 1)
#define OPTION_NO_OMAGIC (OPTION_NOSTDLIB + 1)
+#define OPTION_ACCEPT_UNKNOWN_INPUT_ARCH (OPTION_NO_OMAGIC + 1)
+#define OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH (OPTION_ACCEPT_UNKNOWN_INPUT_ARCH + 1)
/* The long options. This structure is used for both the option
parsing and the help text. */
@@ -267,6 +269,10 @@ static const struct ld_option ld_options[] =
'(', NULL, N_("Start a group"), TWO_DASHES },
{ {"end-group", no_argument, NULL, ')'},
')', NULL, N_("End a group"), TWO_DASHES },
+ { {"accept-unknown-input-arch", no_argument, NULL, OPTION_ACCEPT_UNKNOWN_INPUT_ARCH},
+ '\0', NULL, N_("Accept input files whose architecture cannot be determined"), TWO_DASHES },
+ { {"no-accept-unknown-input-arch", no_argument, NULL, OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH},
+ '\0', NULL, N_("Reject input files whose architecture is unknown"), TWO_DASHES },
{ {"assert", required_argument, NULL, OPTION_ASSERT},
'\0', N_("KEYWORD"), N_("Ignored for SunOS compatibility"), ONE_DASH },
{ {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
@@ -1107,6 +1113,12 @@ parse_args (argc, argv)
case OPTION_NO_CHECK_SECTIONS:
command_line.check_section_addresses = FALSE;
break;
+ case OPTION_ACCEPT_UNKNOWN_INPUT_ARCH:
+ command_line.accept_unknown_input_arch = TRUE;
+ break;
+ case OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH:
+ command_line.accept_unknown_input_arch = FALSE;
+ break;
case '(':
if (ingroup)
einfo (_("%P%F: may not nest groups (--help for usage)\n"));