This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[mips patch RFA] put back bfd support for pcrel-32 relocs
- From: cgd at broadcom dot com
- To: binutils at sources dot redhat dot com
- Date: 13 Jun 2004 23:59:56 -0700
- Subject: [mips patch RFA] put back bfd support for pcrel-32 relocs
This patch puts back mips elf32 bfd support for pcrel-32 relocs, to
restore compatibility with old mips-linux exception handling data.
with the patch i posted to gcc-patches a bit ago, gcc won't try to
emit code that uses these relocs any longer. (they were an
embedded-pic extension.) However, it's desirable to support them at
link time, for compatiblity with existing objects that use them.
tested with binutils sources as of 5/1. something else has broken
binutils sources badly since then for mips linux shlibs (causing
string table offsets to be way out of bounds, iirc -- it's been a few
dasys since i tried), so i couldn't test w/ very current srcs.
tested compatiblity with old and new objects too (i.e., existing
objects that use pcrel-32 relocs for EH data).
(I would commit this as obvious, but i'd like to hear if this is
considered a reasonable solution to the problem.)
chris
--
[ bfd/ChangeLog ]
2004-06-13 Chris Demetriou <cgd@broadcom.com>
* elf32-mips.c (elf_mips_gnu_pcrel32): Add (undoing 2004-04-24
removal) with updated comment.
(bfd_elf32_bfd_reloc_type_lookup): Add back case for
BFD_RELOC_32_PCREL.
(mips_elf32_rtype_to_howto): Add back case for R_MIPS_PC32.
* elfxx-mips.c (mips_elf_calculate_relocation): Likewise.
[ include/elf/ChangeLog ]
2004-06-13 Chris Demetriou <cgd@broadcom.com>
* mips.h (R_MIPS_PC32): Add back (undoing removal on 2004-04-24),
with an updated comment.
Index: bfd/elf32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mips.c,v
retrieving revision 1.175
diff -u -p -r1.175 elf32-mips.c
--- bfd/elf32-mips.c 24 Apr 2004 22:07:13 -0000 1.175
+++ bfd/elf32-mips.c 14 Jun 2004 06:45:05 -0000
@@ -615,6 +615,25 @@ static reloc_howto_type elf_mips_gnu_rel
0xffff, /* dst_mask */
TRUE); /* pcrel_offset */
+/* 32 bit pc-relative. This was a GNU extension used by embedded-PIC.
+ It was co-opted by mips-linux for exception-handling data. It is no
+ longer used, but should continue to be supported by the linker for
+ backward compatibility. (GCC stopped using it in May, 2004.) */
+static reloc_howto_type elf_mips_gnu_pcrel32 =
+ HOWTO (R_MIPS_PC32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ TRUE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ _bfd_mips_elf_generic_reloc, /* special_function */
+ "R_MIPS_PC32", /* name */
+ TRUE, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ TRUE); /* pcrel_offset */
+
/* GNU extension to record C++ vtable hierarchy */
static reloc_howto_type elf_mips_gnu_vtinherit_howto =
HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
@@ -1071,6 +1090,8 @@ bfd_elf32_bfd_reloc_type_lookup (bfd *ab
return &elf_mips_gnu_vtentry_howto;
case BFD_RELOC_16_PCREL_S2:
return &elf_mips_gnu_rel16_s2;
+ case BFD_RELOC_32_PCREL:
+ return &elf_mips_gnu_pcrel32;
}
}
@@ -1092,6 +1113,8 @@ mips_elf32_rtype_to_howto (unsigned int
return &elf_mips_gnu_vtentry_howto;
case R_MIPS_GNU_REL16_S2:
return &elf_mips_gnu_rel16_s2;
+ case R_MIPS_PC32:
+ return &elf_mips_gnu_pcrel32;
default:
BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
return &elf_mips_howto_table_rel[r_type];
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.100
diff -u -p -r1.100 elfxx-mips.c
--- bfd/elfxx-mips.c 24 Apr 2004 22:07:13 -0000 1.100
+++ bfd/elfxx-mips.c 14 Jun 2004 06:45:05 -0000
@@ -3335,6 +3335,11 @@ mips_elf_calculate_relocation (bfd *abfd
value &= howto->dst_mask;
break;
+ case R_MIPS_PC32:
+ value = symbol + addend - p;
+ value &= howto->dst_mask;
+ break;
+
case R_MIPS_GNU_REL16_S2:
value = symbol + _bfd_mips_elf_sign_extend (addend, 18) - p;
overflowed_p = mips_elf_overflow_p (value, 18);
Index: include/elf/mips.h
===================================================================
RCS file: /cvs/src/src/include/elf/mips.h,v
retrieving revision 1.22
diff -u -p -r1.22 mips.h
--- include/elf/mips.h 24 Apr 2004 22:07:14 -0000 1.22
+++ include/elf/mips.h 14 Jun 2004 06:45:06 -0000
@@ -76,6 +76,11 @@ START_RELOC_NUMBERS (elf_mips_reloc_type
/* These relocs are used for the mips16. */
RELOC_NUMBER (R_MIPS16_26, 100)
RELOC_NUMBER (R_MIPS16_GPREL, 101)
+ /* This was a GNU extension used by embedded-PIC. It was co-opted by
+ mips-linux for exception-handling data. It is no longer used, but
+ should continue to be supported by the linker for backward
+ compatibility. (GCC stopped using it in May, 2004.) */
+ RELOC_NUMBER (R_MIPS_PC32, 248)
/* FIXME: this relocation is used internally by gas. */
RELOC_NUMBER (R_MIPS_GNU_REL16_S2, 250)
/* These are GNU extensions to enable C++ vtable garbage collection. */