-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ERROR: Program used external function 'stat' which could not be resolved! #2245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
bugpoint on original testcase takes a long time, however I created a simple testcase: #include <sys/stat.h> $ llvm-gcc -emit-llvm -c test.c -o test.bc $ bugpoint -run-jit test.bc |
The test works fine for me on darwin/x86. Are you on linux? IF so, it would be interesting to find out why the hack in lib/ExececutionEngine/JIT/Intercept.cpp isn't working (search for 'stat' in that file). It may be that we need another similar hack to make it work on your system. |
This is related to bug 274. |
Yes, linux x86-64.
Problem is that stat from libc_nonshared.a is a local symbol, and despite of using -Wl,--export-dynamic, it stays a local symbol, hence dlsym() can't find it. See for examples below. I have a patch in mind, attaching. This doesn't work: #include <stdio.h> int main( void ) This does work: #include <stdio.h> int _stat(const char * path, struct stat * buf) int main( void ) $gcc -Wl,-E p.c -ldl |
use AddSymbol to explicitly add the address of stat symbols |
Patch looks great to me, applied: Thanks! -Chris |
Extended Description
I get this when running the JIT:
/home/edwin/llvm-svn/llvm/Release/bin/lli -force-interpreter=false --disable-core-files Output/clamscan.llvm.bc --debug --no-summary -ddbdir -r inputs/*
ERROR: Program used external function 'stat' which could not be resolved!
/home/edwin/llvm-svn/llvm/Release/bin/lli[0x8cc51b]
/lib/libc.so.6[0x3508432040]
/lib/libc.so.6(gsignal+0x35)[0x3508431fd5]
/lib/libc.so.6(abort+0x110)[0x3508433a30]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::JIT::getPointerToNamedFunction(std::basic_string<char, std::char_traits, std::allocator > const&)+0xf1)[0x5e0c71]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::JIT::getPointerToFunction(llvm::Function*)+0xe1)[0x5e1fb1]
/home/edwin/llvm-svn/llvm/Release/bin/lli[0x5e37b0]
/home/edwin/llvm-svn/llvm/Release/bin/lli[0x5e43f8]
/home/edwin/llvm-svn/llvm/Release/bin/lli[0x4af0be]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::MachineFunctionPass::runOnFunction(llvm::Function&)+0x2c)[0x5c06dc]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::FPPassManager::runOnFunction(llvm::Function&)+0x231)[0x87a351]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::FunctionPassManagerImpl::run(llvm::Function&)+0xdc)[0x87a83c]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::FunctionPassManager::run(llvm::Function&)+0x30)[0x87a990]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::JIT::runJITOnFunction(llvm::Function*)+0x38)[0x5e0d68]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::JIT::getPointerToFunction(llvm::Function*)+0x12d)[0x5e1ffd]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::JIT::runFunction(llvm::Function*, std::vector<llvm::GenericValue, std::allocatorllvm::GenericValue > const&)+0x4c)[0x5e104c]
/home/edwin/llvm-svn/llvm/Release/bin/lli(llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::basic_string<char, std::char_traits, std::allocator > > > const&, char const* const*)+0x382)[0x5eaf92]
/home/edwin/llvm-svn/llvm/Release/bin/lli(main+0x233)[0x4a5463]
/lib/libc.so.6(__libc_start_main+0xf4)[0x350841e1c4]
/home/edwin/llvm-svn/llvm/Release/bin/lli(sinh+0x49)[0x4a4919]
Aborted
Trying to get a bugpoint reduced bytecode ...
The text was updated successfully, but these errors were encountered: