• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
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

Revisão5376d47f66d0e4e07b3d42cb62ad07327cad4292 (tree)
Hora2020-06-24 19:56:16
AutorH.J. Lu <hjl.tools@gmai...>
CommiterH.J. Lu

Mensagem de Log

ld: Set non_ir_ref_regular on source for assignment

We need to set non_ir_ref_regular on the source for assignment to get
the correct LTO resolution:

190 a27be7f4ad90c5ce PREVAILING_DEF real_g

instead of

190 30c3b2d8f967f5ea PREVAILING_DEF_IRONLY real_g

PR ld/26163
* ldexp.c (exp_fold_tree_1): Set non_ir_ref_regular on the source
for assignment.
* testsuite/ld-plugin/lto.exp: Run ld/26163 test.
* testsuite/ld-plugin/pr26163a.c: New file.
* testsuite/ld-plugin/pr26163b.c: Likewise.

Mudança Sumário

Diff

--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
1+2020-06-24 H.J. Lu <hongjiu.lu@intel.com>
2+
3+ PR ld/26163
4+ * ldexp.c (exp_fold_tree_1): Set non_ir_ref_regular on the source
5+ for assignment.
6+ * testsuite/ld-plugin/lto.exp: Run ld/26163 test.
7+ * testsuite/ld-plugin/pr26163a.c: New file.
8+ * testsuite/ld-plugin/pr26163b.c: Likewise.
9+
110 2020-06-24 Alan Modra <amodra@gmail.com>
211
312 * lexsup.c (elf_shlib_list_options): Properly format help message.
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -1217,15 +1217,19 @@ exp_fold_tree_1 (etree_type *tree)
12171217 bfd_link_hide_symbol (link_info.output_bfd,
12181218 &link_info, h);
12191219
1220- /* Copy the symbol type if this is an expression only
1220+ /* Copy the symbol type and set non_ir_ref_regular
1221+ on the source if this is an expression only
12211222 referencing a single symbol. (If the expression
12221223 contains ternary conditions, ignoring symbols on
12231224 false branches.) */
12241225 if (expld.assign_src != NULL
12251226 && (expld.assign_src
12261227 != (struct bfd_link_hash_entry *) -1))
1227- bfd_copy_link_hash_symbol_type (link_info.output_bfd,
1228- h, expld.assign_src);
1228+ {
1229+ bfd_copy_link_hash_symbol_type (link_info.output_bfd,
1230+ h, expld.assign_src);
1231+ expld.assign_src->non_ir_ref_regular = TRUE;
1232+ }
12291233 }
12301234 }
12311235 }
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -207,6 +207,9 @@ set lto_link_tests [list \
207207 [list "Build pr24406-2b.o" \
208208 "" "-O2 -fno-lto" \
209209 {pr24406-2b.c}] \
210+ [list "Build pr26163a.o" \
211+ "" "-O2 -fno-lto" \
212+ {pr26163a.c}] \
210213 ]
211214
212215 if { [at_least_gcc_version 10 0] } {
@@ -502,6 +505,11 @@ set lto_run_tests [list \
502505 {pr24406-2a.c} "pr24406-2" "pass.out" \
503506 "-flto -O2" "c" "" \
504507 "tmpdir/pr24406-2b.o -Wl,--wrap=cook"] \
508+ [list "Run pr26163" \
509+ "-O2 -flto" "" \
510+ {pr26163b.c} "pr24406-2" "pass.out" \
511+ "-flto -O2" "c" "" \
512+ "tmpdir/pr26163a.o -Wl,--defsym,g=real_g"] \
505513 ]
506514
507515 if { [at_least_gcc_version 4 7] } {
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr26163a.c
@@ -0,0 +1,9 @@
1+extern int counter;
2+
3+extern void g(void);
4+
5+void f(void)
6+{
7+ g();
8+ counter++;
9+}
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr26163b.c
@@ -0,0 +1,19 @@
1+#include <stdio.h>
2+
3+int counter;
4+extern void f(void);
5+
6+void
7+real_g(void)
8+{
9+ counter++;
10+}
11+
12+int main()
13+{
14+ real_g();
15+ f();
16+ if (counter == 3)
17+ printf ("PASS\n");
18+ return 0;
19+}