From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16528 invoked by alias); 3 May 2012 07:54:38 -0000 Received: (qmail 16392 invoked by uid 22791); 3 May 2012 07:54:34 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_FD X-Spam-Check-By: sourceware.org Received: from mail-pz0-f44.google.com (HELO mail-pz0-f44.google.com) (209.85.210.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 May 2012 07:53:13 +0000 Received: by dacx6 with SMTP id x6so1102327dac.31 for ; Thu, 03 May 2012 00:53:12 -0700 (PDT) Received: by 10.68.190.69 with SMTP id go5mr152630pbc.98.1336031592493; Thu, 03 May 2012 00:53:12 -0700 (PDT) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id d6sm4525146pbi.23.2012.05.03.00.53.09 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 May 2012 00:53:11 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 81203EA1D74; Thu, 3 May 2012 17:23:05 +0930 (CST) Date: Thu, 03 May 2012 07:54:00 -0000 From: Alan Modra To: Sergio Durigan Junior Cc: binutils@sourceware.org, gdb-patches@sourceware.org, Pedro Alves Subject: Re: [RFC/PATCH] Fix `bfd_{get,set}_*' macros Message-ID: <20120503075305.GJ635@bubble.grove.modra.org> Mail-Followup-To: Sergio Durigan Junior , binutils@sourceware.org, gdb-patches@sourceware.org, Pedro Alves References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-05/txt/msg00060.txt.bz2 On Thu, May 03, 2012 at 01:19:21AM -0300, Sergio Durigan Junior wrote: > * bfd-in2.h (bfd_get_section_name, bfd_get_section_vma, > bfd_get_section_lma, bfd_get_section_alignment, bfd_section_name, > bfd_section_size, bfd_get_section_flags, > bfd_get_section_userdata): Rewrite macros in order to use the > `bfd' argument. > * elf-vxworks.c (elf_vxworks_finish_dynamic_entry): Pass proper `bfd' > as the first argument for `bfd_get_section_alignment'. > * elf32-arm.c (create_ifunc_sections): Likewise, for > `bfd_set_section_alignment'. The above is OK. You guessed wrongly for all the bfd args below, except in elf64-ppc.c. I suggest expanding the macros instead. I've noted the correct bfds below but IMO these macros serve no useful purpose. > * elf32-m32r.c (m32r_elf_relocate_section): Likewise, for > `bfd_get_section_name'. > * elf32-microblaze.c (microblaze_elf_relocate_section): Likewise. > * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise. > (ppc_elf_relocate_section): Likewise. > * elf64-mmix.c (mmix_final_link_relocate): Declaring proper `bfd' > variable. > * elf64-ppc.c (create_linkage_sections): Pass proper `bfd' as the > first argument for `bfd_set_section_alignment'. > --- a/bfd/elf32-m32r.c > +++ b/bfd/elf32-m32r.c > @@ -3007,7 +3007,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, > const char *name; > > BFD_ASSERT (sec != NULL); > - name = bfd_get_section_name (abfd, sec); > + name = bfd_get_section_name (input_bfd, sec); sec->owner > --- a/bfd/elf32-microblaze.c > +++ b/bfd/elf32-microblaze.c > @@ -839,7 +839,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, > /* Only relocate if the symbol is defined. */ > if (sec) > { > - name = bfd_get_section_name (abfd, sec); > + name = bfd_get_section_name (input_bfd, sec); sec->owner > @@ -868,7 +868,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, > bfd_get_filename (input_bfd), > sym_name, > microblaze_elf_howto_table[(int) r_type]->name, > - bfd_get_section_name (abfd, sec)); > + bfd_get_section_name (input_bfd, sec)); sec->owner > @@ -884,7 +884,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, > /* Only relocate if the symbol is defined. */ > if (sec) > { > - name = bfd_get_section_name (abfd, sec); > + name = bfd_get_section_name (input_bfd, sec); sec->owner > @@ -913,7 +913,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, > bfd_get_filename (input_bfd), > sym_name, > microblaze_elf_howto_table[(int) r_type]->name, > - bfd_get_section_name (abfd, sec)); > + bfd_get_section_name (input_bfd, sec)); sec->owner > --- a/bfd/elf32-ppc.c > +++ b/bfd/elf32-ppc.c > @@ -5867,7 +5867,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, > { > /* Strip these too. */ > } > - else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) > + else if (CONST_STRNEQ (bfd_get_section_name (ibfd, s), ".rela")) htab->elf.dynobj > @@ -7886,8 +7886,10 @@ ppc_elf_relocate_section (bfd *output_bfd, > unresolved_reloc = TRUE; > break; > } > - BFD_ASSERT (strcmp (bfd_get_section_name (abfd, sec), ".got") == 0 > - || strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0); > + BFD_ASSERT (strcmp (bfd_get_section_name (input_bfd, sec), > + ".got") == 0 > + || strcmp (bfd_get_section_name (input_bfd, sec), > + ".cgot") == 0); sec->owner twice > @@ -7937,7 +7939,7 @@ ppc_elf_relocate_section (bfd *output_bfd, > } > addend -= SYM_VAL (sda); > > - name = bfd_get_section_name (abfd, sec->output_section); > + name = bfd_get_section_name (input_bfd, sec->output_section); output_bfd > @@ -7969,7 +7971,7 @@ ppc_elf_relocate_section (bfd *output_bfd, > } > addend -= SYM_VAL (sda); > > - name = bfd_get_section_name (abfd, sec->output_section); > + name = bfd_get_section_name (input_bfd, sec->output_section); output_bfd > @@ -7998,7 +8000,7 @@ ppc_elf_relocate_section (bfd *output_bfd, > break; > } > > - name = bfd_get_section_name (abfd, sec->output_section); > + name = bfd_get_section_name (input_bfd, sec->output_section); output_bfd > --- a/bfd/elf64-mmix.c > +++ b/bfd/elf64-mmix.c > @@ -1771,6 +1771,8 @@ mmix_final_link_relocate (reloc_howto_type *howto, asection *input_section, > first_global = 255; > else > { > + bfd *abfd = NULL; > + > first_global = bfd_get_section_vma (abfd, regsec) / 8; input_section->output_section->owner -- Alan Modra Australia Development Lab, IBM