xref: /llvm-project/llvm/test/tools/llvm-objdump/ELF/data-vs-code-priority.s (revision 75cdab6dc2453a508157a9c383b93373a93078d6)
1@ REQUIRES: arm-registered-target
2
3// Test that code symbols take priority over data symbols if both are
4// defined at the same address during disassembly.
5//
6// In the past, llvm-objdump would select the alphabetically last
7// symbol at each address. To demonstrate that it's now choosing by
8// symbol type, we define pairs of code and data symbols at the same
9// address in such a way that the code symbol and data symbol each
10// have a chance to appear alphabetically last. Also, we test that
11// both STT_FUNC and STT_NOTYPE are regarded as code symbols.
12
13@ RUN: llvm-mc -triple armv8a-unknown-linux -filetype=obj %s -o %t.o
14@ RUN: llvm-objdump --no-print-imm-hex --triple armv8a -d %t.o | FileCheck %s
15
16// Ensure that all four instructions in the section are disassembled
17// rather than dumped as data, and that in each case, the code symbol
18// is displayed before the disassembly, and not the data symbol at the
19// same address.
20
21@ CHECK:        Disassembly of section .text:
22@ CHECK-EMPTY:
23@ CHECK-NEXT:   <A1function>:
24@ CHECK-NEXT:   movw r0, #1
25@ CHECK-EMPTY:
26@ CHECK-NEXT:   <B2function>:
27@ CHECK-NEXT:   movw r0, #2
28@ CHECK-EMPTY:
29@ CHECK-NEXT:   <A3notype>:
30@ CHECK-NEXT:   movw r0, #3
31@ CHECK-EMPTY:
32@ CHECK-NEXT:   <B4notype>:
33@ CHECK-NEXT:   movw r0, #4
34
35.text
36
37.globl A1function
38.globl B2function
39.globl A3notype
40.globl B4notype
41.globl B1object
42.globl A2object
43.globl B3object
44.globl A4object
45
46.type A1function,%function
47.type B2function,%function
48.type A3notype,%notype
49.type B4notype,%notype
50.type B1object,%object
51.type A2object,%object
52.type B3object,%object
53.type A4object,%object
54
55A1function:
56B1object:
57        movw r0, #1
58A2object:
59B2function:
60        movw r0, #2
61A3notype:
62B3object:
63        movw r0, #3
64A4object:
65B4notype:
66        movw r0, #4
67