athenavm / athena

Athena monorepo
https://www.athenavm.org/
Apache License 2.0
21 stars 2 forks source link

don't export `sys_alloc_aligned` #227

Closed poszu closed 1 week ago

poszu commented 1 week ago

Fixes #215, Closes #217

The problem described in #215 happens because the sys_alloc_aligned function is present in the athena VM library - in the host code, not in a guest program. It makes no sense to have it there as it is only needed by guest programs running in a VM. This PR removes the export "C" so the function is not exported and is not included in the VM library.

Before:

❯ objdump target/release/libathena_vmlib.so -d | rg 'sys_alloc_aligned>'
00000000001584a0 <sys_alloc_aligned>:

After:

❯ objdump target/release/libathena_vmlib.so -d | rg 'sys_alloc_aligned>'

Note: the same statement is true for other exported system calls. They are also wrongly included in the VM library. However, because of #117, it is not possible to remove them easily without refactoring. There is a weird dependency cycle:

This dependency cycle is "fixed" by using exported functions, which are resolved at link time.