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):
section-offset.patch (494 Bytes)