• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

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

修订版85e95c9817429ff3fa50224697609f4ae0148fdb (tree)
时间2018-02-22 23:39:19
作者Nick Clifton <nickc@redh...>
CommiterNick Clifton

Log Message

Another merge

更改概述

差异

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,21 @@
1+2018-02-09 Eric Botcazou <ebotcazou@adacore.com>
2+
3+ * elfxx-sparc.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Reorder conditions.
4+ (sparc_elf_append_rela): Assert that there is enough room in section.
5+ (_bfd_sparc_elf_copy_indirect_symbol): Fix formatting.
6+ (_bfd_sparc_elf_adjust_dynamic_symbol): Minor tweak.
7+ (allocate_dynrelocs): Remove outdated comments and reorder conditions.
8+ For a symbol subject to a GOT relocation, reserve a slot in the
9+ relocation section if the symbol isn't dynamic and we are in PIC mode.
10+ (_bfd_sparc_elf_relocate_section) <R_SPARC_GOTDATA_OP>: If relocation
11+ is relaxed and a slot was reserved, generate a R_SPARC_NONE relocation.
12+ <R_SPARC_GOTDATA_OP_HIX22>: Adjust comments.
13+ <R_SPARC_PC10>: Reorder conditions. Remove always-false assertion.
14+ (_bfd_sparc_elf_finish_dynamic_symbol): Rename local_undefweak into
15+ resolved_to_zero. Do not generate a dynamic GOT relocation for an
16+ undefined weak symbol with non-default visibility. Remove superfluous
17+ 'else' and fix formatting.
18+
119 2017-12-19 Alan Modra <amodra@gmail.com>
220
321 PR 22626
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -689,13 +689,13 @@ struct _bfd_sparc_elf_dyn_relocs
689689 1. Has non-GOT/non-PLT relocations in text section.
690690 Or
691691 2. Has no GOT/PLT relocation. */
692-#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
693- ((EH)->elf.root.type == bfd_link_hash_undefweak \
694- && bfd_link_executable (INFO) \
695- && (_bfd_sparc_elf_hash_table (INFO)->interp == NULL \
696- || !(EH)->has_got_reloc \
697- || (EH)->has_non_got_reloc \
698- || !(INFO)->dynamic_undefined_weak))
692+#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
693+ ((EH)->elf.root.type == bfd_link_hash_undefweak \
694+ && bfd_link_executable (INFO) \
695+ && (_bfd_sparc_elf_hash_table (INFO)->interp == NULL \
696+ || !(INFO)->dynamic_undefined_weak \
697+ || (EH)->has_non_got_reloc \
698+ || !(EH)->has_got_reloc))
699699
700700 /* SPARC ELF linker hash entry. */
701701
@@ -770,6 +770,7 @@ sparc_elf_append_rela (bfd *abfd, asection *s, Elf_Internal_Rela *rel)
770770 bfd_byte *loc;
771771
772772 bed = get_elf_backend_data (abfd);
773+ BFD_ASSERT (s->reloc_count * bed->s->sizeof_rela < s->size);
773774 loc = s->contents + (s->reloc_count++ * bed->s->sizeof_rela);
774775 bed->s->swap_reloca_out (abfd, rel, loc);
775776 }
@@ -1330,8 +1331,7 @@ _bfd_sparc_elf_copy_indirect_symbol (struct bfd_link_info *info,
13301331 eind->dyn_relocs = NULL;
13311332 }
13321333
1333- if (ind->root.type == bfd_link_hash_indirect
1334- && dir->got.refcount <= 0)
1334+ if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0)
13351335 {
13361336 edir->tls_type = eind->tls_type;
13371337 eind->tls_type = GOT_UNKNOWN;
@@ -2178,8 +2178,8 @@ _bfd_sparc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
21782178 if (h->plt.refcount <= 0
21792179 || (h->type != STT_GNU_IFUNC
21802180 && (SYMBOL_CALLS_LOCAL (info, h)
2181- || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
2182- && h->root.type == bfd_link_hash_undefweak))))
2181+ || (h->root.type == bfd_link_hash_undefweak
2182+ && ELF_ST_VISIBILITY (h->other) != STV_DEFAULT))))
21832183 {
21842184 /* This case can occur if we saw a WPLT30 reloc in an input
21852185 file, but the symbol was never referred to by a dynamic
@@ -2306,12 +2306,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
23062306 && h->def_regular
23072307 && h->ref_regular))
23082308 {
2309- /* Make sure this symbol is output as a dynamic symbol.
2310- Undefined weak syms won't yet be marked as dynamic. */
2311- if (h->dynindx == -1
2312- && !h->forced_local
2313- && !resolved_to_zero
2314- && h->root.type == bfd_link_hash_undefweak)
2309+ /* Undefined weak syms won't yet be marked as dynamic. */
2310+ if (h->root.type == bfd_link_hash_undefweak
2311+ && !resolved_to_zero
2312+ && h->dynindx == -1
2313+ && !h->forced_local)
23152314 {
23162315 if (! bfd_elf_link_record_dynamic_symbol (info, h))
23172316 return FALSE;
@@ -2419,12 +2418,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
24192418 bfd_boolean dyn;
24202419 int tls_type = _bfd_sparc_elf_hash_entry(h)->tls_type;
24212420
2422- /* Make sure this symbol is output as a dynamic symbol.
2423- Undefined weak syms won't yet be marked as dynamic. */
2424- if (h->dynindx == -1
2425- && !h->forced_local
2426- && !resolved_to_zero
2427- && h->root.type == bfd_link_hash_undefweak)
2421+ /* Undefined weak syms won't yet be marked as dynamic. */
2422+ if (h->root.type == bfd_link_hash_undefweak
2423+ && !resolved_to_zero
2424+ && h->dynindx == -1
2425+ && !h->forced_local)
24282426 {
24292427 if (! bfd_elf_link_record_dynamic_symbol (info, h))
24302428 return FALSE;
@@ -2438,21 +2436,25 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
24382436 s->size += SPARC_ELF_WORD_BYTES (htab);
24392437 dyn = htab->elf.dynamic_sections_created;
24402438 /* R_SPARC_TLS_IE_{HI22,LO10} needs one dynamic relocation,
2441- R_SPARC_TLS_GD_{HI22,LO10} needs one if local symbol and two if
2442- global. No dynamic relocations are needed against resolved
2443- undefined weak symbols in an executable. */
2439+ R_SPARC_TLS_GD_{HI22,LO10} needs one if local and two if global. */
24442440 if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
24452441 || tls_type == GOT_TLS_IE
24462442 || h->type == STT_GNU_IFUNC)
24472443 htab->elf.srelgot->size += SPARC_ELF_RELA_BYTES (htab);
24482444 else if (tls_type == GOT_TLS_GD)
24492445 htab->elf.srelgot->size += 2 * SPARC_ELF_RELA_BYTES (htab);
2450- else if (((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
2451- && !resolved_to_zero)
2452- || h->root.type != bfd_link_hash_undefweak)
2453- && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
2454- bfd_link_pic (info),
2455- h))
2446+ else if ((WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)
2447+ /* Even if the symbol isn't dynamic, we may generate a
2448+ reloc for the dynamic linker in PIC mode. */
2449+ || (h->dynindx == -1
2450+ && !h->forced_local
2451+ && h->root.type != bfd_link_hash_undefweak
2452+ && bfd_link_pic (info)))
2453+ /* No dynamic relocations are needed against resolved
2454+ undefined weak symbols in an executable. */
2455+ && !(h->root.type == bfd_link_hash_undefweak
2456+ && (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
2457+ || resolved_to_zero)))
24562458 htab->elf.srelgot->size += SPARC_ELF_RELA_BYTES (htab);
24572459 }
24582460 else
@@ -2562,12 +2564,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
25622564 && (h->root.type == bfd_link_hash_undefweak
25632565 || h->root.type == bfd_link_hash_undefined))))
25642566 {
2565- /* Make sure this symbol is output as a dynamic symbol.
2566- Undefined weak syms won't yet be marked as dynamic. */
2567- if (h->dynindx == -1
2568- && !h->forced_local
2569- && !resolved_to_zero
2570- && h->root.type == bfd_link_hash_undefweak)
2567+ /* Undefined weak syms won't yet be marked as dynamic. */
2568+ if (h->root.type == bfd_link_hash_undefweak
2569+ && !resolved_to_zero
2570+ && h->dynindx == -1
2571+ && !h->forced_local)
25712572 {
25722573 if (! bfd_elf_link_record_dynamic_symbol (info, h))
25732574 return FALSE;
@@ -3332,6 +3333,26 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
33323333 /* {ld,ldx} [%rs1 + %rs2], %rd --> add %rs1, %rs2, %rd */
33333334 relocation = 0x80000000 | (insn & 0x3e07c01f);
33343335 bfd_put_32 (output_bfd, relocation, contents + rel->r_offset);
3336+
3337+ /* If the symbol is global but not dynamic, an .rela.* slot has
3338+ been allocated for it in the GOT so output R_SPARC_NONE here.
3339+ See also the handling of other GOT relocations just below. */
3340+ if (h != NULL
3341+ && h->dynindx == -1
3342+ && !h->forced_local
3343+ && h->root.type != bfd_link_hash_undefweak
3344+ && (h->got.offset & 1) == 0
3345+ && bfd_link_pic (info))
3346+ {
3347+ asection *s = htab->elf.srelgot;
3348+ Elf_Internal_Rela outrel;
3349+
3350+ BFD_ASSERT (s != NULL);
3351+
3352+ memset (&outrel, 0, sizeof outrel);
3353+ sparc_elf_append_rela (output_bfd, s, &outrel);
3354+ h->got.offset |= 1;
3355+ }
33353356 }
33363357 continue;
33373358 }
@@ -3384,19 +3405,17 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
33843405 off &= ~1;
33853406 else
33863407 {
3387- SPARC_ELF_PUT_WORD (htab, output_bfd, relocation,
3388- htab->elf.sgot->contents + off);
3389- h->got.offset |= 1;
3390-
3408+ /* If this symbol isn't dynamic in PIC mode, treat it
3409+ like a local symbol in PIC mode below. */
33913410 if (h->dynindx == -1
33923411 && !h->forced_local
33933412 && h->root.type != bfd_link_hash_undefweak
33943413 && bfd_link_pic (info))
3395- {
3396- /* If this symbol isn't dynamic in PIC
3397- generate R_SPARC_RELATIVE here. */
3398- relative_reloc = TRUE;
3399- }
3414+ relative_reloc = TRUE;
3415+ else
3416+ SPARC_ELF_PUT_WORD (htab, output_bfd, relocation,
3417+ htab->elf.sgot->contents + off);
3418+ h->got.offset |= 1;
34003419 }
34013420 }
34023421 else
@@ -3416,6 +3435,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
34163435 off &= ~1;
34173436 else
34183437 {
3438+ /* For a local symbol in PIC mode, we need to generate a
3439+ R_SPARC_RELATIVE reloc for the dynamic linker. */
34193440 if (bfd_link_pic (info))
34203441 {
34213442 relative_reloc = TRUE;
@@ -3429,12 +3450,9 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
34293450
34303451 if (relative_reloc)
34313452 {
3432- asection *s;
3453+ asection *s = htab->elf.srelgot;
34333454 Elf_Internal_Rela outrel;
34343455
3435- /* We need to generate a R_SPARC_RELATIVE reloc
3436- for the dynamic linker. */
3437- s = htab->elf.srelgot;
34383456 BFD_ASSERT (s != NULL);
34393457
34403458 outrel.r_offset = (htab->elf.sgot->output_section->vma
@@ -3560,9 +3578,9 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
35603578 in PIE. */
35613579 if ((bfd_link_pic (info)
35623580 && (h == NULL
3563- || ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
3564- && !resolved_to_zero)
3565- || h->root.type != bfd_link_hash_undefweak))
3581+ || !(h->root.type == bfd_link_hash_undefweak
3582+ && (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
3583+ || resolved_to_zero)))
35663584 && (! howto->pc_relative
35673585 || !SYMBOL_CALLS_LOCAL (info, h)))
35683586 || (!bfd_link_pic (info)
@@ -3649,7 +3667,6 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
36493667 || !SYMBOLIC_BIND (info, h)
36503668 || !h->def_regular))
36513669 {
3652- BFD_ASSERT (h->dynindx != -1);
36533670 outrel.r_info = SPARC_ELF_R_INFO (htab, rel, h->dynindx, r_type);
36543671 outrel.r_addend = rel->r_addend;
36553672 }
@@ -4494,7 +4511,7 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd,
44944511 struct _bfd_sparc_elf_link_hash_table *htab;
44954512 const struct elf_backend_data *bed;
44964513 struct _bfd_sparc_elf_link_hash_entry *eh;
4497- bfd_boolean local_undefweak;
4514+ bfd_boolean resolved_to_zero;
44984515
44994516 htab = _bfd_sparc_elf_hash_table (info);
45004517 BFD_ASSERT (htab != NULL);
@@ -4505,7 +4522,7 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd,
45054522 /* We keep PLT/GOT entries without dynamic PLT/GOT relocations for
45064523 resolved undefined weak symbols in executable so that their
45074524 references have value 0 at run-time. */
4508- local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
4525+ resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
45094526
45104527 if (h->plt.offset != (bfd_vma) -1)
45114528 {
@@ -4630,8 +4647,7 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd,
46304647 loc += rela_index * bed->s->sizeof_rela;
46314648 bed->s->swap_reloca_out (output_bfd, &rela, loc);
46324649
4633- if (!local_undefweak
4634- && !h->def_regular)
4650+ if (!resolved_to_zero && !h->def_regular)
46354651 {
46364652 /* Mark the symbol as undefined, rather than as defined in
46374653 the .plt section. Leave the value alone. */
@@ -4645,12 +4661,14 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd,
46454661 }
46464662 }
46474663
4648- /* Don't generate dynamic GOT relocation against undefined weak
4649- symbol in executable. */
4664+ /* Don't generate dynamic GOT relocation against resolved undefined weak
4665+ symbols in an executable. */
46504666 if (h->got.offset != (bfd_vma) -1
46514667 && _bfd_sparc_elf_hash_entry(h)->tls_type != GOT_TLS_GD
46524668 && _bfd_sparc_elf_hash_entry(h)->tls_type != GOT_TLS_IE
4653- && !local_undefweak)
4669+ && !(h->root.type == bfd_link_hash_undefweak
4670+ && (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
4671+ || resolved_to_zero)))
46544672 {
46554673 asection *sgot;
46564674 asection *srela;
@@ -4686,8 +4704,8 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd,
46864704 + (h->got.offset & ~(bfd_vma) 1));
46874705 return TRUE;
46884706 }
4689- else if (bfd_link_pic (info)
4690- && SYMBOL_REFERENCES_LOCAL (info, h))
4707+
4708+ if (bfd_link_pic (info) && SYMBOL_REFERENCES_LOCAL (info, h))
46914709 {
46924710 asection *sec = h->root.u.def.section;
46934711 if (h->type == STT_GNU_IFUNC)
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -1,4 +1,4 @@
1-#define BFD_VERSION_DATE 20180110
1+#define BFD_VERSION_DATE 20180115
22 #define BFD_VERSION @bfd_version@
33 #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@
44 #define REPORT_BUGS_TO @report_bugs_to@
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,11 @@
1+2018-01-12 Eric Christopher <echristo@gmail.com>
2+
3+ Apply from master:
4+ 2018-01-12 Sterling Augustine <saugustine@google.com>
5+
6+ * cref.cc (Cref_inputs::Cref_table_compare::operator): Add
7+ conditionals and calls to is_forwarder.
8+
19 2017-12-01 Cary Coutant <ccoutant@gmail.com>
210
311 PR gold/22309
--- a/gold/cref.cc
+++ b/gold/cref.cc
@@ -236,9 +236,13 @@ Cref_inputs::Cref_table_compare::operator()(const Symbol* s1,
236236 }
237237
238238 // We should never have two different symbols with the same name and
239- // version.
239+ // version, where one doesn't forward to the other.
240240 if (s1 == s2)
241241 return false;
242+ if (s1->is_forwarder() && !s2->is_forwarder())
243+ return true;
244+ if (!s1->is_forwarder() && s2->is_forwarder())
245+ return false;
242246 gold_unreachable();
243247 }
244248