This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Diagnose pr54694
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 16 Jan 2014 19:21:42 +0100
- Subject: Re: [PATCH] Diagnose pr54694
- Authentication-results: sourceware.org; auth=none
- References: <52D6B611 dot 6040802 at redhat dot com> <CAMe9rOp35NQCbjSjP6SZ5J-6hxdKBKANXsxA1Gtfsg5XNF4FFQ at mail dot gmail dot com> <52D700F6 dot 2060609 at redhat dot com> <20140115215845 dot GH892 at tucnak dot redhat dot com> <52D8036F dot 5020904 at redhat dot com> <20140116173545 dot GQ892 at tucnak dot redhat dot com> <52D81C1C dot 6040402 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Jan 16, 2014 at 09:51:24AM -0800, Richard Henderson wrote:
> On 01/16/2014 09:35 AM, Jakub Jelinek wrote:
> > Wonder if the test should be turned into dg-do compile,
> > or perhaps a hack like:
> > int xmain() __asm__ ("main");
> > int xmain()
> > instead of
> > int main()
> > to avoid the dynamic stack realigning in main (limit the test to *linux*
> > then?), supply main written in assembly, something else?
>
>
> The __asm__ hack seems reasonable, although you'll also have to deal
> with __USER_LABEL_PREFIX__.
So like this? Tested on x86_64 with
make -k check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} i386.exp=pr9771-1.c'
2014-01-16 Jakub Jelinek <jakub@redhat.com>
PR debug/54694
* gcc.target/i386/pr9771-1.c (main): Rename to...
(real_main): ... this. Add __asm name "main".
(ASMNAME, ASMNAME2, STRING): Define.
--- gcc/testsuite/gcc.target/i386/pr9771-1.c.jj 2013-08-13 12:20:13.000000000 +0200
+++ gcc/testsuite/gcc.target/i386/pr9771-1.c 2014-01-16 19:17:24.807903910 +0100
@@ -45,7 +45,17 @@ void test(void)
exit(0);
}
-int main()
+/* main usually performs dynamic realignment of the stack in case
+ _start would fail to properly align the stack, but for dynamic
+ stack realignment we need frame pointer which is incompatible
+ with -ffixed-ebp and the global register var. So, cheat here
+ and hide from the compiler that main is really main. */
+#define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+#define ASMNAME2(prefix, cname) STRING (prefix) cname
+#define STRING(x) #x
+int real_main() __asm (ASMNAME ("main"));
+
+int real_main()
{
test();
return 0;
Jakub