File: disassemble-same-section-addr.test

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (114 lines) | stat: -rw-r--r-- 4,268 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
## This test shows that llvm-objdump can handle sections with the same address
## when symbols in those sections are referenced. In the past, the section
## picked was non-deterministic, resulting in different symbols being found for
## the section. The test uses YAML for the input, as we need a fully linked ELF
## to reproduce the original failure.

## Two empty sections, one with symbol in, one without.
# RUN: yaml2obj %s --docnum=1 -o %t1 -D SIZE1=0 -D SIZE2=0 -D SECTION=.second -D INDEX=SHN_ABS
# RUN: llvm-objdump -d %t1 | FileCheck %s --check-prefix=TARGET
# RUN: yaml2obj %s --docnum=1 -o %t2 -D SIZE1=0 -D SIZE2=0 -D SECTION=.first -D INDEX=SHN_ABS
# RUN: llvm-objdump -d %t2 | FileCheck %s --check-prefix=TARGET

## Two sections, one empty with symbol, other non-empty, without symbol.
# RUN: yaml2obj %s --docnum=1 -o %t3 -D SIZE1=1 -D SIZE2=0 -D SECTION=.second -D INDEX=SHN_ABS
# RUN: llvm-objdump -d %t3 | FileCheck %s --check-prefix=TARGET
# RUN: yaml2obj %s --docnum=1 -o %t4 -D SIZE1=0 -D SIZE2=1 -D SECTION=.first -D INDEX=SHN_ABS
# RUN: llvm-objdump -d %t4 | FileCheck %s --check-prefix=TARGET

## Fall back to absolute symbol if no symbol found in candidate sections.
# RUN: yaml2obj %s --docnum=1 -o %t5 -D SIZE1=1 -D SIZE2=0 -D SECTION=.caller -D INDEX=SHN_ABS
# RUN: llvm-objdump -d %t5 | FileCheck %s --check-prefix=ABSOLUTE

## Show that other symbols with reserved st_shndx values are treated as absolute
## symbols.
# RUN: yaml2obj %s --docnum=1 -o %t6 -D SIZE1=1 -D SIZE2=0 -D SECTION=.caller -D INDEX=SHN_LOPROC
# RUN: llvm-objdump -d %t6 | FileCheck %s --check-prefix=ABSOLUTE

## Print no target if no symbol in section/absolute symbol found.
# RUN: llvm-objcopy %t5 %t7 -N other
# RUN: llvm-objdump -d %t7 | FileCheck %s --check-prefix=FAIL

# TARGET:   callq 0x5 <target>
# ABSOLUTE: callq 0x5 <other+0x5>
# FAIL:     callq 0x5{{$}}

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
Sections:
  - Name:    .caller
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Address: 0x0
    Content: e800000000 ## Call instruction to next address.
  - Name:    .first
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Address: 0x5
    Size:    [[SIZE1]]
  - Name:    .second
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Address: 0x5
    Size:    [[SIZE2]]
Symbols:
  - Name:    target
    Section: [[SECTION]]
    Value:   0x5
  - Name:    other
    Index:   [[INDEX]]
    Value:   0x0

## Two empty sections, both with symbols.
# RUN: yaml2obj %s --docnum=2 -o %t7 -D SIZE1=0 -D SIZE2=0 -D SYMVAL1=0x5 -D SYMVAL2=0x5
# RUN: llvm-objdump -d %t7 | FileCheck %s --check-prefix=SECOND

## Two sections, both with symbols, one empty, the other not.
# RUN: yaml2obj %s --docnum=2 -o %t8 -D SIZE1=1 -D SIZE2=0 -D SYMVAL1=0x5 -D SYMVAL2=0x5
# RUN: llvm-objdump -d %t8 | FileCheck %s --check-prefix=FIRST
# RUN: yaml2obj %s --docnum=2 -o %t9 -D SIZE1=0 -D SIZE2=1 -D SYMVAL1=0x5 -D SYMVAL2=0x5
# RUN: llvm-objdump -d %t9 | FileCheck %s --check-prefix=SECOND

## Two sections, both with symbols, one empty, other not, symbol in non-empty
## section has value higher than target address.
# RUN: yaml2obj %s --docnum=2 -o %t10 -D SIZE1=1 -D SIZE2=0 -D SYMVAL1=0x6 -D SYMVAL2=0x5
# RUN: llvm-objdump -d %t10 | FileCheck %s --check-prefix=SECOND
# RUN: yaml2obj %s --docnum=2 -o %t11 -D SIZE1=0 -D SIZE2=1 -D SYMVAL1=0x5 -D SYMVAL2=0x6
# RUN: llvm-objdump -d %t11 | FileCheck %s --check-prefix=FIRST

# FIRST:  callq 0x5 <first>
# SECOND: callq 0x5 <second>

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
Sections:
  - Name:    .caller
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Address: 0x0
    Content: e800000000 ## Call instruction to next address.
  - Name:    .first
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Address: 0x5
    Size:    [[SIZE1]]
  - Name:    .second
    Type:    SHT_PROGBITS
    Flags:   [SHF_ALLOC, SHF_EXECINSTR]
    Address: 0x5
    Size:    [[SIZE2]]
Symbols:
  - Name:    first
    Section: .first
    Value:   [[SYMVAL1]]
  - Name:    second
    Section: .second
    Value:   [[SYMVAL2]]