IA32 TLS GD optimization issue
H. J. Lu
hjl@lucon.org
Thu Nov 6 17:49:00 GMT 2003
The ia32 linker can optimize TLS GD to LE or IE. But they are not
consistent. For GD -> LE, we can turn
leal foo(%reg), %eax; call ___tls_get_addr; nop
into
movl %gs:0, %eax; subl $foo@tpoff, %eax # 6 byte form of subl
and
leal foo(%reg), %eax; call ___tls_get_addr
into
movl %gs:0, %eax; subl $foo@tpoff, %eax # 5 byte form of subl
But for GD -> IE, we only support
leal foo(%reg), %eax; call ___tls_get_addr; nop
to
movl %gs:0, %eax; subl $foo@gottpoff(%reg), %eax # 6 byte form of subl
since there is no 5 byte form for "subl $foo@gottpoff(%reg), %eax".
Also I think this patch is needed for
leal foo(%reg), %eax; call ___tls_get_addr
Should we support
leal foo(%reg), %eax; call ___tls_get_addr
at all? If yes, how should we fix it?
H.J.
--- elf32-i386.c.tls 2003-11-04 09:43:23.000000000 -0800
+++ elf32-i386.c 2003-11-06 09:45:57.000000000 -0800
@@ -2473,6 +2473,7 @@ elf_i386_relocate_section (bfd *output_b
(5 byte form of subl). */
memcpy (contents + rel->r_offset - 2,
"\x65\xa1\0\0\0\0\x2d\0\0\0", 11);
+ roff = rel->r_offset + 5;
}
}
bfd_put_32 (output_bfd, tpoff (info, relocation),
More information about the Binutils
mailing list