Linker checks if a symbol in an archive member is a real definition, not
common, before including the archive member in the link output so that
only a real definition in archive will override the common symbol in
object file. Add an LTO test to verify that a real definition in archive
overrides the common symbol in object file.
* testsuite/ld-plugin/common-1.c: New file.
* testsuite/ld-plugin/definition-1.c: Likewise.
* testsuite/ld-plugin/lto.exp: Run common tests.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
--- /dev/null
+#include <stdio.h>
+
+int foo;
+
+int main()
+{
+ if (foo == 1)
+ printf ("PASS\n");
+
+ return 0;
+}
--- /dev/null
+int foo = 1;
"$plug_opt" "-flto $lto_no_fat -fcommon" \
{pr26389.c} \
[list [list "nm" "$plug_opt" "pr26389.d"]]] \
+ [list "Build libdefinition-1.a" \
+ "$plug_opt" \
+ "-O2 -fcommon -flto $lto_no_fat" \
+ {definition-1.c} \
+ {} \
+ "libdefinition-1.a" \
+ ] \
]
if { [at_least_gcc_version 10 0] && [check_lto_shared_available] } {
{pr26262a.c} "pr26262b" "pass.out" \
"-flto -O2" "c" "" \
""] \
+ [list "Run common-1" \
+ "-O2 -flto" \
+ "" \
+ {common-1.c} \
+ "common-1" \
+ "pass.out" \
+ "-O2 -fcommon -flto $lto_no_fat" \
+ "c" \
+ "" \
+ "tmpdir/libdefinition-1.a" \
+ ] \
]
if { [at_least_gcc_version 4 7] } {