mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: split large elf text sections on ppc64x
Some applications built with Go on ppc64x with external linking can fail to link with relocation truncation errors if the elf text section that is generated is larger than 2^26 bytes and that section contains a call instruction (bl) which calls a function beyond the limit addressable by the 24 bit field in the instruction. This solution consists of generating multiple text sections where each is small enough to allow the GNU linker to resolve the calls by generating long branch code where needed. Other changes were added to handle differences in processing when multiple text sections exist. Some adjustments were required to the computation of a method's address when using the method offset table when there are multiple text sections. The number of possible section headers was increased to allow for up to 128 text sections. A test case was also added. Fixes #15823. Change-Id: If8117b0e0afb058cbc072258425a35aef2363c92 Reviewed-on: https://go-review.googlesource.com/27790 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
445f51fb11
commit
b4efd09d18
8 changed files with 362 additions and 27 deletions
|
|
@ -1812,6 +1812,28 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, SymbolType, int64, *
|
|||
if s.Type == obj.STEXT {
|
||||
put(ctxt, s, s.Name, TextSym, s.Value, nil)
|
||||
}
|
||||
|
||||
n := 0
|
||||
|
||||
// Generate base addresses for all text sections if there are multiple
|
||||
for sect := Segtext.Sect; sect != nil; sect = sect.Next {
|
||||
if n == 0 {
|
||||
n++
|
||||
continue
|
||||
}
|
||||
if sect.Name != ".text" {
|
||||
break
|
||||
}
|
||||
s = ctxt.Syms.ROLookup(fmt.Sprintf("runtime.text.%d", n), 0)
|
||||
if s == nil {
|
||||
break
|
||||
}
|
||||
if s.Type == obj.STEXT {
|
||||
put(ctxt, s, s.Name, TextSym, s.Value, nil)
|
||||
}
|
||||
n++
|
||||
}
|
||||
|
||||
s = ctxt.Syms.Lookup("runtime.etext", 0)
|
||||
if s.Type == obj.STEXT {
|
||||
put(ctxt, s, s.Name, TextSym, s.Value, nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue