From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E16DC209603EB for ; Tue, 22 May 2018 02:29:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 022F581FE15B; Tue, 22 May 2018 09:29:50 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-18.rdu2.redhat.com [10.10.120.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2045A2142F2A; Tue, 22 May 2018 09:29:47 +0000 (UTC) To: Leif Lindholm Cc: edk2-devel-01 , "Danilo C. L. de Paula" , Ard Biesheuvel , Cole Robinson , Gerd Hoffmann , Liming Gao , Paolo Bonzini , Yonghong Zhu , pjones@redhat.com References: <20180518182301.25265-1-lersek@redhat.com> <20180521103027.ck3xbokxx4bjekjf@bivouac.eciton.net> From: Laszlo Ersek Message-ID: <72553c05-9ae1-51c4-3728-067a875c2bf0@redhat.com> Date: Tue, 22 May 2018 11:29:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180521103027.ck3xbokxx4bjekjf@bivouac.eciton.net> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 22 May 2018 09:29:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 22 May 2018 09:29:50 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 May 2018 09:29:51 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 05/21/18 12:30, Leif Lindholm wrote: > On Fri, May 18, 2018 at 08:23:01PM +0200, Laszlo Ersek wrote: >> The ElfConvert routines in GenFw don't handle the ".eh_frame" ELF section >> emitted by gcc. For this reason, Leif disabled the generation of that >> section for AARCH64 with "-fno-asynchronous-unwind-tables" in commit >> 28e80befa4fe [1], and Ard did the same for IA32 and X64 in commit >> 26ecc55c027d [2]. (The CLANG38 toolchain received the same flag at its >> inception, in commit 6f756db5ea05 [3].) >> >> However, ".eh_frame" is back now; in upstream gcc commit 9cbee213b579 [4] >> (part of tag "gcc-8_1_0-release"), both "-fasynchronous-unwind-tables" and >> "-funwind-tables" were made the default for AARCH64. (The patch author >> described the effects on the gcc mailing list [5].) We have to counter the >> latter flag with "-fno-unwind-tables", otherwise GenFw chokes on >> ".eh_frame" again (triggered for example on Fedora 28). >> >> "-f[no-]unwind-tables" goes back to at least gcc-4.4 [6], so it's safe to >> add to GCC_AARCH64_CC_FLAGS. > > I'm not against this patch (which fixes a real problem), but would > it be possible to take the opposite approach, as Peter Jones did for > GRUB when the same issue hit there?: > > http://lists.gnu.org/archive/html/grub-devel/2018-02/msg00095.html > > I.e., rather than keep adding flags when new "special" sections are > added by toolchains, explicitly filter those out as part of the link > step. I guess this could be implemented in two places in BaseTools: (1) In GenFw / ElfConvert. I'm afraid that's beyond my binutils-fu at the moment. (2) In "BaseTools/Scripts/GccBase.lds". This is similarly beyond my binutils-fu, but at least I can make more comments on it: We already discard a good number of sections, but we keep (and realign) "eh_frame". From Ard's commit message 26ecc55c027d, I believe the idea here was to "retain the .eh_frame data for external debugging", and then strip it with "objcopy -R .eh_frame" finally (see [Dynamic-Library-File], in "BaseTools/Conf/build_rule.template"). However, in practice we stub out objcopy (see under "GCC Common" in "BaseTools/Conf/tools_def.template"), and then we must prevent the generation of .eh_frame in the first place. Rather than adding "-fno-unwind-tables", I considered moving .eh_frame to /DISCARD/, or else turning $(OBJCOPY) into the real thing. However, that would affect more targets than just AARCH64/GCC, and I really didn't (don't) remember why we have this redundancy with "objcopy -R .eh_frame" vs. "-no-fasynchronous-unwind-tables". The latest practice seemed to be "add more -fno-..." (see the commits I referenced above), so I went with that. I suggest we push this patch now, plus I could: - submit a followup for IA32/X64, if that's deemed best, - file a BZ for GenFw / ElfConvert about the programmatic relocation filtering, - file a BZ for GccBase.lds / tools_def.template, to discard or strip .eh_frame under GCC. Thanks Laszlo