Skip to content

cmd/link: load of "ld -r" host object fails in -newobj mode #35779

@thanm

Description

@thanm

What version of Go are you using (go version)?

$ go version
go version devel +9c6f6409ad Wed Nov 20 15:16:17 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

Build a small program that links in a *.syso object that contains multiple static symbols that have the same name and section.

This is a bit elaborate, but here is a repro recipe:

$ cat /tmp/c1.c
static void blah() { }
int c1() { return 42; }
$ cat /tmp/c2.c
static void blah() { }
int c2() { return 42; }
$ gcc -c -o c1.o /tmp/c1.c
$ gcc -c -o c2.o /tmp/c2.c
$ ld -r -o ldr.syso c1.o c2.o 
$ objdump -t ldr.syso | fgrep blah
0000000000000000 l     F .text	0000000000000007 blah
0000000000000012 l     F .text	0000000000000007 blah
$ rm c1.o c2.o 
$ cat main.go
package main
func main() {
}
$ go build .
$ go build -asmflags=all=-newobj -gcflags=all=-newobj -ldflags=-newobj .
# ...
loadelf: $WORK/b001/_pkg_.a(ldr.syso): duplicate symbol reference: blah in both main(.text) and main(.text)
$

What did you expect to see?

Clean build with -newobj.

What did you see instead?

loadelf error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions