summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-symbolizer
diff options
context:
space:
mode:
authorJames Henderson <jh7370@my.bristol.ac.uk>2019-01-25 11:49:21 +0000
committerJames Henderson <jh7370@my.bristol.ac.uk>2019-01-25 11:49:21 +0000
commit759d5e6783299bf9e71a8adbaa1a4827d411d65a (patch)
tree9981bdefc71cc25bceccc6aa55ad9c49c28e55f3 /llvm/test/tools/llvm-symbolizer
parent7822d25de3a0cdb6293ff342e4ac0280c91f49c7 (diff)
downloadbcm5719-llvm-759d5e6783299bf9e71a8adbaa1a4827d411d65a.tar.gz
bcm5719-llvm-759d5e6783299bf9e71a8adbaa1a4827d411d65a.zip
[llvm-symbolizer] Add switch to adjust addresses by fixed offset
If a stack trace or similar has a list of addresses from an executable or DSO loaded at a variable address (e.g. due to ASLR), the addresses will not directly correspond to the addresses stored in the object file. If a user wishes to use llvm-symbolizer, they have to subtract the load address from every address. This is somewhat inconvenient, especially as the output of --print-address will result in the adjusted address being listed, rather than the address coming from the stack trace, making it harder to map results between the two. This change adds a new switch to llvm-symbolizer --adjust-vma which takes an offset, which is then used to automatically do this calculation. The printed address remains the input address (allowing for easy mapping), whilst the specified offset is applied to the addresses when performing the lookup. The switch is conceptually similar to llvm-objdump's new switch of the same name (see D57051), which in turn mirrors a GNU switch. There is no equivalent switch in addr2line. Reviewed by: grimar Differential Revision: https://reviews.llvm.org/D57151 llvm-svn: 352195
Diffstat (limited to 'llvm/test/tools/llvm-symbolizer')
-rw-r--r--llvm/test/tools/llvm-symbolizer/adjust-vma.s39
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-symbolizer/adjust-vma.s b/llvm/test/tools/llvm-symbolizer/adjust-vma.s
new file mode 100644
index 00000000000..5bb5a336a52
--- /dev/null
+++ b/llvm/test/tools/llvm-symbolizer/adjust-vma.s
@@ -0,0 +1,39 @@
+# REQUIRES: x86-registered-target
+
+.type foo,@function
+.size foo,12
+foo:
+ .space 10
+ nop
+ nop
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -g
+
+# RUN: llvm-symbolizer 0xa 0xb --print-address --obj=%t.o \
+# RUN: | FileCheck %s --check-prefix=NORMAL
+# RUN: llvm-symbolizer 0x10a 0x10b --print-address --adjust-vma 0x100 --obj=%t.o \
+# RUN: | FileCheck %s --check-prefix=ADJUST
+
+# Show that we can handle addresses less than the offset.
+# RUN: llvm-symbolizer 0xa 0xb --print-address --adjust-vma 0xc --obj=%t.o \
+# RUN: | FileCheck %s --check-prefix=OVERFLOW
+
+# NORMAL: 0xa
+# NORMAL-NEXT: foo
+# NORMAL-NEXT: adjust-vma.s:7:0
+# NORMAL-EMPTY:
+# NORMAL-NEXT: 0xb
+# NORMAL-NEXT: foo
+# NORMAL-NEXT: adjust-vma.s:8:0
+
+# ADJUST: 0x10a
+# ADJUST-NEXT: foo
+# ADJUST-NEXT: adjust-vma.s:7:0
+# ADJUST-EMPTY:
+# ADJUST-NEXT: 0x10b
+# ADJUST-NEXT: foo
+# ADJUST-NEXT: adjust-vma.s:8:0
+
+# OVERFLOW: 0xa
+# OVERFLOW-NEXT: ??
+# OVERFLOW-NEXT: ??
OpenPOWER on IntegriCloud