Commit 637f34fe authored by Cherry Zhang's avatar Cherry Zhang

cmd/link: allow duplicated weak symbols on Mach-O

This fixes cgo test issue29563 on Darwin.

Updates #29563.

Change-Id: If480078461247cd7c95931ae3ad4ca89736dd550
Reviewed-on: https://go-review.googlesource.com/c/go/+/170015
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 6e37e3a8
......@@ -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
......
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