Skip to content

Commit c18e6fb

Browse files
committed
cgo: add support for the -T flag
This adds support for specifying linker scripts in LDFLAGS. I looked a bit into whether it allows arbitrary code execution but I couldn't find any sign of that.
1 parent 6a0a441 commit c18e6fb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cgo/cgo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,11 @@ func makePathsAbsolute(args []string, packagePath string) {
447447
args[i] = filepath.Join(packagePath, arg)
448448
}
449449
}
450-
if arg == "-I" || arg == "-L" {
450+
if arg == "-I" || arg == "-L" || arg == "-T" {
451451
nextIsPath = true
452452
continue
453453
}
454-
if strings.HasPrefix(arg, "-I") || strings.HasPrefix(arg, "-L") {
454+
if strings.HasPrefix(arg, "-I") || strings.HasPrefix(arg, "-L") || strings.HasPrefix(arg, "-T") {
455455
path := arg[2:]
456456
if !filepath.IsAbs(path) {
457457
args[i] = arg[:2] + filepath.Join(packagePath, path)

cgo/security.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ var validLinkerFlags = []*regexp.Regexp{
140140
re(`-F([^@\-].*)`),
141141
re(`-l([^@\-].*)`),
142142
re(`-L([^@\-].*)`),
143+
re(`-T([^@\-].*)`),
143144
re(`-O`),
144145
re(`-O([^@\-].*)`),
145146
re(`-f(no-)?(pic|PIC|pie|PIE)`),
@@ -209,6 +210,7 @@ var validLinkerFlagsWithNextArg = []string{
209210
"-F",
210211
"-l",
211212
"-L",
213+
"-T",
212214
"-framework",
213215
"-isysroot",
214216
"--sysroot",

0 commit comments

Comments
 (0)