aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-09-24 18:26:51 +0200
committerAyke van Laethem <[email protected]>2021-09-27 14:55:02 +0200
commite4bed68eda03d3cc635c06b405abd1d63ec4fcb4 (patch)
treebb73b1909dafc8c8770641469e91672f71f89d15
parent9d2c93d169a747a77fbac60fc6d4fa3d971d0694 (diff)
downloadtinygo-e4bed68eda03d3cc635c06b405abd1d63ec4fcb4.tar.gz
tinygo-e4bed68eda03d3cc635c06b405abd1d63ec4fcb4.zip
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.
-rw-r--r--cgo/cgo.go4
-rw-r--r--cgo/security.go2
2 files changed, 4 insertions, 2 deletions
diff --git a/cgo/cgo.go b/cgo/cgo.go
index 8581807fa..8520fecd9 100644
--- a/cgo/cgo.go
+++ b/cgo/cgo.go
@@ -447,11 +447,11 @@ func makePathsAbsolute(args []string, packagePath string) {
args[i] = filepath.Join(packagePath, arg)
}
}
- if arg == "-I" || arg == "-L" {
+ if arg == "-I" || arg == "-L" || arg == "-T" {
nextIsPath = true
continue
}
- if strings.HasPrefix(arg, "-I") || strings.HasPrefix(arg, "-L") {
+ if strings.HasPrefix(arg, "-I") || strings.HasPrefix(arg, "-L") || strings.HasPrefix(arg, "-T") {
path := arg[2:]
if !filepath.IsAbs(path) {
args[i] = arg[:2] + filepath.Join(packagePath, path)
diff --git a/cgo/security.go b/cgo/security.go
index 2fea40c8a..d5f30c88a 100644
--- a/cgo/security.go
+++ b/cgo/security.go
@@ -140,6 +140,7 @@ var validLinkerFlags = []*regexp.Regexp{
re(`-F([^@\-].*)`),
re(`-l([^@\-].*)`),
re(`-L([^@\-].*)`),
+ re(`-T([^@\-].*)`),
re(`-O`),
re(`-O([^@\-].*)`),
re(`-f(no-)?(pic|PIC|pie|PIE)`),
@@ -209,6 +210,7 @@ var validLinkerFlagsWithNextArg = []string{
"-F",
"-l",
"-L",
+ "-T",
"-framework",
"-isysroot",
"--sysroot",