This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch RFC] --as-needed and --add-needed for linker script
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: binutils at sources dot redhat dot com
- Date: Fri, 07 Apr 2006 08:35:17 +0900 (JST)
- Subject: [patch RFC] --as-needed and --add-needed for linker script
Hi,
With the current ld, --as-needed seems not work for linker
scripts:
http://sourceware.org/ml/binutils/2006-03/msg00356.html
It seems that --add-needed also doesn't work for the linker
scripts. How does the attached patch look? It sets the global
as_needed and add_needed flags to their corresponding fields
for the linker script while that script is processing.
It's tested on i686-pc-linux-gnu and sh4-unknown-linux-gnu
with no new failures.
Regards,
kaz
--
ld/ChangeLog
2006-04-06 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* ldlang.c (load_symbols): Set as_needed and add_needed according
to the corresponding script's fields while processing it.
diff -uprN ORIG/src/ld/ldlang.c LOCAL/src/ld/ldlang.c
--- ORIG/src/ld/ldlang.c 2006-04-04 17:52:21.000000000 +0900
+++ LOCAL/src/ld/ldlang.c 2006-04-06 10:18:42.000000000 +0900
@@ -2323,6 +2323,7 @@ load_symbols (lang_input_statement_type
lang_statement_list_type *hold;
bfd_boolean bad_load = TRUE;
bfd_boolean save_ldlang_sysrooted_script;
+ bfd_boolean save_as_needed, save_add_needed;
err = bfd_get_error ();
@@ -2356,6 +2357,10 @@ load_symbols (lang_input_statement_type
stat_ptr = place;
save_ldlang_sysrooted_script = ldlang_sysrooted_script;
ldlang_sysrooted_script = entry->sysrooted;
+ save_as_needed = as_needed;
+ as_needed = entry->as_needed;
+ save_add_needed = add_needed;
+ add_needed = entry->add_needed;
ldfile_assumed_script = TRUE;
parser_input = input_script;
@@ -2366,6 +2371,8 @@ load_symbols (lang_input_statement_type
ldfile_assumed_script = FALSE;
ldlang_sysrooted_script = save_ldlang_sysrooted_script;
+ as_needed = save_as_needed;
+ add_needed = save_add_needed;
stat_ptr = hold;
return ! bad_load;