Skip to content

Commit

Permalink
Handle -undefined as a synonym for --undefined instead of `-u nde…
Browse files Browse the repository at this point in the history
…fined`

Fixes #1059
  • Loading branch information
rui314 committed Jul 18, 2023
1 parent a8eb52f commit 2d25a93
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion elf/cmdline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ std::vector<std::string> parse_nonpositional_args(Context<E> &ctx) {
ctx.arg.unresolved_symbols = UNRESOLVED_IGNORE;
else
Fatal(ctx) << "unknown --unresolved-symbols argument: " << arg;
} else if (read_arg("u") || read_arg("undefined")) {
} else if (read_arg("undefined") || read_arg("u")) {
ctx.arg.undefined.push_back(arg);
} else if (read_arg("require-defined")) {
ctx.arg.require_defined.push_back(arg);
Expand Down
27 changes: 27 additions & 0 deletions test/elf/undefined2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
. $(dirname $0)/common.inc

test_cflags -static || skip

cat <<EOF | $CC -o $t/a.o -c -x assembler -
.globl _start
_start:
EOF

cat <<EOF | $CC -o $t/b.o -c -x assembler -
.globl ndefined
ndefined:
EOF

cat <<EOF | $CC -o $t/c.o -c -x assembler -
.globl foo
foo:
EOF

rm -f $t/d.a
ar cr $t/d.a $t/b.o $t/c.o

./mold -static -o $t/exe $t/a.o $t/d.a -undefined foo
readelf --symbols $t/exe > $t/log
grep -q foo $t/log
! grep -q ndefined $t/log || false

0 comments on commit 2d25a93

Please sign in to comment.