From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32484 invoked by alias); 26 Apr 2006 03:45:25 -0000 Received: (qmail 32470 invoked by uid 22791); 26 Apr 2006 03:45:24 -0000 X-Spam-Check-By: sourceware.org Received: from nproxy.gmail.com (HELO nproxy.gmail.com) (64.233.182.190) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 26 Apr 2006 03:45:21 +0000 Received: by nproxy.gmail.com with SMTP id y38so1035750nfb for ; Tue, 25 Apr 2006 20:45:19 -0700 (PDT) Received: by 10.49.9.8 with SMTP id m8mr44680nfi; Tue, 25 Apr 2006 20:45:19 -0700 (PDT) Received: by 10.48.232.12 with HTTP; Tue, 25 Apr 2006 20:45:19 -0700 (PDT) Message-ID: <6f48278f0604252045u3b055875v1a3e1e8bfab74a22@mail.gmail.com> Date: Wed, 26 Apr 2006 09:29:00 -0000 From: "Jie Zhang" To: binutils@sourceware.org Subject: [PATCH, bfin] Clear relocs for removed entries in .eh_frame section Cc: "Alexandre Oliva" , "Bernd Schmidt" , "Alan Modra" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_8683_23849447.1146023119305" 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/msg00368.txt.bz2 ------=_Part_8683_23849447.1146023119305 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-length: 1536 When debugging a C++ exception unwinding issue for Blackfin FDPIC format, I found a bug of Blackfin BFD FDPIC support. When linking, duplicate CIE will be removed from output .eh_frame section. But the relocations for them are not. When dynamic linker does these relocations, some contents in .eh_frame will be wrongly modified. This causes the exception unwinding failure. I attached a patch for it. But there are several points I'm not sure: 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? 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. 3. Is it possible to not emit the reloc instead of set its type to R_*_NONE? Alex: I think FRV has the same issue. In the lasted release of redhat's frv toolchain from redhat's ftp, the bug is hidden since all dupilicated CIEs are not optimized away because there is CIE format incompatibility between gcc (3.4) and binutils (2.14). Thanks, Jie ------=_Part_8683_23849447.1146023119305 Content-Type: text/x-patch; name=bfin-fdpic-bfd-cie.diff; charset=us-ascii Content-Transfer-Encoding: 7bit X-Attachment-Id: f_emh42c0l Content-Disposition: attachment; filename="bfin-fdpic-bfd-cie.diff" Content-length: 1772 Index: elf32-bfin.c =================================================================== RCS file: /cvsroot/gcc3/binutils/binutils-2.15/bfd/elf32-bfin.c,v retrieving revision 1.35 diff -u -p -r1.35 elf32-bfin.c --- elf32-bfin.c 6 Apr 2006 05:48:02 -0000 1.35 +++ elf32-bfin.c 24 Apr 2006 10:46:44 -0000 @@ -2476,6 +2481,8 @@ bfinfdpic_relocate_section (bfd * output input_section->output_section) & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD)) { + bfd_vma offset; + if (_bfinfdpic_osec_readonly_p (output_bfd, input_section ->output_section)) @@ -2486,15 +2493,23 @@ bfinfdpic_relocate_section (bfd * output name, input_bfd, input_section, rel->r_offset); return FALSE; } - _bfinfdpic_add_dyn_reloc (output_bfd, - bfinfdpic_gotrel_section (info), - _bfd_elf_section_offset - (output_bfd, info, - input_section, rel->r_offset) - + input_section - ->output_section->vma - + input_section->output_offset, - r_type, dynindx, addend, picrel); + offset = _bfd_elf_section_offset (output_bfd, info, + input_section, rel->r_offset); + /* Only output a reloc for a not deleted entry. */ + if (offset >= (bfd_vma) -2) + _bfinfdpic_add_dyn_reloc (output_bfd, + bfinfdpic_gotrel_section (info), + 0, + R_unused0, + dynindx, addend, picrel); + else + _bfinfdpic_add_dyn_reloc (output_bfd, + bfinfdpic_gotrel_section (info), + offset + input_section + ->output_section->vma + + input_section->output_offset, + r_type, + dynindx, addend, picrel); } else addend += bfinfdpic_got_section (info)->output_section->vma; ------=_Part_8683_23849447.1146023119305--