[LLVMdev] How to stop symbol searching without aborting
ofv at wanadoo.es
Fri Jun 5 10:09:14 PDT 2009
Marcus Zetterquist <marcus.zetterquist at gmail.com> writes:
> Today we use Lua to let 3rd party developers add driver-like modules
> to our application.
> The advantages to using Lua compared to DLL:s etc. are that:
> 1) the same driver binary can be used on all OS:es and processor
> architectures etc.
> I'm looking into using LLVM and the bitcode format for this instead.
> The additional, very important advantages are:
> 4) 3rd parties can port existing (huge amounts of) C / C++ code much
> easier - no need to rewrite all code in Lua.
AFAIK, LLVM code is not platform-independent. A C compiler that targets
x86 will generate different LLVM bitcode than the same C compiler when
it targets x86_64, for instance.
> 5) Performance. We will use the LLVM JIT.
> Problem: I can't figure out how to do (2) with the LLVM JIT.
> It is very important that the driver does not have access to any other
> function in the application except those I provide. It's not OK for
> our application to abort if a driver calls an undefined function - I
> want to just disable _that driver_ in that event.
> I can use DisableSymbolSearching() but that causes application to
> abort for unknown symbols.
An LLVM program can call any address, valid or not. If the programmer
figures out the address of one of those "forbidden" functions, he can
call it. You may write some pass for detecting suspicious constructs and
reject them, but solving the problem the right way looks very hard or
impossible to me, mostly because you want to use LLVM code generated by
a C/C++ compiler.
More information about the llvm-dev