mirror of https://github.com/golang/go.git
cmd/internal/ld: reserve space for package list note when -buildmode=shared
This makes the intermediate object file a little bigger but it doesn't waste any space in the final shared library. Fixes #10691 Change-Id: Ic51a571d60291f1ac2dad1b50dba4679643168ae Reviewed-on: https://go-review.googlesource.com/9710 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
a1858e9cf0
commit
de6d5b0801
|
|
@ -169,6 +169,14 @@ func archinit() {
|
|||
ld.Elfinit()
|
||||
|
||||
ld.HEADR = ld.ELFRESERVE
|
||||
if ld.Buildmode == ld.BuildmodeShared {
|
||||
// When building a shared library we write a package list
|
||||
// note that can get quite large. The external linker will
|
||||
// re-layout all the sections anyway, so making this larger
|
||||
// just wastes a little space in the intermediate object
|
||||
// file, not the final shared library.
|
||||
ld.HEADR *= 3
|
||||
}
|
||||
if ld.INITTEXT == -1 {
|
||||
ld.INITTEXT = (1 << 22) + int64(ld.HEADR)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1909,8 +1909,9 @@ func Asmbelf(symo int64) {
|
|||
eh.machine = EM_PPC64
|
||||
}
|
||||
|
||||
elfreserve := int64(ELFRESERVE)
|
||||
startva := INITTEXT - int64(HEADR)
|
||||
resoff := int64(ELFRESERVE)
|
||||
resoff := elfreserve
|
||||
|
||||
var pph *ElfPhdr
|
||||
var pnote *ElfPhdr
|
||||
|
|
@ -1921,6 +1922,12 @@ func Asmbelf(symo int64) {
|
|||
eh.phentsize = 0
|
||||
|
||||
if Buildmode == BuildmodeShared {
|
||||
// The package list note we make space for here can get quite
|
||||
// large. The external linker will re-layout all the sections
|
||||
// anyway, so making this larger just wastes a little space
|
||||
// in the intermediate object file, not the final shared
|
||||
// library.
|
||||
elfreserve *= 3
|
||||
sh := elfshname(".note.go.pkg-list")
|
||||
resoff -= int64(elfgopkgnote(sh, uint64(startva), uint64(resoff)))
|
||||
}
|
||||
|
|
@ -2336,8 +2343,8 @@ elfobj:
|
|||
a += int64(elfwritegopkgnote())
|
||||
}
|
||||
|
||||
if a > ELFRESERVE {
|
||||
Diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE)
|
||||
if a > elfreserve {
|
||||
Diag("ELFRESERVE too small: %d > %d", a, elfreserve)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue