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: Andreas Schwab <schwab at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Andreas Jaeger <aj at suse dot de>, binutils at sources dot redhat dot com
- Date: Tue, 12 Feb 2002 23:08:44 +0100
- Subject: Re: Problem with string merging and PC relative relocations
- References: <hoy9i0lyj2.fsf@gee.suse.de><20020211191102.J798@sunsite.ms.mff.cuni.cz>
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:
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 Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."