This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] S/390: Fix two issues with the IFUNC optimized mem*routines


From: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
Date: Thu, 30 Aug 2012 09:22:11 +0200

> It would only work if ld would be able to get rid of the runtime
> relocations entirely. In order to do this ld would need to rewrite
> the code accessing the GOT slots to use pc or got relative
> addressing.

This is exactly what Sparc does.

Look at the GOTDATA relocation handling in binutils, for example:

	case R_SPARC_GOTDATA_OP:
	  if (SYMBOL_REFERENCES_LOCAL (info, h))
	    {
	      bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset);

	      /* {ld,ldx} [%rs1 + %rs2], %rd --> add %rs1, %rs2, %rd */
	      relocation = 0x80000000 | (insn & 0x3e07c01f);
	      bfd_put_32 (output_bfd, relocation, contents + rel->r_offset);
	    }
	  continue;

GCC emits:

        sethi   %gdop_hix22(foo), %i0
        xor     %i0, %gdop_lox10(foo), %i0
        ld      [%l7 + %i0], %i0, %gdop(foo)

and this gets transformed above by the linker into something like:

        sethi   %hix22(_GLOBAL_OFFSET_TABLE - foo), %i0
        xor     %i0, %lox10(_GLOBAL_OFFSET_TABLE - foo), %i0
        add     %l7, %i0, %i0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]