This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
SH PLT needs the PIC register to be set
- To: gcc-patches at gcc dot gnu dot org
- Subject: SH PLT needs the PIC register to be set
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 02 Sep 2000 01:07:33 -0300
- Organization: GCC Team, Red Hat
- References: <20000901191717.A27744@valinux.com><orn1hrecxf.fsf@guarana.lsd.ic.unicamp.br><20000901203837.A12389@valinux.com><orsnrjcuzj.fsf@guarana.lsd.ic.unicamp.br>
On Sep 2, 2000, Alexandre Oliva <aoliva@redhat.com> wrote:
> Which reminds me of the reason why I had initially set
> current_function_uses_pic_offset_table to 1 in the `symPLT_label2reg'
> define_expand in sh.md :-)
Here's a patch that fixes this thinko. Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* config/sh/sh.md (symPLT_label2reg): Force the initialization of
the PIC register.
Index: gcc/config/sh/sh.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.md,v
retrieving revision 1.42
diff -u -p -r1.42 sh.md
--- gcc/config/sh/sh.md 2000/09/02 03:28:47 1.42
+++ gcc/config/sh/sh.md 2000/09/02 04:07:00
@@ -3531,8 +3531,24 @@ else
(plus:SI (pc)
(unspec [(match_operand:SI 1 "" "")] 9))
(const (plus:SI (label_ref (match_operand:SI 2 "" ""))
- (const_int 2))))))]
- "" "")
+ (const_int 2))))))
+ (use (match_dup 2))]
+ ;; Even though the PIC register is not really used by the call
+ ;; sequence in which this is expanded, the PLT code assumes the PIC
+ ;; register is set, so we must not skip its initialization. Since
+ ;; we only use this expand as part of calling sequences, and never
+ ;; to take the address of a function, this is the best point to
+ ;; insert the (use). Using the PLT to take the address of a
+ ;; function would be wrong, not only because the PLT entry could
+ ;; then be called from a function that doesn't initialize the PIC
+ ;; register to the proper GOT, but also because pointers to the same
+ ;; function might not compare equal, should they be set by different
+ ;; shared libraries.
+ "" "
+{
+ operands[2] = pic_offset_table_rtx;
+ current_function_uses_pic_offset_table = 1;
+}")
;; case instruction for switch statements.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me