[dev.link] cmd/link: make symbol attribute setting more reliable

For dupOK symbols, their attributes should be OR'd. Most of the
attributes are expected to be set consistently across multiple
definitions, but UsedInIface must be OR'd, and for alignment we
need to pick the largest one. Currently the attributes are not
always OR'd, depending on addSym returning true or false. This
doesn't cause any real problem, but it would be a problem if we
make type descriptor symbols content-addressable.

This CL removes the second result of addSym, and lets preloadSyms
always set the attributes. Also removes the alignment handling on
addSym, handles it in preloadSyms only.

Change-Id: I06b3f0adb733f6681956ea9ef54736baa86ae7bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/245720
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Zhang 2020-07-29 19:32:31 -04:00
parent c4ee16eda9
commit 847b9be3f6
2 changed files with 33 additions and 51 deletions

View file

@ -21,11 +21,7 @@ import (
// data or relocations).
func addDummyObjSym(t *testing.T, ldr *Loader, or *oReader, name string) Sym {
idx := uint32(len(ldr.objSyms))
s, ok := ldr.addSym(name, 0, or, idx, nonPkgDef, &goobj2.Sym{})
if !ok {
t.Errorf("AddrSym failed for '" + name + "'")
}
return s
return ldr.addSym(name, 0, or, idx, nonPkgDef, &goobj2.Sym{})
}
func mkLoader() *Loader {