This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 03/15] MIPS/GAS: Fix relaxed dword loads/stores
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: binutils at sourceware dot org
- Date: Sun, 3 Oct 2010 20:39:56 +0100 (BST)
- Subject: [PATCH 03/15] MIPS/GAS: Fix relaxed dword loads/stores
Hi,
This is a fix for the original issue that made me prepare this series of
patches. We have a problem with some doubleword memory access macros such
as LD.
Considering the following program:
$ cat ld.s
ld $4,foo+4096
we get the following output:
$ mips-linux-as -32 -o ld.o ld.s
$ mips-linux-objdump -dr ld.o
ld.o: file format elf32-tradbigmips
Disassembly of section .text:
00000000 <.text>:
0: 3c010000 lui at,0x0
4: 8c24fffc lw a0,-4(at)
8: 8c250000 lw a1,0(at)
c: 00000000 nop
Oops!
This is fixed by the following change. It looks like a piece of leftover
code from old relaxation support has stayed and triggers when a forward
reference turns out to require absolute addressing. It also shows how our
test coverage for these macros is insufficient. Improving the coverage
will be the point of the following patches.
2010-10-03 Maciej W. Rozycki <macro@linux-mips.org>
gas/
* config/tc-mips.c (macro)[ldd_std]: Fix the relaxation variant
for absolute addressing.
OK to apply?
Maciej
binutils-2.20.51-20100925-mips-l-d-reloc.patch
Index: binutils-2.20.51/gas/config/tc-mips.c
===================================================================
--- binutils-2.20.51.orig/gas/config/tc-mips.c
+++ binutils-2.20.51/gas/config/tc-mips.c
@@ -7200,26 +7200,7 @@ macro (struct mips_cl_insn *ip)
relax_switch ();
- /* We just generated two relocs. When tc_gen_reloc
- handles this case, it will skip the first reloc and
- handle the second. The second reloc already has an
- extra addend of 4, which we added above. We must
- subtract it out, and then subtract another 4 to make
- the first reloc come out right. The second reloc
- will come out right because we are going to add 4 to
- offset_expr when we build its instruction below.
-
- If we have a symbol, then we don't want to include
- the offset, because it will wind up being included
- when we generate the reloc. */
-
- if (offset_expr.X_op == O_constant)
- offset_expr.X_add_number -= 8;
- else
- {
- offset_expr.X_add_number = -4;
- offset_expr.X_op = O_constant;
- }
+ offset_expr.X_add_number -= 4;
}
used_at = 1;
macro_build_lui (&offset_expr, AT);