From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2407 invoked by alias); 3 May 2012 16:01:14 -0000 Received: (qmail 2385 invoked by uid 22791); 3 May 2012 16:01:08 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,TW_FD,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 May 2012 16:00:48 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q43G0lnr019955 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 May 2012 12:00:47 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q43G0jPk031157; Thu, 3 May 2012 12:00:46 -0400 Message-ID: <4FA2ABAD.3010403@redhat.com> Date: Thu, 03 May 2012 16:01:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120424 Thunderbird/12.0 MIME-Version: 1.0 To: Sergio Durigan Junior , binutils@sourceware.org, gdb-patches@sourceware.org Subject: Re: [RFC/PATCH] Fix `bfd_{get,set}_*' macros References: <20120503075305.GJ635@bubble.grove.modra.org> In-Reply-To: <20120503075305.GJ635@bubble.grove.modra.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit 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/msg00090.txt.bz2 On 05/03/2012 08:53 AM, Alan Modra wrote: > 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. #define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0) #define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0) #define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0) #define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0) #define bfd_section_name(bfd, ptr) ((ptr)->name) #define bfd_section_size(bfd, ptr) ((ptr)->size) #define bfd_get_section_size(ptr) ((ptr)->size) #define bfd_section_vma(bfd, ptr) ((ptr)->vma) #define bfd_section_lma(bfd, ptr) ((ptr)->lma) #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) #define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0) #define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata) Or replace with bfd_section_name, bfd_section_vma, etc. (making them lvalues along the way) ? If dropping the bfd argument, IMO, it's better to use the 'bfd_section' prefix for bfd_section macros (like bfd_section_name, etc. above), rather than 'bfd_get_', and leave the latter for macros/functions that really take a struct bfd as "this". That'd mean s/bfd_get_section_flags/bfd_section_flags/ for example. But IMO, we shouldn't require Sérgio do this, unless he wants to. His patch just fixes a handful of places to correctly use the already years-old existing interface... -- Pedro Alves