mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go, cmd/link: build c-archive as position independent on ELF
This permits people to use -buildmode=c-archive to produce an archive file that can be included in a PIE or shared library. Change-Id: Ie340ee2f08bcff4f6fd1415f7d96d51ee3a7c9a1 Reviewed-on: https://go-review.googlesource.com/24180 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
dc9755c2a2
commit
d92a3606f5
6 changed files with 101 additions and 9 deletions
|
|
@ -51,8 +51,19 @@ func addcall(ctxt *ld.Link, s *ld.Symbol, t *ld.Symbol) {
|
|||
}
|
||||
|
||||
func gentext(ctxt *ld.Link) {
|
||||
if !ld.DynlinkingGo() && ld.Buildmode != ld.BuildmodePIE && ld.Buildmode != ld.BuildmodeCShared {
|
||||
return
|
||||
if ld.DynlinkingGo() {
|
||||
// We need get_pc_thunk.
|
||||
} else {
|
||||
switch ld.Buildmode {
|
||||
case ld.BuildmodeCArchive:
|
||||
if !ld.Iself {
|
||||
return
|
||||
}
|
||||
case ld.BuildmodePIE, ld.BuildmodeCShared:
|
||||
// We need get_pc_thunk.
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Generate little thunks that load the PC of the next instruction into a register.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue