This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Handling of -fpic in ASM_OUTPUT_MI_THUNK in sparc
- To: Teemu Torma <tot at trema dot com>
- Subject: Re: Handling of -fpic in ASM_OUTPUT_MI_THUNK in sparc
- From: Richard Henderson <rth at cygnus dot com>
- Date: Tue, 18 Nov 1997 12:26:27 -0800
- Cc: egcs at cygnus dot com
- References: <199711181604.RAA19200@lev.labs.trema.com>
- Reply-To: Richard Henderson <rth at cygnus dot com>
On Tue, Nov 18, 1997 at 05:04:33PM +0100, Teemu Torma wrote:
> Is there any reason why not to emit the thunk to a writable segment?
Yes, there is a better way.
> Besides, the current test does not help if the main program compiled
> without -fpic emits thunks that call methods in a shared library.
Absolutely correct.
r~
Tue Nov 18 12:21:54 1997 Richard Henderson <rth@cygnus.com>
* sparc.h (ASM_OUTPUT_MI_THUNK): Move %o7 through %g1 instead of
save+restore. Fix pic+big_offset delay slot. Use "pic" case for
unix always, since we want to be able to thunk to functions in a
shared library from an application.
Index: gcc/config/sparc/sparc.h
===================================================================
RCS file: /cvs/cvsfiles/egcs/gcc/config/sparc/sparc.h,v
retrieving revision 1.10
diff -u -p -d -r1.10 sparc.h
--- sparc.h 1997/10/24 19:36:54 1.10
+++ sparc.h 1997/11/18 20:21:30
@@ -3016,11 +3016,15 @@ do { \
int big_delta = (DELTA) >= 4096 || (DELTA) < -4096; \
if (big_delta) \
fprintf (FILE, "\tset %d,%%g1\n\tadd %%o0,%%g1,%%o0\n", (DELTA)); \
- if (flag_pic) \
+ /* Don't use the jmp solution unless we know the target is local to \
+ the application or shared object. \
+ XXX: Wimp out and don't actually check anything except if this is \
+ an embedded target where we assume there are no shared libs. */ \
+ if (!TARGET_CM_EMBMEDANY || flag_pic) \
{ \
if (! big_delta) \
fprintf (FILE, "\tadd %%o0,%d,%%o0\n", DELTA); \
- fprintf (FILE, "\tsave %%sp,-112,%%sp\n"); \
+ fprintf (FILE, "\tmov %%o7,%%g1\n"); \
fprintf (FILE, "\tcall "); \
assemble_name \
(FILE, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (FUNCTION))); \
@@ -3043,10 +3047,10 @@ do { \
(FILE, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (FUNCTION))); \
fprintf (FILE, ")\n"); \
} \
- if (big_delta) \
+ if (!TARGET_CM_EMBMEDANY || flag_pic) \
+ fprintf (FILE, "\tmov %%g1,%%o7\n"); \
+ else if (big_delta) \
fprintf (FILE, "\tnop\n"); \
- else if (flag_pic) \
- fprintf (FILE, "\trestore\n"); \
else \
fprintf (FILE, "\tadd %%o0,%d,%%o0\n", DELTA); \
} while (0)