Commit 164f99e5 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

Revert "cmd/link: replace SHIDDEN bit in SymKind with a bit of Attribute"

This reverts commit a69222d9.

Reason for revert: broke ppc64le

Change-Id: I57d275177e90f036caf7dbade9669b8121dfa437
Reviewed-on: https://go-review.googlesource.com/42194Reviewed-by: 's avatarMichael Hudson-Doyle <michael.hudson@canonical.com>
parent a69222d9
...@@ -250,7 +250,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int { ...@@ -250,7 +250,7 @@ func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
// (https://sourceware.org/bugzilla/show_bug.cgi?id=18270). So // (https://sourceware.org/bugzilla/show_bug.cgi?id=18270). So
// we convert the adrp; ld64 + R_ARM64_GOTPCREL into adrp; // we convert the adrp; ld64 + R_ARM64_GOTPCREL into adrp;
// add + R_ADDRARM64. // add + R_ADDRARM64.
if !(r.Sym.Version != 0 || r.Sym.Attr.VisibilityHidden() || r.Sym.Attr.Local()) && r.Sym.Type == ld.STEXT && ctxt.DynlinkingGo() { if !(r.Sym.Version != 0 || (r.Sym.Type&ld.SHIDDEN != 0) || r.Sym.Attr.Local()) && r.Sym.Type == ld.STEXT && ctxt.DynlinkingGo() {
if o2&0xffc00000 != 0xf9400000 { if o2&0xffc00000 != 0xf9400000 {
ld.Errorf(s, "R_ARM64_GOTPCREL against unexpected instruction %x", o2) ld.Errorf(s, "R_ARM64_GOTPCREL against unexpected instruction %x", o2)
} }
......
...@@ -386,7 +386,7 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -386,7 +386,7 @@ func relocsym(ctxt *Link, s *Symbol) {
continue continue
} }
if r.Sym != nil && ((r.Sym.Type == 0 && !r.Sym.Attr.VisibilityHidden()) || r.Sym.Type&SMASK == SXREF) { if r.Sym != nil && (r.Sym.Type&(SMASK|SHIDDEN) == 0 || r.Sym.Type&SMASK == SXREF) {
// When putting the runtime but not main into a shared library // When putting the runtime but not main into a shared library
// these symbols are undefined and that's OK. // these symbols are undefined and that's OK.
if Buildmode == BuildmodeShared { if Buildmode == BuildmodeShared {
......
...@@ -1060,7 +1060,8 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int, loc ...@@ -1060,7 +1060,8 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int, loc
// set dupok generally. See http://codereview.appspot.com/5823055/ // set dupok generally. See http://codereview.appspot.com/5823055/
// comment #5 for details. // comment #5 for details.
if s != nil && sym.other == 2 { if s != nil && sym.other == 2 {
s.Attr |= AttrDuplicateOK | AttrVisibilityHidden s.Type |= SHIDDEN
s.Attr |= AttrDuplicateOK
} }
} }
...@@ -1076,7 +1077,7 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int, loc ...@@ -1076,7 +1077,7 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int, loc
// so put it in the hash table. // so put it in the hash table.
if needSym != 0 { if needSym != 0 {
s = ctxt.Syms.Lookup(sym.name, localSymVersion) s = ctxt.Syms.Lookup(sym.name, localSymVersion)
s.Attr |= AttrVisibilityHidden s.Type |= SHIDDEN
} }
break break
...@@ -1088,14 +1089,14 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int, loc ...@@ -1088,14 +1089,14 @@ func readelfsym(ctxt *Link, elfobj *ElfObj, i int, sym *ElfSym, needSym int, loc
// don't bother to add them into the hash table // don't bother to add them into the hash table
s = ctxt.Syms.newsym(sym.name, localSymVersion) s = ctxt.Syms.newsym(sym.name, localSymVersion)
s.Attr |= AttrVisibilityHidden s.Type |= SHIDDEN
} }
case ElfSymBindWeak: case ElfSymBindWeak:
if needSym != 0 { if needSym != 0 {
s = ctxt.Syms.Lookup(sym.name, 0) s = ctxt.Syms.Lookup(sym.name, 0)
if sym.other == 2 { if sym.other == 2 {
s.Attr |= AttrVisibilityHidden s.Type |= SHIDDEN
} }
} }
......
...@@ -135,11 +135,6 @@ const ( ...@@ -135,11 +135,6 @@ const (
// AttrMakeTypelink Amarks types that should be added to the typelink // AttrMakeTypelink Amarks types that should be added to the typelink
// table. See typelinks.go:typelinks(). // table. See typelinks.go:typelinks().
AttrMakeTypelink AttrMakeTypelink
// AttrVisibilityHidden symbols are ELF symbols with
// visibility set to STV_HIDDEN. They become local symbols in
// the final executable. Only relevant when internally linking
// on an ELF platform.
AttrVisibilityHidden
) )
func (a Attribute) DuplicateOK() bool { return a&AttrDuplicateOK != 0 } func (a Attribute) DuplicateOK() bool { return a&AttrDuplicateOK != 0 }
...@@ -155,7 +150,6 @@ func (a Attribute) OnList() bool { return a&AttrOnList != 0 } ...@@ -155,7 +150,6 @@ func (a Attribute) OnList() bool { return a&AttrOnList != 0 }
func (a Attribute) Local() bool { return a&AttrLocal != 0 } func (a Attribute) Local() bool { return a&AttrLocal != 0 }
func (a Attribute) ReflectMethod() bool { return a&AttrReflectMethod != 0 } func (a Attribute) ReflectMethod() bool { return a&AttrReflectMethod != 0 }
func (a Attribute) MakeTypelink() bool { return a&AttrMakeTypelink != 0 } func (a Attribute) MakeTypelink() bool { return a&AttrMakeTypelink != 0 }
func (a Attribute) VisibilityHidden() bool { return a&AttrVisibilityHidden != 0 }
func (a Attribute) CgoExport() bool { func (a Attribute) CgoExport() bool {
return a.CgoExportDynamic() || a.CgoExportStatic() return a.CgoExportDynamic() || a.CgoExportStatic()
......
...@@ -1041,9 +1041,7 @@ func writePESymTableRecords(ctxt *Link) int { ...@@ -1041,9 +1041,7 @@ func writePESymTableRecords(ctxt *Link) int {
typ = 0x0308 // "array of structs" typ = 0x0308 // "array of structs"
} }
class := IMAGE_SYM_CLASS_EXTERNAL class := IMAGE_SYM_CLASS_EXTERNAL
// TODO(mwudson): I think s.Attr.VisibilityHidden() if s.Version != 0 || (s.Type&SHIDDEN != 0) || s.Attr.Local() {
// can only ever be true for an ELF link.
if s.Version != 0 || s.Attr.VisibilityHidden() || s.Attr.Local() {
class = IMAGE_SYM_CLASS_STATIC class = IMAGE_SYM_CLASS_STATIC
} }
writeOneSymbol(s, value, sect, typ, uint8(class)) writeOneSymbol(s, value, sect, typ, uint8(class))
......
...@@ -106,6 +106,7 @@ const ( ...@@ -106,6 +106,7 @@ const (
SDWARFINFO SDWARFINFO
SSUB = SymKind(1 << 8) SSUB = SymKind(1 << 8)
SMASK = SymKind(SSUB - 1) SMASK = SymKind(SSUB - 1)
SHIDDEN = SymKind(1 << 9)
SCONTAINER = SymKind(1 << 10) // has a sub-symbol SCONTAINER = SymKind(1 << 10) // has a sub-symbol
) )
......
...@@ -127,7 +127,7 @@ func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, go_ *S ...@@ -127,7 +127,7 @@ func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, go_ *S
// maybe one day STB_WEAK. // maybe one day STB_WEAK.
bind := STB_GLOBAL bind := STB_GLOBAL
if x.Version != 0 || x.Attr.VisibilityHidden() || x.Attr.Local() { if x.Version != 0 || (x.Type&SHIDDEN != 0) || x.Attr.Local() {
bind = STB_LOCAL bind = STB_LOCAL
} }
...@@ -144,11 +144,7 @@ func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, go_ *S ...@@ -144,11 +144,7 @@ func putelfsym(ctxt *Link, x *Symbol, s string, t SymbolType, addr int64, go_ *S
addr -= int64(xo.Sect.Vaddr) addr -= int64(xo.Sect.Vaddr)
} }
other := STV_DEFAULT other := STV_DEFAULT
if x.Attr.VisibilityHidden() { if x.Type&SHIDDEN != 0 {
// TODO(mwhudson): We only set AttrVisibilityHidden in ldelf,
// i.e. when internally linking. But STV_HIDDEN visibility only
// matters in object files, i.e. when externally linking. So I
// don't think this makes a lot of sense.
other = STV_HIDDEN other = STV_HIDDEN
} }
if (Buildmode == BuildmodeCArchive || Buildmode == BuildmodePIE || ctxt.DynlinkingGo()) && SysArch.Family == sys.PPC64 && typ == STT_FUNC && x.Name != "runtime.duffzero" && x.Name != "runtime.duffcopy" { if (Buildmode == BuildmodeCArchive || Buildmode == BuildmodePIE || ctxt.DynlinkingGo()) && SysArch.Family == sys.PPC64 && typ == STT_FUNC && x.Name != "runtime.duffzero" && x.Name != "runtime.duffcopy" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment