aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/objfile
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2025-11-02 13:54:22 -0800
committerGopher Robot <gobot@golang.org>2025-11-04 16:38:05 -0800
commit7347b54727519eecf693e9c10c504dc28611cbbf (patch)
treee14a50efa08ed2e21936fc556557498fc4f87360 /src/cmd/internal/objfile
parent6914dd11c05678e78a50d6bd0c6f6789e00f6d6d (diff)
downloadgo-7347b54727519eecf693e9c10c504dc28611cbbf.tar.xz
cmd/link: don't generate .gosymtab section
Since Go 1.2 the section is always empty. Also remove the code looking for .gosymtab in cmd/internal/objfile. For #76038 Change-Id: Icd34c870ed0c6da8001e8d32305f79905ee2b066 Reviewed-on: https://go-review.googlesource.com/c/go/+/717200 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Commit-Queue: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/cmd/internal/objfile')
-rw-r--r--src/cmd/internal/objfile/elf.go22
-rw-r--r--src/cmd/internal/objfile/goobj.go4
-rw-r--r--src/cmd/internal/objfile/macho.go11
-rw-r--r--src/cmd/internal/objfile/objfile.go6
-rw-r--r--src/cmd/internal/objfile/pe.go15
-rw-r--r--src/cmd/internal/objfile/plan9obj.go13
-rw-r--r--src/cmd/internal/objfile/xcoff.go7
7 files changed, 22 insertions, 56 deletions
diff --git a/src/cmd/internal/objfile/elf.go b/src/cmd/internal/objfile/elf.go
index 8923290cff..6988cea936 100644
--- a/src/cmd/internal/objfile/elf.go
+++ b/src/cmd/internal/objfile/elf.go
@@ -64,40 +64,26 @@ func (f *elfFile) symbols() ([]Sym, error) {
return syms, nil
}
-func (f *elfFile) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
+func (f *elfFile) pcln() (textStart uint64, pclntab []byte, err error) {
if sect := f.elf.Section(".text"); sect != nil {
textStart = sect.Addr
}
- sect := f.elf.Section(".gosymtab")
- if sect == nil {
- // try .data.rel.ro.gosymtab, for PIE binaries
- sect = f.elf.Section(".data.rel.ro.gosymtab")
- }
- if sect != nil {
- if symtab, err = sect.Data(); err != nil {
- return 0, nil, nil, err
- }
- } else {
- // if both sections failed, try the symbol
- symtab = f.symbolData("runtime.symtab", "runtime.esymtab")
- }
-
- sect = f.elf.Section(".gopclntab")
+ sect := f.elf.Section(".gopclntab")
if sect == nil {
// try .data.rel.ro.gopclntab, for PIE binaries
sect = f.elf.Section(".data.rel.ro.gopclntab")
}
if sect != nil {
if pclntab, err = sect.Data(); err != nil {
- return 0, nil, nil, err
+ return 0, nil, err
}
} else {
// if both sections failed, try the symbol
pclntab = f.symbolData("runtime.pclntab", "runtime.epclntab")
}
- return textStart, symtab, pclntab, nil
+ return textStart, pclntab, nil
}
func (f *elfFile) text() (textStart uint64, text []byte, err error) {
diff --git a/src/cmd/internal/objfile/goobj.go b/src/cmd/internal/objfile/goobj.go
index 7d564a2661..ec852d0669 100644
--- a/src/cmd/internal/objfile/goobj.go
+++ b/src/cmd/internal/objfile/goobj.go
@@ -221,10 +221,10 @@ func (f *goobjFile) symbols() ([]Sym, error) {
return syms, nil
}
-func (f *goobjFile) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
+func (f *goobjFile) pcln() (textStart uint64, pclntab []byte, err error) {
// Should never be called. We implement Liner below, callers
// should use that instead.
- return 0, nil, nil, fmt.Errorf("pcln not available in go object file")
+ return 0, nil, fmt.Errorf("pcln not available in go object file")
}
// PCToLine returns the file name, line, and function data for the given pc.
diff --git a/src/cmd/internal/objfile/macho.go b/src/cmd/internal/objfile/macho.go
index 8258145f26..eaf665faee 100644
--- a/src/cmd/internal/objfile/macho.go
+++ b/src/cmd/internal/objfile/macho.go
@@ -79,21 +79,16 @@ func (f *machoFile) symbols() ([]Sym, error) {
return syms, nil
}
-func (f *machoFile) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
+func (f *machoFile) pcln() (textStart uint64, pclntab []byte, err error) {
if sect := f.macho.Section("__text"); sect != nil {
textStart = sect.Addr
}
- if sect := f.macho.Section("__gosymtab"); sect != nil {
- if symtab, err = sect.Data(); err != nil {
- return 0, nil, nil, err
- }
- }
if sect := f.macho.Section("__gopclntab"); sect != nil {
if pclntab, err = sect.Data(); err != nil {
- return 0, nil, nil, err
+ return 0, nil, err
}
}
- return textStart, symtab, pclntab, nil
+ return textStart, pclntab, nil
}
func (f *machoFile) text() (textStart uint64, text []byte, err error) {
diff --git a/src/cmd/internal/objfile/objfile.go b/src/cmd/internal/objfile/objfile.go
index ed9aae280e..32e06dfd99 100644
--- a/src/cmd/internal/objfile/objfile.go
+++ b/src/cmd/internal/objfile/objfile.go
@@ -18,7 +18,7 @@ import (
type rawFile interface {
symbols() (syms []Sym, err error)
- pcln() (textStart uint64, symtab, pclntab []byte, err error)
+ pcln() (textStart uint64, pclntab []byte, err error)
text() (textStart uint64, text []byte, err error)
goarch() string
loadAddress() (uint64, error)
@@ -141,7 +141,7 @@ func (e *Entry) PCLineTable() (Liner, error) {
return pcln, nil
}
// Otherwise, read the pcln tables and build a Liner out of that.
- textStart, symtab, pclntab, err := e.raw.pcln()
+ textStart, pclntab, err := e.raw.pcln()
if err != nil {
return nil, err
}
@@ -154,7 +154,7 @@ func (e *Entry) PCLineTable() (Liner, error) {
}
}
}
- return gosym.NewTable(symtab, gosym.NewLineTable(pclntab, textStart))
+ return gosym.NewTable(nil, gosym.NewLineTable(pclntab, textStart))
}
func (e *Entry) Text() (uint64, []byte, error) {
diff --git a/src/cmd/internal/objfile/pe.go b/src/cmd/internal/objfile/pe.go
index c5c08264a9..e94821298f 100644
--- a/src/cmd/internal/objfile/pe.go
+++ b/src/cmd/internal/objfile/pe.go
@@ -90,10 +90,10 @@ func (f *peFile) symbols() ([]Sym, error) {
return syms, nil
}
-func (f *peFile) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
+func (f *peFile) pcln() (textStart uint64, pclntab []byte, err error) {
imageBase, err := f.imageBase()
if err != nil {
- return 0, nil, nil, err
+ return 0, nil, err
}
if sect := f.pe.Section(".text"); sect != nil {
@@ -104,17 +104,10 @@ func (f *peFile) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
// TODO: Remove code looking for the old symbols when we no longer care about 1.3.
var err2 error
if pclntab, err2 = loadPETable(f.pe, "pclntab", "epclntab"); err2 != nil {
- return 0, nil, nil, err
- }
- }
- if symtab, err = loadPETable(f.pe, "runtime.symtab", "runtime.esymtab"); err != nil {
- // Same as above.
- var err2 error
- if symtab, err2 = loadPETable(f.pe, "symtab", "esymtab"); err2 != nil {
- return 0, nil, nil, err
+ return 0, nil, err
}
}
- return textStart, symtab, pclntab, nil
+ return textStart, pclntab, nil
}
func (f *peFile) text() (textStart uint64, text []byte, err error) {
diff --git a/src/cmd/internal/objfile/plan9obj.go b/src/cmd/internal/objfile/plan9obj.go
index c91970762c..edd40230ce 100644
--- a/src/cmd/internal/objfile/plan9obj.go
+++ b/src/cmd/internal/objfile/plan9obj.go
@@ -71,24 +71,17 @@ func (f *plan9File) symbols() ([]Sym, error) {
return syms, nil
}
-func (f *plan9File) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
+func (f *plan9File) pcln() (textStart uint64, pclntab []byte, err error) {
textStart = f.plan9.LoadAddress + f.plan9.HdrSize
if pclntab, err = loadPlan9Table(f.plan9, "runtime.pclntab", "runtime.epclntab"); err != nil {
// We didn't find the symbols, so look for the names used in 1.3 and earlier.
// TODO: Remove code looking for the old symbols when we no longer care about 1.3.
var err2 error
if pclntab, err2 = loadPlan9Table(f.plan9, "pclntab", "epclntab"); err2 != nil {
- return 0, nil, nil, err
+ return 0, nil, err
}
}
- if symtab, err = loadPlan9Table(f.plan9, "runtime.symtab", "runtime.esymtab"); err != nil {
- // Same as above.
- var err2 error
- if symtab, err2 = loadPlan9Table(f.plan9, "symtab", "esymtab"); err2 != nil {
- return 0, nil, nil, err
- }
- }
- return textStart, symtab, pclntab, nil
+ return textStart, pclntab, nil
}
func (f *plan9File) text() (textStart uint64, text []byte, err error) {
diff --git a/src/cmd/internal/objfile/xcoff.go b/src/cmd/internal/objfile/xcoff.go
index 24f42760c9..85928621f1 100644
--- a/src/cmd/internal/objfile/xcoff.go
+++ b/src/cmd/internal/objfile/xcoff.go
@@ -87,15 +87,14 @@ func (f *xcoffFile) symbols() ([]Sym, error) {
return syms, nil
}
-func (f *xcoffFile) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
+func (f *xcoffFile) pcln() (textStart uint64, pclntab []byte, err error) {
if sect := f.xcoff.Section(".text"); sect != nil {
textStart = sect.VirtualAddress
}
if pclntab, err = loadXCOFFTable(f.xcoff, "runtime.pclntab", "runtime.epclntab"); err != nil {
- return 0, nil, nil, err
+ return 0, nil, err
}
- symtab, _ = loadXCOFFTable(f.xcoff, "runtime.symtab", "runtime.esymtab") // ignore error, this symbol is not useful anyway
- return textStart, symtab, pclntab, nil
+ return textStart, pclntab, nil
}
func (f *xcoffFile) text() (textStart uint64, text []byte, err error) {