I’m writing a GC plugin, targeting x86_64. I’m stuck on handling stack maps. I generate assembly for them like in the documentation: http://llvm.org/docs/GarbageCollection.html#emitting-assembly-code-gcmetadataprinter and now I’m trying to figure out the best way to correlate stack maps with call frames.
I have an idea to put a label before every stack map entry and then put the address of this label within well known offset from the function. Then, while walking the call stack and having function address I could retrieve relevant stack map entry…
My current approach to generating the label for stack map entries looks like this:
MCSymbol *ala = AP.OutContext.GetOrCreateSymbol(StringRef(“ala”));
But then, I don’t know how to emit the address of the label near the function. I mean, I think I’d use something like this ‘OS.EmitSymbolValue(ala, 4)’, but I’m not sure where I should hook into to achieve this.
Note that I’m fairly new to LLVM and the approach I described above does not necessarily make much sense. I’d pleased to hear the proper way to handle stack maps.