--- /dev/null
+# 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
+...
--- /dev/null
+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: ...