summaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2010-10-28 06:45:32 +0000
committerAlan Modra <amodra@bigpond.net.au>2010-10-28 06:45:32 +0000
commit5d352a8ce5ca0240d7f420de6dbba43381d14d62 (patch)
treeb173769577f941c766753fefb04d1d88122f2f59 /ld/ldlang.c
parent137f733fe272a442a75bf523129b3c8dfb9d2f43 (diff)
downloadbinutils-redhat-5d352a8ce5ca0240d7f420de6dbba43381d14d62.tar.gz
* ldlang.h (ldlang_add_undef): Add cmdline param.
* ldlang.c (undef_from_cmdline): New var. (ldlang_add_undef): Add cmdline param. Set undef_from_cmdline. (lang_end): Really require -e or -u from command line on relocatable --gc-sections. * ldemul.c (after_parse_default): Adjust ldlang_add_undef call. * ldgram.y (extern_name_list_body): Likewise. * lexsup.c (parse_args): Likewise. * emultempl/aix.em (gld${EMULATION_NAME}_read_file): Likewise.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 2bb2e93cd4..95ef5f5d96 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -101,6 +101,7 @@ lang_statement_list_type input_file_chain;
struct bfd_sym_chain entry_symbol = { NULL, NULL };
const char *entry_section = ".text";
bfd_boolean entry_from_cmdline;
+bfd_boolean undef_from_cmdline;
bfd_boolean lang_has_input_file = FALSE;
bfd_boolean had_output_filename = FALSE;
bfd_boolean lang_float_flag = FALSE;
@@ -3297,11 +3298,12 @@ typedef struct bfd_sym_chain ldlang_undef_chain_list_type;
#define ldlang_undef_chain_list_head entry_symbol.next
void
-ldlang_add_undef (const char *const name)
+ldlang_add_undef (const char *const name, bfd_boolean cmdline)
{
- ldlang_undef_chain_list_type *new_undef = (ldlang_undef_chain_list_type *)
- stat_alloc (sizeof (ldlang_undef_chain_list_type));
+ ldlang_undef_chain_list_type *new_undef;
+ undef_from_cmdline = undef_from_cmdline || cmdline;
+ new_undef = (ldlang_undef_chain_list_type *) stat_alloc (sizeof (*new_undef));
new_undef->next = ldlang_undef_chain_list_head;
ldlang_undef_chain_list_head = new_undef;
@@ -5583,8 +5585,7 @@ lang_end (void)
/* Force the user to specify a root when generating a relocatable with
--gc-sections. */
if (link_info.gc_sections && link_info.relocatable
- && (entry_symbol.name == NULL
- && ldlang_undef_chain_list_head == NULL))
+ && !(entry_from_cmdline || undef_from_cmdline))
einfo (_("%P%F: gc-sections requires either an entry or "
"an undefined symbol\n"));