<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<br><div><div>On Apr 20, 2008, at 5:36 PM, Gordon Henriksen wrote:</div><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The shadow stack walker is in the runtime directory with the semispace <span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">heap example. The runtime directory is built to LLVM IR using llvm-<span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">gcc. So it's skipped unless you configure llvm with llvm-gcc support.</div></blockquote><div><br></div>doh! That's how I missed the binary. thanks!</div><div><br><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Since the semispace heap doesn't actually work (it's an example, at </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">best), I suggest you simply copy the stack visitor into your project; <span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">it's only a dozen lines of code or so.</div></blockquote><div><br></div>Ok, copying; can't find ShadowStackEntry though. Even make in that dir doesn't work:</div><div><br></div><div>/usr/local/llvm-2.2/runtime/GC/SemiSpace $ sudo make</div><div>Password:</div><div>llvm[0]: Compiling semispace.c for Release build (bytecode)</div><div>semispace.c:107: error: expected specifier-qualifier-list before 'ShadowStackEntry'</div><div>semispace.c:111: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token</div><div>semispace.c: In function 'llvm_cg_walk_gcroots':</div><div>semispace.c:114: error: 'StackEntry' undeclared (first use in this function)</div><div>semispace.c:114: error: (Each undeclared identifier is reported only once</div><div>semispace.c:114: error: for each function it appears in.)</div><div>semispace.c:114: error: 'R' undeclared (first use in this function)</div><div>make: *** [/usr/local/llvm-2.2/runtime/GC/SemiSpace/Release/semispace.ll] Error 1</div><div><br></div><div>It *seems* like it could be StackEntry instead? Perhaps this is a type I must include / generate for my type system?</div><div><br><blockquote type="cite"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-converted-space"><font class="Apple-style-span" color="#0000DD"><br></font> </span>%a = malloc i32</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-converted-space"> </span>%pa = alloca i32*</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-converted-space"> </span>store i32* %a, i32** %pa</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-converted-space"> </span>%c = bitcast i32** %pa to i8**</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-converted-space"> </span>call void @llvm.gcroot(i8** %c, i8* null); *pa = 99;</div> </blockquote><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Note that the malloc instruction always allocates from the system <span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">heap, not your managed heap; putting a malloc pointer into a GC <span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">pointer will probably confuse your collector. So you'll likely need to <span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">replace 'malloc i32' with some call into your own allocator.</div></blockquote><div><br></div>Yep, was going to get to that once I could bind; was trying one GC thing at a time. :)</div><div><br><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">Your allocator should probably bzero the memory before returning it; </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">malloc returns uninitialized memory, which will crash the collector if <span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">you reach a collection point before completely initializing the object.</div></blockquote><div><br></div>Will do that too :)</div><div><br></div><div>Got a simple, complete t.ll file that works with the semispace thing? I could reproduce stuff from the shadowstack paper I guess. how does the gc "shadow-stack" gcroot intrinsic work exactly? I couldn't read the assembly very well. Seems my example above wouldn't work would it unless i create/fill in a shadow stack record?</div><div><br></div><div>Taking a giant step back, I can build something similar to semispace.c myself so I'm in control of my world, right? i would set up the shadow stack using IR instructions and could avoid gcroot by notifying my collector as I see fit... </div><div><br></div><div>Sorry I'm so lost...just trying to figure out what llvm does for me and what I have to do.</div><div><br></div><div>Ter</div></body></html>