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

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

cmd/link: duplicate DT_NEEDED with cgo_import_dynamic #39256

4a6f656c opened this issue May 26, 2020 · 1 comment
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@4a6f656c
Copy link
Contributor

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

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

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 26, 2020
@andybons andybons added this to the Go1.15 milestone May 26, 2020
@cherrymui cherrymui modified the milestones: Go1.15, Go1.16 May 27, 2020
@golang golang locked and limited conversation to collaborators Aug 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants