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

Producing non-Go-specific object files #9

Closed
c-blake opened this issue Apr 17, 2023 · 3 comments
Closed

Producing non-Go-specific object files #9

c-blake opened this issue Apr 17, 2023 · 3 comments

Comments

@c-blake
Copy link

c-blake commented Apr 17, 2023

Go assembly & even Go object files seem a world of their own.. So much so that an audit of only that is unlikely to be accepted as a validation of plain hashtree.

It seemed worth asking (in light of the someday audit of this repo and a desire to link to audited code from C, Nim, Python, etc.), if you know a way to maintain a clear chain of custody / do a clean transformation from a Go assembly origin to ELF .o/.so on Linux | Mach-O on OSX | COFF on Windows. (I realize function calling conventions may vary, but this situation seems to have literally only 1 function.)

I could not seem to get gccgo -c (version 12.2.1) to accept hash_amd64.s at all. (Running that did show a couple stray space-after-backslash issues - I can do a PR if you want). Seems gccgo may not even support assembler/OSX/Win in the same way at all, at least 4 years ago according to Ian, the author.

I did find go tool asm -S hash_amd64.s; go tool objdump -gnu hash_amd64.o which emits GAS syntax text as comments { though data interpreted as instructions is not pretty.. :-) }. So, it may be possible to build a fully expanded variant that way & touch up call entry & exit for re-assembly by GAS.

Maybe you have better ideas? Thanks in advance!

@potuz
Copy link
Collaborator

potuz commented May 1, 2023

I don't think this is possible at all, the stack structure of the Go runtime is very different than the C ABI and Go takes care of that completely. Notice that there's not even an attempt in the gohashtree library to deal with stack alignment nor to reserve space in the stack to deal with the saving of variables. Go takes care of that. This is one of the biggest complications in hashtree and in its testing across different OSs. I very much doubt one would be able to export any of these assembly into the other by an automated process.

@c-blake
Copy link
Author

c-blake commented May 1, 2023

Yeah. Thanks for the reply. I guess that just means the arm64 port needs to be done to support a lot of Cloud/Apple hardware on anything but Go.

@c-blake c-blake closed this as completed May 1, 2023
@potuz
Copy link
Collaborator

potuz commented May 1, 2023

Yeah. Thanks for the reply. I guess that just means the arm64 port needs to be done to support a lot of Cloud/Apple hardware on anything but Go.

yeah indeed, that's in my open issues for hashtree, will open an issue now and I hope to work on that in the coming weeks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants