ed25519-dalek-rustgo
ed25519-dalek-rustgo copied to clipboard
[WIP] Simplify the build, use .syso rather than manual `go tool` invocations
Go recently restricted the ability to use go:cgo_*
directives outside of cgo-generated code so the current build no longer works.
I've modified the build to use the syso trick which greatly simplifies the tool invocations. Everything builds successfully and all the symbols are found (tested on Debian GNU/Linux buster) but I get a segfault as soon as I run the program.
So I guess rustgo.s
needs to be updated, but my assembly hacking skills are lacking here. Since you've been through this process before, I thought you might be able to fix this up quicker on top of what I've already done.
For a start, changing MOVQ scalar_base_mult(SB), AX \n CALL AX
to CALL scalar_base_mult(SB)
results in a "simpler" segfault error but I have no idea if it's a "better" error.
Looks like go is not performing relocations when linking the syso into the binary, objdump -rS
of the syso file has expected lines like:
0000000000000000 <scalar_base_mult>:
#[no_mangle]
pub extern fn scalar_base_mult(dst: &mut [u8; 32], k: &[u8; 32]) {
0: 55 push %rbp
[..]
4a: e8 00 00 00 00 callq 4f <scalar_base_mult+0x4f>
4b: R_X86_64_PLT32 _ZN16curve25519_dalek5curve13ExtendedPoint16compress_edwards17h445d29c3c5f4a1baE-0x4
[..]
0000000000000000 <_ZN16curve25519_dalek5curve13ExtendedPoint16compress_edwards17h445d29c3c5f4a1baE>:
pub fn compress_edwards(&self) -> CompressedEdwardsY {
0: 55 push %rbp
but the binary ./ed25519-dalek-rustgo
only has:
0000000000401000 <scalar_base_mult>:
401000: 55 push %rbp
[..]
401052: e8 00 00 00 00 callq 401057 <scalar_base_mult+0x57>
401057: c5 f8 10 00 vmovups (%rax),%xmm0
which is obviously invalid, yet the compress_edwards
function still exists later in that file.
Not sure if this is fixable by passing extra flags to go build
...
Looks like this is the same issue mentioned near the end of your original blog post, but unfortunately cgo_import_dynamic
is not allowed these days... :(
Might be fixed by https://go-review.googlesource.com/c/go/+/94675