From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28695 invoked by alias); 6 Apr 2006 23:35:24 -0000 Received: (qmail 28685 invoked by uid 22791); 6 Apr 2006 23:35:23 -0000 X-Spam-Check-By: sourceware.org Received: from mo00.iij4u.or.jp (HELO mo00.iij4u.or.jp) (210.130.0.19) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 06 Apr 2006 23:35:21 +0000 Received: MO(mo00) for id k36NZIsT023484; Fri, 7 Apr 2006 08:35:18 +0900 (JST) Received: from localhost (216.30.30.125.dy.iij4u.or.jp [125.30.30.216]) by r-rr.iij4u.or.jp (4U-MR/r-rr) id k36NZIWI026464 for ; Fri, 7 Apr 2006 08:35:18 +0900 (JST) Date: Fri, 07 Apr 2006 00:40:00 -0000 Message-Id: <20060407.083517.23008921.kkojima@rr.iij4u.or.jp> To: binutils@sources.redhat.com Subject: [patch RFC] --as-needed and --add-needed for linker script From: Kaz Kojima Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00095.txt.bz2 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 * 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;