diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-05-08 13:42:36 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-05-16 08:07:15 -0700 |
commit | 390b3bd897fee15aafdf8c4ed37d2e78840d9617 (patch) | |
tree | 274f4e7cddbd98ace8651b19bab229f3b70c27be | |
parent | 25070364b0ce33eed46aa5d78ebebbec6accec7e (diff) | |
download | binutils-gdb-390b3bd897fee15aafdf8c4ed37d2e78840d9617.tar.gz |
Add X86 RELAX_PC32/RELAX_PLT32 and R_386_GOTPLT32
-rw-r--r-- | bfd/bfd-in2.h | 7 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 56 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 40 | ||||
-rw-r--r-- | bfd/libbfd.h | 7 | ||||
-rw-r--r-- | bfd/reloc.c | 10 | ||||
-rw-r--r-- | include/elf/i386.h | 3 | ||||
-rw-r--r-- | include/elf/x86-64.h | 8 |
7 files changed, 91 insertions, 40 deletions
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 6f7ae3476a4..ab8bdf8701a 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -3171,6 +3171,9 @@ instruction. */ BFD_RELOC_386_TLS_DESC_CALL, BFD_RELOC_386_TLS_DESC, BFD_RELOC_386_IRELATIVE, + BFD_RELOC_386_GOTPLT32, + BFD_RELOC_386_RELAX_PC32, + BFD_RELOC_386_RELAX_PLT32, /* x86-64/elf relocations */ BFD_RELOC_X86_64_GOT32, @@ -3200,8 +3203,8 @@ instruction. */ BFD_RELOC_X86_64_TLSDESC_CALL, BFD_RELOC_X86_64_TLSDESC, BFD_RELOC_X86_64_IRELATIVE, - BFD_RELOC_X86_64_PC32_BND, - BFD_RELOC_X86_64_PLT32_BND, + BFD_RELOC_X86_64_RELAX_PC32, + BFD_RELOC_X86_64_RELAX_PLT32, /* ns32k relocations */ BFD_RELOC_NS32K_IMM_8, diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index c6ff7463a35..d9399cf66a0 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -146,10 +146,19 @@ static reloc_howto_type elf_howto_table[]= HOWTO(R_386_IRELATIVE, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_386_IRELATIVE", TRUE, 0xffffffff, 0xffffffff, FALSE), + HOWTO(R_386_GOTPLT32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_GOTPLT32", + TRUE, 0xffffffff, 0xffffffff, FALSE), + HOWTO(R_386_RELAX_PC32, 0, 2, 32, TRUE, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_RELAX_PC32", + TRUE, 0xffffffff, 0xffffffff, TRUE), + HOWTO(R_386_RELAX_PLT32, 0, 2, 32, TRUE, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_386_RELAX_PLT32", + TRUE, 0xffffffff, 0xffffffff, TRUE), /* Another gap. */ -#define R_386_irelative (R_386_IRELATIVE + 1 - R_386_tls_offset) -#define R_386_vt_offset (R_386_GNU_VTINHERIT - R_386_irelative) +#define R_386_relax_plt32 (R_386_RELAX_PLT32 + 1 - R_386_tls_offset) +#define R_386_vt_offset (R_386_GNU_VTINHERIT - R_386_relax_plt32) /* GNU extension to record C++ vtable hierarchy. */ HOWTO (R_386_GNU_VTINHERIT, /* type */ @@ -332,6 +341,18 @@ elf_i386_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, TRACE ("BFD_RELOC_386_IRELATIVE"); return &elf_howto_table[R_386_IRELATIVE - R_386_tls_offset]; + case BFD_RELOC_386_GOTPLT32: + TRACE ("BFD_RELOC_386_GOTPLT32"); + return &elf_howto_table[R_386_GOTPLT32 - R_386_tls_offset]; + + case BFD_RELOC_386_RELAX_PC32: + TRACE ("BFD_RELOC_386_RELAX_PC32"); + return &elf_howto_table[R_386_RELAX_PC32 - R_386_tls_offset]; + + case BFD_RELOC_386_RELAX_PLT32: + TRACE ("BFD_RELOC_386_RELAX_PLT32"); + return &elf_howto_table[R_386_RELAX_PLT32 - R_386_tls_offset]; + case BFD_RELOC_VTABLE_INHERIT: TRACE ("BFD_RELOC_VTABLE_INHERIT"); return &elf_howto_table[R_386_GNU_VTINHERIT - R_386_vt_offset]; @@ -371,9 +392,9 @@ elf_i386_rtype_to_howto (bfd *abfd, unsigned r_type) && ((indx = r_type - R_386_ext_offset) - R_386_standard >= R_386_ext - R_386_standard) && ((indx = r_type - R_386_tls_offset) - R_386_ext - >= R_386_irelative - R_386_ext) - && ((indx = r_type - R_386_vt_offset) - R_386_irelative - >= R_386_vt - R_386_irelative)) + >= R_386_relax_plt32 - R_386_ext) + && ((indx = r_type - R_386_vt_offset) - R_386_relax_plt32 + >= R_386_vt - R_386_relax_plt32)) { (*_bfd_error_handler) (_("%B: invalid relocation type %d"), abfd, (int) r_type); @@ -1565,6 +1586,8 @@ elf_i386_check_relocs (bfd *abfd, case R_386_32: case R_386_PC32: case R_386_PLT32: + case R_386_RELAX_PC32: + case R_386_RELAX_PLT32: case R_386_GOT32: if (htab->elf.dynobj == NULL) htab->elf.dynobj = abfd; @@ -1591,6 +1614,7 @@ elf_i386_check_relocs (bfd *abfd, goto create_got; case R_386_PLT32: + case R_386_RELAX_PLT32: /* This symbol requires a procedure linkage table entry. We actually build the entry in adjust_dynamic_symbol, because this might be a case of linking PIC code which is @@ -1741,6 +1765,7 @@ elf_i386_check_relocs (bfd *abfd, case R_386_32: case R_386_PC32: + case R_386_RELAX_PC32: if (h != NULL && info->executable) { /* If this reloc is in a read-only section, we might @@ -1754,7 +1779,7 @@ elf_i386_check_relocs (bfd *abfd, /* We may need a .plt entry if the function this reloc refers to is in a shared lib. */ h->plt.refcount += 1; - if (r_type != R_386_PC32) + if (r_type != R_386_PC32 && r_type != R_386_RELAX_PC32) h->pointer_equality_needed = 1; } @@ -1783,7 +1808,7 @@ do_size: symbol. */ if ((info->shared && (sec->flags & SEC_ALLOC) != 0 - && (r_type != R_386_PC32 + && ((r_type != R_386_RELAX_PC32 && r_type != R_386_PC32) || (h != NULL && (! SYMBOLIC_BIND (info, h) || h->root.type == bfd_link_hash_defweak @@ -1857,7 +1882,9 @@ do_size: p->count += 1; /* Count size relocation as PC-relative relocation. */ - if (r_type == R_386_PC32 || size_reloc) + if (r_type == R_386_PC32 + || r_type == R_386_RELAX_PC32 + || size_reloc) p->pc_count += 1; } break; @@ -2060,6 +2087,7 @@ elf_i386_gc_sweep_hook (bfd *abfd, case R_386_32: case R_386_PC32: + case R_386_RELAX_PC32: case R_386_SIZE32: if (info->shared && (h == NULL || h->type != STT_GNU_IFUNC)) @@ -2067,6 +2095,7 @@ elf_i386_gc_sweep_hook (bfd *abfd, /* Fall through */ case R_386_PLT32: + case R_386_RELAX_PLT32: if (h != NULL) { if (h->plt.refcount > 0) @@ -3359,7 +3388,7 @@ elf_i386_relocate_section (bfd *output_bfd, && ((indx = r_type - R_386_ext_offset) - R_386_standard >= R_386_ext - R_386_standard) && ((indx = r_type - R_386_tls_offset) - R_386_ext - >= R_386_irelative - R_386_ext)) + >= R_386_relax_plt32 - R_386_ext)) { (*_bfd_error_handler) (_("%B: unrecognized relocation (0x%x) in section `%A'"), @@ -3581,6 +3610,8 @@ elf_i386_relocate_section (bfd *output_bfd, /* FALLTHROUGH */ case R_386_PC32: case R_386_PLT32: + case R_386_RELAX_PC32: + case R_386_RELAX_PLT32: goto do_relocation; case R_386_GOT32: @@ -3816,6 +3847,7 @@ elf_i386_relocate_section (bfd *output_bfd, break; case R_386_PLT32: + case R_386_RELAX_PLT32: /* Relocation is to the entry for this symbol in the procedure linkage table. */ @@ -3859,6 +3891,7 @@ elf_i386_relocate_section (bfd *output_bfd, case R_386_32: case R_386_PC32: + case R_386_RELAX_PC32: if ((input_section->flags & SEC_ALLOC) == 0 || is_vxworks_tls) break; @@ -3867,7 +3900,9 @@ elf_i386_relocate_section (bfd *output_bfd, && (h == NULL || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) - && ((r_type != R_386_PC32 && r_type != R_386_SIZE32) + && ((r_type != R_386_PC32 + && r_type != R_386_RELAX_PC32 + && r_type != R_386_SIZE32) || !SYMBOL_CALLS_LOCAL (info, h))) || (ELIMINATE_COPY_RELOCS && !info->shared @@ -3905,6 +3940,7 @@ elf_i386_relocate_section (bfd *output_bfd, else if (h != NULL && h->dynindx != -1 && (r_type == R_386_PC32 + || r_type == R_386_RELAX_PC32 || !info->shared || !SYMBOLIC_BIND (info, h) || !h->def_regular)) diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 01df2308ea4..ac726cf541b 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -170,18 +170,18 @@ static reloc_howto_type x86_64_elf_howto_table[] = HOWTO(R_X86_64_RELATIVE64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_X86_64_RELATIVE64", FALSE, MINUS_ONE, MINUS_ONE, FALSE), - HOWTO(R_X86_64_PC32_BND, 0, 2, 32, TRUE, 0, complain_overflow_signed, - bfd_elf_generic_reloc, "R_X86_64_PC32_BND", FALSE, 0xffffffff, 0xffffffff, + HOWTO(R_X86_64_RELAX_PC32, 0, 2, 32, TRUE, 0, complain_overflow_signed, + bfd_elf_generic_reloc, "R_X86_64_RELAX_PC32", FALSE, 0xffffffff, 0xffffffff, TRUE), - HOWTO(R_X86_64_PLT32_BND, 0, 2, 32, TRUE, 0, complain_overflow_signed, - bfd_elf_generic_reloc, "R_X86_64_PLT32_BND", FALSE, 0xffffffff, 0xffffffff, + HOWTO(R_X86_64_RELAX_PLT32, 0, 2, 32, TRUE, 0, complain_overflow_signed, + bfd_elf_generic_reloc, "R_X86_64_RELAX_PLT32", FALSE, 0xffffffff, 0xffffffff, TRUE), /* We have a gap in the reloc numbers here. R_X86_64_standard counts the number up to this point, and R_X86_64_vt_offset is the value to subtract from a reloc type of R_X86_64_GNU_VT* to form an index into this table. */ -#define R_X86_64_standard (R_X86_64_PLT32_BND + 1) +#define R_X86_64_standard (R_X86_64_RELAX_PLT32 + 1) #define R_X86_64_vt_offset (R_X86_64_GNU_VTINHERIT - R_X86_64_standard) /* GNU extension to record C++ vtable hierarchy. */ @@ -203,7 +203,7 @@ static reloc_howto_type x86_64_elf_howto_table[] = ( ((TYPE) == R_X86_64_PC8) \ || ((TYPE) == R_X86_64_PC16) \ || ((TYPE) == R_X86_64_PC32) \ - || ((TYPE) == R_X86_64_PC32_BND) \ + || ((TYPE) == R_X86_64_RELAX_PC32) \ || ((TYPE) == R_X86_64_PC64)) /* Map BFD relocs to the x86_64 elf relocs. */ @@ -253,8 +253,8 @@ static const struct elf_reloc_map x86_64_reloc_map[] = { BFD_RELOC_X86_64_TLSDESC_CALL, R_X86_64_TLSDESC_CALL, }, { BFD_RELOC_X86_64_TLSDESC, R_X86_64_TLSDESC, }, { BFD_RELOC_X86_64_IRELATIVE, R_X86_64_IRELATIVE, }, - { BFD_RELOC_X86_64_PC32_BND, R_X86_64_PC32_BND,}, - { BFD_RELOC_X86_64_PLT32_BND, R_X86_64_PLT32_BND,}, + { BFD_RELOC_X86_64_RELAX_PC32, R_X86_64_RELAX_PC32,}, + { BFD_RELOC_X86_64_RELAX_PLT32, R_X86_64_RELAX_PLT32,}, { BFD_RELOC_VTABLE_INHERIT, R_X86_64_GNU_VTINHERIT, }, { BFD_RELOC_VTABLE_ENTRY, R_X86_64_GNU_VTENTRY, }, }; @@ -1664,8 +1664,8 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, default: break; - case R_X86_64_PC32_BND: - case R_X86_64_PLT32_BND: + case R_X86_64_RELAX_PC32: + case R_X86_64_RELAX_PLT32: case R_X86_64_PC32: case R_X86_64_PLT32: case R_X86_64_32: @@ -1865,7 +1865,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, break; case R_X86_64_PLT32: - case R_X86_64_PLT32_BND: + case R_X86_64_RELAX_PLT32: /* This symbol requires a procedure linkage table entry. We actually build the entry in adjust_dynamic_symbol, because this might be a case of linking PIC code which is @@ -1926,7 +1926,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_X86_64_PC8: case R_X86_64_PC16: case R_X86_64_PC32: - case R_X86_64_PC32_BND: + case R_X86_64_RELAX_PC32: case R_X86_64_PC64: case R_X86_64_64: pointer: @@ -1944,7 +1944,7 @@ pointer: refers to is in a shared lib. */ h->plt.refcount += 1; if (r_type != R_X86_64_PC32 - && r_type != R_X86_64_PC32_BND + && r_type != R_X86_64_RELAX_PC32 && r_type != R_X86_64_PC64) h->pointer_equality_needed = 1; } @@ -2264,7 +2264,7 @@ elf_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, case R_X86_64_PC8: case R_X86_64_PC16: case R_X86_64_PC32: - case R_X86_64_PC32_BND: + case R_X86_64_RELAX_PC32: case R_X86_64_PC64: case R_X86_64_SIZE32: case R_X86_64_SIZE64: @@ -2274,7 +2274,7 @@ elf_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, /* Fall thru */ case R_X86_64_PLT32: - case R_X86_64_PLT32_BND: + case R_X86_64_RELAX_PLT32: case R_X86_64_PLTOFF64: if (h != NULL) { @@ -3772,10 +3772,10 @@ elf_x86_64_relocate_section (bfd *output_bfd, } /* FALLTHROUGH */ case R_X86_64_PC32: - case R_X86_64_PC32_BND: + case R_X86_64_RELAX_PC32: case R_X86_64_PC64: case R_X86_64_PLT32: - case R_X86_64_PLT32_BND: + case R_X86_64_RELAX_PLT32: goto do_relocation; case R_X86_64_GOTPCREL: @@ -4057,7 +4057,7 @@ elf_x86_64_relocate_section (bfd *output_bfd, break; case R_X86_64_PLT32: - case R_X86_64_PLT32_BND: + case R_X86_64_RELAX_PLT32: /* Relocation is to the entry for this symbol in the procedure linkage table. */ @@ -4111,7 +4111,7 @@ elf_x86_64_relocate_section (bfd *output_bfd, case R_X86_64_PC8: case R_X86_64_PC16: case R_X86_64_PC32: - case R_X86_64_PC32_BND: + case R_X86_64_RELAX_PC32: /* Don't complain about -fPIC if the symbol is undefined when building executable. */ if (info->shared @@ -4124,7 +4124,7 @@ elf_x86_64_relocate_section (bfd *output_bfd, bfd_boolean fail = FALSE; bfd_boolean branch = ((r_type == R_X86_64_PC32 - || r_type == R_X86_64_PC32_BND) + || r_type == R_X86_64_RELAX_PC32) && is_32bit_relative_branch (contents, rel->r_offset)); if (SYMBOL_REFERENCES_LOCAL (info, h)) diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 14600aa1aa0..185e86e344a 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -1292,6 +1292,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_386_TLS_DESC_CALL", "BFD_RELOC_386_TLS_DESC", "BFD_RELOC_386_IRELATIVE", + "BFD_RELOC_386_GOTPLT32", + "BFD_RELOC_386_RELAX_PC32", + "BFD_RELOC_386_RELAX_PLT32", "BFD_RELOC_X86_64_GOT32", "BFD_RELOC_X86_64_PLT32", "BFD_RELOC_X86_64_COPY", @@ -1319,8 +1322,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_X86_64_TLSDESC_CALL", "BFD_RELOC_X86_64_TLSDESC", "BFD_RELOC_X86_64_IRELATIVE", - "BFD_RELOC_X86_64_PC32_BND", - "BFD_RELOC_X86_64_PLT32_BND", + "BFD_RELOC_X86_64_RELAX_PC32", + "BFD_RELOC_X86_64_RELAX_PLT32", "BFD_RELOC_NS32K_IMM_8", "BFD_RELOC_NS32K_IMM_16", "BFD_RELOC_NS32K_IMM_32", diff --git a/bfd/reloc.c b/bfd/reloc.c index 8c4a88a33e2..4f2974d8287 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -2676,6 +2676,12 @@ ENUMX BFD_RELOC_386_TLS_DESC ENUMX BFD_RELOC_386_IRELATIVE +ENUMX + BFD_RELOC_386_GOTPLT32 +ENUMX + BFD_RELOC_386_RELAX_PC32 +ENUMX + BFD_RELOC_386_RELAX_PLT32 ENUMDOC i386/elf relocations @@ -2734,9 +2740,9 @@ ENUMX ENUMX BFD_RELOC_X86_64_IRELATIVE ENUMX - BFD_RELOC_X86_64_PC32_BND + BFD_RELOC_X86_64_RELAX_PC32 ENUMX - BFD_RELOC_X86_64_PLT32_BND + BFD_RELOC_X86_64_RELAX_PLT32 ENUMDOC x86-64/elf relocations diff --git a/include/elf/i386.h b/include/elf/i386.h index 08c94556a30..06f51ac4cd4 100644 --- a/include/elf/i386.h +++ b/include/elf/i386.h @@ -66,6 +66,9 @@ START_RELOC_NUMBERS (elf_i386_reloc_type) RELOC_NUMBER (R_386_TLS_DESC_CALL,40) RELOC_NUMBER (R_386_TLS_DESC, 41) RELOC_NUMBER (R_386_IRELATIVE, 42) /* Adjust indirectly by program base */ + RELOC_NUMBER (R_386_GOTPLT32, 43) /* 32 bit GOT/GOTPLT entry */ + RELOC_NUMBER (R_386_RELAX_PC32, 44) /* Relaxable PC relative 32 bit signed */ + RELOC_NUMBER (R_386_RELAX_PLT32, 45) /* Relaxable 32 bit PLT address */ /* Used by Intel. */ RELOC_NUMBER (R_386_USED_BY_INTEL_200, 200) diff --git a/include/elf/x86-64.h b/include/elf/x86-64.h index f18ec662db3..23c3f3105f9 100644 --- a/include/elf/x86-64.h +++ b/include/elf/x86-64.h @@ -72,10 +72,10 @@ START_RELOC_NUMBERS (elf_x86_64_reloc_type) RELOC_NUMBER (R_X86_64_TLSDESC, 36) /* 2x64-bit TLS descriptor. */ RELOC_NUMBER (R_X86_64_IRELATIVE, 37) /* Adjust indirectly by program base */ RELOC_NUMBER (R_X86_64_RELATIVE64, 38) /* 64bit adjust by program base */ - RELOC_NUMBER (R_X86_64_PC32_BND, 39) /* PC relative 32 bit - signed with BND prefix */ - RELOC_NUMBER (R_X86_64_PLT32_BND, 40) /* 32 bit PLT address with - BND prefix */ + RELOC_NUMBER (R_X86_64_RELAX_PC32, 39) /* Relaxable PC relative 32 + bit signed */ + RELOC_NUMBER (R_X86_64_RELAX_PLT32, 40) /* Relaxable 32 bit PLT + address */ RELOC_NUMBER (R_X86_64_GNU_VTINHERIT, 250) /* GNU C++ hack */ RELOC_NUMBER (R_X86_64_GNU_VTENTRY, 251) /* GNU C++ hack */ END_RELOC_NUMBERS (R_X86_64_max) |