xref: /llvm-project/llvm/test/tools/llvm-objdump/X86/adjust-vma.test (revision 7b7470600c1b30d6f1acf500976e1c06e5282aa0)
1# RUN: yaml2obj %s -o %t
2# RUN: llvm-objdump --all-headers -D -z %t | FileCheck %s --check-prefixes=COMMON,NOADJUST
3# RUN: llvm-objdump --all-headers -D -z --adjust-vma=0x0 %t | FileCheck %s --check-prefixes=COMMON,NOADJUST
4# RUN: llvm-objdump --all-headers -D -z --adjust-vma=0x123000 %t | FileCheck %s --check-prefixes=COMMON,ADJUST
5
6# NOADJUST:      Sections:
7# NOADJUST-NEXT: Idx Name           Size     VMA              Type
8# NOADJUST-NEXT:  0                 00000000 0000000000000000
9# NOADJUST-NEXT:  1 .text           00000002 0000000000000000 TEXT
10# NOADJUST-NEXT:  2 .debug_str      00000004 0000000000000000
11# NOADJUST-NEXT:  3 .rela.debug_str 00000018 0000000000000000
12# NOADJUST-NEXT:  4 .data           00000004 0000000000000000 DATA
13# NOADJUST-NEXT:  5 .rela.data      00000018 0000000000000000
14# NOADJUST-NEXT:  6 .symtab         {{.*}}   0000000000000000
15# NOADJUST-NEXT:  7 .strtab         {{.*}}   0000000000000000
16# NOADJUST-NEXT:  8 .shstrtab       0000003c 0000000000000000
17
18# ADJUST:        Sections:
19# ADJUST-NEXT:   Idx Name           Size     VMA              Type
20# ADJUST-NEXT:    0                 00000000 0000000000000000
21# ADJUST-NEXT:    1 .text           00000002 0000000000123000 TEXT
22# ADJUST-NEXT:    2 .debug_str      00000004 0000000000000000
23# ADJUST-NEXT:    3 .rela.debug_str 00000018 0000000000000000
24# ADJUST-NEXT:    4 .data           00000004 0000000000123000 DATA
25# ADJUST-NEXT:    5 .rela.data      00000018 0000000000000000
26# ADJUST-NEXT:    6 .symtab         {{.*}}   0000000000000000
27# ADJUST-NEXT:    7 .strtab         {{.*}}   0000000000000000
28# ADJUST-NEXT:    8 .shstrtab       0000003c 0000000000000000
29
30# NOADJUST:      SYMBOL TABLE:
31# NOADJUST-NEXT:  0000000000000001  l F .text      0000000000000000 func
32# NOADJUST-NEXT:  0000000000000000  l   .text      0000000000000000 sym
33# NOADJUST-NEXT:  0000000000000000  l d .text      0000000000000000 .text
34# NOADJUST-NEXT:  0000000000003333  l   *ABS*      0000000000000000 abs
35# NOADJUST-NEXT:  0000000000000000  l   .debug_str 0000000000000000 debug_str_sym
36
37# ADJUST:        SYMBOL TABLE:
38# ADJUST-NEXT:    0000000000123001  l F .text      0000000000000000 func
39# ADJUST-NEXT:    0000000000123000  l   .text      0000000000000000 sym
40# ADJUST-NEXT:    0000000000123000  l d .text      0000000000000000 .text
41# ADJUST-NEXT:    0000000000003333  l   *ABS*      0000000000000000 abs
42# ADJUST-NEXT:    0000000000000000  l   .debug_str 0000000000000000 debug_str_sym
43
44# NOADJUST:      0000000000000000 <sym>:
45# NOADJUST-NEXT:   0: {{.*}}  nop
46# NOADJUST:      0000000000000001 <func>:
47# NOADJUST-NEXT:   1: {{.*}}  retq
48
49# ADJUST:        0000000000123000 <sym>:
50# ADJUST-NEXT:     123000: {{.*}} nop
51# ADJUST:        0000000000123001 <func>:
52# ADJUST-NEXT:     123001: {{.*}} retq
53
54# NOADJUST:      0000000000000000 <debug_str_sym>:
55# NOADJUST-NEXT:   0: {{.*}}  %al, (%rax)
56# NOADJUST-NEXT:      0000000000000001:  R_X86_64_32  .text
57# NOADJUST-NEXT:   2: {{.*}}  addb    %al, (%rax)
58
59# ADJUST:        0000000000000000 <debug_str_sym>:
60# ADJUST-NEXT:     0: {{.*}}  %al, (%rax)
61# ADJUST-NEXT:        0000000000123001:  R_X86_64_32  .text
62# ADJUST-NEXT:     2: {{.*}}  addb    %al, (%rax)
63
64# COMMON:        0000000000000000    <.rela.debug_str>:
65# COMMON-NEXT:     0: {{.*}}  addl %eax, (%rax)
66## ... There are more lines here. We do not care.
67
68# NOADJUST:      0000000000000000  <.data>:
69# NOADJUST-NEXT:  0: {{.*}} addb    %al, (%rax)
70# NOADJUST-NEXT: 0000000000000000: R_X86_64_32  .text
71# NOADJUST-NEXT:  2: {{.*}} addb    %al, (%rax)
72
73# ADJUST:        0000000000123000  <.data>:
74# ADJUST-NEXT:    123000: {{.*}}  addb    %al, (%rax)
75# ADJUST-NEXT:   0000000000123000: R_X86_64_32  .text
76# ADJUST-NEXT:    123002: {{.*}}  addb    %al, (%rax)
77
78# COMMON:        0000000000000000   <.rela.data>:
79# COMMON-NEXT:    0: {{.*}} addb %al, (%rax)
80## ... There are more lines here. We do not care.
81
82--- !ELF
83FileHeader:
84  Class:           ELFCLASS64
85  Data:            ELFDATA2LSB
86  Type:            ET_REL
87  Machine:         EM_X86_64
88Sections:
89  - Name:            .text
90    Type:            SHT_PROGBITS
91    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
92    AddressAlign:    0x0000000000000004
93    Content:         90C3
94  - Name:            .debug_str
95    Type:            SHT_PROGBITS
96    Flags:           [ SHF_MERGE, SHF_STRINGS ]
97    AddressAlign:    0x0000000000000001
98    Content:         '00000000'
99  - Name:            .rela.debug_str
100    Type:            SHT_RELA
101    Link:            .symtab
102    AddressAlign:    0x0000000000000008
103    Info:            .debug_str
104    Relocations:
105      - Offset:          0x0000000000000001
106        Symbol:          .text
107        Type:            R_X86_64_32
108  - Name:            .data
109    Type:            SHT_PROGBITS
110    Flags:           [ SHF_WRITE, SHF_ALLOC ]
111    AddressAlign:    0x0000000000000001
112    Content:         '00000000'
113  - Name:            .rela.data
114    Type:            SHT_RELA
115    Link:            .symtab
116    AddressAlign:    0x0000000000000008
117    Info:            .data
118    Relocations:
119      - Offset:      0x0000000000000000
120        Symbol:      .text
121        Type:        R_X86_64_32
122Symbols:
123  - Name:            func
124    Type:            STT_FUNC
125    Section:         .text
126    Value:           0x0000000000000001
127  - Name:            sym
128    Section:         .text
129  - Name:            .text
130    Type:            STT_SECTION
131    Section:         .text
132  - Name:            abs
133    Index:           SHN_ABS
134    Value:           0x3333
135  - Name:            debug_str_sym
136    Section:         .debug_str
137