• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Révisionc337a1627c7e0edf6d46e66dee513c56975d0625 (tree)
l'heure2016-04-29 20:31:54
AuteurH.J. Lu <hjl.tools@gmai...>
CommiterH.J. Lu

Message de Log

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.

Change Summary

Modification

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
11 2016-04-29 H.J. Lu <hongjiu.lu@intel.com>
22
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+
39 * elf64-x86-64.c (elf_x86_64_check_relocs): Set
410 check_relocs_failed on error.
511
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1506,7 +1506,8 @@ elf_i386_tls_transition (struct bfd_link_info *info, bfd *abfd,
15061506
15071507 /* Rename some of the generic section flags to better document how they
15081508 are used here. */
1509-#define need_convert_load sec_flg0
1509+#define need_convert_load sec_flg0
1510+#define check_relocs_failed sec_flg1
15101511
15111512 /* Look through the relocs for a section during the first phase, and
15121513 calculate needed space in the global offset table, procedure linkage
@@ -1533,7 +1534,10 @@ elf_i386_check_relocs (bfd *abfd,
15331534
15341535 htab = elf_i386_hash_table (info);
15351536 if (htab == NULL)
1536- return FALSE;
1537+ {
1538+ sec->check_relocs_failed = 1;
1539+ return FALSE;
1540+ }
15371541
15381542 use_plt_got = (!get_elf_i386_backend_data (abfd)->is_vxworks
15391543 && (get_elf_i386_backend_data (abfd)
@@ -1563,7 +1567,7 @@ elf_i386_check_relocs (bfd *abfd,
15631567 (*_bfd_error_handler) (_("%B: bad symbol index: %d"),
15641568 abfd,
15651569 r_symndx);
1566- return FALSE;
1570+ goto error_return;
15671571 }
15681572
15691573 if (r_symndx < symtab_hdr->sh_info)
@@ -1572,14 +1576,14 @@ elf_i386_check_relocs (bfd *abfd,
15721576 isym = bfd_sym_from_r_symndx (&htab->sym_cache,
15731577 abfd, r_symndx);
15741578 if (isym == NULL)
1575- return FALSE;
1579+ goto error_return;
15761580
15771581 /* Check relocation against local STT_GNU_IFUNC symbol. */
15781582 if (ELF32_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
15791583 {
15801584 h = elf_i386_get_local_sym_hash (htab, abfd, rel, TRUE);
15811585 if (h == NULL)
1582- return FALSE;
1586+ goto error_return;
15831587
15841588 /* Fake a STT_GNU_IFUNC symbol. */
15851589 h->type = STT_GNU_IFUNC;
@@ -1621,7 +1625,7 @@ elf_i386_check_relocs (bfd *abfd,
16211625 if (h->type == STT_GNU_IFUNC
16221626 && !_bfd_elf_create_ifunc_sections (htab->elf.dynobj,
16231627 info))
1624- return FALSE;
1628+ goto error_return;
16251629 break;
16261630 }
16271631
@@ -1638,7 +1642,7 @@ elf_i386_check_relocs (bfd *abfd,
16381642 symtab_hdr, sym_hashes,
16391643 &r_type, GOT_UNKNOWN,
16401644 rel, rel_end, h, r_symndx))
1641- return FALSE;
1645+ goto error_return;
16421646
16431647 switch (r_type)
16441648 {
@@ -1729,7 +1733,7 @@ elf_i386_check_relocs (bfd *abfd,
17291733 local_got_refcounts = (bfd_signed_vma *)
17301734 bfd_zalloc (abfd, size);
17311735 if (local_got_refcounts == NULL)
1732- return FALSE;
1736+ goto error_return;
17331737 elf_local_got_refcounts (abfd) = local_got_refcounts;
17341738 elf_i386_local_tlsdesc_gotent (abfd)
17351739 = (bfd_vma *) (local_got_refcounts + symtab_hdr->sh_info);
@@ -1765,7 +1769,7 @@ elf_i386_check_relocs (bfd *abfd,
17651769 "thread local symbol"),
17661770 abfd, name);
17671771 bfd_set_error (bfd_error_bad_value);
1768- return FALSE;
1772+ goto error_return;
17691773 }
17701774 }
17711775
@@ -1787,7 +1791,7 @@ elf_i386_check_relocs (bfd *abfd,
17871791 if (htab->elf.dynobj == NULL)
17881792 htab->elf.dynobj = abfd;
17891793 if (!_bfd_elf_create_got_section (htab->elf.dynobj, info))
1790- return FALSE;
1794+ goto error_return;
17911795 }
17921796 if (r_type != R_386_TLS_IE)
17931797 {
@@ -1903,7 +1907,7 @@ do_size:
19031907 (sec, htab->elf.dynobj, 2, abfd, /*rela?*/ FALSE);
19041908
19051909 if (sreloc == NULL)
1906- return FALSE;
1910+ goto error_return;
19071911 }
19081912
19091913 /* If this is a global symbol, we count the number of
@@ -1923,7 +1927,7 @@ do_size:
19231927 isym = bfd_sym_from_r_symndx (&htab->sym_cache,
19241928 abfd, r_symndx);
19251929 if (isym == NULL)
1926- return FALSE;
1930+ goto error_return;
19271931
19281932 s = bfd_section_from_elf_index (abfd, isym->st_shndx);
19291933 if (s == NULL)
@@ -1940,7 +1944,7 @@ do_size:
19401944 p = (struct elf_dyn_relocs *) bfd_alloc (htab->elf.dynobj,
19411945 amt);
19421946 if (p == NULL)
1943- return FALSE;
1947+ goto error_return;
19441948 p->next = *head;
19451949 *head = p;
19461950 p->sec = sec;
@@ -1959,7 +1963,7 @@ do_size:
19591963 Reconstruct it for later use during GC. */
19601964 case R_386_GNU_VTINHERIT:
19611965 if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
1962- return FALSE;
1966+ goto error_return;
19631967 break;
19641968
19651969 /* This relocation describes which C++ vtable entries are actually
@@ -1968,7 +1972,7 @@ do_size:
19681972 BFD_ASSERT (h != NULL);
19691973 if (h != NULL
19701974 && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
1971- return FALSE;
1975+ goto error_return;
19721976 break;
19731977
19741978 default:
@@ -2006,7 +2010,7 @@ do_size:
20062010 || !bfd_set_section_alignment (htab->elf.dynobj,
20072011 htab->plt_got,
20082012 plt_got_align))
2009- return FALSE;
2013+ goto error_return;
20102014 }
20112015
20122016 if ((r_type == R_386_GOT32 || r_type == R_386_GOT32X)
@@ -2015,6 +2019,10 @@ do_size:
20152019 }
20162020
20172021 return TRUE;
2022+
2023+error_return:
2024+ sec->check_relocs_failed = 1;
2025+ return FALSE;
20182026 }
20192027
20202028 /* Return the section that should be marked against GC for a given
@@ -3581,6 +3589,10 @@ elf_i386_relocate_section (bfd *output_bfd,
35813589
35823590 BFD_ASSERT (is_i386_elf (input_bfd));
35833591
3592+ /* Skip if check_relocs failed. */
3593+ if (input_section->check_relocs_failed)
3594+ return FALSE;
3595+
35843596 htab = elf_i386_hash_table (info);
35853597 if (htab == NULL)
35863598 return FALSE;