This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Problem with string merging and PC relative relocations
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Geoff Keating <geoffk at redhat dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 11 Feb 2002 19:16:06 +0100
- Subject: Re: Problem with string merging and PC relative relocations
- References: <hoy9i0lyj2.fsf@gee.suse.de> <200202111807.g1BI75J13282@desire.geoffk.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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