[llvm-commits] MachOObjectFile fix functions
Danil Malyshev
dmalyshev at accesssoftek.com
Wed Nov 9 14:41:57 PST 2011
Hello Owen,
> I don't like this. Getting symbol virtual addresses is one of the most common operations we do in, say, llvm-objdump.cpp or MachODump.cpp. I think this will make that code needlessly complex and non-obvious.
Ok, I agree.
> I don't particularly mind standardizing on this as the definition for "getOffset" methods, but it doesn't seem particularly useful to me either. Why require a two-stage lookup (section offset + symbol offset from section) rather than just defining it to return a file offset?
The symbol iterator iterate all symbols from all sections, so it make sense if symbol.getOffset() will returns the file offset. But we get relocations only for selected section, so relocation.getOffset() should return offset from this section. In addition we can get section virtual address or section offset one time and use it for each relocation in this section.
So, please find attached the changed patch which following changes:
- getSymbolOffset(), getSymbolAddress(), getRelocationAddress() returns same result for ELFObjectFile, MachOObjectFile and COFFObjectFile.
- added getRelocationOffset()
- fixed MachOObjectFile::getSymbolSize()
- fixed MachOObjectFile::getSymbolSection()
- fixed MachOObjectFile::getSymbolOffset() for symbols without section data.
Regards,
Danil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111109/bf8e37d7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ObjectFile_fix_functions-02.patch
Type: application/octet-stream
Size: 12453 bytes
Desc: ObjectFile_fix_functions-02.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111109/bf8e37d7/attachment.obj>
More information about the llvm-commits
mailing list