public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
@ 2018-05-18 18:23 Laszlo Ersek
  2018-05-19  8:21 ` Ard Biesheuvel
  2018-05-21 10:30 ` Leif Lindholm
  0 siblings, 2 replies; 9+ messages in thread
From: Laszlo Ersek @ 2018-05-18 18:23 UTC (permalink / raw)
  To: edk2-devel-01
  Cc: Danilo C. L. de Paula, Ard Biesheuvel, Cole Robinson,
	Gerd Hoffmann, Leif Lindholm, Liming Gao, Paolo Bonzini,
	Yonghong Zhu

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.

[1] https://github.com/tianocore/edk2/commit/28e80befa4fe
[2] https://github.com/tianocore/edk2/commit/26ecc55c027d
[3] https://github.com/tianocore/edk2/commit/6f756db5ea05
[4] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9cbee213b579
[5] http://mid.mail-archive.com/7b28c03a-c032-6cec-c127-1c12cbe98eeb@foss.arm.com
[6] https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Code-Gen-Options.html

Cc: "Danilo C. L. de Paula" <ddepaula@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Cole Robinson <crobinso@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reported-by: "Danilo C. L. de Paula" <ddepaula@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
    Repo:   https://github.com/lersek/edk2.git
    Branch: aarch64_no_unwind_tables

 BaseTools/Conf/tools_def.template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 03d700018550..9429033fe2e3 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -4537,7 +4537,7 @@ DEFINE GCC_X64_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-ad
 DEFINE GCC_IPF_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency
 DEFINE GCC_ARM_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie
 DEFINE GCC_ARM_CC_XIPFLAGS         = -mno-unaligned-access
-DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-pic -fno-pie -ffixed-x18
+DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
 DEFINE GCC_AARCH64_CC_XIPFLAGS     = -mstrict-align -mgeneral-regs-only
 DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
 DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
-- 
2.14.1.3.gb7cf6e02401b



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
  2018-05-18 18:23 [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS Laszlo Ersek
@ 2018-05-19  8:21 ` Ard Biesheuvel
  2018-05-21  0:37   ` Gao, Liming
  2018-05-21 10:30 ` Leif Lindholm
  1 sibling, 1 reply; 9+ messages in thread
From: Ard Biesheuvel @ 2018-05-19  8:21 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: edk2-devel-01, Danilo C. L. de Paula, Cole Robinson,
	Gerd Hoffmann, Leif Lindholm, Liming Gao, Paolo Bonzini,
	Yonghong Zhu

On 18 May 2018 at 20:23, Laszlo Ersek <lersek@redhat.com> 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.
>
> [1] https://github.com/tianocore/edk2/commit/28e80befa4fe
> [2] https://github.com/tianocore/edk2/commit/26ecc55c027d
> [3] https://github.com/tianocore/edk2/commit/6f756db5ea05
> [4] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9cbee213b579
> [5] http://mid.mail-archive.com/7b28c03a-c032-6cec-c127-1c12cbe98eeb@foss.arm.com
> [6] https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Code-Gen-Options.html
>
> Cc: "Danilo C. L. de Paula" <ddepaula@redhat.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Cole Robinson <crobinso@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Reported-by: "Danilo C. L. de Paula" <ddepaula@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>
> Notes:
>     Repo:   https://github.com/lersek/edk2.git
>     Branch: aarch64_no_unwind_tables
>
>  BaseTools/Conf/tools_def.template | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> index 03d700018550..9429033fe2e3 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -4537,7 +4537,7 @@ DEFINE GCC_X64_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-ad
>  DEFINE GCC_IPF_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency
>  DEFINE GCC_ARM_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie
>  DEFINE GCC_ARM_CC_XIPFLAGS         = -mno-unaligned-access
> -DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-pic -fno-pie -ffixed-x18
> +DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
>  DEFINE GCC_AARCH64_CC_XIPFLAGS     = -mstrict-align -mgeneral-regs-only
>  DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
>  DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
> --
> 2.14.1.3.gb7cf6e02401b
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
  2018-05-19  8:21 ` Ard Biesheuvel
@ 2018-05-21  0:37   ` Gao, Liming
  2018-05-21  9:32     ` Ard Biesheuvel
  0 siblings, 1 reply; 9+ messages in thread
From: Gao, Liming @ 2018-05-21  0:37 UTC (permalink / raw)
  To: Ard Biesheuvel, Laszlo Ersek
  Cc: edk2-devel-01, Danilo C. L. de Paula, Cole Robinson,
	Gerd Hoffmann, Leif Lindholm, Paolo Bonzini, Zhu, Yonghong

Laszlo:
  Is this change required for IA32 and X64 arch?

Thanks
Liming
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: Saturday, May 19, 2018 4:21 PM
> To: Laszlo Ersek <lersek@redhat.com>
> Cc: edk2-devel-01 <edk2-devel@lists.01.org>; Danilo C. L. de Paula <ddepaula@redhat.com>; Cole Robinson <crobinso@redhat.com>;
> Gerd Hoffmann <kraxel@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>; Gao, Liming <liming.gao@intel.com>; Paolo Bonzini
> <pbonzini@redhat.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
> Subject: Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
> 
> On 18 May 2018 at 20:23, Laszlo Ersek <lersek@redhat.com> 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.
> >
> > [1] https://github.com/tianocore/edk2/commit/28e80befa4fe
> > [2] https://github.com/tianocore/edk2/commit/26ecc55c027d
> > [3] https://github.com/tianocore/edk2/commit/6f756db5ea05
> > [4] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9cbee213b579
> > [5] http://mid.mail-archive.com/7b28c03a-c032-6cec-c127-1c12cbe98eeb@foss.arm.com
> > [6] https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Code-Gen-Options.html
> >
> > Cc: "Danilo C. L. de Paula" <ddepaula@redhat.com>
> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > Cc: Cole Robinson <crobinso@redhat.com>
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: Leif Lindholm <leif.lindholm@linaro.org>
> > Cc: Liming Gao <liming.gao@intel.com>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> > Reported-by: "Danilo C. L. de Paula" <ddepaula@redhat.com>
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> 
> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> 
> > ---
> >
> > Notes:
> >     Repo:   https://github.com/lersek/edk2.git
> >     Branch: aarch64_no_unwind_tables
> >
> >  BaseTools/Conf/tools_def.template | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> > index 03d700018550..9429033fe2e3 100755
> > --- a/BaseTools/Conf/tools_def.template
> > +++ b/BaseTools/Conf/tools_def.template
> > @@ -4537,7 +4537,7 @@ DEFINE GCC_X64_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-ad
> >  DEFINE GCC_IPF_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency
> >  DEFINE GCC_ARM_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums
> -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie
> >  DEFINE GCC_ARM_CC_XIPFLAGS         = -mno-unaligned-access
> > -DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm
> -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-pic -fno-pie -ffixed-x18
> > +DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm
> -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic
> -fno-pie -ffixed-x18
> >  DEFINE GCC_AARCH64_CC_XIPFLAGS     = -mstrict-align -mgeneral-regs-only
> >  DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
> >  DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
> > --
> > 2.14.1.3.gb7cf6e02401b
> >

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
  2018-05-21  0:37   ` Gao, Liming
@ 2018-05-21  9:32     ` Ard Biesheuvel
  2018-05-22  9:05       ` Laszlo Ersek
  0 siblings, 1 reply; 9+ messages in thread
From: Ard Biesheuvel @ 2018-05-21  9:32 UTC (permalink / raw)
  To: Gao, Liming
  Cc: Laszlo Ersek, edk2-devel-01, Danilo C. L. de Paula, Cole Robinson,
	Gerd Hoffmann, Leif Lindholm, Paolo Bonzini, Zhu, Yonghong

On 21 May 2018 at 02:37, Gao, Liming <liming.gao@intel.com> wrote:
> Laszlo:
>   Is this change required for IA32 and X64 arch?
>

The upstream GCC change is limited to AArch64, but I suppose it
wouldn't hurt to add this to IA32/X64 as well, given that it currently
only reaffirms the default, and will do the right thing if that
default ever changes for IA32/X64 as well.


>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: Saturday, May 19, 2018 4:21 PM
>> To: Laszlo Ersek <lersek@redhat.com>
>> Cc: edk2-devel-01 <edk2-devel@lists.01.org>; Danilo C. L. de Paula <ddepaula@redhat.com>; Cole Robinson <crobinso@redhat.com>;
>> Gerd Hoffmann <kraxel@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>; Gao, Liming <liming.gao@intel.com>; Paolo Bonzini
>> <pbonzini@redhat.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
>> Subject: Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
>>
>> On 18 May 2018 at 20:23, Laszlo Ersek <lersek@redhat.com> 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.
>> >
>> > [1] https://github.com/tianocore/edk2/commit/28e80befa4fe
>> > [2] https://github.com/tianocore/edk2/commit/26ecc55c027d
>> > [3] https://github.com/tianocore/edk2/commit/6f756db5ea05
>> > [4] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9cbee213b579
>> > [5] http://mid.mail-archive.com/7b28c03a-c032-6cec-c127-1c12cbe98eeb@foss.arm.com
>> > [6] https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Code-Gen-Options.html
>> >
>> > Cc: "Danilo C. L. de Paula" <ddepaula@redhat.com>
>> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> > Cc: Cole Robinson <crobinso@redhat.com>
>> > Cc: Gerd Hoffmann <kraxel@redhat.com>
>> > Cc: Leif Lindholm <leif.lindholm@linaro.org>
>> > Cc: Liming Gao <liming.gao@intel.com>
>> > Cc: Paolo Bonzini <pbonzini@redhat.com>
>> > Cc: Yonghong Zhu <yonghong.zhu@intel.com>
>> > Reported-by: "Danilo C. L. de Paula" <ddepaula@redhat.com>
>> > Contributed-under: TianoCore Contribution Agreement 1.1
>> > Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>>
>> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>
>> > ---
>> >
>> > Notes:
>> >     Repo:   https://github.com/lersek/edk2.git
>> >     Branch: aarch64_no_unwind_tables
>> >
>> >  BaseTools/Conf/tools_def.template | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
>> > index 03d700018550..9429033fe2e3 100755
>> > --- a/BaseTools/Conf/tools_def.template
>> > +++ b/BaseTools/Conf/tools_def.template
>> > @@ -4537,7 +4537,7 @@ DEFINE GCC_X64_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-ad
>> >  DEFINE GCC_IPF_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency
>> >  DEFINE GCC_ARM_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums
>> -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie
>> >  DEFINE GCC_ARM_CC_XIPFLAGS         = -mno-unaligned-access
>> > -DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm
>> -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-pic -fno-pie -ffixed-x18
>> > +DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm
>> -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic
>> -fno-pie -ffixed-x18
>> >  DEFINE GCC_AARCH64_CC_XIPFLAGS     = -mstrict-align -mgeneral-regs-only
>> >  DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
>> >  DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
>> > --
>> > 2.14.1.3.gb7cf6e02401b
>> >


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
  2018-05-18 18:23 [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS Laszlo Ersek
  2018-05-19  8:21 ` Ard Biesheuvel
@ 2018-05-21 10:30 ` Leif Lindholm
  2018-05-22  9:29   ` Laszlo Ersek
  1 sibling, 1 reply; 9+ messages in thread
From: Leif Lindholm @ 2018-05-21 10:30 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: edk2-devel-01, Danilo C. L. de Paula, Ard Biesheuvel,
	Cole Robinson, Gerd Hoffmann, Liming Gao, Paolo Bonzini,
	Yonghong Zhu, pjones

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.

/
    Leif

> [1] https://github.com/tianocore/edk2/commit/28e80befa4fe
> [2] https://github.com/tianocore/edk2/commit/26ecc55c027d
> [3] https://github.com/tianocore/edk2/commit/6f756db5ea05
> [4] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9cbee213b579
> [5] http://mid.mail-archive.com/7b28c03a-c032-6cec-c127-1c12cbe98eeb@foss.arm.com
> [6] https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Code-Gen-Options.html
> 
> Cc: "Danilo C. L. de Paula" <ddepaula@redhat.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Cole Robinson <crobinso@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
> Reported-by: "Danilo C. L. de Paula" <ddepaula@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> 
> Notes:
>     Repo:   https://github.com/lersek/edk2.git
>     Branch: aarch64_no_unwind_tables
> 
>  BaseTools/Conf/tools_def.template | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> index 03d700018550..9429033fe2e3 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -4537,7 +4537,7 @@ DEFINE GCC_X64_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-ad
>  DEFINE GCC_IPF_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency
>  DEFINE GCC_ARM_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie
>  DEFINE GCC_ARM_CC_XIPFLAGS         = -mno-unaligned-access
> -DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-pic -fno-pie -ffixed-x18
> +DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic -fno-pie -ffixed-x18
>  DEFINE GCC_AARCH64_CC_XIPFLAGS     = -mstrict-align -mgeneral-regs-only
>  DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
>  DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
> -- 
> 2.14.1.3.gb7cf6e02401b
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
  2018-05-21  9:32     ` Ard Biesheuvel
@ 2018-05-22  9:05       ` Laszlo Ersek
  0 siblings, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2018-05-22  9:05 UTC (permalink / raw)
  To: Ard Biesheuvel, Gao, Liming
  Cc: edk2-devel-01, Danilo C. L. de Paula, Cole Robinson,
	Gerd Hoffmann, Leif Lindholm, Paolo Bonzini, Zhu, Yonghong

On 05/21/18 11:32, Ard Biesheuvel wrote:
> On 21 May 2018 at 02:37, Gao, Liming <liming.gao@intel.com> wrote:
>> Laszlo:
>>   Is this change required for IA32 and X64 arch?
>>
> 
> The upstream GCC change is limited to AArch64, but I suppose it
> wouldn't hurt to add this to IA32/X64 as well, given that it currently
> only reaffirms the default, and will do the right thing if that
> default ever changes for IA32/X64 as well.

Right; I wanted to keep the patch surgical. I don't really understand
why it makes sense for gcc to use different "unwind-tables" defaults for
AARCH64 vs. IA32/X64; however, I did think the gcc developers must have
made a conscious decision, to restrict the change to AARCH64.

I can submit a followup patch for IA32/X64, but I'll first respond under
Leif's suggestion too (that subthread will likely take more discussion).

Thanks!
Laszlo

> 
> 
>>> -----Original Message-----
>>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>>> Sent: Saturday, May 19, 2018 4:21 PM
>>> To: Laszlo Ersek <lersek@redhat.com>
>>> Cc: edk2-devel-01 <edk2-devel@lists.01.org>; Danilo C. L. de Paula <ddepaula@redhat.com>; Cole Robinson <crobinso@redhat.com>;
>>> Gerd Hoffmann <kraxel@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>; Gao, Liming <liming.gao@intel.com>; Paolo Bonzini
>>> <pbonzini@redhat.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
>>> Subject: Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
>>>
>>> On 18 May 2018 at 20:23, Laszlo Ersek <lersek@redhat.com> 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.
>>>>
>>>> [1] https://github.com/tianocore/edk2/commit/28e80befa4fe
>>>> [2] https://github.com/tianocore/edk2/commit/26ecc55c027d
>>>> [3] https://github.com/tianocore/edk2/commit/6f756db5ea05
>>>> [4] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9cbee213b579
>>>> [5] http://mid.mail-archive.com/7b28c03a-c032-6cec-c127-1c12cbe98eeb@foss.arm.com
>>>> [6] https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Code-Gen-Options.html
>>>>
>>>> Cc: "Danilo C. L. de Paula" <ddepaula@redhat.com>
>>>> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>>> Cc: Cole Robinson <crobinso@redhat.com>
>>>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>>>> Cc: Leif Lindholm <leif.lindholm@linaro.org>
>>>> Cc: Liming Gao <liming.gao@intel.com>
>>>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>>>> Cc: Yonghong Zhu <yonghong.zhu@intel.com>
>>>> Reported-by: "Danilo C. L. de Paula" <ddepaula@redhat.com>
>>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>>>
>>> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>>
>>>> ---
>>>>
>>>> Notes:
>>>>     Repo:   https://github.com/lersek/edk2.git
>>>>     Branch: aarch64_no_unwind_tables
>>>>
>>>>  BaseTools/Conf/tools_def.template | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
>>>> index 03d700018550..9429033fe2e3 100755
>>>> --- a/BaseTools/Conf/tools_def.template
>>>> +++ b/BaseTools/Conf/tools_def.template
>>>> @@ -4537,7 +4537,7 @@ DEFINE GCC_X64_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-ad
>>>>  DEFINE GCC_IPF_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency
>>>>  DEFINE GCC_ARM_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -mabi=aapcs -fno-short-enums
>>> -funsigned-char -ffunction-sections -fdata-sections -fomit-frame-pointer -Wno-address -mthumb -mfloat-abi=soft -fno-pic -fno-pie
>>>>  DEFINE GCC_ARM_CC_XIPFLAGS         = -mno-unaligned-access
>>>> -DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm
>>> -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-pic -fno-pie -ffixed-x18
>>>> +DEFINE GCC_AARCH64_CC_FLAGS        = DEF(GCC_ALL_CC_FLAGS) -mlittle-endian -fno-short-enums -fverbose-asm
>>> -funsigned-char  -ffunction-sections -fdata-sections -Wno-address -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-pic
>>> -fno-pie -ffixed-x18
>>>>  DEFINE GCC_AARCH64_CC_XIPFLAGS     = -mstrict-align -mgeneral-regs-only
>>>>  DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
>>>>  DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
>>>> --
>>>> 2.14.1.3.gb7cf6e02401b
>>>>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
  2018-05-21 10:30 ` Leif Lindholm
@ 2018-05-22  9:29   ` Laszlo Ersek
  2018-05-23 14:21     ` Gao, Liming
  0 siblings, 1 reply; 9+ messages in thread
From: Laszlo Ersek @ 2018-05-22  9:29 UTC (permalink / raw)
  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

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], <Command.GCC, Command.GCCLD> 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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
  2018-05-22  9:29   ` Laszlo Ersek
@ 2018-05-23 14:21     ` Gao, Liming
  2018-05-23 15:18       ` Laszlo Ersek
  0 siblings, 1 reply; 9+ messages in thread
From: Gao, Liming @ 2018-05-23 14:21 UTC (permalink / raw)
  To: Laszlo Ersek, Leif Lindholm
  Cc: Ard Biesheuvel, edk2-devel-01, pjones@redhat.com, Cole Robinson,
	Paolo Bonzini, Danilo C. L. de Paula

Laszlo:
  I agree to add this change first in tools_def.txt. Then, update IA32/X64 arch when there is a real request. For long term, I prefer to file a BZ for GccBase.lds / tools_def.template, to discard or strip .eh_frame under GCC.

  Reviewed-by: Liming Gao <liming.gao@intel.com>

Thanks
Liming
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
> Sent: Tuesday, May 22, 2018 5:30 PM
> To: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; edk2-devel-01 <edk2-devel@lists.01.org>; Gao, Liming <liming.gao@intel.com>;
> pjones@redhat.com; Cole Robinson <crobinso@redhat.com>; Paolo Bonzini <pbonzini@redhat.com>; Danilo C. L. de Paula
> <ddepaula@redhat.com>
> Subject: Re: [edk2] [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
> 
> 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], <Command.GCC, Command.GCCLD> 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
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
  2018-05-23 14:21     ` Gao, Liming
@ 2018-05-23 15:18       ` Laszlo Ersek
  0 siblings, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2018-05-23 15:18 UTC (permalink / raw)
  To: Gao, Liming, Leif Lindholm
  Cc: Ard Biesheuvel, edk2-devel-01, pjones@redhat.com, Cole Robinson,
	Paolo Bonzini, Danilo C. L. de Paula

On 05/23/18 16:21, Gao, Liming wrote:
> Laszlo:
>   I agree to add this change first in tools_def.txt. Then, update IA32/X64 arch when there is a real request. For long term, I prefer to file a BZ for GccBase.lds / tools_def.template, to discard or strip .eh_frame under GCC.
> 
>   Reviewed-by: Liming Gao <liming.gao@intel.com>

Thanks! I've pushed this patch now as commit cbf00651eda6, and filed
<https://bugzilla.tianocore.org/show_bug.cgi?id=955>.

Cheers,
Laszlo


>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
>> Sent: Tuesday, May 22, 2018 5:30 PM
>> To: Leif Lindholm <leif.lindholm@linaro.org>
>> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; edk2-devel-01 <edk2-devel@lists.01.org>; Gao, Liming <liming.gao@intel.com>;
>> pjones@redhat.com; Cole Robinson <crobinso@redhat.com>; Paolo Bonzini <pbonzini@redhat.com>; Danilo C. L. de Paula
>> <ddepaula@redhat.com>
>> Subject: Re: [edk2] [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS
>>
>> 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], <Command.GCC, Command.GCCLD> 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
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-05-23 15:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-18 18:23 [PATCH] BaseTools/tools_def: add "-fno-unwind-tables" to GCC_AARCH64_CC_FLAGS Laszlo Ersek
2018-05-19  8:21 ` Ard Biesheuvel
2018-05-21  0:37   ` Gao, Liming
2018-05-21  9:32     ` Ard Biesheuvel
2018-05-22  9:05       ` Laszlo Ersek
2018-05-21 10:30 ` Leif Lindholm
2018-05-22  9:29   ` Laszlo Ersek
2018-05-23 14:21     ` Gao, Liming
2018-05-23 15:18       ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox