Fix things the other way round. Instead of restoring the mips

embedded pic support into binutils, instead fixup gcc to not emit
any embedded pic relocations.
This commit is contained in:
Eric Andersen 2005-03-02 12:30:29 +00:00
parent 5968b7e4de
commit cd2388d5b3
3 changed files with 59 additions and 119 deletions

View File

@ -1,44 +0,0 @@
#! /bin/sh -e
## 117_mips_symbolic_link.dpatch
##
## DP: Description: Handle symbolic multigot links. (#270619)
## DP: Author: Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
## DP: Upstream status: Not submitted
## DP: Date: 2004-09-08
if [ $# -lt 1 ]; then
echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
exit 1
fi
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
case "$1" in
-patch) patch -p1 ${patch_opts} < $0;;
-unpatch) patch -R -p1 ${patch_opts} < $0;;
*)
echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
exit 1;;
esac
exit 0
@DPATCH@
diff -urpN binutils-2.15.orig/bfd/elfxx-mips.c binutils-2.15/bfd/elfxx-mips.c
--- binutils-2.15.orig/bfd/elfxx-mips.c 2004-05-17 21:36:03.000000000 +0200
+++ binutils-2.15/bfd/elfxx-mips.c 2004-08-29 08:48:22.000000000 +0200
@@ -3909,11 +3910,8 @@ mips_elf_create_dynamic_relocation (bfd
/* We must now calculate the dynamic symbol table index to use
in the relocation. */
if (h != NULL
- && (! info->symbolic || (h->root.elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0)
- /* h->root.dynindx may be -1 if this symbol was marked to
- become local. */
- && h->root.dynindx != -1)
+ && ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
+ || (h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0))
{
indx = h->root.dynindx;
if (SGI_COMPAT (output_bfd))

View File

@ -1,75 +0,0 @@
--- binutils/gas/config/tc-mips.c.orig 2004-12-20 12:16:50.000000000 -0700
+++ binutils/gas/config/tc-mips.c 2005-03-02 03:42:08.000000000 -0700
@@ -10955,8 +10955,6 @@
buf = (bfd_byte *) (fixP->fx_frag->fr_literal + fixP->fx_where);
- assert (! fixP->fx_pcrel);
-
/* Don't treat parts of a composite relocation as done. There are two
reasons for this:
@@ -11000,7 +10998,6 @@
case BFD_RELOC_MIPS_CALL_HI16:
case BFD_RELOC_MIPS_CALL_LO16:
case BFD_RELOC_MIPS16_GPREL:
- assert (! fixP->fx_pcrel);
/* Nothing needed to do. The value comes from the reloc entry */
break;
@@ -12867,8 +12864,23 @@
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
- assert (! fixp->fx_pcrel);
- reloc->addend = fixp->fx_addnumber;
+ if (fixp->fx_pcrel)
+ {
+ if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
+ {
+ /* At this point, fx_addnumber is "symbol offset - reloc->address".
+ Relocations want only the symbol offset. */
+ reloc->addend = fixp->fx_addnumber + reloc->address;
+ }
+ else
+ {
+ /* A gruesome hack which is a result of the gruesome gas reloc
+ handling. */
+ reloc->addend = reloc->address;
+ }
+ }
+ else
+ reloc->addend = fixp->fx_addnumber;
/* Since the old MIPS ELF ABI uses Rel instead of Rela, encode the vtable
entry to be used in the relocation's section offset. */
@@ -12879,6 +12891,16 @@
}
code = fixp->fx_r_type;
+ if (fixp->fx_pcrel)
+ {
+ if (code == BFD_RELOC_32)
+ code = BFD_RELOC_32_PCREL;
+ else
+ as_bad_where (fixp->fx_file, fixp->fx_line,
+ _("Cannot make %s relocation PC relative"),
+ bfd_get_reloc_code_name (code));
+ }
+
/* To support a PC relative reloc, we used a Cygnus extension.
We check for that here to make sure that we don't let such a
--- binutils/gas/config/tc-mips.h 29 Apr 2004 05:14:22 -0000 1.35
+++ binutils/gas/config/tc-mips.h 5 May 2004 17:38:51 -0000
@@ -58,6 +58,10 @@
#define MAX_MEM_FOR_RS_ALIGN_CODE (1 + 2)
+/* We permit PC relative difference expressions when generating
+ embedded PIC code. */
+#define DIFF_EXPR_OK
+
/* Tell assembler that we have an itbl_mips.h header file to include. */
#define HAVE_ITBL_CPU

View File

@ -0,0 +1,59 @@
From: cgd at broadcom dot com
To: gcc-patches at gcc dot gnu dot org
Cc: mark at codesourcery dot com
Date: 13 Jun 2004 22:51:30 -0700
Subject: [trunk + 3.4-branch RFA] don't use empic relocs for mips-linuxeh
This patch changes mips-linux to avoid using embedded-pic relocs for
its eh data. (Support for generating these for new code is removed in
current binutils srcs.)
Relating to this, previously, mips-linux and mips64-linux would use
different representations for their EH data (even for mips64-linux o32
abi), due to the mips64-linux n32/64 BFDs not supporting the
embedded-pic relocs. This was a bug.
For more explanation, see the thread of the URL quoted in the comment
in linux.h.
Tested the same w/ sources of about a week ago for c/c++ for
mips-linux (native) before/after. Also verified .o compatibility
before/after just to be sure.
I'd like this approved for the branch as well, so 3.4.1 will work
nicely w/ the next major binutils release.
thanks,
chris
2004-06-13 Chris Demetriou <cgd@broadcom.com>
* config/mips/linux.h (ASM_PREFERRED_EH_DATA_FORMAT): Redefine
to return DW_EH_PE_absptr.
Index: config/mips/linux.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/linux.h,v
retrieving revision 1.77
diff -u -p -r1.77 linux.h
--- gcc/gcc/config/mips/linux.h 19 Feb 2004 22:07:51 -0000 1.77
+++ gcc/gcc/config/mips/linux.h 14 Jun 2004 05:49:51 -0000
@@ -170,10 +170,11 @@ Boston, MA 02111-1307, USA. */
#undef FUNCTION_NAME_ALREADY_DECLARED
#define FUNCTION_NAME_ALREADY_DECLARED 1
-#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
- (flag_pic \
- ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4\
- : DW_EH_PE_absptr)
+/* If possible, we should attempt to use GP-relative relocs for this
+ (see <a href="http://sources.redhat.com/ml/binutils/2004-05/msg00227.html">http://sources.redhat.com/ml/binutils/2004-05/msg00227.html</a>).
+ However, until that is implement, this just uses standard, absolute
+ references. */
+#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) DW_EH_PE_absptr
/* The glibc _mcount stub will save $v0 for us. Don't mess with saving
it, since ASM_OUTPUT_REG_PUSH/ASM_OUTPUT_REG_POP do not work in the