From: Hans-Peter Nilsson Date: Sun, 29 Feb 2004 21:46:28 +0000 (+0000) Subject: re PR target/14346 ([3.3 only] With -fpic/-fPIC, thunks jump through PLT, not directl... X-Git-Tag: releases/gcc-3.3.4~216 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=473f54388eb9572c2ba1dbc1b43d8791f1c50161;p=thirdparty%2Fgcc.git re PR target/14346 ([3.3 only] With -fpic/-fPIC, thunks jump through PLT, not directly to thunked function) PR target/14346 * config/cris/cris.c (cris_asm_output_mi_thunk): For PIC, prepend TAB to jumping "add.d" insn. Avoid PLT indirection by equating a local symbol and jumping through it. From-SVN: r78675 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2cbc69d61ede..806e5e99c9cf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2004-02-29 Hans-Peter Nilsson + + PR target/14346 + * config/cris/cris.c (cris_asm_output_mi_thunk): For PIC, prepend + TAB to jumping "add.d" insn. Avoid PLT indirection by equating a + local symbol and jumping through it. + 2004-02-29 Gabriel Dos Reis Backport from mainline: diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index 9f620ca080b4..9973c7b9ed16 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -1,5 +1,5 @@ /* Definitions for GCC. Part of the machine description for CRIS. - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Contributed by Axis Communications. Written by Hans-Peter Nilsson. This file is part of GCC. @@ -2635,10 +2635,24 @@ cris_asm_output_mi_thunk (stream, thunkdecl, delta, vcall_offset, funcdecl) { const char *name = XSTR (XEXP (DECL_RTL (funcdecl), 0), 0); + /* We have no other relative (to either PC or GOT) reloc than one + that requests a PLT entry. Since we don't set up the GOT + register, the jump absolutely must not be redirected through a + PLT entry. We manage anyway by going through a local symbol. + This depends on the assembler to not short-circuit equalities + set by the ".set" directive (at least not for PIC relocs) and + on the linker to direct R_CRIS_32_PLT_PCREL relocs *directly* + to the symbol for local symbols, instead of through a PLT + entry. */ name = (* targetm.strip_name_encoding) (name); - fprintf (stream, "add.d "); + fprintf (stream, "\tadd.d "); assemble_name (stream, name); - fprintf (stream, "%s,$pc\n", CRIS_PLT_PCOFFSET_SUFFIX); + fprintf (stream, "..xth%s,$pc\n", CRIS_PLT_PCOFFSET_SUFFIX); + fprintf (stream, "\t.set "); + assemble_name (stream, name); + fprintf (stream, "..xth,"); + assemble_name (stream, name); + fprintf (stream, "\n"); } else {