diff --git a/src/cmd/link/internal/loadmacho/ldmacho.go b/src/cmd/link/internal/loadmacho/ldmacho.go index 85aa606ff5..e2b0d63aa3 100644 --- a/src/cmd/link/internal/loadmacho/ldmacho.go +++ b/src/cmd/link/internal/loadmacho/ldmacho.go @@ -43,11 +43,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -const ( - N_EXT = 0x01 - N_TYPE = 0x1e - N_STAB = 0xe0 -) // TODO(crawshaw): de-duplicate these symbols with cmd/internal/ld const ( @@ -161,6 +156,19 @@ type ldMachoDysymtab struct { indir []uint32 } +// ldMachoSym.type_ +const ( + N_EXT = 0x01 + N_TYPE = 0x1e + N_STAB = 0xe0 +) + +// ldMachoSym.desc +const ( + N_WEAK_REF = 0x40 + N_WEAK_DEF = 0x80 +) + const ( LdMachoCpuVax = 1 LdMachoCpu68000 = 6 @@ -616,6 +624,9 @@ func Load(arch *sys.Arch, syms *sym.Symbols, f *bio.Reader, pkg string, length i if machsym.type_&N_EXT == 0 { s.Attr |= sym.AttrDuplicateOK } + if machsym.desc&(N_WEAK_REF|N_WEAK_DEF) != 0 { + s.Attr |= sym.AttrDuplicateOK + } machsym.sym = s if machsym.sectnum == 0 { // undefined continue