Normally an OS provides a libc that is wrapper for all the kernel functions + some other useful libs as Math.
So one needs to bind Pascal's functions for memory allocation, file system access and console input/output to the ones provided by ELKS' libc. But of course it is a lot of work. I was inspired seeing that Free Pascal supports many platforms.