When disassembling a call, llvm-objdump searches for the symbol for the
target of the call among the symbols of the last section whose start
address is smaller or equal to the target address of the call,
irregardless of the type of sections. Since this considers non
allocatable sections, there's possibility of the wrong section being
selected, i.e. if the target address is 0 where non allocatable section
are likely to have 0 for value. This commit restrict the search to
section that contain text.
With this patch test tools/llvm-objdump/X86/disassemble-functions.test
starts to fail because of the call to foo in main that gets disassembled
as "callq <foo>" while there's an implicit-check-not=foo. The test is
adapted to use "<foo>:" and similarly "<somedata>:" in the
implicit-check-not.
With this patch, test ELF/pre_init_fini_array.s starts to fail because
it calls the initializer and finilizer arrays as if it were functions
while it's only arrays of function pointers. Test is adapted to use
indirect call instead and use the --syms option to cross-check the
address of the call targets.
This is somewhat redundant with the DISASM checks below, except for the cross-check of the address with the section that would be lost. Should this be removed noneless? Alternatively I could remove the whole readobj section and translate into llvm-objdump equivalent instead.