Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
c971f95c
Commit
c971f95c
authored
Sep 10, 2013
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/build: allow $ in cgo LDFLAGS
Fixes #6038. R=iant CC=golang-dev
https://golang.org/cl/13649043
parent
358ae207
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
src/cmd/go/test.bash
src/cmd/go/test.bash
+19
-0
src/pkg/go/build/build.go
src/pkg/go/build/build.go
+6
-3
No files found.
src/cmd/go/test.bash
View file @
c971f95c
...
...
@@ -483,6 +483,25 @@ fi
rm
-rf
$d
unset
GOPATH
TEST
'cgo handles -Wl,$ORIGIN'
d
=
$(
TMPDIR
=
/var/tmp
mktemp
-d
-t
testgoXXX
)
export
GOPATH
=
$d
mkdir
-p
$d
/src/origin
echo
'
package origin
// #cgo LDFLAGS: -Wl,-rpath -Wl,$ORIGIN
// void f(void) {}
import "C"
func f() { C.f() }
'
>
$d
/src/origin/origin.go
if
!
./testgo build origin
;
then
echo
build failed
ok
=
false
fi
rm
-rf
$d
unset
GOPATH
# clean up
if
$started
;
then
stop
;
fi
rm
-rf
testdata/bin testdata/bin1
...
...
src/pkg/go/build/build.go
View file @
c971f95c
...
...
@@ -920,7 +920,7 @@ func (ctxt *Context) saveCgo(filename string, di *Package, cg *ast.CommentGroup)
return
fmt
.
Errorf
(
"%s: invalid #cgo line: %s"
,
filename
,
orig
)
}
for
_
,
arg
:=
range
args
{
if
!
safeName
(
arg
)
{
if
!
safe
Cgo
Name
(
arg
)
{
return
fmt
.
Errorf
(
"%s: malformed #cgo argument: %s"
,
filename
,
arg
)
}
}
...
...
@@ -943,9 +943,12 @@ func (ctxt *Context) saveCgo(filename string, di *Package, cg *ast.CommentGroup)
return
nil
}
var
safeBytes
=
[]
byte
(
"+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:"
)
// NOTE: $ is not safe for the shell, but it is allowed here because of linker options like -Wl,$ORIGIN.
// We never pass these arguments to a shell (just to programs we construct argv for), so this should be okay.
// See golang.org/issue/6038.
var
safeBytes
=
[]
byte
(
"+-.,/0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz:$"
)
func
safeName
(
s
string
)
bool
{
func
safe
Cgo
Name
(
s
string
)
bool
{
if
s
==
""
{
return
false
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment