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
runtime: ARM uClinux crash with -buildmode=c-archive #31378
Comments
The Go runtime on GNU/Linux systems currently expects that entries in the This could likely be fixed by changing the runtime package to read |
Thanks, the same problem in when running in c-shared mode. |
how to fix this problem, have patch? func args(c int32, v **byte) { |
Change https://golang.org/cl/334991 mentions this issue: |
This issue has always existed in the alpine environment. Can the go teams plan to fix this issue? @ianlancetaylor |
Please answer these questions before submitting your issue. Thanks!
What did you do?
main.go
package main
/*
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
*/
import "C"
//export TestAdd
func TestAdd(a C.int32_t, b C.int32_t) C.int32_t {
return a + b
}
func main() {}
build:
CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=5 CC=arm-hisiv500-linux-uclibcgnueabi-gcc CXX=arm-hisiv500-linux-uclibcgnueabi-g++ go build -buildmode=c-archive
output dlltest.a
test.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
extern "C" {
int32_t TestAdd(int32_t a, int32_t b);
}
int main(int argc, char* argv[])
{
int ret = TestAdd(10, 11);
printf("TestAdd, ret=%d", ret);
}
build:
export CC=arm-hisiv500-linux-uclibcgnueabi-gcc
export CXX=arm-hisiv500-linux-uclibcgnueabi-g++
$CXX -g test.c -o test dlltest.a -lpthread
output test exe file.
file test
test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped
copy test to ARM board, run it.
What did you expect to see?
output TestAdd, ret=21
What did you see instead?
Segmentation fault
System details
gdb debug output
Program received signal SIGSEGV, Segmentation fault.
[Switching to LWP 427]
runtime.sysargs (argc=0, argv=0x0) at /usr/local/go-linux-arm-bootstrap/src/runtime/os_linux.go:206
The text was updated successfully, but these errors were encountered: