-
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mark shared symbols as weak if all references are weak
Previously, mold marked an imported symbol as a strong one if the symbol came from a DSO and was exported as a strong symbol by the DSO. This logic resulted in a miscomputation of the weakness bit, causing a compatibility issue with other linkers. Now, an imported symbol is marked as strong only when there's at least one strong reference to it. In other words, if all references to an imported symbol are weak, the symbol will be imported as a weak one. Fixes llvm/llvm-project#83080
- Loading branch information
Showing
5 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
. $(dirname $0)/common.inc | ||
|
||
cat <<EOF | $CC -fPIC -c -o $t/a.o -xc - | ||
int foo() { return 0; } | ||
EOF | ||
|
||
$CC -B. -o $t/b.so $t/a.o -shared | ||
|
||
cat <<EOF | $CC -fPIC -c -o $t/c.o -xc - | ||
#include <stdio.h> | ||
__attribute__((weak)) int foo(); | ||
int main() { | ||
printf("%d\n", foo ? foo() : 3); | ||
} | ||
EOF | ||
|
||
$CC -B. -o $t/d.so $t/c.o $t/b.so -shared | ||
readelf -W --dyn-syms $t/d.so | grep -q 'WEAK DEFAULT UND foo' |