Skip to content

shell: use binfmt_misc instead of ld_preload #178

@progrium

Description

@progrium

While in the shell/Linux, you can run Wasm executables as Wanix tasks like native Linux executables. This is currently achieved with 3 parts:

  • wexec: Linux executable that uses /task to allocate, start, and attach STDIO to a wasi task for a Wasm executable
  • preload: Linux library that decorates libc execve, execvp, execvpe to use wexec if there is a .wasm file extension
  • init: shell init script that ultimately runs the Busybox shell with LD_PRELOAD pointing to preload

As a side effect of this approach, we cannot build Busybox as a static binary because using LD_PRELOAD requires the dynamic linker (ld-linux), which then means we need a handful of files in /lib.

We could drop most of the /lib files, the preload component entirely, and go back to using a static build of Busybox by using binfmt_misc to simply register wexec as the "handler" for .wasm files.

Seems ideal, but I've never used it before and only learned about it just as I got the ld_preload approach working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions