From: Jakub Jelinek <jakub@redhat.com>
To: Richard Earnshaw <richard.earnshaw@arm.com>,
Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>,
Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] arm: Fix up arm installed unwind.h for use in pedantic modes [PR93615]
Date: Fri, 07 Feb 2020 08:19:00 -0000 [thread overview]
Message-ID: <20200207081857.GS17695@tucnak> (raw)
Hi!
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.
#define UNWIND_STACK_REG 13
#define UNWIND_POINTER_REG 12
#define FDPIC_REGNUM 9
#define STR(x) #x
#define XSTR(x) STR(x)
or e.g.
typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State,
_Unwind_Control_Block *, _Unwind_Context *);
in unwind-arm-common.h.
Bootstrapped/regtested on armv7hl-linux-gnueabi, ok for trunk?
2020-02-07 Jakub Jelinek <jakub@redhat.com>
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.
--- libgcc/config/arm/unwind-arm.h.jj 2020-01-12 11:54:38.616380172 +0100
+++ libgcc/config/arm/unwind-arm.h 2020-02-06 16:16:54.244624408 +0100
@@ -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_Fin
#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__)
--- gcc/testsuite/gcc.dg/pr93615.c.jj 2020-02-06 22:40:00.921472574 +0100
+++ gcc/testsuite/gcc.dg/pr93615.c 2020-02-06 22:39:52.937591443 +0100
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c11" } */
+/* { dg-require-effective-target exceptions } */
+
+#include <unwind.h>
+
+int
+main ()
+{
+ return 0;
+}
Jakub
next reply other threads:[~2020-02-07 8:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 8:19 Jakub Jelinek [this message]
2020-02-07 9:30 ` Ramana Radhakrishnan
2020-02-10 13:04 ` Christophe Lyon
2020-02-10 13:26 ` Jakub Jelinek
2020-02-10 14:36 ` Christophe Lyon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200207081857.GS17695@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kyrylo.tkachov@arm.com \
--cc=ramana.radhakrishnan@arm.com \
--cc=richard.earnshaw@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).