Problem with string merging and PC relative relocations

Jakub Jelinek jakub@redhat.com
Mon Feb 11 10:52:00 GMT 2002
On Mon, Feb 11, 2002 at 10:07:05AM -0800, Geoff Keating wrote:
> > Has anybody an idea how to fix this?
> 
> Remove the warning.

No.

> Relocs can have arbitrary offsets, and just
> because a reloc is to an address that doesn't appear to be inside the
> section doesn't mean that the final reference is to that address.
> 
> For instance, given
> 
> int foo(int b)
> {
>   return "abcdef"[b-10];
> }
> 
> it's perfectly valid to generate a reloc to the address of the string
> minus 10, and in fact this is the most efficient code.

This should result in relocation against .LCxyz - 10, not
.rodata.str1.1 + 752 (until final link), exactly so that this information is
preserved.
Previously, gas did not change any relocs against SHF_MERGE .L* symbols into
STT_SECTION + addend, now it does so if it points right to the start of the
string (the most common case).

	Jakub



More information about the Binutils mailing list