cmd/go/internal/work: allow single character values in -Wl, linker flags

Allow single character values in -Wl, linker flags by modifying the regular
expressions to use the star operator instead of the plus operator.

Fixes #70924

Change-Id: Ie7940197cc8503440a87c6b29409a13377a20534
GitHub-Last-Rev: 42e8ac87d6
GitHub-Pull-Request: golang/go#70937
Reviewed-on: https://go-review.googlesource.com/c/go/+/638035
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Pedro Tôrres 2024-12-20 06:45:52 +00:00 committed by Gopher Robot
parent 05d8984781
commit 9f6c80a76a
2 changed files with 13 additions and 6 deletions

View file

@ -201,23 +201,23 @@ var validLinkerFlags = []*lazyregexp.Regexp{
re(`-Wl,--end-group`), re(`-Wl,--end-group`),
re(`-Wl,--(no-)?export-dynamic`), re(`-Wl,--(no-)?export-dynamic`),
re(`-Wl,-E`), re(`-Wl,-E`),
re(`-Wl,-framework,[^,@\-][^,]+`), re(`-Wl,-framework,[^,@\-][^,]*`),
re(`-Wl,--hash-style=(sysv|gnu|both)`), re(`-Wl,--hash-style=(sysv|gnu|both)`),
re(`-Wl,-headerpad_max_install_names`), re(`-Wl,-headerpad_max_install_names`),
re(`-Wl,--no-undefined`), re(`-Wl,--no-undefined`),
re(`-Wl,--pop-state`), re(`-Wl,--pop-state`),
re(`-Wl,--push-state`), re(`-Wl,--push-state`),
re(`-Wl,-R,?([^@\-,][^,@]*$)`), re(`-Wl,-R,?([^@\-,][^,@]*$)`),
re(`-Wl,--just-symbols[=,]([^,@\-][^,@]+)`), re(`-Wl,--just-symbols[=,]([^,@\-][^,@]*)`),
re(`-Wl,-rpath(-link)?[=,]([^,@\-][^,]+)`), re(`-Wl,-rpath(-link)?[=,]([^,@\-][^,]*)`),
re(`-Wl,-s`), re(`-Wl,-s`),
re(`-Wl,-search_paths_first`), re(`-Wl,-search_paths_first`),
re(`-Wl,-sectcreate,([^,@\-][^,]+),([^,@\-][^,]+),([^,@\-][^,]+)`), re(`-Wl,-sectcreate,([^,@\-][^,]*),([^,@\-][^,]*),([^,@\-][^,]*)`),
re(`-Wl,--start-group`), re(`-Wl,--start-group`),
re(`-Wl,-?-static`), re(`-Wl,-?-static`),
re(`-Wl,-?-subsystem,(native|windows|console|posix|xbox)`), re(`-Wl,-?-subsystem,(native|windows|console|posix|xbox)`),
re(`-Wl,-syslibroot[=,]([^,@\-][^,]+)`), re(`-Wl,-syslibroot[=,]([^,@\-][^,]*)`),
re(`-Wl,-undefined[=,]([^,@\-][^,]+)`), re(`-Wl,-undefined[=,]([^,@\-][^,]*)`),
re(`-Wl,-?-unresolved-symbols=[^,]+`), re(`-Wl,-?-unresolved-symbols=[^,]+`),
re(`-Wl,--(no-)?warn-([^,]+)`), re(`-Wl,--(no-)?warn-([^,]+)`),
re(`-Wl,-?-wrap[=,][^,@\-][^,]*`), re(`-Wl,-?-wrap[=,][^,@\-][^,]*`),

View file

@ -182,6 +182,13 @@ var goodLinkerFlags = [][]string{
{"-Wl,--pop-state"}, {"-Wl,--pop-state"},
{"-Wl,--push-state,--as-needed"}, {"-Wl,--push-state,--as-needed"},
{"-Wl,--push-state,--no-as-needed,-Bstatic"}, {"-Wl,--push-state,--no-as-needed,-Bstatic"},
{"-Wl,--just-symbols,."},
{"-Wl,-framework,."},
{"-Wl,-rpath,."},
{"-Wl,-rpath-link,."},
{"-Wl,-sectcreate,.,.,."},
{"-Wl,-syslibroot,."},
{"-Wl,-undefined,."},
} }
var badLinkerFlags = [][]string{ var badLinkerFlags = [][]string{