[LLVMdev] How to get ELF section virtual starting address from MCSymbolRefExpr?

Carter, Jack jcarter at mips.com
Thu Nov 17 12:32:29 PST 2011


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

The need is to combine that offset to the virtual address of the section it belongs, in this case .text, but it could be any section.

I can get a MCSectionELF class object from MCSymbol that I get from MCSymbolRefExpr:

  int Kind = Value->getKind();
  if (Kind == MCExpr::SymbolRef) {
    const MCSymbol &Sym = SRE->getSymbol();
    const MCSectionELF = dyn_cast_or_null<MCSectionELF>(Sym.getSection());
  }

But can't see how to get the virtual address of the section. This is odd since I would have expected methods for accessing every part of the ELF section header entry.

How does one get the virtual address (sh_addr in ELF) starting from a MCSymbolRefExpr?

Thanks,

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


More information about the llvm-dev mailing list