mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-02-23 13:21:43 +08:00
x86: Report invalid TLS relocation name
Get TLS relocation name from its lex_got entry when reporting invalid instructions with TLS relocations. PR gas/28595 * config/tc-i386.c (gotrel): Moved from ... (lex_got): There. (i386_assemble): Get invalid TLS relocation name from its lex_got entry when reporting TLS relocation error. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
parent
d660d20c0c
commit
24e3920d1d
@ -1293,6 +1293,94 @@ static htab_t op_hash;
|
||||
|
||||
/* Hash table for register lookup. */
|
||||
static htab_t reg_hash;
|
||||
|
||||
static const struct
|
||||
{
|
||||
const char *str;
|
||||
int len;
|
||||
const enum bfd_reloc_code_real rel[2];
|
||||
const i386_operand_type types64;
|
||||
bool need_GOT_symbol;
|
||||
}
|
||||
gotrel[] =
|
||||
{
|
||||
#define OPERAND_TYPE_IMM32_32S_DISP32 { .bitfield = \
|
||||
{ .imm32 = 1, .imm32s = 1, .disp32 = 1 } }
|
||||
#define OPERAND_TYPE_IMM32_32S_64_DISP32 { .bitfield = \
|
||||
{ .imm32 = 1, .imm32s = 1, .imm64 = 1, .disp32 = 1 } }
|
||||
#define OPERAND_TYPE_IMM32_32S_64_DISP32_64 { .bitfield = \
|
||||
{ .imm32 = 1, .imm32s = 1, .imm64 = 1, .disp32 = 1, .disp64 = 1 } }
|
||||
#define OPERAND_TYPE_IMM64_DISP64 { .bitfield = \
|
||||
{ .imm64 = 1, .disp64 = 1 } }
|
||||
|
||||
#ifndef TE_PE
|
||||
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
|
||||
{ STRING_COMMA_LEN ("SIZE"), { BFD_RELOC_SIZE32,
|
||||
BFD_RELOC_SIZE32 },
|
||||
{ .bitfield = { .imm32 = 1, .imm64 = 1 } }, false },
|
||||
#endif
|
||||
{ STRING_COMMA_LEN ("PLTOFF"), { _dummy_first_bfd_reloc_code_real,
|
||||
BFD_RELOC_X86_64_PLTOFF64 },
|
||||
{ .bitfield = { .imm64 = 1 } }, true },
|
||||
{ STRING_COMMA_LEN ("PLT"), { BFD_RELOC_386_PLT32,
|
||||
BFD_RELOC_X86_64_PLT32 },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, false },
|
||||
{ STRING_COMMA_LEN ("GOTPLT"), { _dummy_first_bfd_reloc_code_real,
|
||||
BFD_RELOC_X86_64_GOTPLT64 },
|
||||
OPERAND_TYPE_IMM64_DISP64, true },
|
||||
{ STRING_COMMA_LEN ("GOTOFF"), { BFD_RELOC_386_GOTOFF,
|
||||
BFD_RELOC_X86_64_GOTOFF64 },
|
||||
OPERAND_TYPE_IMM64_DISP64, true },
|
||||
{ STRING_COMMA_LEN ("GOTPCREL"), { _dummy_first_bfd_reloc_code_real,
|
||||
BFD_RELOC_X86_64_GOTPCREL },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TLSGD"), { BFD_RELOC_386_TLS_GD,
|
||||
BFD_RELOC_X86_64_TLSGD },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TLSLDM"), { BFD_RELOC_386_TLS_LDM,
|
||||
_dummy_first_bfd_reloc_code_real },
|
||||
OPERAND_TYPE_NONE, true },
|
||||
{ STRING_COMMA_LEN ("TLSLD"), { _dummy_first_bfd_reloc_code_real,
|
||||
BFD_RELOC_X86_64_TLSLD },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("GOTTPOFF"), { BFD_RELOC_386_TLS_IE_32,
|
||||
BFD_RELOC_X86_64_GOTTPOFF },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TPOFF"), { BFD_RELOC_386_TLS_LE_32,
|
||||
BFD_RELOC_X86_64_TPOFF32 },
|
||||
OPERAND_TYPE_IMM32_32S_64_DISP32_64, true },
|
||||
{ STRING_COMMA_LEN ("NTPOFF"), { BFD_RELOC_386_TLS_LE,
|
||||
_dummy_first_bfd_reloc_code_real },
|
||||
OPERAND_TYPE_NONE, true },
|
||||
{ STRING_COMMA_LEN ("DTPOFF"), { BFD_RELOC_386_TLS_LDO_32,
|
||||
BFD_RELOC_X86_64_DTPOFF32 },
|
||||
OPERAND_TYPE_IMM32_32S_64_DISP32_64, true },
|
||||
{ STRING_COMMA_LEN ("GOTNTPOFF"),{ BFD_RELOC_386_TLS_GOTIE,
|
||||
_dummy_first_bfd_reloc_code_real },
|
||||
OPERAND_TYPE_NONE, true },
|
||||
{ STRING_COMMA_LEN ("INDNTPOFF"),{ BFD_RELOC_386_TLS_IE,
|
||||
_dummy_first_bfd_reloc_code_real },
|
||||
OPERAND_TYPE_NONE, true },
|
||||
{ STRING_COMMA_LEN ("GOT"), { BFD_RELOC_386_GOT32,
|
||||
BFD_RELOC_X86_64_GOT32 },
|
||||
OPERAND_TYPE_IMM32_32S_64_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TLSDESC"), { BFD_RELOC_386_TLS_GOTDESC,
|
||||
BFD_RELOC_X86_64_GOTPC32_TLSDESC },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TLSCALL"), { BFD_RELOC_386_TLS_DESC_CALL,
|
||||
BFD_RELOC_X86_64_TLSDESC_CALL },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
#else /* TE_PE */
|
||||
{ STRING_COMMA_LEN ("SECREL32"), { BFD_RELOC_32_SECREL,
|
||||
BFD_RELOC_32_SECREL },
|
||||
OPERAND_TYPE_IMM32_32S_64_DISP32_64, false },
|
||||
#endif
|
||||
|
||||
#undef OPERAND_TYPE_IMM32_32S_DISP32
|
||||
#undef OPERAND_TYPE_IMM32_32S_64_DISP32
|
||||
#undef OPERAND_TYPE_IMM32_32S_64_DISP32_64
|
||||
#undef OPERAND_TYPE_IMM64_DISP64
|
||||
};
|
||||
|
||||
/* Various efficient no-op patterns for aligning code labels.
|
||||
Note: Don't try to assemble the instructions in the comments.
|
||||
@ -6586,8 +6674,16 @@ i386_assemble (char *line)
|
||||
case BFD_RELOC_X86_64_GOTTPOFF:
|
||||
case BFD_RELOC_386_TLS_GOTIE:
|
||||
case BFD_RELOC_X86_64_TLSLD:
|
||||
as_bad (_("TLS relocation cannot be used with `%s'"), insn_name (&i.tm));
|
||||
return;
|
||||
for (unsigned int k = 0; k < ARRAY_SIZE (gotrel); k++)
|
||||
{
|
||||
if (gotrel[k].rel[object_64bit] == i.reloc[j])
|
||||
{
|
||||
as_bad (_("%s relocation cannot be used with `%s'"),
|
||||
gotrel[k].str, insn_name (&i.tm));
|
||||
return;
|
||||
}
|
||||
}
|
||||
abort ();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -12326,95 +12422,6 @@ lex_got (enum bfd_reloc_code_real *rel,
|
||||
we don't yet know the operand size (this will be set by insn
|
||||
matching). Hence we record the word32 relocation here,
|
||||
and adjust the reloc according to the real size in reloc(). */
|
||||
static const struct
|
||||
{
|
||||
const char *str;
|
||||
int len;
|
||||
const enum bfd_reloc_code_real rel[2];
|
||||
const i386_operand_type types64;
|
||||
bool need_GOT_symbol;
|
||||
}
|
||||
gotrel[] =
|
||||
{
|
||||
|
||||
#define OPERAND_TYPE_IMM32_32S_DISP32 { .bitfield = \
|
||||
{ .imm32 = 1, .imm32s = 1, .disp32 = 1 } }
|
||||
#define OPERAND_TYPE_IMM32_32S_64_DISP32 { .bitfield = \
|
||||
{ .imm32 = 1, .imm32s = 1, .imm64 = 1, .disp32 = 1 } }
|
||||
#define OPERAND_TYPE_IMM32_32S_64_DISP32_64 { .bitfield = \
|
||||
{ .imm32 = 1, .imm32s = 1, .imm64 = 1, .disp32 = 1, .disp64 = 1 } }
|
||||
#define OPERAND_TYPE_IMM64_DISP64 { .bitfield = \
|
||||
{ .imm64 = 1, .disp64 = 1 } }
|
||||
|
||||
#ifndef TE_PE
|
||||
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
|
||||
{ STRING_COMMA_LEN ("SIZE"), { BFD_RELOC_SIZE32,
|
||||
BFD_RELOC_SIZE32 },
|
||||
{ .bitfield = { .imm32 = 1, .imm64 = 1 } }, false },
|
||||
#endif
|
||||
{ STRING_COMMA_LEN ("PLTOFF"), { _dummy_first_bfd_reloc_code_real,
|
||||
BFD_RELOC_X86_64_PLTOFF64 },
|
||||
{ .bitfield = { .imm64 = 1 } }, true },
|
||||
{ STRING_COMMA_LEN ("PLT"), { BFD_RELOC_386_PLT32,
|
||||
BFD_RELOC_X86_64_PLT32 },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, false },
|
||||
{ STRING_COMMA_LEN ("GOTPLT"), { _dummy_first_bfd_reloc_code_real,
|
||||
BFD_RELOC_X86_64_GOTPLT64 },
|
||||
OPERAND_TYPE_IMM64_DISP64, true },
|
||||
{ STRING_COMMA_LEN ("GOTOFF"), { BFD_RELOC_386_GOTOFF,
|
||||
BFD_RELOC_X86_64_GOTOFF64 },
|
||||
OPERAND_TYPE_IMM64_DISP64, true },
|
||||
{ STRING_COMMA_LEN ("GOTPCREL"), { _dummy_first_bfd_reloc_code_real,
|
||||
BFD_RELOC_X86_64_GOTPCREL },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TLSGD"), { BFD_RELOC_386_TLS_GD,
|
||||
BFD_RELOC_X86_64_TLSGD },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TLSLDM"), { BFD_RELOC_386_TLS_LDM,
|
||||
_dummy_first_bfd_reloc_code_real },
|
||||
OPERAND_TYPE_NONE, true },
|
||||
{ STRING_COMMA_LEN ("TLSLD"), { _dummy_first_bfd_reloc_code_real,
|
||||
BFD_RELOC_X86_64_TLSLD },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("GOTTPOFF"), { BFD_RELOC_386_TLS_IE_32,
|
||||
BFD_RELOC_X86_64_GOTTPOFF },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TPOFF"), { BFD_RELOC_386_TLS_LE_32,
|
||||
BFD_RELOC_X86_64_TPOFF32 },
|
||||
OPERAND_TYPE_IMM32_32S_64_DISP32_64, true },
|
||||
{ STRING_COMMA_LEN ("NTPOFF"), { BFD_RELOC_386_TLS_LE,
|
||||
_dummy_first_bfd_reloc_code_real },
|
||||
OPERAND_TYPE_NONE, true },
|
||||
{ STRING_COMMA_LEN ("DTPOFF"), { BFD_RELOC_386_TLS_LDO_32,
|
||||
BFD_RELOC_X86_64_DTPOFF32 },
|
||||
OPERAND_TYPE_IMM32_32S_64_DISP32_64, true },
|
||||
{ STRING_COMMA_LEN ("GOTNTPOFF"),{ BFD_RELOC_386_TLS_GOTIE,
|
||||
_dummy_first_bfd_reloc_code_real },
|
||||
OPERAND_TYPE_NONE, true },
|
||||
{ STRING_COMMA_LEN ("INDNTPOFF"),{ BFD_RELOC_386_TLS_IE,
|
||||
_dummy_first_bfd_reloc_code_real },
|
||||
OPERAND_TYPE_NONE, true },
|
||||
{ STRING_COMMA_LEN ("GOT"), { BFD_RELOC_386_GOT32,
|
||||
BFD_RELOC_X86_64_GOT32 },
|
||||
OPERAND_TYPE_IMM32_32S_64_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TLSDESC"), { BFD_RELOC_386_TLS_GOTDESC,
|
||||
BFD_RELOC_X86_64_GOTPC32_TLSDESC },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
{ STRING_COMMA_LEN ("TLSCALL"), { BFD_RELOC_386_TLS_DESC_CALL,
|
||||
BFD_RELOC_X86_64_TLSDESC_CALL },
|
||||
OPERAND_TYPE_IMM32_32S_DISP32, true },
|
||||
#else /* TE_PE */
|
||||
{ STRING_COMMA_LEN ("SECREL32"), { BFD_RELOC_32_SECREL,
|
||||
BFD_RELOC_32_SECREL },
|
||||
OPERAND_TYPE_IMM32_32S_64_DISP32_64, false },
|
||||
#endif
|
||||
|
||||
#undef OPERAND_TYPE_IMM32_32S_DISP32
|
||||
#undef OPERAND_TYPE_IMM32_32S_64_DISP32
|
||||
#undef OPERAND_TYPE_IMM32_32S_64_DISP32_64
|
||||
#undef OPERAND_TYPE_IMM64_DISP64
|
||||
|
||||
};
|
||||
char *cp;
|
||||
unsigned int j;
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
.*: Assembler messages:
|
||||
.*:3: Error: .* `kmovd'
|
||||
.*:3: Error: GOTNTPOFF relocation cannot be used with `kmovd'
|
||||
|
@ -1,3 +1,3 @@
|
||||
.*: Assembler messages:
|
||||
.*:3: Error: .* `kmovq'
|
||||
.*:4: Error: .* `kmovq'
|
||||
.*:3: Error: GOTTPOFF relocation cannot be used with `kmovq'
|
||||
.*:4: Error: TLSLD relocation cannot be used with `kmovq'
|
||||
|
Loading…
Reference in New Issue
Block a user