Stream: cranelift

Topic: Accessing libc functions


view this post on Zulip PROMETHIA (Feb 20 2023 at 15:29):

While working on an existing project I've run into a really weird issue. The project already had a JIT mode that uses cranelift_jit, and is capable of importing libc functions by declaring them by name with the import linkage, and that seems to be all. At no point does the compiler explicitly link in any libc functions or libc itself. But while writing a lazy jit backend, which needs hotswap and thus enables PIC (it's normally disabled by the non-lazy JIT) suddenly these functions crash when called, but the crash can be avoided by adding them to the symbol table (or presumably adding a lookup function that can find them).
Why does the non-PIC backend not need to import libc functions, and what would be the easiest way to fix this/import the libc functions?

view this post on Zulip PROMETHIA (Feb 20 2023 at 15:32):

I'm aware that there's a default fallback function that searches both the program's symbol table and the system's default C runtime, which I assume is how it's working in greedy jit mode. But I'm confused as to why enabling PIC seems to prevent this lookup from working.

view this post on Zulip PROMETHIA (Feb 20 2023 at 17:10):

Nevermind- I think the issue was elsewhere. It appeared to be crashing when calling extern functions but it was actually unrelated, but happened to occur right around them


Last updated: Nov 22 2024 at 16:03 UTC