[llvm-commits] MachOObjectFile fix functions

Owen Anderson resistor at mac.com
Fri Nov 4 01:49:29 PDT 2011


Danil,

These changes are not correct.  I've spent a lot of time over the last few weeks getting these right by comparing them with existing MachO tools.  While it's quite possible there are still bugs, I'm fairly confident of them in general.  Specific incorrectness are noted below:

- getSymbolOffset

The Value field of a MachO symbol table entry is a virtual address, not a file offset.  AFAIK, the best way to find the file offset for the symbol is to get the subtract the section virtual address from the symbol virtual address, and add that to section offset.

- getSymbolAddress

Your implementation of this seems to be based on an incorrect understanding of what this method is supposed to return.  It is supposed to return the virtual address of the symbol, i.e. the address where the symbol will reside when the dynamic linker maps this object.  Instead, you're returning a pointer in the current process's address space, based on where the object file happens to be memory mapped at the moment.  If the ELF implementation does this, it is simply wrong.

- getRelocationAddress

This change is simply wrong.  The value field on MachO relocations holds an offset from the beginning of the section, not a virtual address.  You have to add that the the current section's virtual address to obtain the correct value, as the existing code currently does.

--Owen

On Nov 03, 2011, at 02:54 PM, Danil Malyshev <dmalyshev at accesssoftek.com> wrote:

Hello everyone,
 
Please find attached the patch for review.
The patch changed several MachOObjectFile functions:
- Fix getSymbolOffset(), getSymbolAddress() and getRelocationAddress(), now it's works same as in ELFObjectFile.
- Add implementation getSymbolSize()
 
 
Regards,
Danil
 
_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111104/95b039eb/attachment.html>


More information about the llvm-commits mailing list