LLVM Metadata to Dwarf tags

Hi everyone,

I’m working on a project where I need to add the addresses’s of specific instructions to the DWARF output.

I’ve been digging around for the last week or so trying to figure out exactly what I need to do, but this is my first list posting.

I came across this posting: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-September/034464.html
which seems to be doing almost exactly what I want to do, however it was created with LLVM 2.7 in mind. Since then, from what I can tell, the LLVM MC project has been created and blown away the usefulness of the descriptions contained in that thread. (Example: AsmPrinter::processDebugLoc() no longer exists). Does anyone have any pointers on how to update this for LLVM/clang 3.0?

To be more specific, I’ve added a special stack guard intrinsic similar to StackProtector.cpp which uses a per function random immediate instead of ___stack_chk_guard. What I am trying to accomplish is to get the offset into the final x86 object file of each one of these immediate values.

An example of the output in Assembly looks like:
movq $653406579, -8(%rbp) ## imm = 0x26F23173

In reality, I’d settle for a simple way to get the offset into the Obj file of the movq instruction that I could putput to a separate file, but It’d be better if I could get it into the DWARF tags.

Does anyone have any familiarity with this to give me some pointers?

Thanks,
AK

You basically want to create a label and a relocation to that label in the dwarf output. You'll need to make up your own tag for this sort of thing.

-eric