[LLVMdev] Shadow Stack

Trevor Elliott trevor at galois.com
Wed Jan 19 09:34:55 PST 2011


Hi Everyone,

I've managed to create a small example that reproduces the error that
I'm seeing when generating code, or running the interpreter:

-----------------------------------------------------------------------

@llvm_gc_root_chain = global i8* null

declare i8* @malloc(i32)
declare void @llvm.gcroot(i8**, i8*) nounwind

define i32 @main() gc "shadow-stack" {
  %value = call i8* @malloc(i32 32)
  %ptr   = alloca i8*
  store i8* %value, i8** %ptr
  call void @llvm.gcroot(i8** %ptr, i8* null)

  ret i32 0
}

-----------------------------------------------------------------------

I am building and running it with:

 $ llvm-as test.ll
 $ lli test.bc

And the resulting stack trace is:

-----------------------------------------------------------------------

0  libLLVM-2.8.so  0x0000003cc36eee9f
1  libLLVM-2.8.so  0x0000003cc36ef99a
2  libpthread.so.0 0x0000003cc200f4a0
3  libLLVM-2.8.so  0x0000003cc33360dd
llvm::StructType::StructType(llvm::LLVMContext&, std::vector<llvm::Type
const*, std::allocator<llvm::Type const*> > const&, bool) + 237
4  libLLVM-2.8.so  0x0000003cc3337c95
llvm::StructType::get(llvm::LLVMContext&, std::vector<llvm::Type const*,
std::allocator<llvm::Type const*> > const&, bool) + 533
5  libLLVM-2.8.so  0x0000003cc3242d58
6  libLLVM-2.8.so  0x0000003cc318f09e
7  libLLVM-2.8.so  0x0000003cc3330628
llvm::FPPassManager::runOnFunction(llvm::Function&) + 424
8  libLLVM-2.8.so  0x0000003cc33307cb
llvm::FunctionPassManagerImpl::run(llvm::Function&) + 91
9  libLLVM-2.8.so  0x0000003cc33309bd
llvm::FunctionPassManager::run(llvm::Function&) + 173
10 libLLVM-2.8.so  0x0000003cc33e8647
llvm::JIT::jitTheFunction(llvm::Function*, llvm::MutexGuard const&) + 39
11 libLLVM-2.8.so  0x0000003cc33e8a2f
llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard
const&) + 15
12 libLLVM-2.8.so  0x0000003cc33e8cde
llvm::JIT::getPointerToFunction(llvm::Function*) + 606
13 libLLVM-2.8.so  0x0000003cc33ea253
llvm::JIT::runFunction(llvm::Function*, std::vector<llvm::GenericValue,
std::allocator<llvm::GenericValue> > const&) + 67
14 libLLVM-2.8.so  0x0000003cc336ad4a
llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*,
std::vector<std::string, std::allocator<std::string> > const&, char
const* const*) + 1130
15 lli             0x0000000000404cd6 main + 2054
16 libc.so.6       0x0000003cc1c1ec5d __libc_start_main + 253
17 lli             0x0000000000403689
Stack dump:
0.	Program arguments: lli test.bc
1.	Running pass 'Lower Garbage Collection Instructions' on function '@main'

-----------------------------------------------------------------------

A similar stack trace is generated when running llc instead.  Any ideas?

Thanks!

--trevor

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3612 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110119/7df408a9/attachment.bin>


More information about the llvm-dev mailing list