Carter, Jack
2011-Nov-17 20:32 UTC
[LLVMdev] How to get ELF section virtual starting address from MCSymbolRefExpr?
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>
Rafael Ávila de Espíndola
2011-Nov-19 19:07 UTC
[LLVMdev] How to get ELF section virtual starting address from MCSymbolRefExpr?
On 11-11-17 12:32 PM, Carter, Jack wrote:> 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?The offset is not know until relaxation. You probably want an expression that is (cur_label - label_at_section_start), no?> Thanks, > > Jack >Cheers, Rafael
Seemingly Similar Threads
- [LLVMdev] How to get ELF section virtual starting address from MCSymbolRefExpr?
- [LLVMdev] [PATCH] TLS support for Windows 32+64bit
- [LLVMdev] arm64 / iOS support
- [LLVMdev] Rephrased: How to get function virtual starting address from MCSymbolRefExpr?
- [LLVMdev] [PATCH] TLS support for Windows 32+64bit