Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: duplicate DT_NEEDED with cgo_import_dynamic #39256

Open
4a6f656c opened this issue May 26, 2020 · 1 comment
Open

cmd/link: duplicate DT_NEEDED with cgo_import_dynamic #39256

4a6f656c opened this issue May 26, 2020 · 1 comment
Milestone

Comments

@4a6f656c
Copy link
Contributor

@4a6f656c 4a6f656c commented May 26, 2020

Using Go -tip and building the following two files:

$ cat x.go
package main

import (
        _ "unsafe"
)

//go:cgo_import_dynamic libc_getpid getpid "libc.so"
//go:cgo_import_dynamic libc_kill kill "libc.so"
//go:cgo_import_dynamic libc_close close "libc.so"
//go:cgo_import_dynamic libc_open open "libc.so"

//go:linkname libc_getpid libc_getpid
//go:linkname libc_kill libc_kill
//go:linkname libc_open libc_open
//go:linkname libc_close libc_close

func trampoline()

func main() {
        trampoline()
}
$ cat x.s
TEXT ·trampoline(SB),0,$0
        CALL    libc_getpid(SB)
        CALL    libc_kill(SB)
        CALL    libc_open(SB)
        CALL    libc_close(SB)
        RET

Results in DT_NEEDED being repeated for each cgo_import_dynamic statement:

$ go version     
go version devel +bcda68447b Mon May 25 21:01:14 2020 +0000 openbsd/amd64
$ go build -o x  
$ readelf -a x | grep NEEDED  
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]

Only one of these entries should really exist.

@gopherbot
Copy link

@gopherbot gopherbot commented May 26, 2020

Change https://golang.org/cl/235257 mentions this issue: cmd/link: avoid duplicate DT_NEEDED entries

@andybons andybons added this to the Go1.15 milestone May 26, 2020
@cherrymui cherrymui modified the milestones: Go1.15, Go1.16 May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.