From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4139 invoked by alias); 18 Aug 2009 15:44:05 -0000 Received: (qmail 3993 invoked by uid 22791); 18 Aug 2009 15:44:03 -0000 X-SWARE-Spam-Status: No, hits=-49.3 required=5.0 tests=AWL,BAYES_00,CHARSET_FARAWAY_HEADER,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Aug 2009 15:43:58 +0000 Received: from wpaz5.hot.corp.google.com (wpaz5.hot.corp.google.com [172.24.198.69]) by smtp-out.google.com with ESMTP id n7IFht8g021474 for ; Tue, 18 Aug 2009 16:43:55 +0100 Received: from rv-out-0506.google.com (rvbf9.prod.google.com [10.140.82.9]) by wpaz5.hot.corp.google.com with ESMTP id n7IFhqf5027300 for ; Tue, 18 Aug 2009 08:43:53 -0700 Received: by rv-out-0506.google.com with SMTP id f9so1009201rvb.43 for ; Tue, 18 Aug 2009 08:43:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.187.20 with SMTP id k20mr2980343rvf.203.1250610232602; Tue, 18 Aug 2009 08:43:52 -0700 (PDT) In-Reply-To: References: <498552560908171552w266b6278gfc92e6032b007f88@mail.gmail.com> Date: Tue, 18 Aug 2009 16:29:00 -0000 Message-ID: <498552560908180843u3a9eeffcr174298efb97ae380@mail.gmail.com> Subject: Re: [PATCH][GOLD] Add make_elf_object target hooks. From: =?Big5?B?RG91ZyBLd2FuICjD9q62vHcp?= To: Ian Lance Taylor Cc: binutils@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00321.txt.bz2 2009/8/18 Ian Lance Taylor : >> + =A0 =A0 =A0obj->setup(ehdr); > > It no longer makes sense for Object::setup to take an ehdr parameter. > It should take a target parameter, and avoid looking up the target > again. Agree. I suppose all objects have targets and their targets do not change. Should setup() be simply part of the constructor? > >> + =A0// make_elf_object hooks. =A0There are four versions of these for >> + =A0// different address sizes and endianities. >> + >> +#ifdef HAVE_TARGET_32_LITTLE >> + =A0// Virtual functions which may be overriden by the child class. >> + =A0virtual Object* >> + =A0do_make_elf_object(const std::string& name, Input_file* input_file, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0off_t offset, const elfcpp::Ehdr<32= , false>& ehdr); >> +#endif >> + >> +#ifdef HAVE_TARGET_32_BIG >> + =A0// Virtual functions which may be overriden by the child class. >> + =A0virtual Object* >> + =A0do_make_elf_object(const std::string& name, Input_file* input_file, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0off_t offset, const elfcpp::Ehdr<32= , true>& ehdr); >> +#endif >> + >> +#ifdef HAVE_TARGET_64_LITTLE >> + =A0// Virtual functions which may be overriden by the child class. >> + =A0virtual Object* >> + =A0do_make_elf_object(const std::string& name, Input_file* input_file, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0off_t offset, const elfcpp::Ehdr<64= , false>& ehdr); >> +#endif >> + >> +#ifdef HAVE_TARGET_64_BIG >> + =A0// Virtual functions which may be overriden by the child class. >> + =A0virtual Object* >> + =A0do_make_elf_object(const std::string& name, Input_file* input_file, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0off_t offset, const elfcpp::Ehdr<64= , true>& ehdr); >> +#endif > > Interesting problem. =A0I wonder if there is anything we can do to make > that easier to write. Unfortunately, virtual functions cannot be templated. That's why I mentioned changing the paratmeter ehdr back to a raw unsigned char pointer. If we do so, we only have one virtual function instead of four. The downside of doing that is that callers must ensure that the pointer points to something valid. Passing an Elfcpp::Ehdr object enforces that automatically. -Doug > Ian >