<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Ignore sections when printing branch targets in non-relocatable objects"
href="https://bugs.llvm.org/show_bug.cgi?id=45627">45627</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Ignore sections when printing branch targets in non-relocatable objects
</td>
</tr>
<tr>
<th>Product</th>
<td>tools
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>llvm-objdump
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jh7370.2008@my.bristol.ac.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Currently, llvm-objdump tries to look up the symbols for call targets based on
the nearest section to a given address (i.e. the one with the highest address
that is not greater than the target address). If it can't find a symbol in the
given section with a value equal to or less than the target address, it falls
back to using absolute symbols.
This process has two problems. Firstly, if there happens to be an absolute
symbol with the correct value, but a symbol in the section picked also exists
with a lower address, the symbol in the section is picked instead, even though
there's an exact match. Secondly, if the target is the start address of a
section and there happens to be a symbol at the end of the preceding section,
with a matching symbol, it will never be picked, even if there are no symbols
in the section with the start address matching the target.
Both these behaviours are different to GNU objdump (in the version I tested at
least). Furthermore, I don't think the current behaviour even makes
philosophical sense - it shouldn't matter which section a symbol is in for it
to be considered a possible target. llvm-objdump should just pick the best one.
For example, a direct match will always be better than an indirect match, and
the section should only come into play when determining which of multiple
viable candidates should be picked.
Here is an example which illustrates both problems:
// bar.s
.text
nop
.global end
end:
.section .text_1,"ax",@progbits
nop
.global _start
_start:
call _start - 1
call _start + 1
.global abs
abs = 0x201123
// Commands
PS C:\Work\TempWork> C:\llvm\build\Debug\bin\clang.exe -c bar.s
PS C:\Work\TempWork> C:\llvm\build\Debug\bin\ld.lld.exe bar.o -o bar.elf
PS C:\Work\TempWork> C:\llvm\build\Debug\bin\llvm-objdump bar.elf -d
bar.elf: file format elf64-x86-64
Disassembly of section .text:
0000000000201120 <.text>:
201120: 90 nop
Disassembly of section .text_1:
0000000000201121 <.text_1>:
201121: 90 nop
0000000000201122 <_start>:
201122: e8 fa ff ff ff callq 0x201121 <.text_1>
201127: e8 f7 ff ff ff callq 0x201123 <_start+0x1>
PS C:\Work\TempWork> objdump -d bar.elf
bar.elf: file format elf64-x86-64
Disassembly of section .text:
0000000000201120 <end-0x1>:
201120: 90 nop
Disassembly of section .text_1:
0000000000201121 <_start-0x1>:
201121: 90 nop
0000000000201122 <_start>:
201122: e8 fa ff ff ff callq 201121 <end>
201127: e8 f7 ff ff ff callq 201123 <abs>
As can be seen, GNU objdump uses "end" and "abs" instead of the non-existent
.text_1 symbol and indirect _start+0x1 symbol. I think GNU's output here is
better than ours.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>