mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/link: merge .pdata and .xdata sections from host object files
The Go linker doesn't currently merge .pdata/.xdata sections from the host object files generated by the C compiler when using internal linking. This means that the stack can't be unwind in C -> Go. This CL fixes that and adds a test to ensure that the stack can be unwind in C -> Go and Go -> C transitions, which was not well tested. Updates #57302 Change-Id: Ie86a5e6e30b80978277e66ccc2c48550e51263c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/534555 Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
96eeb4512b
commit
3aa2823d8b
8 changed files with 368 additions and 53 deletions
|
|
@ -2220,15 +2220,21 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string,
|
|||
0xc401, // arm
|
||||
0x64aa: // arm64
|
||||
ldpe := func(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
|
||||
textp, rsrc, err := loadpe.Load(ctxt.loader, ctxt.Arch, ctxt.IncVersion(), f, pkg, length, pn)
|
||||
ls, err := loadpe.Load(ctxt.loader, ctxt.Arch, ctxt.IncVersion(), f, pkg, length, pn)
|
||||
if err != nil {
|
||||
Errorf(nil, "%v", err)
|
||||
return
|
||||
}
|
||||
if len(rsrc) != 0 {
|
||||
setpersrc(ctxt, rsrc)
|
||||
if len(ls.Resources) != 0 {
|
||||
setpersrc(ctxt, ls.Resources)
|
||||
}
|
||||
ctxt.Textp = append(ctxt.Textp, textp...)
|
||||
if ls.PData != 0 {
|
||||
sehp.pdata = append(sehp.pdata, ls.PData)
|
||||
}
|
||||
if ls.XData != 0 {
|
||||
sehp.xdata = append(sehp.xdata, ls.XData)
|
||||
}
|
||||
ctxt.Textp = append(ctxt.Textp, ls.Textp...)
|
||||
}
|
||||
return ldhostobj(ldpe, ctxt.HeadType, f, pkg, length, pn, file)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue