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

Link app with the kernel into one ELF #1207

Open
wkozaczuk opened this issue Jul 28, 2022 · 0 comments
Open

Link app with the kernel into one ELF #1207

wkozaczuk opened this issue Jul 28, 2022 · 0 comments

Comments

@wkozaczuk
Copy link
Collaborator

wkozaczuk commented Jul 28, 2022

I think something close to what I am trying to propose has been discussed here - https://groups.google.com/g/osv-dev/c/DI6FBYHYNdQ/m/OU6kcZuYAwAJ. And I think some of the things discussed there were addressed by the ability to build the kernel with most non-libc symbols and STD C++ hidden, enabling garbage collection (see 730fd82), extracting ZFS as a separate library, conditionally adding drivers using a concept of "profiles" and finally supporting building version of the kernel with only symbols needed by specific app (see d19ccb1).

But I think we can go one step further and allow linking some apps with the kernel into a single elf - say loader_with_app.elf and the hello world would not be difficult I think. The initial and naive prototype would simply involve calling main directly from loader.cc and linking with apps/native-example/hello.o. Now the kernel is compiled as position-dependent executable and correct compiler options would need to be used when compiling the app object files. This is where I am not sure how it would "scale" beyond a single-object file case of the "hello world" example. Also, how would it work for non-C apps - C++ or things like Rust? And most likely this would not ever work for things like Golang. But for some cases - say Redis or Nginx it might make perfect sense.

Obviously in such a case kernel would expose 0 symbols and ideally do not even need most of its dynamic linker, right? From the security perspective, it would be a total "closed world" appliance. Would we benefit from a performance perspective? Possibly.

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

No branches or pull requests

1 participant