Skip to content

Commit

Permalink
Revert "cmd/link: load symbols from .syso in external link mode"
Browse files Browse the repository at this point in the history
This reverts CL 186417.

Reason for revert: Broke darwin (10_14), linux (ppc), aix (ppc)

Updates golang#33139

Change-Id: I8bf3c817a96a0e57e45754a097cea7062b2fcdfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/198177
Run-TryBot: Andrew Bonventre <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Bryan C. Mills <[email protected]>
  • Loading branch information
andybons committed Oct 1, 2019
1 parent af88080 commit 1820cca
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 76 deletions.
29 changes: 0 additions & 29 deletions src/cmd/go/testdata/script/link_syso_issue33139.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/cmd/link/internal/arm/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ func archreloc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val int64) (int64, bo
rs = rs.Outer
}

if rs.Type != sym.SHOSTOBJ && rs.Type != sym.SDYNIMPORT && rs.Type != sym.SUNDEFEXT && rs.Sect == nil {
if rs.Type != sym.SHOSTOBJ && rs.Type != sym.SDYNIMPORT && rs.Sect == nil {
ld.Errorf(s, "missing section for %s", rs.Name)
}
r.Xsym = rs
Expand Down
13 changes: 1 addition & 12 deletions src/cmd/link/internal/ld/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func trampoline(ctxt *Link, s *sym.Symbol) {
if !r.Type.IsDirectJump() {
continue
}
if Symaddr(r.Sym) == 0 && (r.Sym.Type != sym.SDYNIMPORT && r.Sym.Type != sym.SUNDEFEXT) {
if Symaddr(r.Sym) == 0 && r.Sym.Type != sym.SDYNIMPORT {
if r.Sym.File != s.File {
if !isRuntimeDepPkg(s.File) || !isRuntimeDepPkg(r.Sym.File) {
ctxt.ErrorUnresolved(s, r)
Expand Down Expand Up @@ -418,17 +418,6 @@ func relocsym(ctxt *Link, s *sym.Symbol) {
}
fallthrough
case objabi.R_CALL, objabi.R_PCREL:
if ctxt.LinkMode == LinkExternal && r.Sym != nil && r.Sym.Type == sym.SUNDEFEXT {
// pass through to the external linker.
r.Done = false
r.Xadd = 0
if ctxt.IsELF {
r.Xadd -= int64(r.Siz)
}
r.Xsym = r.Sym
o = 0
break
}
if ctxt.LinkMode == LinkExternal && r.Sym != nil && r.Sym.Type != sym.SCONST && (r.Sym.Sect != s.Sect || r.Type == objabi.R_GOTPCREL) {
r.Done = false

Expand Down
18 changes: 0 additions & 18 deletions src/cmd/link/internal/ld/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,24 +334,6 @@ func fieldtrack(ctxt *Link) {
}

func (ctxt *Link) addexport() {
// Track undefined external symbols during external link.
if ctxt.LinkMode == LinkExternal {
for _, s := range ctxt.Syms.Allsym {
if !s.Attr.Reachable() || s.Attr.Special() || s.Attr.SubSymbol() {
continue
}
if s.Type != sym.STEXT {
continue
}
for i := range s.R {
r := &s.R[i]
if r.Sym != nil && r.Sym.Type == sym.Sxxx {
r.Sym.Type = sym.SUNDEFEXT
}
}
}
}

// TODO(aix)
if ctxt.HeadType == objabi.Hdarwin || ctxt.HeadType == objabi.Haix {
return
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/link/internal/ld/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -2348,7 +2348,7 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
}
put(ctxt, s, s.Name, BSSSym, Symaddr(s), s.Gotype)

case sym.SHOSTOBJ, sym.SUNDEFEXT:
case sym.SHOSTOBJ:
if ctxt.HeadType == objabi.Hwindows || ctxt.IsELF {
put(ctxt, s, s.Name, UndefinedSym, s.Value, nil)
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/link/internal/ld/macho.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ func machogenasmsym(ctxt *Link) {
}
}

if s.Type == sym.SDYNIMPORT || s.Type == sym.SHOSTOBJ || s.Type == sym.SUNDEFEXT {
if s.Type == sym.SDYNIMPORT || s.Type == sym.SHOSTOBJ {
if s.Attr.Reachable() {
addsym(ctxt, s, "", DataSym, 0, nil)
}
Expand Down Expand Up @@ -886,7 +886,7 @@ func machosymtab(ctxt *Link) {
// replace "·" as ".", because DTrace cannot handle it.
Addstring(symstr, strings.Replace(s.Extname(), "·", ".", -1))

if s.Type == sym.SDYNIMPORT || s.Type == sym.SHOSTOBJ || s.Type == sym.SUNDEFEXT {
if s.Type == sym.SDYNIMPORT || s.Type == sym.SHOSTOBJ {
symtab.AddUint8(0x01) // type N_EXT, external symbol
symtab.AddUint8(0) // no section
symtab.AddUint16(ctxt.Arch, 0) // desc
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/link/internal/ld/pe.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func (f *peFile) writeSymbols(ctxt *Link) {
// Only windows/386 requires underscore prefix on external symbols.
if ctxt.Arch.Family == sys.I386 &&
ctxt.LinkMode == LinkExternal &&
(s.Type == sym.SHOSTOBJ || s.Type == sym.SUNDEFEXT || s.Attr.CgoExport()) {
(s.Type == sym.SHOSTOBJ || s.Attr.CgoExport()) {
s.Name = "_" + s.Name
}

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/link/internal/ld/symtab.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func putelfsym(ctxt *Link, x *sym.Symbol, s string, t SymbolType, addr int64, go
}

var elfshnum int
if xo.Type == sym.SDYNIMPORT || xo.Type == sym.SHOSTOBJ || xo.Type == sym.SUNDEFEXT {
if xo.Type == sym.SDYNIMPORT || xo.Type == sym.SHOSTOBJ {
elfshnum = SHN_UNDEF
} else {
if xo.Sect == nil {
Expand Down
1 change: 0 additions & 1 deletion src/cmd/link/internal/sym/symkind.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ const (
SCONST
SDYNIMPORT
SHOSTOBJ
SUNDEFEXT // Undefined symbol for resolution by external linker

// Sections for debugging information
SDWARFSECT
Expand Down
19 changes: 9 additions & 10 deletions src/cmd/link/internal/sym/symkind_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1820cca

Please sign in to comment.