diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-05-28 09:34:10 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-05-28 09:34:28 -0700 |
commit | 1273b2f8ac8778f0c6f0f3b492940e3a5bdd7776 (patch) | |
tree | 235fa6d65ad5972c26832a21c0b23d65793e6c9f /bfd/elf32-i386.c | |
parent | 9d7c4ba5e5b711824bb2cc5de21d28e3fd6de002 (diff) | |
download | gdb-1273b2f8ac8778f0c6f0f3b492940e3a5bdd7776.zip gdb-1273b2f8ac8778f0c6f0f3b492940e3a5bdd7776.tar.gz gdb-1273b2f8ac8778f0c6f0f3b492940e3a5bdd7776.tar.bz2 |
x86: Restore PC16 relocation overflow check
The x86-64 psABI has
---
A program or object file using R_X86_64_8, R_X86_64_16, R_X86_64_PC16
or R_X86_64_PC8 relocations is not conformant to this ABI, these
relocations are only added for documentation purposes.
---
Since x86 PC16 relocations have been used for 16-bit programs in an ELF32
or ELF64 container, PC16 relocation should wrap-around in 16-bit address
space. Revert
commit a7664973b24a242cd9ea17deb5eaf503065fc0bd
Author: Jan Beulich <jbeulich@suse.com>
Date: Mon Apr 26 10:41:35 2021 +0200
x86: correct overflow checking for 16-bit PC-relative relocs
and xfail the related tests. Also revert
commit 50c95a739c91ae70cf8481936611aa1f5397a384
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed May 26 12:13:13 2021 -0700
x86: Propery check PC16 reloc overflow in 16-bit mode instructions
while keeping PR ld/27905 tests for PC16 relocation in 16-bit programs.
bfd/
PR ld/27905
* elf32-i386.c: Don't include "libiberty.h".
(elf_howto_table): Revert commits a7664973b24 and 50c95a739c9.
(elf_i386_rtype_to_howto): Revert commit 50c95a739c9.
(elf_i386_info_to_howto_rel): Likewise.
(elf_i386_tls_transition): Likewise.
(elf_i386_relocate_section): Likewise.
* elf64-x86-64.c (x86_64_elf_howto_table): Revert commits
a7664973b24 and 50c95a739c9.
(elf_x86_64_rtype_to_howto): Revert commit 50c95a739c9.
* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Likewise.
* elfxx-x86.h (elf_x86_obj_tdata): Likewise.
(elf_x86_has_code16): Likewise.
binutils/
PR ld/27905
* readelf.c (decode_x86_feature_2): Revert commit 50c95a739c9.
gas/
PR ld/27905
* config/tc-i386.c (set_code_flag): Revert commit 50c95a739c9.
(set_16bit_gcc_code_flag): Likewise.
(x86_cleanup): Likewise.
* testsuite/gas/i386/code16-2.d: Updated.
* testsuite/gas/i386/x86-64-code16-2.d: Likewise.
include/
PR ld/27905
* elf/common.h (GNU_PROPERTY_X86_FEATURE_2_CODE16): Removed.
ld/
PR ld/27905
* testsuite/ld-i386/pcrel16-2.d: xfail.
* testsuite/ld-x86-64/pcrel16-2.d: Likewise.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r-- | bfd/elf32-i386.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index c68741a..cf7cd07 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -22,7 +22,6 @@ #include "elf-vxworks.h" #include "dwarf2.h" #include "opcode/i386.h" -#include "libiberty.h" /* 386 uses REL relocations instead of RELA. */ #define USE_REL 1 @@ -94,7 +93,7 @@ static reloc_howto_type elf_howto_table[]= HOWTO(R_386_16, 0, 1, 16, false, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_386_16", true, 0xffff, 0xffff, false), - HOWTO(R_386_PC16, 0, 1, 16, true, 0, complain_overflow_signed, + HOWTO(R_386_PC16, 0, 1, 16, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_386_PC16", true, 0xffff, 0xffff, true), HOWTO(R_386_8, 0, 0, 8, false, 0, complain_overflow_bitfield, @@ -176,14 +175,10 @@ static reloc_howto_type elf_howto_table[]= false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false), /* pcrel_offset */ + false) /* pcrel_offset */ #define R_386_vt (R_386_GNU_VTENTRY + 1 - R_386_vt_offset) -/* Use complain_overflow_bitfield on R_386_PC16 for code16. */ - HOWTO(R_386_PC16, 0, 1, 16, true, 0, complain_overflow_bitfield, - bfd_elf_generic_reloc, "R_386_PC16", - true, 0xffff, 0xffff, true) }; #define X86_PCREL_TYPE_P(TYPE) ((TYPE) == R_386_PC32) @@ -374,7 +369,7 @@ elf_i386_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, } static reloc_howto_type * -elf_i386_rtype_to_howto (bfd *abfd, unsigned r_type) +elf_i386_rtype_to_howto (unsigned r_type) { unsigned int indx; @@ -389,11 +384,6 @@ elf_i386_rtype_to_howto (bfd *abfd, unsigned r_type) /* PR 17512: file: 0f67f69d. */ if (elf_howto_table [indx].type != r_type) return NULL; - - /* Use complain_overflow_bitfield on R_386_PC16 for code16. */ - if (r_type == (unsigned int) R_386_PC16 && elf_x86_has_code16 (abfd)) - indx = ARRAY_SIZE (elf_howto_table) - 1; - return &elf_howto_table[indx]; } @@ -404,8 +394,7 @@ elf_i386_info_to_howto_rel (bfd *abfd, { unsigned int r_type = ELF32_R_TYPE (dst->r_info); - if ((cache_ptr->howto = elf_i386_rtype_to_howto (abfd, r_type)) - == NULL) + if ((cache_ptr->howto = elf_i386_rtype_to_howto (r_type)) == NULL) { /* xgettext:c-format */ _bfd_error_handler (_("%pB: unsupported relocation type %#x"), @@ -1153,8 +1142,8 @@ elf_i386_tls_transition (struct bfd_link_info *info, bfd *abfd, reloc_howto_type *from, *to; const char *name; - from = elf_i386_rtype_to_howto (abfd, from_type); - to = elf_i386_rtype_to_howto (abfd, to_type); + from = elf_i386_rtype_to_howto (from_type); + to = elf_i386_rtype_to_howto (to_type); if (h) name = h->root.root.string; @@ -2085,7 +2074,7 @@ elf_i386_relocate_section (bfd *output_bfd, continue; } - howto = elf_i386_rtype_to_howto (input_bfd, r_type); + howto = elf_i386_rtype_to_howto (r_type); if (howto == NULL) return _bfd_unrecognized_reloc (input_bfd, input_section, r_type); |