This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Committed, 3.3-branch: cris.c: Fix PR target/14346: thunk mustn't jump through PLT.


See PR for details.  Due to lack of infrastructure for tests that
require creating shared libraries, the test-case in the PR wasn't
(pruned and) installed.  Another solution would have been to apply
<URL:http://gcc.gnu.org/ml/gcc-patches/2003-06/msg02603.html> and its
follow-ups, but I considered that to be too invasive.  I guess no
other platform *requires* the symbol for the target of the thunk to
be local.

Built and tested cross to cris-axis-linux-gnu (just a sanity check;
nothing there besides building libraries triggers this bug).
Test-case "manually" checked.

	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.

Index: cris.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris.c,v
retrieving revision 1.32.4.2
diff -p -c -r1.32.4.2 cris.c
*** cris.c	12 Dec 2003 13:58:01 -0000	1.32.4.2
--- cris.c	29 Feb 2004 19:04:20 -0000
***************
*** 1,5 ****
  /* Definitions for GCC.  Part of the machine description for CRIS.
!    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
     Contributed by Axis Communications.  Written by Hans-Peter Nilsson.
  
  This file is part of GCC.
--- 1,5 ----
  /* Definitions for GCC.  Part of the machine description for CRIS.
!    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.
*************** cris_asm_output_mi_thunk (stream, thunkd
*** 2635,2644 ****
      {
        const char *name = XSTR (XEXP (DECL_RTL (funcdecl), 0), 0);
  
        name = (* targetm.strip_name_encoding) (name);
!       fprintf (stream, "add.d ");
        assemble_name (stream, name);
!       fprintf (stream, "%s,$pc\n", CRIS_PLT_PCOFFSET_SUFFIX);
      }
    else
      {
--- 2651,2674 ----
      {
        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, "\tadd.d ");
!       assemble_name (stream, name);
!       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
      {

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]