8000 linux gcc8 fun name error · Issue #11 · minio/c2goasm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.
This repository was archived by the owner on Dec 1, 2021. It is now read-only.
linux gcc8 fun name error #11
Open
@zeromake

Description

@zeromake

env

  • system: linux amd64(archlinux)
  • gcc: v8.1.0
  • clang & llvm: v6.0.0
  • yasm: v1.3.0
  • c2goasm: last master
  • asm2plan9s: last master

problem

run

git clone https://github.com/minio/c2goasm.git
cd c2goasm/test/cpp
./assemble.sh ./MaddConstant.cpp
cd ../../
go build
./c2goasm -a ./test/cpp/MaddConstant.s ./test/MaddConstant_amd64.s

error

Processing ./test/cpp/MaddConstant.s
panic: Failed to find function prototype for _Z12MaddConstantPfS_S_

goroutine 1 [running]:
main.parseCompanionFile(0xc4200131c0, 0x1c, 0xc420013268, 0x16, 0x0, 0x0, 0x1, 0x40e6d9, 0x51eb80, 0xc42004d850)
        /home/zero/go-works/src/c2goasm/arguments.go:75 +0x24c
main.process(0xc420094600, 0x1e, 0x20, 0xc4200131c0, 0x1c, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/zero/go-works/src/c2goasm/c2goasm.go:86 +0x205
main.main()
        /home/zero/go-works/src/c2goasm/c2goasm.go:264 +0x390

Try to repair

diff --git a/subroutine.go b/subroutine.go

index 00d98f7..c6b3ec4 100644
--- a/subroutine.go
+++ b/subroutine.go
@@ -266,7 +266,7 @@ func extractNamePart(part string) (int, string) {
 func extractName(name string) string {

        // Only proceed for C++ mangled names
-       if !(strings.HasPrefix(name, "_ZN") || strings.HasPrefix(name, "__Z")) {
+       if !(strings.HasPrefix(name, "_ZN") || strings.HasPrefix(name, "__Z") || strings.HasPrefix(name, "_Z")) {
                return name
        }

but run go test -v ./... has error

FAIL    c2goasm/cgocmp [build failed]
=== RUN   TestMaddArgs10
--- PASS: TestMaddArgs10 (0.00s)
=== RUN   TestMaddConstant
unexpected fault address 0x0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x4e7ba3]

goroutine 6 [running]:
runtime.throw(0x52fa3b, 0x5)
        /usr/lib/go/src/runtime/panic.go:616 +0x81 fp=0xc420039e00 sp=0xc420039de0 pc=0x428a91
runtime.sigpanic()
        /usr/lib/go/src/runtime/signal_unix.go:395 +0x211 fp=0xc420039e50 sp=0xc420039e00 pc=0x43bc61
c2goasm/test._MaddConstant(0xc420039ea0, 0xc420039ec0, 0xc420039e70)
        /home/zero/go-works/src/c2goasm/test/MaddConstant_amd64.s:11 +0x13 fp=0xc420039e58 sp=0xc420039e50 pc=0x4e7ba3
c2goasm/test.MaddConstant(0x3f80000000000000, 0x4040000040000000, 0x40a0000040800000, 0x40e0000040c00000, 0x4000000000000000, 0x40c0000040800000, 0x4120000041000000, 0x4160000041400000, 0x0, 0x0, ...)
        /home/zero/go-works/src/c2goasm/test/MaddConstant_amd64.go:17 +0x5c fp=0xc420039ea0 sp=0xc420039e58 pc=0x4e5f3c
c2goasm/test.TestMaddConstant(0xc4200a21e0)
        /home/zero/go-works/src/c2goasm/test/MaddConstant_test.go:17 +0xd2 fp=0xc420039fa8 sp=0xc420039ea0 pc=0x4e65f2
testing.tRunner(0xc4200a21e0, 0x538520)
        /usr/lib/go/src/testing/testing.go:777 +0xd0 fp=0xc420039fd0 sp=0xc420039fa8 pc=0x4ad900
runtime.goexit()
        /usr/lib/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420039fd8 sp=0xc420039fd0 pc=0x454c51
created by testing.(*T).Run
        /usr/lib/go/src/testing/testing.go:824 +0x2e0

goroutine 1 [chan receive]:
testing.(*T).Run(0xc4200a21e0, 0x53176a, 0x10, 0x538520, 0x465d01)
        /usr/lib/go/src/testing/testing.go:825 +0x301
testing.runTests.func1(0xc4200a2000)
        /usr/lib/go/src/testing/testing.go:1063 +0x64
testing.tRunner(0xc4200a2000, 0xc42004ddf8)
        /usr/lib/go/src/testing/testing.go:777 +0xd0
testing.runTests(0xc42000a080, 0x5da340, 0x7, 0x7, 0x40e959)
        /usr/lib/go/src/testing/testing.go:1061 +0x2c4
testing.(*M).Run(0xc42009e000, 0x0)
        /usr/lib/go/src/testing/testing.go:978 +0x171
main.main()
        _testmain.go:56 +0x151
FAIL    c2goasm/test    0.003s

asm source

test/cpp/MaddConstant.s

	.file	"MaddConstant.cpp"
	.intel_syntax noprefix
	.text
	.p2align 4,,15
	.globl	_Z12MaddConstantPfS_S_
	.type	_Z12MaddConstantPfS_S_, @function
_Z12MaddConstantPfS_S_:
	vmovaps	ymm0, YMMWORD PTR [rdi]
	vmovaps	ymm1, YMMWORD PTR _ZL1a[rip]
	vfmadd132ps	ymm0, ymm1, YMMWORD PTR [rsi]
	vmovups	XMMWORD PTR [rdx], xmm0
	vextractf128	XMMWORD PTR 16[rdx], ymm0, 0x1
	vzeroupper
	ret
	.size	_Z12MaddConstantPfS_S_, .-_Z12MaddConstantPfS_S_
	.section	.rodata
	.align 32
	.type	_ZL1a, @object
	.size	_ZL1a, 32
_ZL1a:
	.long	1065353216
	.long	1073741824
	.long	1077936128
	.long	1082130432
	.long	1084227584
	.long	1086324736
	.long	1088421888
	.long	1090519040
	.ident	"GCC: (GNU) 8.1.0"
	.section	.note.GNU-stack,"",@progbits

test/MaddConstant_amd64.s

//+build !noasm !appengine
// AUTO-GENERATED BY C2GOASM -- DO NOT EDIT

TEXT ·_MaddConstant(SB), $0-24

    MOVQ vec1+0(FP), DI
    MOVQ vec2+8(FP), SI
    MOVQ result+16(FP), DX

    LONG $0x0728fcc5             // vmovaps    ymm0, YMMWORD PTR [rdi]
    QUAD $0x000000000d28fcc5     // vmovaps    ymm1, YMMWORD PTR _ZL1a[rip]
    LONG $0x9875e2c4; BYTE $0x06 // vfmadd132ps    ymm0, ymm1, YMMWORD PTR [rsi]
    LONG $0x0211f8c5             // vmovups    XMMWORD PTR [rdx], xmm0
    LONG $0x197de3c4; WORD $0x1042; BYTE $0x01 // vextractf128    XMMWORD PTR 16[rdx], ymm0, 0x1
    VZEROUPPER
    RET

source by my fork

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0