Repository navigation
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.help wanted
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.13.5 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/dd/Library/Caches/go-build" GOENV="/Users/dd/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/dd/dev/source/golang/gopath" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/n5/26_m50tn4_j2n3gmvt19300h0000gn/T/go-build651869539=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
main.go:
package main
import (
"fmt"
)
func b()
func print32(i uint32) {
fmt.Printf("0x%x\n", i)
}
func main() {
b()
}
asm_arm.s:
#include "textflag.h"
TEXT ·b(SB), NOSPLIT, $4
MOVW $1, R0
MOVW $4, R1
MOVW R0, (R13)(R1)
CALL ·print32(SB)
RET
then run,
objdump -d -df 'main.b' ./demo
and
go tool objdump -S -s 'main\.b' ./demo
./demo is the target executable file.
What did you expect to see?
main.b:
b8e18: 08 e0 2d e5 str lr, [sp, #-8]!
b8e1c: 01 00 a0 e3 mov r0, #1
b8e20: 04 10 a0 e3 mov r1, #4
b8e24: 01 00 8d e7 str r0, [sp, r1]
b8e28: c5 ff ff eb bl #-236 <main.print32>
b8e2c: 08 f0 9d e4 ldr pc, [sp], #8687
and
TEXT main.b(SB)
0xb8e18 e52de008 MOVW.W R14, -0x8(R13)
0xb8e1c e3a00001 MOVW $1, R0
0xb8e20 e3a01004 MOVW $4, R1
0xb8e24 e78d0001 MOVW R0, (R13)(R1)
0xb8e28 ebffffc5 BL main.print32(SB)
0xb8e2c e49df008 RET #8
What did you see instead?
main.b:
b8e18: 08 e0 2d e5 str lr, [sp, #-8]!
b8e1c: 01 00 a0 e3 mov r0, #1
b8e20: 04 10 a0 e3 mov r1, #4
b8e24: 00 00 8d e5 str r0, [sp]
b8e28: c5 ff ff eb bl #-236 <main.print32>
b8e2c: 08 f0 9d e4 ldr pc, [sp], #8
and
TEXT main.b(SB)
0xb8e18 e52de008 MOVW.W R14, -0x8(R13)
0xb8e1c e3a00001 MOVW $1, R0
0xb8e20 e3a01004 MOVW $4, R1
0xb8e24 e58d0000 MOVW R0, (R13)
0xb8e28 ebffffc5 BL main.print32(SB)
0xb8e2c e49df008 RET #8
don't know why the code of register offset was lost?
MOVW R0, (R13)(R1)
change into
MOVW R0, (R13)
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.help wanted
Type
Projects
- StatusShow more project fieldsTriage Backlog
Activity
cherrymui commentedon Dec 23, 2019
Try
MOVW R0, R1<<0(R13).I'm sorry the syntax is different. We should handle
(R1)(R13)syntax as well.ClarkGuan commentedon Dec 23, 2019
Glad to hear from you!Yes. I've found that it can generate the same machine code.
But I also found some other problems, like:
using go tool objdump can output:
If I write this code in my source file, I will get some errors, like
I don't know how many more problems like this...
cherrymui commentedon Dec 23, 2019
Try
It is unfortunate that the objdump output syntax doesn't match the input. We could fix objdump.
ClarkGuan commentedon Dec 24, 2019
There is no very specific document to describe the corresponding relationship between go assembly and arm assembly, so objdump maybe the only way to understand the above differences.
If the output of objdump is not standard and correct, it will be a problem indeed.
ianlancetaylor commentedon Jun 16, 2020
Moving to backlog milestone.