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
Andreas Schwab <schwab@suse.de> writes:
> Jakub Jelinek <jakub@redhat.com> writes:
>
> |> On Mon, Feb 11, 2002 at 06:27:13PM +0100, Andreas Jaeger wrote:
> |> >
> |> > Andreas Schwab and myself looked closer into this message on x86-64:
> |> >
> |> > x86_64-unknown-linux-ld: /abuild/aj/build/elf/librtld.os: access beyond end of merged section (-4 + 0)
> |> >
> |> > We've located this relocation in dl-cache.os (part of glibc):
> |> > 216: 48 8d 3d 00 00 00 00 lea 0(%rip),%rdi # 21d <_dl_load_cache_lookup+0x12d>
> |> > 219: R_X86_64_PC32 .rodata.str1.1+0xfffffffffffffffc
> |> >
> |> > The problem is the PC-relative addressing here. The offset
> |> > compensates for the fact that the addressing is relative to the *next*
> |> > instruction. So, it is not really an offset into the string section -
> |> > and should not be treated as such.
> |>
> |> This should not happen.
> |> Only local relocs against SHF_MERGE section with zero addend should be
> |> converted to STT_SECTION + addend.
> |> This is what gas/write.c (adjust_reloc_syms):
> |> /* Never adjust a reloc against local symbol in a merge section
> |> with non-zero addend. */
> |> if ((symsec->flags & SEC_MERGE) && fixp->fx_offset)
> |> {
> |> symbol_mark_used_in_reloc (fixp->fx_addsy);
> |> goto done;
> |> }
> |>
> |> is for. If you modify the addend later in tc-*, you need to care about it in
> |> your tc-* files.
>
> This should fix the problem:
It does indeed. Now we get a reference for a symbol inside the rodata
section:
216: 48 8d 3d 00 00 00 00 lea 0(%rip),%rdi # 21d <_dl_load_cache
_lookup+0x12d>
219: R_X86_64_PC32 .LC7+0xfffffffffffffffc
Jakub, does this look ok?
Andreas
> 2002-02-12 Andreas Schwab <schwab@suse.de>
>
> * config/tc-i386.c (tc_i386_fix_adjustable): Don't adjust
> pc-relative relocations to merge sections in 64-bit mode.
>
> --- gas/config/tc-i386.c.~1.109.~ Tue Feb 12 10:30:44 2002
> +++ gas/config/tc-i386.c Tue Feb 12 18:04:13 2002
> @@ -1178,7 +1178,12 @@
> /* Prevent all adjustments to global symbols, or else dynamic
> linking will not work correctly. */
> if (S_IS_EXTERNAL (fixP->fx_addsy)
> - || S_IS_WEAK (fixP->fx_addsy))
> + || S_IS_WEAK (fixP->fx_addsy)
> + /* Don't adjust pc-relative references to merge sections in 64-bit
> + mode. */
> + || (use_rela_relocations
> + && (S_GET_SEGMENT (fixP->fx_addsy)->flags & SEC_MERGE) != 0
> + && fixP->fx_pcrel))
> return 0;
> #endif
> /* adjust_reloc_syms doesn't know about the GOT. */
>
> Andreas.
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj