While working on some other changes I came across a problem where
ELFObjectFile::getSymbolFileOffset was returning a different value than I
expected in the case where the symbol in question was a section. Looking at the
code, it seems obviously wrong, but I didn't want to just commit my change
without at least asking if anyone knew of a good reason for the current
behavior. I know there have been some discussions in the past about the
address/offset ambiguity in this interface but I couldn't find anything
directly addressing this question.
Looking at the revision history, it seems that the current implementation has
been in place since getSymbolOffset was created (in
lib/Object/ELFObjectFile.cpp, r139683) based on an earlier getSymbolAddress
implementation and wasn't updated when other aspects of the function were
corrected and the function was renamed getSymbolFileOffset(in
lib/Object/ELFObjectFile.cpp, r145408) .
Here's the change I'm proposing (also attached as a patch file):
Index: include/llvm/Object/ELF.h
==================================================================---
include/llvm/Object/ELF.h (revision 172846)
+++ include/llvm/Object/ELF.h (working copy)
@@ -1000,7 +1000,7 @@
switch (symb->getType()) {
case ELF::STT_SECTION:
- Result = Section ? Section->sh_addr : UnknownAddressOrSize;
+ Result = Section ? Section->sh_offset : UnknownAddressOrSize;
return object_error::success;
case ELF::STT_FUNC:
case ELF::STT_OBJECT:
-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130118/506f6f0a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: section-offset.patch
Type: application/octet-stream
Size: 494 bytes
Desc: section-offset.patch
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130118/506f6f0a/attachment.obj>
On Fri, Jan 18, 2013 at 3:13 PM, Kaylor, Andrew <andrew.kaylor at intel.com> wrote:> While working on some other changes I came across a problem where > ELFObjectFile::getSymbolFileOffset was returning a different value than I > expected in the case where the symbol in question was a section. Looking at > the code, it seems obviously wrong, but I didn’t want to just commit my > change without at least asking if anyone knew of a good reason for the > current behavior. I know there have been some discussions in the past about > the address/offset ambiguity in this interface but I couldn’t find anything > directly addressing this question. > > > > Looking at the revision history, it seems that the current implementation > has been in place since getSymbolOffset was created (in > lib/Object/ELFObjectFile.cpp, r139683) based on an earlier getSymbolAddress > implementation and wasn’t updated when other aspects of the function were > corrected and the function was renamed getSymbolFileOffset(in > lib/Object/ELFObjectFile.cpp, r145408) . > > > > Here’s the change I’m proposing (also attached as a patch file): > > > > Index: include/llvm/Object/ELF.h > > ==================================================================> > --- include/llvm/Object/ELF.h (revision 172846) > > +++ include/llvm/Object/ELF.h (working copy) > > @@ -1000,7 +1000,7 @@ > > switch (symb->getType()) { > > case ELF::STT_SECTION: > > - Result = Section ? Section->sh_addr : UnknownAddressOrSize; > > + Result = Section ? Section->sh_offset : UnknownAddressOrSize; > > return object_error::success; > > case ELF::STT_FUNC: > > case ELF::STT_OBJECT: > > > > -Andy > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >LGTM. - Michael Spencer
Apparently Analagous Threads
- [LLVMdev] llvm-objdump related patch
- [LLVMdev] ELFObjectFile changes, llvm-objdump showing 'wrong' values?
- [LLVMdev] ELFObjectFile changes, llvm-objdump showing 'wrong' values?
- [LLVMdev] llvm-objdump related patch
- How to objcopy via LLVM toolchain for armv7e-m ELF32LE?