• Austin Clements's avatar
    cmd/cgo: accept weak dynamic imports · a2fb5cd8
    Austin Clements authored
    cgo produces dynamic imports for Go binaries by scanning the dynamic
    imports table of a binary produced by the system C compiler and
    linker. Currently, since it uses elf.File.ImportedSymbols, it only
    reads global symbols. Unfortunately, recent versions of lld emit weak
    symbol imports for several pthread symbols, which means the cgo tool
    doesn't emit dynamic imports for them, which ultimately causes linking
    of cgo binaries to fail.
    
    Fix this by using elf.File.DynamicSymbols instead and filtering down
    to both global and weak symbols.
    
    Fixes #31912.
    
    Change-Id: If346a7eca6733e3bfa2cccf74a9cda02a3e81d38
    Reviewed-on: https://go-review.googlesource.com/c/go/+/184100
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
    a2fb5cd8
out.go 57 KB