[llvm-bugs] [Bug 49518] New: llvm-objdump doesn't calculate relative branch target address for arm binaries

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 10 10:39:18 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49518

            Bug ID: 49518
           Summary: llvm-objdump doesn't calculate relative branch target
                    address for arm binaries
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: llvm-objdump
          Assignee: unassignedbugs at nondot.org
          Reporter: yabinc at google.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 24617
  --> https://bugs.llvm.org/attachment.cgi?id=24617&action=edit
arm binary for testing

For arm binaries, llvm-objdump doesn't calculate relative branch target
address. Instead, it only shows offsets from current address. And users need to
calculate target address manually. Below is an example:

$ llvm-objdump -dlC --no-show-raw-insn --start-address=0x784
--stop-address=0x7d4 simpleperf_runtest_two_functions_arm

00000784 <main>:
; main():
...
     7a4:       movs    r1, #0
; system/extras/simpleperf/runtest/two_functions.cpp:9
     7a6:       str.w   r1, [r7, r0, lsl #2]
; system/extras/simpleperf/runtest/two_functions.cpp:8
     7aa:       adds    r1, #1
     7ac:       cmp     r6, r1
     7ae:       bne     #-12 <main+0x22>

To know the branch target address of bne instruction in 0x7ae, we need to
calculate either 0x7ae + 4 - 12, or 0x784 + 0x22. But there is no directly show
of 0x7a6.

For comparison, binutils objdump for arm binaries shows branch target address
as below:

$ arm-linux-androideabi-objdump  -dlC --no-show-raw-insn --start-address=0x784
--stop-address=0x7d4  simpleperf_runtest_two_functions_arm

00000784 <main>:
...
system/extras/simpleperf/runtest/two_functions.cpp:9
     7a6:       str.w   r1, [r7, r0, lsl #2]
system/extras/simpleperf/runtest/two_functions.cpp:8
     7aa:       adds    r1, #1
     7ac:       cmp     r6, r1
     7ae:       bne.n   7a6 <main+0x22>
...


And llvm-objdump shows branch target address for binaries in other targets,
including arm64, x86, x86_64.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210310/95695b1c/attachment.html>


More information about the llvm-bugs mailing list