[LLVMdev] ELFObjectFile::getSymbolFileOffset
Michael Spencer
bigcheesegs at gmail.com
Fri Jan 18 15:29:55 PST 2013
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
More information about the llvm-dev
mailing list