The following fixes a thinko in the handling of interposed weak
definitions which confused the interposition check in
get_availability by setting DECL_EXTERNAL too early.
PR lto/91299
gcc/lto/
* lto-symtab.cc (lto_symtab_merge_symbols): Set DECL_EXTERNAL
only after calling get_availability.
gcc/testsuite/
* gcc.dg/lto/pr91299_0.c: New testcase.
* gcc.dg/lto/pr91299_1.c: Likewise.
|| node->resolution == LDPR_RESOLVED_EXEC
|| node->resolution == LDPR_RESOLVED_DYN))
{
- DECL_EXTERNAL (node->decl) = 1;
/* If alias to local symbol was preempted by external definition,
we know it is not pointing to the local symbol. Remove it. */
if (node->alias
node->remove_all_references ();
}
}
+ DECL_EXTERNAL (node->decl) = 1;
}
if (!(cnode = dyn_cast <cgraph_node *> (node))
--- /dev/null
+/* { dg-lto-do run } */
+/* { dg-lto-options { { -O2 -flto } } } */
+
+__attribute__((weak)) int get_t(void)
+{
+ return 0;
+}
+
+int a;
+int main(void)
+{
+ a = get_t();
+ if (a != 1)
+ __builtin_abort ();
+ return 0;
+}
--- /dev/null
+/* { dg-options "-fno-lto" } */
+
+int get_t(void)
+{
+ return 1;
+}