mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
cmd/link: fix -buildmode=pie / -linkshared combination
main.main and main.init were not being marked as reachable. Fixes #17076 Change-Id: Ib3e29bd35ba6252962e6ba89173ca321ed6849b9 Reviewed-on: https://go-review.googlesource.com/28996 Reviewed-by: David Crawshaw <crawshaw@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
38d35e714a
commit
8f9671d11a
|
@ -394,6 +394,14 @@ func TestTrivialExecutable(t *testing.T) {
|
||||||
AssertHasRPath(t, "./bin/trivial", gorootInstallDir)
|
AssertHasRPath(t, "./bin/trivial", gorootInstallDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build a trivial program in PIE mode that links against the shared runtime and check it runs.
|
||||||
|
func TestTrivialExecutablePIE(t *testing.T) {
|
||||||
|
goCmd(t, "build", "-buildmode=pie", "-o", "trivial.pie", "-linkshared", "trivial")
|
||||||
|
run(t, "trivial executable", "./trivial.pie")
|
||||||
|
AssertIsLinkedTo(t, "./trivial.pie", soname)
|
||||||
|
AssertHasRPath(t, "./trivial.pie", gorootInstallDir)
|
||||||
|
}
|
||||||
|
|
||||||
// Build an executable that uses cgo linked against the shared runtime and check it
|
// Build an executable that uses cgo linked against the shared runtime and check it
|
||||||
// runs.
|
// runs.
|
||||||
func TestCgoExecutable(t *testing.T) {
|
func TestCgoExecutable(t *testing.T) {
|
||||||
|
|
|
@ -241,7 +241,7 @@ func (d *deadcodepass) init() {
|
||||||
// In a normal binary, start at main.main and the init
|
// In a normal binary, start at main.main and the init
|
||||||
// functions and mark what is reachable from there.
|
// functions and mark what is reachable from there.
|
||||||
names = append(names, *flagEntrySymbol)
|
names = append(names, *flagEntrySymbol)
|
||||||
if *FlagLinkshared && Buildmode == BuildmodeExe {
|
if *FlagLinkshared && (Buildmode == BuildmodeExe || Buildmode == BuildmodePIE) {
|
||||||
names = append(names, "main.main", "main.init")
|
names = append(names, "main.main", "main.init")
|
||||||
}
|
}
|
||||||
for _, name := range markextra {
|
for _, name := range markextra {
|
||||||
|
|
Loading…
Reference in a new issue