This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR target/12538 (SPARC)
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 11 Oct 2003 13:13:54 +0200
- Subject: [PATCH] Fix PR target/12538 (SPARC)
Hi,
The PR reports a segfault when running a program compiled with -mflat -fpic.
The problem is two-fold:
- the PIC register (%l7) is clobbered by functions that use the PIC table,
- the PC return register (%o7) is clobbered by the mechanism that sets
the PIC register.
Compiled on sparc-sun-solaris2.5.1. The patch eliminates 470 failures in the
execute.exp testsuite run with -mflat -fpic (I'm probably the first one to
run it with these options :-) so it is now on par with the -mflat testsuite.
Btw, has anyone ever tried to bootstrap GCC with -mflat?
Ok for mainline?
2003-10-11 Eric Botcazou <ebotcazou@libertysurf.fr>
PR target/12538
* config/sparc/sparc.c (MUST_SAVE_REGISTER): Save
%l7 and %o7 when the PIC offset table is used.
--
Eric Botcazou
Index: config/sparc/sparc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.c,v
retrieving revision 1.262
diff -u -p -r1.262 sparc.c
--- config/sparc/sparc.c 4 Oct 2003 21:36:08 -0000 1.262
+++ config/sparc/sparc.c 11 Oct 2003 08:17:17 -0000
@@ -7265,9 +7265,13 @@ struct sparc_frame_info zero_frame_info;
#define RETURN_ADDR_MASK (1 << (RETURN_ADDR_REGNUM))
#define MUST_SAVE_REGISTER(regno) \
- ((regs_ever_live[regno] && !call_used_regs[regno]) \
- || (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed) \
- || (regno == RETURN_ADDR_REGNUM && regs_ever_live[RETURN_ADDR_REGNUM]))
+ ((regs_ever_live[regno] && !call_used_regs[regno]) \
+ || (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed) \
+ || (regno == RETURN_ADDR_REGNUM && regs_ever_live[RETURN_ADDR_REGNUM]) \
+ /* When the PIC offset table is used, the PIC register %l7 (reg #23) */ \
+ /* is set by using a bare call that clobbers %o7 (reg #15). */ \
+ || (flag_pic && current_function_uses_pic_offset_table \
+ && (regno == 23 || regno == 15)))
/* Return the bytes needed to compute the frame pointer from the current
stack pointer. */