Skip to content

cmd/compile: register conflict between external linker and duffzero on arm64 #32773

@xuanjiazhen

Description

@xuanjiazhen

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

$ go version
go version go1.12.4 linux/arm64

We build our Go app on arm64. In a recent version, we encountered a segment violation error when it run. Through gdb debugging we found that the error originated from the register conflict between external linker and duffzero (I guess).

The error occurred in a line in the runtime·duffzero in duff_arm64.s.
It is found by GDB that it is in the __runtime.duffzero_veneer function before entering runtime·duffzero. This function looks like this:

Dump of assembler code fo function __runtime.duffzero_veneer:
0x0000xxx<+0>: adrp x16,0x460000<runtime.call1073741824+8>
0x0000xxx<+4>: add x16,x16,#0xbec
0x0000xxx<+8>: br x16

br x16 will jump into runtime·duffzero.

TEXT runtime·duffzero(SB), NOSPLIT|NOFRAME, $0-0
	STP.P	(ZR, ZR), 16(R16)
	STP.P	(ZR, ZR), 16(R16)
	STP.P	(ZR, ZR), 16(R16)
...

But at this time the address in x16 is the address of the code segment. Then it went wrong.

cmd/internal/obj/arm64/a.out.go:
REGRT1 = REG_R16 // ARM64 IP0, for external linker, runtime, duffzero and duffcopy

It seems that external linker and duffzero has the same register.

I don't know if I have made it clear. I want to know if this is a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions