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 <[email protected]>
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