mirror of
https://github.com/golang/go
synced 2024-11-11 21:40:21 -07:00
cmd/link: exit early when -d is used on libc platforms
On platforms where we use libc for syscalls, we dynamically link with libc and therefore dynamic linking cannot be disabled. Exit early when -d is specified. Update #42459. Change-Id: I05abfe111df723b5ee512ceafef734e3804dd0a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/365658 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
b31dda8a2a
commit
57aba325c8
@ -172,6 +172,10 @@ func Main(arch *sys.Arch, theArch Arch) {
|
|||||||
usage()
|
usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *FlagD && ctxt.UsesLibc() {
|
||||||
|
Exitf("dynamic linking required on %s; -d flag cannot be used", buildcfg.GOOS)
|
||||||
|
}
|
||||||
|
|
||||||
checkStrictDups = *FlagStrictDups
|
checkStrictDups = *FlagStrictDups
|
||||||
|
|
||||||
if !buildcfg.Experiment.RegabiWrappers {
|
if !buildcfg.Experiment.RegabiWrappers {
|
||||||
|
@ -185,3 +185,13 @@ func (t *Target) mustSetHeadType() {
|
|||||||
func (t *Target) IsBigEndian() bool {
|
func (t *Target) IsBigEndian() bool {
|
||||||
return t.Arch.ByteOrder == binary.BigEndian
|
return t.Arch.ByteOrder == binary.BigEndian
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Target) UsesLibc() bool {
|
||||||
|
t.mustSetHeadType()
|
||||||
|
switch t.HeadType {
|
||||||
|
case objabi.Haix, objabi.Hdarwin, objabi.Hopenbsd, objabi.Hsolaris, objabi.Hwindows:
|
||||||
|
// platforms where we use libc for syscalls.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -1290,10 +1290,6 @@ func Xcoffadddynrel(target *Target, ldr *loader.Loader, syms *ArchSyms, s loader
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ctxt *Link) doxcoff() {
|
func (ctxt *Link) doxcoff() {
|
||||||
if *FlagD {
|
|
||||||
// All XCOFF files have dynamic symbols because of the syscalls.
|
|
||||||
Exitf("-d is not available on AIX")
|
|
||||||
}
|
|
||||||
ldr := ctxt.loader
|
ldr := ctxt.loader
|
||||||
|
|
||||||
// TOC
|
// TOC
|
||||||
|
Loading…
Reference in New Issue
Block a user