[llvm] 56cd447 - [llvm-xray] Add basic test for AArch64 support

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 14:01:36 PST 2019


Author: Shoaib Meenai
Date: 2019-11-08T14:00:31-08:00
New Revision: 56cd447eec8eec71a6e61d2dd142bf5dadfc154a

URL: https://github.com/llvm/llvm-project/commit/56cd447eec8eec71a6e61d2dd142bf5dadfc154a
DIFF: https://github.com/llvm/llvm-project/commit/56cd447eec8eec71a6e61d2dd142bf5dadfc154a.diff

LOG: [llvm-xray] Add basic test for AArch64 support

Based on a test provided by Ian Levesque <ianlevesque at fb.com>.

Added: 
    llvm/test/tools/llvm-xray/AArch64/Inputs/elf64-pic.yaml
    llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64.test

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-xray/AArch64/Inputs/elf64-pic.yaml b/llvm/test/tools/llvm-xray/AArch64/Inputs/elf64-pic.yaml
new file mode 100644
index 000000000000..9b9b2960aea8
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/AArch64/Inputs/elf64-pic.yaml
@@ -0,0 +1,159 @@
+# Generated from the following source:
+# __attribute__((xray_always_instrument)) void foo() {}
+# __attribute__((xray_always_instrument)) void bar() {}
+# __attribute__((xray_always_instrument)) void jar() {}
+
+# Built with the following arguments:
+# -target aarch64-none-linux-android -fxray-instrument
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_DYN
+  Machine:         EM_AARCH64
+  Entry:           0x0000000000000420
+Sections:
+  - Name:            .hash
+    Type:            SHT_HASH
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x0000000000000228
+    Link:            .dynsym
+    AddressAlign:    0x0000000000000004
+    EntSize:         0x0000000000000004
+    Bucket:          [ 0, 0, 3, 0 ]
+    Chain:           [ 0, 0, 1, 2 ]
+  - Name:            .rela.dyn
+    Type:            SHT_RELA
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x0000000000000270
+    Link:            .dynsym
+    AddressAlign:    0x0000000000000008
+    EntSize:         0x0000000000000018
+    Relocations:
+      - Offset:          0x00000000000025B0
+        Type:            R_AARCH64_RELATIVE
+        Addend:          1056
+      - Offset:          0x00000000000025D0
+        Type:            R_AARCH64_RELATIVE
+        Addend:          1088
+      - Offset:          0x00000000000025F0
+        Type:            R_AARCH64_RELATIVE
+        Addend:          1124
+      - Offset:          0x0000000000002610
+        Type:            R_AARCH64_RELATIVE
+        Addend:          1156
+      - Offset:          0x0000000000002630
+        Type:            R_AARCH64_RELATIVE
+        Addend:          1192
+      - Offset:          0x0000000000002650
+        Type:            R_AARCH64_RELATIVE
+        Addend:          1224
+      - Offset:          0x0000000000002670
+        Type:            R_AARCH64_RELATIVE
+        Addend:          9648
+      - Offset:          0x0000000000002678
+        Type:            R_AARCH64_RELATIVE
+        Addend:          9712
+      - Offset:          0x0000000000002680
+        Type:            R_AARCH64_RELATIVE
+        Addend:          9712
+      - Offset:          0x0000000000002688
+        Type:            R_AARCH64_RELATIVE
+        Addend:          9776
+      - Offset:          0x0000000000002690
+        Type:            R_AARCH64_RELATIVE
+        Addend:          9776
+      - Offset:          0x0000000000002698
+        Type:            R_AARCH64_RELATIVE
+        Addend:          9840
+      - Offset:          0x00000000000025F8
+        Symbol:          _Z3barv
+        Type:            R_AARCH64_ABS64
+      - Offset:          0x0000000000002618
+        Symbol:          _Z3barv
+        Type:            R_AARCH64_ABS64
+      - Offset:          0x00000000000025B8
+        Symbol:          _Z3foov
+        Type:            R_AARCH64_ABS64
+      - Offset:          0x00000000000025D8
+        Symbol:          _Z3foov
+        Type:            R_AARCH64_ABS64
+      - Offset:          0x0000000000002638
+        Symbol:          _Z3jarv
+        Type:            R_AARCH64_ABS64
+      - Offset:          0x0000000000002658
+        Symbol:          _Z3jarv
+        Type:            R_AARCH64_ABS64
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x0000000000000420
+    AddressAlign:    0x0000000000000004
+    Content:         080000141F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D5080000141F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D5C0035FD6080000141F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D5080000141F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D5C0035FD6080000141F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D5080000141F2003D51F2003D51F2003D51F2003D51F2003D51F2003D51F2003D5C0035FD6
+  - Name:            .dynamic
+    Type:            SHT_DYNAMIC
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x00000000000014F0
+    Link:            .dynstr
+    AddressAlign:    0x0000000000000008
+    EntSize:         0x0000000000000010
+    Entries:
+      - Tag:             DT_FLAGS
+        Value:           0x0000000000000008
+      - Tag:             DT_FLAGS_1
+        Value:           0x0000000000000001
+      - Tag:             DT_RELA
+        Value:           0x0000000000000270
+      - Tag:             DT_RELASZ
+        Value:           0x00000000000001B0
+      - Tag:             DT_RELAENT
+        Value:           0x0000000000000018
+      - Tag:             DT_RELACOUNT
+        Value:           0x000000000000000C
+      - Tag:             DT_SYMTAB
+        Value:           0x00000000000001C8
+      - Tag:             DT_SYMENT
+        Value:           0x0000000000000018
+      - Tag:             DT_STRTAB
+        Value:           0x0000000000000250
+      - Tag:             DT_STRSZ
+        Value:           0x0000000000000019
+      - Tag:             DT_HASH
+        Value:           0x0000000000000228
+      - Tag:             DT_NULL
+        Value:           0x0000000000000000
+  - Name:            xray_instr_map
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC, SHF_LINK_ORDER ]
+    Address:         0x00000000000025B0
+    Link:            .text
+    AddressAlign:    0x0000000000000001
+    Content:         '000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001010000000000000000000000000000'
+  - Name:            xray_fn_idx
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC, SHF_LINK_ORDER ]
+    Address:         0x0000000000002670
+    Link:            .text
+    AddressAlign:    0x0000000000000010
+    Content:         '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
+DynamicSymbols:
+  - Name:            _Z3barv
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x0000000000000464
+    Size:            0x0000000000000044
+  - Name:            _Z3foov
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x0000000000000420
+    Size:            0x0000000000000044
+  - Name:            _Z3jarv
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x00000000000004A8
+    Size:            0x0000000000000044
+...

diff  --git a/llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64.test b/llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64.test
new file mode 100644
index 000000000000..8f39548c3f56
--- /dev/null
+++ b/llvm/test/tools/llvm-xray/AArch64/extract-instrmap-aarch64.test
@@ -0,0 +1,14 @@
+This test makes sure we can extract the instrumentation map from an
+XRay-instrumented PIE file.
+
+RUN: yaml2obj %S/Inputs/elf64-pic.yaml -o %t.so
+RUN: llvm-xray extract %t.so -s | FileCheck %s
+
+CHECK:      ---
+CHECK-NEXT: - { id: 1, address: 0x0000000000000420, function: 0x0000000000000420, kind: function-enter, always-instrument: true, function-name: 'foo()' }
+CHECK-NEXT: - { id: 1, address: 0x0000000000000440, function: 0x0000000000000420, kind: function-exit, always-instrument: true, function-name: 'foo()' }
+CHECK-NEXT: - { id: 2, address: 0x0000000000000464, function: 0x0000000000000464, kind: function-enter, always-instrument: true, function-name: 'bar()' }
+CHECK-NEXT: - { id: 2, address: 0x0000000000000484, function: 0x0000000000000464, kind: function-exit, always-instrument: true, function-name: 'bar()' }
+CHECK-NEXT: - { id: 3, address: 0x00000000000004A8, function: 0x00000000000004A8, kind: function-enter, always-instrument: true, function-name: 'jar()' }
+CHECK-NEXT: - { id: 3, address: 0x00000000000004C8, function: 0x00000000000004A8, kind: function-exit, always-instrument: true, function-name: 'jar()' }
+CHECK-NEXT: ...


        


More information about the llvm-commits mailing list