News for hackers. Stuff that matters.
Re:PH7 – An Embedded Implementation of PHP (C Library) by justincormack on Wednesday February 19, 2014 @12:04PM (#7264587)
LuaJIT can output bytecode as .o files that you can just link. It is not very well documented but its pretty easy once you get the hang of it.
Re:PH7 – An Embedded Implementation of PHP (C Library) by Touche on Wednesday February 19, 2014 @12:29PM (#7264758)
.o files are not executable. You still have to link it to something that executes, and that something isn't Lua.
Re:PH7 – An Embedded Implementation of PHP (C Library) by oscargrouch on Wednesday February 19, 2014 @02:53PM (#7265796)
.o files are executable code.. they are just not a native file executable (elf, coff, mach-o) = headers + .o files
Re:PH7 – An Embedded Implementation of PHP (C Library) by justincormack on Wednesday February 19, 2014 @05:44PM (#7267022)
yeah, you link to lua.a or lua.so and a very small stub to run the code. There is an example here https://github.com/justincormack/ljsyscall/blob/master/examp...
Re:PH7 – An Embedded Implementation of PHP (C Library) by ygra on Wednesday February 19, 2014 @01:30PM (#7265192)
Couldn't you tell the linker to use one of the functions in the .o as entry point?
Re:PH7 – An Embedded Implementation of PHP (C Library) by oscargrouch on Wednesday February 19, 2014 @02:31PM (#7265658)
yes..

1 - create the object files (with luajit?)

2 - create a main() in c.. use "extern" to reference the external symbol in the .o files and call it from main.

The symbols in the object files produced by luajit or whatever need to be exported/ visible.. (are they mangled?)

3 - create a object file for main.c

4 - link the .o created from luajit(or whatever, dart?) and main.o together

If the linker cant find the external symbol it wont link to a binary (so you need to know how, in what names they are exported.. use objdump to lookup for symbols)

Re:PH7 – An Embedded Implementation of PHP (C Library) by Touche on Wednesday February 19, 2014 @01:46PM (#7265317)
Code example?

edit: If so I've been doing it wrong for years.

Re:PH7 – An Embedded Implementation of PHP (C Library) by stephan10h on Wednesday February 19, 2014 @05:37PM (#7266950)
Re:PH7 – An Embedded Implementation of PHP (C Library) by ygra on Thursday February 20, 2014 @12:52AM (#7269131)
ld has a -e argument [−4] (and MSVC's link has /ENTRY [37]). Otherwise, if there is a function with the expected name, calling convention and arguments in the object file I doubt the linker will complain.

[−4] ftp://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_24.html

[37] http://msdn.microsoft.com/library/f9t8842e.aspx