GNU Binutils with patches for OS216
Révision | c337a1627c7e0edf6d46e66dee513c56975d0625 (tree) |
---|---|
l'heure | 2016-04-29 20:31:54 |
Auteur | H.J. Lu <hjl.tools@gmai...> |
Commiter | H.J. Lu |
i386: Don't relocate section when check_relocs failed
No need to relocate section when check_relocs failed.
* elf32-i386.c (check_relocs_failed): New.
(elf_i386_check_relocs): Set check_relocs_failed on error.
(elf_i386_relocate_section): Skip if check_relocs failed.
@@ -1,5 +1,11 @@ | ||
1 | 1 | 2016-04-29 H.J. Lu <hongjiu.lu@intel.com> |
2 | 2 | |
3 | + * elf32-i386.c (check_relocs_failed): New. | |
4 | + (elf_i386_check_relocs): Set check_relocs_failed on error. | |
5 | + (elf_i386_relocate_section): Skip if check_relocs failed. | |
6 | + | |
7 | +2016-04-29 H.J. Lu <hongjiu.lu@intel.com> | |
8 | + | |
3 | 9 | * elf64-x86-64.c (elf_x86_64_check_relocs): Set |
4 | 10 | check_relocs_failed on error. |
5 | 11 |
@@ -1506,7 +1506,8 @@ elf_i386_tls_transition (struct bfd_link_info *info, bfd *abfd, | ||
1506 | 1506 | |
1507 | 1507 | /* Rename some of the generic section flags to better document how they |
1508 | 1508 | are used here. */ |
1509 | -#define need_convert_load sec_flg0 | |
1509 | +#define need_convert_load sec_flg0 | |
1510 | +#define check_relocs_failed sec_flg1 | |
1510 | 1511 | |
1511 | 1512 | /* Look through the relocs for a section during the first phase, and |
1512 | 1513 | calculate needed space in the global offset table, procedure linkage |
@@ -1533,7 +1534,10 @@ elf_i386_check_relocs (bfd *abfd, | ||
1533 | 1534 | |
1534 | 1535 | htab = elf_i386_hash_table (info); |
1535 | 1536 | if (htab == NULL) |
1536 | - return FALSE; | |
1537 | + { | |
1538 | + sec->check_relocs_failed = 1; | |
1539 | + return FALSE; | |
1540 | + } | |
1537 | 1541 | |
1538 | 1542 | use_plt_got = (!get_elf_i386_backend_data (abfd)->is_vxworks |
1539 | 1543 | && (get_elf_i386_backend_data (abfd) |
@@ -1563,7 +1567,7 @@ elf_i386_check_relocs (bfd *abfd, | ||
1563 | 1567 | (*_bfd_error_handler) (_("%B: bad symbol index: %d"), |
1564 | 1568 | abfd, |
1565 | 1569 | r_symndx); |
1566 | - return FALSE; | |
1570 | + goto error_return; | |
1567 | 1571 | } |
1568 | 1572 | |
1569 | 1573 | if (r_symndx < symtab_hdr->sh_info) |
@@ -1572,14 +1576,14 @@ elf_i386_check_relocs (bfd *abfd, | ||
1572 | 1576 | isym = bfd_sym_from_r_symndx (&htab->sym_cache, |
1573 | 1577 | abfd, r_symndx); |
1574 | 1578 | if (isym == NULL) |
1575 | - return FALSE; | |
1579 | + goto error_return; | |
1576 | 1580 | |
1577 | 1581 | /* Check relocation against local STT_GNU_IFUNC symbol. */ |
1578 | 1582 | if (ELF32_ST_TYPE (isym->st_info) == STT_GNU_IFUNC) |
1579 | 1583 | { |
1580 | 1584 | h = elf_i386_get_local_sym_hash (htab, abfd, rel, TRUE); |
1581 | 1585 | if (h == NULL) |
1582 | - return FALSE; | |
1586 | + goto error_return; | |
1583 | 1587 | |
1584 | 1588 | /* Fake a STT_GNU_IFUNC symbol. */ |
1585 | 1589 | h->type = STT_GNU_IFUNC; |
@@ -1621,7 +1625,7 @@ elf_i386_check_relocs (bfd *abfd, | ||
1621 | 1625 | if (h->type == STT_GNU_IFUNC |
1622 | 1626 | && !_bfd_elf_create_ifunc_sections (htab->elf.dynobj, |
1623 | 1627 | info)) |
1624 | - return FALSE; | |
1628 | + goto error_return; | |
1625 | 1629 | break; |
1626 | 1630 | } |
1627 | 1631 |
@@ -1638,7 +1642,7 @@ elf_i386_check_relocs (bfd *abfd, | ||
1638 | 1642 | symtab_hdr, sym_hashes, |
1639 | 1643 | &r_type, GOT_UNKNOWN, |
1640 | 1644 | rel, rel_end, h, r_symndx)) |
1641 | - return FALSE; | |
1645 | + goto error_return; | |
1642 | 1646 | |
1643 | 1647 | switch (r_type) |
1644 | 1648 | { |
@@ -1729,7 +1733,7 @@ elf_i386_check_relocs (bfd *abfd, | ||
1729 | 1733 | local_got_refcounts = (bfd_signed_vma *) |
1730 | 1734 | bfd_zalloc (abfd, size); |
1731 | 1735 | if (local_got_refcounts == NULL) |
1732 | - return FALSE; | |
1736 | + goto error_return; | |
1733 | 1737 | elf_local_got_refcounts (abfd) = local_got_refcounts; |
1734 | 1738 | elf_i386_local_tlsdesc_gotent (abfd) |
1735 | 1739 | = (bfd_vma *) (local_got_refcounts + symtab_hdr->sh_info); |
@@ -1765,7 +1769,7 @@ elf_i386_check_relocs (bfd *abfd, | ||
1765 | 1769 | "thread local symbol"), |
1766 | 1770 | abfd, name); |
1767 | 1771 | bfd_set_error (bfd_error_bad_value); |
1768 | - return FALSE; | |
1772 | + goto error_return; | |
1769 | 1773 | } |
1770 | 1774 | } |
1771 | 1775 |
@@ -1787,7 +1791,7 @@ elf_i386_check_relocs (bfd *abfd, | ||
1787 | 1791 | if (htab->elf.dynobj == NULL) |
1788 | 1792 | htab->elf.dynobj = abfd; |
1789 | 1793 | if (!_bfd_elf_create_got_section (htab->elf.dynobj, info)) |
1790 | - return FALSE; | |
1794 | + goto error_return; | |
1791 | 1795 | } |
1792 | 1796 | if (r_type != R_386_TLS_IE) |
1793 | 1797 | { |
@@ -1903,7 +1907,7 @@ do_size: | ||
1903 | 1907 | (sec, htab->elf.dynobj, 2, abfd, /*rela?*/ FALSE); |
1904 | 1908 | |
1905 | 1909 | if (sreloc == NULL) |
1906 | - return FALSE; | |
1910 | + goto error_return; | |
1907 | 1911 | } |
1908 | 1912 | |
1909 | 1913 | /* If this is a global symbol, we count the number of |
@@ -1923,7 +1927,7 @@ do_size: | ||
1923 | 1927 | isym = bfd_sym_from_r_symndx (&htab->sym_cache, |
1924 | 1928 | abfd, r_symndx); |
1925 | 1929 | if (isym == NULL) |
1926 | - return FALSE; | |
1930 | + goto error_return; | |
1927 | 1931 | |
1928 | 1932 | s = bfd_section_from_elf_index (abfd, isym->st_shndx); |
1929 | 1933 | if (s == NULL) |
@@ -1940,7 +1944,7 @@ do_size: | ||
1940 | 1944 | p = (struct elf_dyn_relocs *) bfd_alloc (htab->elf.dynobj, |
1941 | 1945 | amt); |
1942 | 1946 | if (p == NULL) |
1943 | - return FALSE; | |
1947 | + goto error_return; | |
1944 | 1948 | p->next = *head; |
1945 | 1949 | *head = p; |
1946 | 1950 | p->sec = sec; |
@@ -1959,7 +1963,7 @@ do_size: | ||
1959 | 1963 | Reconstruct it for later use during GC. */ |
1960 | 1964 | case R_386_GNU_VTINHERIT: |
1961 | 1965 | if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) |
1962 | - return FALSE; | |
1966 | + goto error_return; | |
1963 | 1967 | break; |
1964 | 1968 | |
1965 | 1969 | /* This relocation describes which C++ vtable entries are actually |
@@ -1968,7 +1972,7 @@ do_size: | ||
1968 | 1972 | BFD_ASSERT (h != NULL); |
1969 | 1973 | if (h != NULL |
1970 | 1974 | && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset)) |
1971 | - return FALSE; | |
1975 | + goto error_return; | |
1972 | 1976 | break; |
1973 | 1977 | |
1974 | 1978 | default: |
@@ -2006,7 +2010,7 @@ do_size: | ||
2006 | 2010 | || !bfd_set_section_alignment (htab->elf.dynobj, |
2007 | 2011 | htab->plt_got, |
2008 | 2012 | plt_got_align)) |
2009 | - return FALSE; | |
2013 | + goto error_return; | |
2010 | 2014 | } |
2011 | 2015 | |
2012 | 2016 | if ((r_type == R_386_GOT32 || r_type == R_386_GOT32X) |
@@ -2015,6 +2019,10 @@ do_size: | ||
2015 | 2019 | } |
2016 | 2020 | |
2017 | 2021 | return TRUE; |
2022 | + | |
2023 | +error_return: | |
2024 | + sec->check_relocs_failed = 1; | |
2025 | + return FALSE; | |
2018 | 2026 | } |
2019 | 2027 | |
2020 | 2028 | /* Return the section that should be marked against GC for a given |
@@ -3581,6 +3589,10 @@ elf_i386_relocate_section (bfd *output_bfd, | ||
3581 | 3589 | |
3582 | 3590 | BFD_ASSERT (is_i386_elf (input_bfd)); |
3583 | 3591 | |
3592 | + /* Skip if check_relocs failed. */ | |
3593 | + if (input_section->check_relocs_failed) | |
3594 | + return FALSE; | |
3595 | + | |
3584 | 3596 | htab = elf_i386_hash_table (info); |
3585 | 3597 | if (htab == NULL) |
3586 | 3598 | return FALSE; |