<div style="font-family: arial, helvetica, sans-serif"><font size="2"><div>Hi!</div><div><br></div><div><div>libObject seems to incorrectly implement ELFObjectFile::getSymbolAddress. See this reproducer:</div><div>$ cat main.cc </div>
<div>int main() {</div><div>  return 0;</div><div>}</div><div>$ g++ main.cc -o main.out</div><div>$ nm main.out | grep main</div><div>                 U __libc_start_main@@GLIBC_2.2.5</div><div>00000000004004b4 T main</div>
<div>$ llvm-nm main.out | grep main</div><div>         U __libc_start_main@@GLIBC_2.2.5</div><div>00800884 T main</div><div><br></div><div>Let's try to get what's wrong:</div><div>800884 - 4004b4 = 4003d0</div><div>
$ objdump -h main.out | grep .text</div><div> 11 .text         000001c8  00000000004003d0  00000000004003d0  000003d0  2**4</div><div><br></div><div>So, the symbol address is incorrectly incremented by the section offset. To my understanding, attached patch should be applied to fix this. Please check if this is ok to apply.</div>
<div>getSymbolFileOffset in the same file seems to be fine, at least according to this quote from ELF specs:</div><div><br></div><div>Symbol table entries for different object file types have slightly different interpretations for the st_value member.</div>
<div><...></div><div>* In relocatable files, st_value holds a section offset for a defined symbol. That is, st_value is an offset from the beginning of the section that st_shndx identifies.</div><div>* In executable and shared object files, st_value holds a virtual address. [...]</div>
</div><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</font></div>