From 811a475ea3fcc55ee4aea7c81171891ef19dfc25 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 7 Feb 2020 11:01:14 +0100 Subject: [PATCH] arm: Fix up arm installed unwind.h for use in pedantic modes [PR93615] As the following testcase shows, unwind.h on ARM can't be (starting with GCC 10) compiled with -std=c* modes, only -std=gnu* modes. The problem is it uses asm keyword, which isn't a keyword in those modes (system headers vs. non-system ones don't make a difference here). glibc and other installed headers use __asm or __asm__ keywords instead that work fine in both standard and gnu modes. While there, as it is an installed header, I think it is also wrong to completely ignore any identifier namespace rules. The generic unwind.h defines just _Unwind* namespace identifiers plus _sleb128_t/_uleb128_t (but e.g. unlike libstdc++/glibc headers doesn't uglify operand names), the ARM unwind.h is much worse here. I've just changed the gnu_Unwind_Find_got function at least not be in user identifier namespace, but perhaps it would be good to go further and rename e.g. or e.g. typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State, _Unwind_Control_Block *, _Unwind_Context *); in unwind-arm-common.h. 2020-02-07 Jakub Jelinek PR target/93615 * config/arm/unwind-arm.h (gnu_Unwind_Find_got): Rename to ... (_Unwind_gnu_Find_got): ... this. Use __asm instead of asm. Remove trailing :s in asm. Formatting fixes. (_Unwind_decode_typeinfo_ptr): Adjust caller. * gcc.dg/pr93615.c: New test. --- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/pr93615.c | 11 +++++++++++ libgcc/ChangeLog | 8 ++++++++ libgcc/config/arm/unwind-arm.h | 14 +++++--------- 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr93615.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6be609acf3f..32aa39c02a4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2020-02-07 Jakub Jelinek + PR target/93615 + * gcc.dg/pr93615.c: New test. + PR target/93611 * gcc.target/i386/pr93611.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr93615.c b/gcc/testsuite/gcc.dg/pr93615.c new file mode 100644 index 00000000000..2e98f5200c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr93615.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ +/* { dg-require-effective-target exceptions } */ + +#include + +int +main () +{ + return 0; +} diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 9ec9edf7066..b6e5ffc640d 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,11 @@ +2020-02-07 Jakub Jelinek + + PR target/93615 + * config/arm/unwind-arm.h (gnu_Unwind_Find_got): Rename to ... + (_Unwind_gnu_Find_got): ... this. Use __asm instead of asm. Remove + trailing :s in asm. Formatting fixes. + (_Unwind_decode_typeinfo_ptr): Adjust caller. + 2020-01-31 Sandra Loosemore nios2: Support for GOT-relative DW_EH_PE_datarel encoding. diff --git a/libgcc/config/arm/unwind-arm.h b/libgcc/config/arm/unwind-arm.h index 1c8285582ea..e77b769d782 100644 --- a/libgcc/config/arm/unwind-arm.h +++ b/libgcc/config/arm/unwind-arm.h @@ -43,19 +43,15 @@ extern "C" { #endif _Unwind_Ptr __attribute__((weak)) __gnu_Unwind_Find_got (_Unwind_Ptr); -static inline _Unwind_Ptr gnu_Unwind_Find_got (_Unwind_Ptr ptr) +static inline _Unwind_Ptr _Unwind_gnu_Find_got (_Unwind_Ptr ptr) { _Unwind_Ptr res; if (__gnu_Unwind_Find_got) - res = __gnu_Unwind_Find_got (ptr); + res = __gnu_Unwind_Find_got (ptr); else - { - asm volatile ("mov %[result], r" XSTR(FDPIC_REGNUM) - : [result]"=r" (res) - : - :); - } + __asm volatile ("mov %[result], r" XSTR(FDPIC_REGNUM) + : [result] "=r" (res)); return res; } @@ -75,7 +71,7 @@ static inline _Unwind_Ptr gnu_Unwind_Find_got (_Unwind_Ptr ptr) #if __FDPIC__ /* For FDPIC, we store the offset of the GOT entry. */ /* So, first get GOT from dynamic linker and then use indirect access. */ - tmp += gnu_Unwind_Find_got (ptr); + tmp += _Unwind_gnu_Find_got (ptr); tmp = *(_Unwind_Word *) tmp; #elif (defined(linux) && !defined(__uClinux__)) || defined(__NetBSD__) \ || defined(__FreeBSD__) || defined(__fuchsia__) -- 2.30.2