For x86-win32 we got __ImageBase, Is there any *simple* way to create a GlobalVariable pointing to the image base on all platforms? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160903/74cb585c/attachment-0001.html>
Joerg Sonnenberger via llvm-dev
2016-Sep-03 15:21 UTC
[llvm-dev] GlobalVariable to image base
On Sat, Sep 03, 2016 at 05:05:32PM +0300, BBLN via llvm-dev wrote:> For x86-win32 we got __ImageBase, > Is there any *simple* way to create a GlobalVariable pointing to the image > base on all platforms?What is an image base? Joerg
Image base is the PE/COFF base address (the relocated one) - pointer to header. In ELF the PIC calculations use PC + offset to GOT, so the image base would be actually PC minus assumed PC offset, or GOT minus assumed GOT offset (offset taken from the ELF header) I guess that could be easy calculated using MachineInstruction. Just thinking if something can be done using IR and GlobalVariables.. 2016-09-03 18:21 GMT+03:00 Joerg Sonnenberger via llvm-dev < llvm-dev at lists.llvm.org>:> On Sat, Sep 03, 2016 at 05:05:32PM +0300, BBLN via llvm-dev wrote: > > For x86-win32 we got __ImageBase, > > Is there any *simple* way to create a GlobalVariable pointing to the > image > > base on all platforms? > > What is an image base? > > Joerg > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160903/667daf1c/attachment.html>
I don't think there's an easy way for all platforms. Try __executable_start for ELF, though. On Sat, Sep 3, 2016 at 7:05 AM, BBLN via llvm-dev <llvm-dev at lists.llvm.org> wrote:> For x86-win32 we got __ImageBase, > Is there any *simple* way to create a GlobalVariable pointing to the image > base on all platforms? > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160906/0a116b40/attachment.html>
Possibly Parallel Threads
- [LLVMdev] Alloca and GlobalVariable
- Create the GlobalVariable which have extern in one header file
- How to read String value of GlobalVariable?
- [LLVMdev] Leaking GlobalVariable from lowerInvoke pass
- [LLVMdev] GlobalVariable initializer using from beyond the grave