summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2004-10-11 02:40:47 +0000
committerAlan Modra <amodra@bigpond.net.au>2004-10-11 02:40:47 +0000
commitf39d3190a3b59a5e33ac666bb4fc38e50d1cd76c (patch)
treeb2017f3791feeec8cd3b09029b169f5bedd53211
parent7ce192ace93f1f2bd1591a73e201ced599342a1a (diff)
downloadbinutils-redhat-f39d3190a3b59a5e33ac666bb4fc38e50d1cd76c.tar.gz
PR 423
* ldfile.c (ldfile_try_open_bfd): Ensure dynamic objects are rejected when linking statically.
-rw-r--r--ld/ChangeLog12
-rw-r--r--ld/ldfile.c20
2 files changed, 25 insertions, 7 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index ce025828ce..1f805b3d77 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2004-10-11 Alan Modra <amodra@bigpond.net.au>
+
+ PR 423
+ * ldfile.c (ldfile_try_open_bfd): Ensure dynamic objects are
+ rejected when linking statically.
+
2004-10-08 Daniel Jacobowitz <dan@debian.org>
* configure.tgt: Include elf_x86_64 for i[3-7]86-*-solaris2*.
@@ -24,7 +30,7 @@
* Makefile.in: Regenerate.
2004-10-07 Jeff Baker <jbaker@qnx.com>
-
+
* lexsup.c: Handle --warn-shared-textrel option.
(ld_options): Restore alpha sorting of options.
* ldmain.c (main): Initialise warn_shared_info field to FALSE.
@@ -32,9 +38,9 @@
* NEWS: Added mention of --warn-shared-textrel option.
2004-10-05 Tomer Levi <Tomer.Levi@nsc.com>
-
+
* emultempl/crxelf.em (disable_relaxation): Add.
- (crxelf_before_allocation): Enable --relax option by default.
+ (crxelf_before_allocation): Enable --relax option by default.
(PARSE_AND_LIST_PROLOGUE): Add OPTION_NO_RELAX.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add --no-relax.
(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_NO_RELAX.
diff --git a/ld/ldfile.c b/ld/ldfile.c
index e7a7d8cec0..25d53e0358 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -151,9 +151,10 @@ ldfile_try_open_bfd (const char *attempt,
/* If we are searching for this file, see if the architecture is
compatible with the output file. If it isn't, keep searching.
If we can't open the file as an object file, stop the search
- here. */
+ here. If we are statically linking, ensure that we don't link
+ a dynamic object. */
- if (entry->search_dirs_flag)
+ if (entry->search_dirs_flag || !entry->dynamic)
{
bfd *check;
@@ -167,6 +168,7 @@ ldfile_try_open_bfd (const char *attempt,
if (! bfd_check_format (check, bfd_object))
{
if (check == entry->the_bfd
+ && entry->search_dirs_flag
&& bfd_get_error () == bfd_error_file_not_recognized
&& ! ldemul_unrecognized_file (entry))
{
@@ -260,8 +262,18 @@ ldfile_try_open_bfd (const char *attempt,
return TRUE;
}
- if ((bfd_arch_get_compatible (check, output_bfd,
- command_line.accept_unknown_input_arch) == NULL)
+ if (!entry->dynamic && (entry->the_bfd->flags & DYNAMIC) != 0)
+ {
+ einfo (_("%F%P: attempted static link of dynamic object `%s'\n"),
+ attempt);
+ bfd_close (entry->the_bfd);
+ entry->the_bfd = NULL;
+ return FALSE;
+ }
+
+ if (entry->search_dirs_flag
+ && !bfd_arch_get_compatible (check, output_bfd,
+ command_line.accept_unknown_input_arch)
/* 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