[LLVMdev] Rephrased: How to get function virtual starting address from MCSymbolRefExpr?

Carter, Jack jcarter at mips.com
Thu Nov 17 13:05:03 PST 2011


I was mistaken as to needing the virtual address of the section , but really need to know the virtual address of the beginning of the function that contains the label whose symbol expression we have.

I have a case where I the expression (MCSymbolRefExpr) is the offset from the beginning of the function.


AsmPrinter::EmitJumpTableEntry() calls EmitGPRel32Value()<http://llvm.org/doxygen/classllvm_1_1MCStreamer.html#a3c0872c5c75608d870c0b6aaf0d206ed>

   case MachineJumpTableInfo::EK_GPRel32BlockAddress<http://llvm.org/doxygen/classllvm_1_1MachineJumpTableInfo.html#aaa21facdbb167f7c33d21907b8e5b9d3a0145ef8496d090993849ec0d7ca947f7>: {
     // EK_GPRel32BlockAddress - Each entry is an address of block, encoded
     // with a relocation as gp-relative, e.g.:
     //     .gprel32 LBB123
     MCSymbol<http://llvm.org/doxygen/classllvm_1_1MCSymbol.html> *MBBSym = MBB->getSymbol<http://llvm.org/doxygen/classllvm_1_1MachineBasicBlock.html#a24d0da534c4fb156547a04749b9f6468>();
     OutStreamer<http://llvm.org/doxygen/classllvm_1_1AsmPrinter.html#a32ad5336c0020843cbb5a982c0f1a708>.EmitGPRel32Value<http://llvm.org/doxygen/classllvm_1_1MCStreamer.html#a3c0872c5c75608d870c0b6aaf0d206ed>(MCSymbolRefExpr::Create<http://llvm.org/doxygen/classllvm_1_1MCSymbolRefExpr.html#acfd4c9d4f462e858c577dc0f57ef2d30>(MBBSym, OutContext<http://llvm.org/doxygen/classllvm_1_1AsmPrinter.html#aa7625af893e242d33b9f182066f59310>));

But can't in the process seem to lose the hook to the parent function.
It would seem that we need to add MachineBasicBlock<http://llvm.org/doxygen/classllvm_1_1MachineBasicBlock.html> *MBB to the call, but
if that isn't necessary would like to know how else to achieve the goal

Thanks,

Jack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111117/42d22a22/attachment.html>


More information about the llvm-dev mailing list