This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Fix elf64-mips.c handling of relocs against *ABS*
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Thu, 07 Oct 2004 20:06:46 +0100
- Subject: Fix elf64-mips.c handling of relocs against *ABS*
As mentioned in my earlier message, this patch fixes the way elf64-mips.c
handles relocations against the absolute section. Equivalent code already
exists in the elfcode.h version.
Tested on mips64-elf and mips64-linux-gnu. OK to install?
Richard
bfd/
* elf64-mips.c (mips_elf64_write_rel): Use STN_UNDEF for relocs
against the absolute section.
(mips_elf64_write_rela): Likewise.
gas/testsuite/
* gas/mips/elf-rel22.[sd]: New test.
* gas/mips/mips.exp: Run it.
Index: bfd/elf64-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mips.c,v
retrieving revision 1.61
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.61 elf64-mips.c
*** bfd/elf64-mips.c 29 Jun 2004 13:46:33 -0000 1.61
--- bfd/elf64-mips.c 7 Oct 2004 18:41:14 -0000
*************** mips_elf64_write_rel (bfd *abfd, asectio
*** 2352,2357 ****
--- 2352,2359 ----
sym = *ptr->sym_ptr_ptr;
if (sym == last_sym)
n = last_sym_idx;
+ else if (bfd_is_abs_section (sym->section) && sym->value == 0)
+ n = STN_UNDEF;
else
{
last_sym = sym;
*************** mips_elf64_write_rela (bfd *abfd, asecti
*** 2448,2453 ****
--- 2450,2457 ----
sym = *ptr->sym_ptr_ptr;
if (sym == last_sym)
n = last_sym_idx;
+ else if (bfd_is_abs_section (sym->section) && sym->value == 0)
+ n = STN_UNDEF;
else
{
last_sym = sym;
*** /dev/null Fri Apr 23 00:21:55 2004
--- gas/testsuite/gas/mips/elf-rel22.d Thu Oct 7 19:40:32 2004
***************
*** 0 ****
--- 1,9 ----
+ #as: -march=mips3 -mabi=64
+ #readelf: --relocs
+ #name: MIPS ELF reloc 22
+
+ Relocation section '\.rela\.text' .*:
+ .*
+ .* R_MIPS_LO16 * 0+04
+ * Type2: R_MIPS_SUB *
+ * Type3: R_MIPS_LO16 *
*** /dev/null Fri Apr 23 00:21:55 2004
--- gas/testsuite/gas/mips/elf-rel22.s Thu Oct 7 19:39:29 2004
***************
*** 0 ****
--- 1,4 ----
+ lui $4,%lo(%neg(%lo(bar-foo)))
+ foo:
+ nop
+ bar:
*** gas/testsuite/gas/mips.1/mips.exp Thu Oct 7 19:05:44 2004
--- gas/testsuite/gas/mips/mips.exp Thu Oct 7 19:39:37 2004
*************** if { [istarget mips*-*-*] } then {
*** 664,669 ****
--- 664,670 ----
run_dump_test "elf-rel20"
if $has_newabi {
run_dump_test "elf-rel21"
+ run_dump_test "elf-rel22"
}
if { !$no_mips16 } {