This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] mips_frob_file -- fix hi/lo pairings
- From: Catherine Moore <clm at codesourcery dot com>
- To: binutils at sourceware dot org
- Cc: Catherine Moore <clm at codesourcery dot com>
- Date: Fri, 09 May 2008 15:06:44 -0400
- Subject: [patch] mips_frob_file -- fix hi/lo pairings
The linker reported that it couldn't find a matching lo16 reloc. The problem was occurring because
the assembler was pairing a hi16 reloc with a mips16_lo16 reloc. The linker expected that hi16
relocs would only be paired with lo16 relocs. The patch modifies the assembler to produce the
expected pairings. Okay to install?
Thanks,
Catherine
gas/
* config/tc-mips.c (mips_frob_file): Don't match MIPS16 relocs
with non-MIPS16 relocs.
gas/testsuite/
* gas/mips/mips16-hilo-match.s: New test.
* gas/mips/mip16-hilo-match.d: New test output.Index: config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.383
diff -p -r1.383 tc-mips.c
*** config/tc-mips.c 28 Apr 2008 17:06:28 -0000 1.383
--- config/tc-mips.c 9 May 2008 18:15:15 -0000
*************** void
*** 11749,11754 ****
--- 11749,11755 ----
mips_frob_file (void)
{
struct mips_hi_fixup *l;
+ bfd_reloc_code_real_type looking_for_rtype = BFD_RELOC_UNUSED;
for (l = mips_hi_fixup_list; l != NULL; l = l->next)
{
*************** mips_frob_file (void)
*** 11778,11790 ****
hi_pos = NULL;
lo_pos = NULL;
matched_lo_p = FALSE;
for (pos = &seginfo->fix_root; *pos != NULL; pos = &(*pos)->fx_next)
{
if (*pos == l->fixp)
hi_pos = pos;
! if (((*pos)->fx_r_type == BFD_RELOC_LO16
! || (*pos)->fx_r_type == BFD_RELOC_MIPS16_LO16)
&& (*pos)->fx_addsy == l->fixp->fx_addsy
&& (*pos)->fx_offset >= l->fixp->fx_offset
&& (lo_pos == NULL
--- 11779,11797 ----
hi_pos = NULL;
lo_pos = NULL;
matched_lo_p = FALSE;
+
+ if (l->fixp->fx_r_type == BFD_RELOC_MIPS16_HI16
+ || l->fixp->fx_r_type == BFD_RELOC_MIPS16_HI16_S)
+ looking_for_rtype = BFD_RELOC_MIPS16_LO16;
+ else
+ looking_for_rtype = BFD_RELOC_LO16;
+
for (pos = &seginfo->fix_root; *pos != NULL; pos = &(*pos)->fx_next)
{
if (*pos == l->fixp)
hi_pos = pos;
! if ((*pos)->fx_r_type == looking_for_rtype
&& (*pos)->fx_addsy == l->fixp->fx_addsy
&& (*pos)->fx_offset >= l->fixp->fx_offset
&& (lo_pos == NULL
Index: testsuite/gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.138
diff -p -r1.138 mips.exp
*** testsuite/gas/mips/mips.exp 28 Apr 2008 17:10:18 -0000 1.138
--- testsuite/gas/mips/mips.exp 9 May 2008 18:15:15 -0000
*************** if { [istarget mips*-*-vxworks*] } {
*** 528,533 ****
--- 528,534 ----
if $has_newabi {
run_dump_test "mips16-hilo-n32"
}
+ run_dump_test "mips16-hilo-match"
}
run_list_test "mips-no-jalx" "-32"
run_dump_test "delay"
Index: testsuite/gas/mips/mips16-hilo-match.d
===================================================================
RCS file: testsuite/gas/mips/mips16-hilo-match.d
diff -N testsuite/gas/mips/mips16-hilo-match.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gas/mips/mips16-hilo-match.d 9 May 2008 18:15:15 -0000
***************
*** 0 ****
--- 1,40 ----
+ #objdump: -r
+ #name: MIPS16 mips16-hilo-match
+
+ .*: +file format .*mips.*
+
+ RELOCATION RECORDS FOR \[\.text\]:
+ OFFSET TYPE VALUE
+ 00000010 R_MIPS_HI16 var4
+ 00000018 R_MIPS_LO16 var4
+ 00000008 R_MIPS_HI16 __var1
+ 00000020 R_MIPS_LO16 __var1
+ 0000001c R_MIPS_HI16 .sbss
+ 0000002c R_MIPS_LO16 .sbss
+ 00000030 R_MIPS_26 func4
+ 00000028 R_MIPS_HI16 __var3
+ 00000034 R_MIPS_LO16 __var3
+ 00000038 R_MIPS_LO16 hilo_match
+ 0000003c R_MIPS_HI16 .bss
+ 00000044 R_MIPS_LO16 .bss
+ 00000040 R_MIPS_HI16 .bss
+ 00000048 R_MIPS_LO16 .bss
+ 0000004c R_MIPS_26 func3
+ 00000024 R_MIPS_HI16 hilo_match
+ 00000050 R_MIPS_LO16 hilo_match
+ 0000005e R_MIPS16_HI16 .data
+ 00000068 R_MIPS16_LO16 .data
+ 0000006c R_MIPS16_26 func1
+ 00000072 R_MIPS16_26 func2
+ 00000078 R_MIPS16_HI16 hilo_match
+ 00000080 R_MIPS16_LO16 hilo_match
+ 00000086 R_MIPS16_LO16 hilo_match
+ 0000008a R_MIPS16_26 func1
+
+
+ RELOCATION RECORDS FOR \[\.pdr\]:
+ OFFSET TYPE VALUE
+ 00000000 R_MIPS_32 _pinit
+ 00000020 R_MIPS_32 pdelt
+
+
Index: testsuite/gas/mips/mips16-hilo-match.s
===================================================================
RCS file: testsuite/gas/mips/mips16-hilo-match.s
diff -N testsuite/gas/mips/mips16-hilo-match.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gas/mips/mips16-hilo-match.s 9 May 2008 18:15:15 -0000
***************
*** 0 ****
--- 1,148 ----+ .set nomips16
+ .ent _pinit
+ _pinit:
+
+ lw $3,8($23)
+ li $5,1
+ lui $2,%hi(__var1)
+ ori $3,$3,0x1
+ lui $4,%hi(var4)
+ sw $3,8($23)
+ addiu $4,$4,%lo(var4)
+ lui $3,%hi(var5)
+ sw $5,%lo(__var1)($2)
+ lui $19,%hi(hilo_match)
+ .LVL100:
+ lui $2,%hi(__var3)
+ sw $5,%lo(var5)($3)
+ .set noreorder
+ .set nomacro
+ jal func4
+ sw $5,%lo(__var3)($2)
+ .set macro
+ .set reorder
+
+ lw $17,%lo(hilo_match)($19)
+ .LVL101:
+ lui $2,%hi(var6)
+ lui $3,%hi(var6+704)
+ addiu $16,$2,%lo(var6)
+ .LVL102:
+ addiu $18,$3,%lo(var6+704)
+ .set noreorder
+ .set nomacro
+ jal func3
+ sw $2,%lo(hilo_match)($19)
+
+ .end _pinit
+ .LFE84:
+ .size _pinit, .-_pinit
+ .align 2
+ .globl pdelt
+ .LFB120:
+ .set mips16
+ .ent pdelt
+ pdelt:
+ .set macro
+ .set reorder
+
+ li $2,16
+ .L321:
+ .LVL212:
+ j $31
+ .LVL213:
+ .L322:
+ lhu $2,36($17)
+ move $4,$16
+ li $16,%hi(var2)
+ sll $16,$16,8
+ addiu $2,1
+ sll $16,$16,8
+ addiu $16,%lo(var2)
+ .set noreorder
+ .set nomacro
+ jal func1
+ sh $2,36($17)
+ .set macro
+ .set reorder
+
+ .set noreorder
+ .set nomacro
+ jal func2
+ move $4,$16
+ .set macro
+ .set reorder
+
+ li $3,%hi(hilo_match)
+ sll $3,$3,8
+ sll $3,$3,8
+ lw $2,%lo(hilo_match)($3)
+ sw $2,0($17)
+ sw $17,%lo(hilo_match)($3)
+ .set noreorder
+ .set nomacro
+ jal func1
+ move $4,$16
+ .set macro
+ .set reorder
+
+ .LVL214:
+ .set noreorder
+ .set nomacro
+ j $31
+ li $2,0
+ .set macro
+ .set reorder
+
+ .end pdelt
+ .align 2
+ .weak __var3
+ .section .sbss,"aw",@nobits
+ .align 2
+ .type __var3, @object+ .space 4
+ .weak __var1
+ .align 2
+ .type __var1, @object
+ .size __var1, 4
+ __var1:
+ .space 4
+ .data
+ .align 2
+ .weak __hilo_match
+ .align 2
+ .type __hilo_match, @object
+ .size __hilo_match, 4
+ __hilo_match:
+ .space 4
+ .data
+ .align 2
+ .align 2
+ .type var2, @object
+ .size var2, 32
+ var2:
+ .word 0
+ .word -1
+ .word 0
+ .byte 0
+ .byte 0+ .byte 0
+ .byte 0
+ .word 0
+ .word 0
+ .half 0
+ .space 6
+ .align 2
+ .rdata
+ .align 2
+ .space 8
+ .local var5
+ .comm var5,4,4
+ .align 2
+ .local var6
+ .comm var6,704,4
+ .size __var3, 4
+ __var3:
+ .align 2
+ .globl _pinit
+ .LFB84:
* gas/mips/mips.exp: Run mips16-hilo-match.