mirror of
https://github.com/golang/go
synced 2024-10-14 11:53:56 +00:00
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: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
6e37e3a80b
commit
637f34fee0
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue