Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's `mmap` call and syntax of function pointer at the end of the file (needed to call the compiled code).

P.S. Otherwise, it is ready to run itself, work in progress.



Allowing it to call arbitrary functions using dlopen()/dlsym() would be the idea I have for fixing the first problem - it'd also increase its power substantially since it can then make use of any other library's functions instead of the currently hardcoded list. Supporting function pointers would be a bit harder and involve changing the parser/code generator.


How would you tell it which shared library to dlopen?

Was looking into changing the order of arguments to go the right way 'round. Also changing address refs to be PC-relative, to avoid the relocation phase. Seems pretty straightforward.


I thought about `dlopen`, but did not know how to fetch it libc platform-independently (`dlopen(argv[0])` is fine on OS X, but not on Linux).

Now I see that the first argument can be NULL, that approach is feasible.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: