mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-19 01:19:41 +08:00
x86: Report expected register for elf_x86_tls_error_indirect_call
Since R_386_TLS_DESC_CALL can only be used with call *variable@TLSCALL(%eax) and R_X86_64_TLSDESC_CALL can only be used with call *variable@TLSCALL(%rax) update TLS transition error report to display the expected register in indirect CALL. bfd/ PR ld/32017 * elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize the ax_register field. (_bfd_x86_elf_link_report_tls_transition_error): Report the expected register in elf_x86_tls_error_indirect_call error. * elfxx-x86.h (elf_x86_link_hash_table): Add ax_register. ld/ PR ld/32017 * testsuite/ld-i386/tlsgdesc2.d: Updated. * testsuite/ld-i386/tlsgdesc2.s: Change jmp to call via ECX. * testsuite/ld-x86-64/tlsdesc4.d: Updated. * testsuite/ld-x86-64/tlsdesc4.s: Change jmp to call via RCX. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
@@ -745,6 +745,7 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd)
|
||||
ret->tls_get_addr = "__tls_get_addr";
|
||||
ret->relative_r_type = R_X86_64_RELATIVE;
|
||||
ret->relative_r_name = "R_X86_64_RELATIVE";
|
||||
ret->ax_register = "RAX";
|
||||
ret->elf_append_reloc = elf_append_rela;
|
||||
ret->elf_write_addend_in_got = _bfd_elf64_write_addend;
|
||||
}
|
||||
@@ -776,6 +777,7 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd)
|
||||
ret->pointer_r_type = R_386_32;
|
||||
ret->relative_r_type = R_386_RELATIVE;
|
||||
ret->relative_r_name = "R_386_RELATIVE";
|
||||
ret->ax_register = "EAX";
|
||||
ret->elf_append_reloc = elf_append_rel;
|
||||
ret->elf_write_addend = _bfd_elf32_write_addend;
|
||||
ret->elf_write_addend_in_got = _bfd_elf32_write_addend;
|
||||
@@ -3211,15 +3213,14 @@ _bfd_x86_elf_link_report_tls_transition_error
|
||||
enum elf_x86_tls_error_type tls_error)
|
||||
{
|
||||
const char *name;
|
||||
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||
struct elf_x86_link_hash_table *htab
|
||||
= elf_x86_hash_table (info, bed->target_id);
|
||||
|
||||
if (h)
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
const struct elf_backend_data *bed
|
||||
= get_elf_backend_data (abfd);
|
||||
struct elf_x86_link_hash_table *htab
|
||||
= elf_x86_hash_table (info, bed->target_id);
|
||||
if (htab == NULL)
|
||||
name = "*unknown*";
|
||||
else
|
||||
@@ -3265,8 +3266,9 @@ _bfd_x86_elf_link_report_tls_transition_error
|
||||
info->callbacks->einfo
|
||||
/* xgettext:c-format */
|
||||
(_("%pB(%pA+0x%v): relocation %s against `%s' must be used "
|
||||
"in indirect CALL only\n"),
|
||||
abfd, asect, rel->r_offset, from_reloc_name, name);
|
||||
"in indirect CALL with %s register only\n"),
|
||||
abfd, asect, rel->r_offset, from_reloc_name, name,
|
||||
htab->ax_register);
|
||||
break;
|
||||
|
||||
case elf_x86_tls_error_lea:
|
||||
|
||||
@@ -687,6 +687,7 @@ struct elf_x86_link_hash_table
|
||||
const char *dynamic_interpreter;
|
||||
const char *tls_get_addr;
|
||||
const char *relative_r_name;
|
||||
const char *ax_register;
|
||||
void (*elf_append_reloc) (bfd *, asection *, Elf_Internal_Rela *);
|
||||
void (*elf_write_addend) (bfd *, uint64_t, void *);
|
||||
void (*elf_write_addend_in_got) (bfd *, uint64_t, void *);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#name: TLS GDesc->LE transition check (indirect CALL)
|
||||
#as: --32
|
||||
#ld: -melf_i386
|
||||
#error: .*: relocation R_386_TLS_DESC_CALL against `foo' must be used in indirect CALL only
|
||||
#error: .*: relocation R_386_TLS_DESC_CALL against `foo' must be used in indirect CALL with EAX register only
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
.text
|
||||
.globl _start
|
||||
_start:
|
||||
leal foo@tlsdesc(%ebx), %eax
|
||||
jmp *foo@tlscall(%eax)
|
||||
leal foo@tlsdesc(%ebx), %ecx
|
||||
call *foo@tlscall(%ecx)
|
||||
.section .tdata,"awT",@progbits
|
||||
.align 4
|
||||
.type foo, @object
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#name: TLS GDesc->LE transition check (indirect CALL)
|
||||
#as: --64
|
||||
#ld: -melf_x86_64
|
||||
#error: .*: relocation R_X86_64_TLSDESC_CALL against `foo' must be used in indirect CALL only
|
||||
#error: .*: relocation R_X86_64_TLSDESC_CALL against `foo' must be used in indirect CALL with RAX register only
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
.globl _start
|
||||
.type _start,@function
|
||||
_start:
|
||||
leaq foo@tlsdesc(%rip), %rax
|
||||
jmp *foo@tlscall(%rax)
|
||||
leaq foo@tlsdesc(%rip), %rcx
|
||||
call *foo@tlscall(%rcx)
|
||||
.globl foo
|
||||
.section .tdata,"awT",@progbits
|
||||
.align 8
|
||||
|
||||
Reference in New Issue
Block a user