mirror of
https://github.com/rui314/mold.git
synced 2024-09-22 02:20:51 +03:00
Add -warn-common
This commit is contained in:
parent
802f4229c2
commit
4519f8660c
@ -290,6 +290,10 @@ void parse_nonpositional_args(std::span<std::string_view> args,
|
||||
} else if (read_flag(args, "stats")) {
|
||||
config.stats = true;
|
||||
Counter::enabled = true;
|
||||
} else if (read_flag(args, "warn-common")) {
|
||||
config.warn_common = true;
|
||||
} else if (read_flag(args, "no-warn-common")) {
|
||||
config.warn_common = false;
|
||||
} else if (read_z_flag(args, "now")) {
|
||||
config.z_now = true;
|
||||
} else if (read_z_flag(args, "execstack")) {
|
||||
|
1
mold.h
1
mold.h
@ -89,6 +89,7 @@ struct Config {
|
||||
bool strip_all = false;
|
||||
bool strip_debug = false;
|
||||
bool trace = false;
|
||||
bool warn_common = false;
|
||||
bool z_copyreloc = true;
|
||||
bool z_defs = false;
|
||||
bool z_delete = true;
|
||||
|
@ -848,8 +848,11 @@ void ObjectFile::convert_common_symbols() {
|
||||
continue;
|
||||
|
||||
Symbol *sym = symbols[i];
|
||||
if (sym->file != this)
|
||||
if (sym->file != this) {
|
||||
if (config.warn_common)
|
||||
SyncOut() << *this << ": " << "multiple common symbols: " << *sym;
|
||||
continue;
|
||||
}
|
||||
|
||||
assert(sym->esym->st_value);
|
||||
|
||||
|
26
test/warn-common.sh
Executable file
26
test/warn-common.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
cd $(dirname $0)
|
||||
echo -n "Testing $(basename -s .sh $0) ... "
|
||||
t=$(pwd)/tmp/$(basename -s .sh $0)
|
||||
mkdir -p $t
|
||||
|
||||
cat <<EOF | clang -fcommon -c -xc -o $t/a.o -
|
||||
int foo;
|
||||
EOF
|
||||
|
||||
cat <<EOF | clang -fcommon -c -xc -o $t/b.o -
|
||||
int foo;
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o $t/b.o
|
||||
! fgrep -q 'multiple common symbols' $t/log
|
||||
|
||||
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o $t/b.o -Wl,-warn-common >& $t/log
|
||||
fgrep -q 'multiple common symbols' $t/log
|
||||
|
||||
echo OK
|
Loading…
Reference in New Issue
Block a user