From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7934 invoked by alias); 26 Apr 2006 06:32:36 -0000 Received: (qmail 7926 invoked by uid 22791); 26 Apr 2006 06:32:35 -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, 26 Apr 2006 06:32:33 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id 465831E138F; Wed, 26 Apr 2006 16:02:29 +0930 (CST) Date: Wed, 26 Apr 2006 09:34:00 -0000 From: Alan Modra To: Jie Zhang Cc: binutils@sourceware.org, Alexandre Oliva , Bernd Schmidt Subject: Re: [PATCH, bfin] Clear relocs for removed entries in .eh_frame section Message-ID: <20060426063229.GV27430@bubble.grove.modra.org> Mail-Followup-To: Jie Zhang , binutils@sourceware.org, Alexandre Oliva , Bernd Schmidt References: <6f48278f0604252045u3b055875v1a3e1e8bfab74a22@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f48278f0604252045u3b055875v1a3e1e8bfab74a22@mail.gmail.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-04/txt/msg00369.txt.bz2 On Wed, Apr 26, 2006 at 11:45:19AM +0800, Jie Zhang wrote: > 1. I saw this in elflink.c:elf_link_input_bfd () > > /* This is a reloc for a deleted entry or somesuch. > Turn it into an R_*_NONE reloc, at the same > offset as the last reloc. elf_eh_frame.c and > elf_bfd_discard_info rely on reloc offsets > being ordered. */ > > In my patch I just set the offset to zero. It seems works. I don't > know if we need do the same. > > Alan: The comment was from you. Can you help me understand it? bfd_elf_discard_info indirectly calls bfd_elf_reloc_symbol_deleted_p, which scans relocs looking for a particular offset. for (; rcookie->rel < rcookie->relend; rcookie->rel++) { unsigned long r_symndx; if (! rcookie->bad_symtab) if (rcookie->rel->r_offset > offset) return FALSE; if (rcookie->rel->r_offset != offset) continue; There are some macros in elf-eh-frame.c, ENSURE_NO_RELOCS and SKIP_RELOCS that similarly test r_offset. The above code won't work in general if relocs are unordered. However, I see that the way the code is written, setting r_offset to zero is OK. You just need to ensure r_offset is not set to some larger value than r_offset in following relocs. > 2. In bfinfdpic_relocate_section () there are several calls to > _bfd_elf_section_offset () before calling _bfinfdpic_add_dyn_reloc (). > Only in one place the return value of _bfd_elf_section_offset () is > checked in my patch. It seems works. But I'm not sure if we need add > such check for all these calls. If _bfd_elf_section_offset can return -1 or -2 then you need to add the check. If it cannot, eg. because the particular reloc type is not used in eh_frame or stabs section, then you don't need the check. Of course, if you don't need the check, then you also don't need to call _bfd_elf_section_offset. :-) > 3. Is it possible to not emit the reloc instead of set its type to R_*_NONE? It's too late. You have already allocated space for the dynamic relocs. -- Alan Modra IBM OzLabs - Linux Technology Centre