From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-x22c.google.com (mail-it0-x22c.google.com [IPv6:2607:f8b0:4001:c0b::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C9A0E21A02906 for ; Thu, 25 May 2017 12:55:07 -0700 (PDT) Received: by mail-it0-x22c.google.com with SMTP id a10so442272itg.1 for ; Thu, 25 May 2017 12:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=rxhDfqV89QC1UeSiTAHiLh18VM3BTtOFHau9OzbpJNU=; b=A+ORFQue2ZV2KpwvKyTBizUSGJpJN/TAMHUz5Axnye/mJxNIOSjMZn63e7/6LHDkU7 bL7wMqQmgBkktBzzG1N3Lb2iiP7hXowLm522MqtPkSRfHuwCslVg8gvTzQpDyXsFzStj JWeDz9UjhcHbOfhWxMFZMSv8WF9fadD3BxHRA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=rxhDfqV89QC1UeSiTAHiLh18VM3BTtOFHau9OzbpJNU=; b=n7APbD9f0SUtOIonLGxs4yxEWt+jqxKVyLoevlsLwyMISItTpOPz2yO7IfflXfqEC3 pq7jeHGxO2+o17Cc/7ToduCCPvLLuRS3yHrGY1hHIevRxE6CostjUipV2ErqCcQx/61d Ds2zT+FzyN//w8X5mtZdPAD9mCTkD1MGaU0dMtXbBvFYQfk0X9uUm8Cts2OpSbqeGL/M BjOTZzDGOLy4u18P6qDaiLoQcS04gpEigi2lLACZ70glrgsQuSH+sEZbG/5acir3yaqj xI0zDa/77XuUUCzOuPVtzCH58luixHbZQFN0D5RgF8gUnV7vhbF5qXKhi8A8YxmP+jOo Di0g== X-Gm-Message-State: AODbwcB0TqcsByrkiXEn6Mo6NNB+vmGcdKN3fPaPUqzsVltOUnBYqBuX OR94TB4k6XOyMe08AlS1D92gr6DpcG3K X-Received: by 10.36.92.143 with SMTP id q137mr15960024itb.98.1495742105626; Thu, 25 May 2017 12:55:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.164.24 with HTTP; Thu, 25 May 2017 12:55:05 -0700 (PDT) In-Reply-To: <435e1d65-7710-f548-c591-558307e266bc@redhat.com> References: <1495581673-10788-1-git-send-email-michael.d.kinney@intel.com> <60f3303b-c333-101d-b6e5-806ab85075a9@redhat.com> <435e1d65-7710-f548-c591-558307e266bc@redhat.com> From: Ard Biesheuvel Date: Thu, 25 May 2017 12:55:05 -0700 Message-ID: To: Laszlo Ersek Cc: "Kinney, Michael D" , "Andrew Fish (afish@apple.com)" , "Wu, Hao A" , "edk2-devel@lists.01.org" , "Fan, Jeff" Subject: Re: [Patch] SourceLevelDebugPkg/SecPeiDebugAgentLib: Fix duplicate symbol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 May 2017 19:55:08 -0000 Content-Type: text/plain; charset="UTF-8" On 25 May 2017 at 11:06, Laszlo Ersek wrote: > On 05/25/17 19:38, Kinney, Michael D wrote: >> Laszlo, >> >> I think the equivalent flag for GCC builds is --whole-archive. >> >> I tried adding that flag to DLINK_FLAGS in GCC5, and I get the >> following error building OVMF from edk2/master with >> -D SOURCE_DEBUG_ENABLE set. >> >> DxeLoad.obj (symbol from plugin): In function `InstallIplPermanentMemoryPpis': >> (.text+0x0): multiple definition of `mMemoryDiscoveredNotifyList' >> SecPeiDebugAgentLib.obj (symbol from plugin):(.text+0x0): first defined here >> collect2: error: ld returned 1 exit status > > Great find! That's the error message we should get. > > Unfortunately, after reading the "ld" manual on "--whole-archive", it > seems that the complete object files will actually be copied into the > resultant binary, even if several of their symbols will remain unused. I > think that's quite sub-optimal. (I haven't verified this though.) What > we'd like to get is (a) the full verification at link time, and (b) > inclusion of *only* those symbols that are actually necessary. > > In your testing, when you build OVMF with and without "--whole-archive", > do you see a difference in, say, the DXEFV footprint, when the build > completes? > > (If so, then I wonder if we should add "--whole-archive" only to the > NOOPT build... Not sure.) > I haven't tried, but I would expect --gc-sections to deal with the unused objects. >> Visual Studio 2015 Update 2 has also added a new linker flag called >> /WHOLEARCHIVE. I am working on evaluating that flag to see if it >> catches the same issue. > > Thanks! > Laszlo > >>> -----Original Message----- >>> From: Laszlo Ersek [mailto:lersek@redhat.com] >>> Sent: Thursday, May 25, 2017 9:09 AM >>> To: Kinney, Michael D ; Ard Biesheuvel >>> ; Andrew Fish (afish@apple.com) >>> Cc: Wu, Hao A ; edk2-devel@lists.01.org; Fan, Jeff >>> >>> Subject: Re: [edk2] [Patch] SourceLevelDebugPkg/SecPeiDebugAgentLib: Fix duplicate >>> symbol >>> >>> On 05/25/17 03:47, Kinney, Michael D wrote: >>>> Andrew, >>>> >>>> I think I have found an alternate fix for this XCODE5 specific >>>> build failure. Since there appears to be a difference in the >>>> linker behavior between MSFT/GCC/XCODE tool chains, I reviewed >>>> the 'ld' command line options used in XCODE5 tool chain in >>>> tools_def.txt. >>>> >>>> There is a flag set call '-all_load'. The description of this >>>> flag is 'Loads all members of static archive libraries.'. >>>> >>>> I tried removing this flag from the XCODE5 specific SLINK_FLAGS >>>> and DLINK_FLAGS statements in tools_def.txt, and the duplicate >>>> symbol build failure is no longer present. I am able to build >>>> and boot OVMF with XCODE5 with -D SOURCE_DEBUG_ENABLE flag set. >>>> >>>> This seems to make XCODE5 linker behavior match the MSFT and GCC >>>> linker behavior. >>>> >>>> Do you know why '-all_load' is used in XCODE5 and what impacts >>>> there may be from removing it? >>> >>> Please don't remove -all_load from there; instead we should figure out >>> if the same can be brought to MSFT and GCC. >>> >>> The error message that XCODE5 emitted caught a real bug (undefined >>> behavior according to ISO C, see my previous email), and so we should >>> keep that detection enabled (we should even extend it to other >>> toolchains, if that's possible). >>> >>> As for docs, I found this: >>> >>> http://www.manpages.info/macosx/ld.1.html >>> >>>> -all_load >>>> Loads all members of static archive libraries. This option does >>>> not apply to dynamic shared libraries. >>> >>> >>> Thanks >>> Laszlo >