This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [patch] MIPS: Fix synthesized doubleword transfers (ping)
Richard Sandiford <rsandifo@redhat.com> writes:
> "Maciej W. Rozycki" <macro@linux-mips.org> writes:
>> * config/tc-mips.c (macro): Avoid a reloc overflow for word
>> memory transfers in expansions of the "li.d", "l.d", "s.d", "ld"
>> and "sd" macros.
>
> Don't these instructions require doubleword-aligned addresses?
> If so, I don't see the problem. The relocs for "sym+offset"
> should always be sorted as:
>
> HI16 sym (in-place addend of %hi(offset))
> LO16 sym (in-place addend of %lo(offset))
> LO16 sym (in-place addend of %lo(offset+4))
>
> and the linker will do the right thing.
>
> I suppose bad things could happen if you composed an aligned
> address from an unaligned symbol and an unaligned offset,
> but is that allowed?
FWIW, I checked what the MIPSpro assembler does. Given:
ld $4,foo
as -32 -non_shared will generate:
0: 3c010000 lui at,0x0
0: R_MIPS_HI16 foo
4: 8c240000 lw a0,0(at)
4: R_MIPS_LO16 foo
8: 8c250004 lw a1,4(at)
8: R_MIPS_LO16 foo
just like gas does. Not that I'm saying we should do something simply
because MIPSpro does it. Just thought I'd throw it into the pot.
[ Although, as is probably clear from earlier messages, my preference is
to keep things the way they are, and require any symbolic component to
be 8-byte aligned. I've never heard of any practical problems with that
restriction. OTOH, after the above, I don't have any new data or
arguments to add, so I'll shut up now ;) ]
Richard