[llvm-objdump] - Implement the --adjust-vma option.
authorGeorge Rimar <grimar@accesssoftek.com>
Mon, 28 Jan 2019 10:44:01 +0000 (10:44 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Mon, 28 Jan 2019 10:44:01 +0000 (10:44 +0000)
commit4c3b2976216b197fd62d21663e6b81706dd698cb
tree52bfec0de0826c799cd5b3b0f2301f5eb8f4e112
parent574e0c5e328b89c598d31a243c5587a7ba5176c1
[llvm-objdump] - Implement the --adjust-vma option.

GNU objdump's help says: "--adjust-vma: Add OFFSET to all displayed section addresses"
In real life what it does is a bit more complicated
(and IMO not always reasonable. For example, GNU objdump prints not only VMA, but also LMA
for sections. And with --adjust-vma it adjusts LMA, but only when a section has relocations.
llvm-objsump does not seem to support printing LMAs yet, but GNU's logic anyways does not
make sense for me here).

This patch tries to adjust VMA. I tried to implement a reasonable approach.
I am not adjusting sections that are not allocatable. As, for example, adjusting debug sections
VA's and rel[a] sections VA's should not make sense. This behavior seems to be GNU compatible.

Differential revision: https://reviews.llvm.org/D57051

llvm-svn: 352347
llvm/test/tools/llvm-objdump/X86/adjust-vma.test [new file with mode: 0644]
llvm/tools/llvm-objdump/llvm-objdump.cpp