diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-01-13 05:42:11 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-01-13 05:42:27 -0800 |
commit | 844bf810cf9feebe50772c29d72256ec3c872270 (patch) | |
tree | 8f5b2e5910362329d797430702357726d8763e9a /gas/config/tc-i386.c | |
parent | 5347ed60c50b79958f83963bd7d01da0372c339b (diff) | |
download | binutils-844bf810cf9feebe50772c29d72256ec3c872270.zip binutils-844bf810cf9feebe50772c29d72256ec3c872270.tar.gz binutils-844bf810cf9feebe50772c29d72256ec3c872270.tar.bz2 |
x86: Don't generate GOT_symbol for PLT relocations
Don't generate the _GLOBAL_OFFSET_TABLE_ symbol for PLT relocations
since it isn't needed.
PR gas/27178
* config/tc-i386.c (lex_got::gotrel): Add need_GOT_symbol.
Don't generate GOT_symbol for PLT relocations.
* testsuite/gas/i386/i386.exp: Run PR gas/27178 tests.
* testsuite/gas/i386/no-got.d: New file.
* testsuite/gas/i386/no-got.s: Likewise.
* testsuite/gas/i386/x86-64-no-got.d: Likewise.
* testsuite/gas/i386/x86-64-no-got.s: Likewise.
Diffstat (limited to 'gas/config/tc-i386.c')
-rw-r--r-- | gas/config/tc-i386.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 9a2dfc9..a7d2ff1 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -10018,63 +10018,64 @@ lex_got (enum bfd_reloc_code_real *rel, int len; const enum bfd_reloc_code_real rel[2]; const i386_operand_type types64; + bfd_boolean need_GOT_symbol; } gotrel[] = { #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) { STRING_COMMA_LEN ("SIZE"), { BFD_RELOC_SIZE32, BFD_RELOC_SIZE32 }, - OPERAND_TYPE_IMM32_64 }, + OPERAND_TYPE_IMM32_64, FALSE }, #endif { STRING_COMMA_LEN ("PLTOFF"), { _dummy_first_bfd_reloc_code_real, BFD_RELOC_X86_64_PLTOFF64 }, - OPERAND_TYPE_IMM64 }, + OPERAND_TYPE_IMM64, TRUE }, { STRING_COMMA_LEN ("PLT"), { BFD_RELOC_386_PLT32, BFD_RELOC_X86_64_PLT32 }, - OPERAND_TYPE_IMM32_32S_DISP32 }, + 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 }, + OPERAND_TYPE_IMM64_DISP64, TRUE }, { STRING_COMMA_LEN ("GOTOFF"), { BFD_RELOC_386_GOTOFF, BFD_RELOC_X86_64_GOTOFF64 }, - OPERAND_TYPE_IMM64_DISP64 }, + 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 }, + 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 }, + OPERAND_TYPE_IMM32_32S_DISP32, TRUE }, { STRING_COMMA_LEN ("TLSLDM"), { BFD_RELOC_386_TLS_LDM, _dummy_first_bfd_reloc_code_real }, - OPERAND_TYPE_NONE }, + OPERAND_TYPE_NONE, TRUE }, { STRING_COMMA_LEN ("TLSLD"), { _dummy_first_bfd_reloc_code_real, BFD_RELOC_X86_64_TLSLD }, - OPERAND_TYPE_IMM32_32S_DISP32 }, + 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 }, + 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 }, + 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 }, + 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 }, + 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 }, + OPERAND_TYPE_NONE, TRUE }, { STRING_COMMA_LEN ("INDNTPOFF"),{ BFD_RELOC_386_TLS_IE, _dummy_first_bfd_reloc_code_real }, - OPERAND_TYPE_NONE }, + OPERAND_TYPE_NONE, TRUE }, { STRING_COMMA_LEN ("GOT"), { BFD_RELOC_386_GOT32, BFD_RELOC_X86_64_GOT32 }, - OPERAND_TYPE_IMM32_32S_64_DISP32 }, + 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 }, + 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 }, + OPERAND_TYPE_IMM32_32S_DISP32, TRUE }, }; char *cp; unsigned int j; @@ -10111,7 +10112,7 @@ lex_got (enum bfd_reloc_code_real *rel, *types = gotrel[j].types64; } - if (j != 0 && GOT_symbol == NULL) + if (gotrel[j].need_GOT_symbol && GOT_symbol == NULL) GOT_symbol = symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME); /* The length of the first part of our input line. */ |