From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19035 invoked by alias); 17 May 2006 00:35:27 -0000 Received: (qmail 19026 invoked by uid 22791); 17 May 2006 00:35:27 -0000 X-Spam-Check-By: sourceware.org Received: from CPE-144-136-172-108.sa.bigpond.net.au (HELO grove.modra.org) (144.136.172.108) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 17 May 2006 00:35:24 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id 0EE241DF5D9; Wed, 17 May 2006 10:05:20 +0930 (CST) Date: Wed, 17 May 2006 11:34:00 -0000 From: Alan Modra To: Etienne Lorrain Cc: binutils@sourceware.org Subject: Re: `.sym' referenced in section `reloc_sym' of file.o: defined in discarded section `.text.sym' of file.o Message-ID: <20060517003519.GJ19700@bubble.grove.modra.org> Mail-Followup-To: Etienne Lorrain , binutils@sourceware.org References: <20060516150145.GI19700@bubble.grove.modra.org> <20060516152841.79869.qmail@web26907.mail.ukl.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060516152841.79869.qmail@web26907.mail.ukl.yahoo.com> User-Agent: Mutt/1.4i 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-05/txt/msg00286.txt.bz2 On Tue, May 16, 2006 at 05:28:41PM +0200, Etienne Lorrain wrote: > --- Alan Modra wrote: > > On Tue, May 16, 2006 at 01:34:25PM +0200, Etienne Lorrain wrote: > > > My problem is when the function (for instance) linux_set_params is not used > > > at all in the link process, and is discarded because I am using GCC > > > -ffunction-sections and LD --gc-sections, it is still referenced in > > > ".section reloc_paramcode_section" > > > > What is special about reloc_paramcode_section? ie. How are you managing > > to confuse the linker into thinking the reference in that section is not > > a normal use, which should result in linux_set_params being kept? > > > > Do you have a small self-contained testcase? > > I do not know what is special about reloc_paramcode_section, but I noticed It's special because it is non-alloc, non-load. --gc-sections does not remove such sections, but does not treat their relocs specially. ie. unless reloc_paramcode_section is itself referenced from somewhere, its relocs will not be examined to see whether other sections referenced by it should be kept. See http://sources.redhat.com/ml/binutils/2004-08/msg00178.html Perhaps I should have restricted that change to sections without relocs. That would still keep sections like .comment and .note.GNU-stack, but drop your "special" section. I'm applying the following: * elflink.c (elf_gc_sweep): Don't specially keep non-alloc, non-load sections if they have relocs. Index: bfd/elflink.c =================================================================== RCS file: /cvs/src/src/bfd/elflink.c,v retrieving revision 1.213 diff -u -p -r1.213 elflink.c --- bfd/elflink.c 11 May 2006 15:55:40 -0000 1.213 +++ bfd/elflink.c 17 May 2006 00:28:23 -0000 @@ -8965,7 +8965,7 @@ elf_gc_sweep (bfd *abfd, struct bfd_link { /* Keep debug and special sections. */ if ((o->flags & (SEC_DEBUGGING | SEC_LINKER_CREATED)) != 0 - || (o->flags & (SEC_ALLOC | SEC_LOAD)) == 0) + || (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0) o->gc_mark = 1; if (o->gc_mark) > the message do not appear if --no-check-sections is not a parameter of ld !!! That would be because you are hitting a fatal error without --no-check-sections. > ld: error: no memory region specified for loadable section `.rel.dyn' -- Alan Modra IBM OzLabs - Linux Technology Centre