Skip to content
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

Save R15 before global access #255

Merged
merged 4 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ jobs:
run: |
go vet -v ./...

- name: go build plugin
if: runner.os == 'Linux' || runner.os == 'macOS'
run:
# Make sure that plugin buildmode works since we save the R15 register (#254)
go build -buildmode=plugin ./examples/libc

- name: go build
run: |
go build -v ./...
Expand Down Expand Up @@ -97,6 +103,11 @@ jobs:
env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go test -c -o=purego-test-cgo .
env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10

echo "=> go build plugin"
# Make sure that plugin buildmode works since we save the R15 register (#254)
env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -buildmode=plugin ./examples/libc

go env -u CC
go env -u CXX

Expand Down Expand Up @@ -147,6 +158,10 @@ jobs:

# verify Go is available
go version

echo "=> go build plugin"
# Make sure that plugin buildmode works since we save the R15 register (#254)
go build -buildmode=plugin ./examples/libc

echo "=> go build"
go build -v ./...
Expand Down
6 changes: 3 additions & 3 deletions sys_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ TEXT callbackasm1(SB), NOSPLIT|NOFRAME, $0

PUSHQ R10 // push the stack pointer below registers

// Switch from the host ABI to the Go ABI.
PUSH_REGS_HOST_TO_ABI0()

// determine index into runtime·cbs table
MOVQ $callbackasm(SB), DX
SUBQ DX, AX
Expand All @@ -130,9 +133,6 @@ TEXT callbackasm1(SB), NOSPLIT|NOFRAME, $0
DIVL CX
SUBQ $1, AX // subtract 1 because return PC is to the next slot

// Switch from the host ABI to the Go ABI.
PUSH_REGS_HOST_TO_ABI0()

// Create a struct callbackArgs on our stack to be passed as
// the "frame" to cgocallback and on to callbackWrap.
// $24 to make enough room for the arguments to runtime.cgocallback
Expand Down
Loading