mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
cmd/link: fix cgo on riscv64 when building with gcc-15
It's not currently possible to build cgo programs that are partially compiled with gcc-15 on riscv64 using the internal linker. There are two reasons for this. 1. When gcc-15 compiles _cgo_export.c, which contains no actual code, for a riscv64 target, it emits a label in the .text section called .Letext0. This label is referred to by another section, .debug_line, and an entry is generated in the symbol table for it. The Go linker panics when processing the .Letext0 symbol in _cgo_export.o, as it occurs in an empty section. 2. GCC-15 is generating additional debug symbols with the .LVUS prefix, e.g., .LVUS33, that need to be ignored. We fix the issue by removing the check in cmd/link/internal/loader/loader.go that panics if we encounter a symbol in an empty section (the comments preceding this check suggest it's safe to remove it) and by adding .LVUS to the list of symbol prefixes to ignore. Fixes #72840 Change-Id: I00658b6bdd01606dde1581b5bc2f42edfc37de82 Reviewed-on: https://go-review.googlesource.com/c/go/+/668276 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
This commit is contained in:
parent
214b208e24
commit
12e5efd710
@ -609,7 +609,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(elfsym.name, ".LASF") || strings.HasPrefix(elfsym.name, ".LLRL") || strings.HasPrefix(elfsym.name, ".LLST") {
|
if strings.HasPrefix(elfsym.name, ".LASF") || strings.HasPrefix(elfsym.name, ".LLRL") || strings.HasPrefix(elfsym.name, ".LLST") || strings.HasPrefix(elfsym.name, ".LVUS") {
|
||||||
// gcc on s390x and riscv64 does this.
|
// gcc on s390x and riscv64 does this.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -1719,14 +1719,6 @@ func (l *Loader) GetVarDwarfAuxSym(i Sym) Sym {
|
|||||||
// expected to have the actual content/payload) and then a set of
|
// expected to have the actual content/payload) and then a set of
|
||||||
// interior loader.Sym's that point into a portion of the container.
|
// interior loader.Sym's that point into a portion of the container.
|
||||||
func (l *Loader) AddInteriorSym(container Sym, interior Sym) {
|
func (l *Loader) AddInteriorSym(container Sym, interior Sym) {
|
||||||
// Container symbols are expected to have content/data.
|
|
||||||
// NB: this restriction may turn out to be too strict (it's possible
|
|
||||||
// to imagine a zero-sized container with an interior symbol pointing
|
|
||||||
// into it); it's ok to relax or remove it if we counter an
|
|
||||||
// oddball host object that triggers this.
|
|
||||||
if l.SymSize(container) == 0 && len(l.Data(container)) == 0 {
|
|
||||||
panic("unexpected empty container symbol")
|
|
||||||
}
|
|
||||||
// The interior symbols for a container are not expected to have
|
// The interior symbols for a container are not expected to have
|
||||||
// content/data or relocations.
|
// content/data or relocations.
|
||||||
if len(l.Data(interior)) != 0 {
|
if len(l.Data(interior)) != 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user