[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / llvm / test / tools / llvm-objdump / section-filter.test
bloba1f41285355372f0478fca51b600a88611959ac2
1 ## Test that --section works correctly for -h.
2 ## We test the LMA here too, because the code at the time of writing uses the 
3 ## value of --section when looking up section LMAs.
4 # RUN: yaml2obj %s --docnum=1 -o %t.h.elf
5 # RUN: llvm-objdump -h %t.h.elf -j.text --section=.bss \
6 # RUN:   | FileCheck %s --check-prefix=SHDRS --implicit-check-not=.data --implicit-check-not=.text2
8 # SHDRS: Name  Size     VMA              LMA
9 # SHDRS: .text 00000001 0000000000000400 0000000000001000
10 # SHDRS: .bss  00000001 0000000000000420 0000000000003000
12 --- !ELF
13 FileHeader:
14   Class:   ELFCLASS64
15   Data:    ELFDATA2LSB
16   Type:    ET_EXEC
17   Machine: EM_X86_64
18 Sections:
19   - Name:         .text
20     Type:         SHT_PROGBITS
21     Flags:        [SHF_ALLOC, SHF_EXECINSTR]
22     Address:      0x400
23     AddressAlign: 0x10
24     Content:      'c3'
25   - Name:         .text2
26     Type:         SHT_PROGBITS
27     Flags:        [SHF_ALLOC, SHF_EXECINSTR]
28     Address:      0x401
29     Content:      '90'
30   - Name:         .data
31     Type:         SHT_PROGBITS
32     Flags:        [SHF_ALLOC, SHF_WRITE]
33     Address:      0x410
34     AddressAlign: 0x10
35     Content:      '42'
36   - Name:         .bss
37     Type:         SHT_NOBITS
38     Flags:        [SHF_ALLOC, SHF_WRITE]
39     Address:      0x420
40     AddressAlign: 0x10
41     Size:         1
42 ProgramHeaders:
43   - Type:     PT_LOAD
44     VAddr:    0x400
45     PAddr:    0x1000
46     FirstSec: .text
47     LastSec:  .text2
48   - Type:     PT_LOAD
49     VAddr:    0x410
50     PAddr:    0x2000
51     FirstSec: .data
52     LastSec:  .data
53   - Type:     PT_LOAD
54     VAddr:    0x420
55     PAddr:    0x3000
56     FirstSec: .bss
57     LastSec:  .bss
59 ## Test that --section works with --fault-map-section.
60 # RUN: yaml2obj %s --docnum=2 -o %t.o
61 # RUN: llvm-objdump %t.o --fault-map-section -j __clangast \
62 # RUN:   | FileCheck %s --check-prefixes=FAULTMAP,NO-FAULTMAP
63 # RUN: llvm-objdump %t.o --fault-map-section -j .llvm_faultmaps \
64 # RUN:   | FileCheck %s --check-prefixes=FAULTMAP,WITH-FAULTMAP
66 # FAULTMAP:           FaultMap table:
67 # NO-FAULTMAP-NEXT:   <not found>
68 # WITH-FAULTMAP-NEXT: Version: 0x1
69 # WITH-FAULTMAP-NEXT: NumFunctions: 0
71 ## Test that --section works with --raw-clang-ast.
72 # RUN: llvm-objdump %t.o --raw-clang-ast -j .llvm_faultmaps \
73 # RUN:   | FileCheck %s --check-prefix=NO-AST --allow-empty
74 # RUN: llvm-objdump %t.o --raw-clang-ast -j __clangast \
75 # RUN:   | FileCheck %s --check-prefix=CLANG-AST
77 # NO-AST-NOT: {{.}}
78 # CLANG-AST: foobar
80 --- !ELF
81 FileHeader:
82   Class:   ELFCLASS64
83   Data:    ELFDATA2LSB
84   Type:    ET_REL
85   Machine: EM_X86_64
86 Sections:
87   - Name:    .llvm_faultmaps
88     Type:    SHT_PROGBITS
89     Content: '0100000000000000'
90   - Name:    __clangast
91     Type:    SHT_PROGBITS
92     Content: '666f6f626172' # "foobar"
94 ## Test that the -j alias can be used flexibly. Create a baseline and ensure
95 ## all other combinations compatible with POSIX are identical.
96 # RUN: llvm-objdump %t.h.elf -h -s --section .symtab > %t.full
97 # RUN: llvm-objdump %t.h.elf -h -s -j .symtab > %t.1
98 # RUN: llvm-objdump %t.h.elf -h -s -j.symtab > %t.2
99 # RUN: llvm-objdump %t.h.elf -hsj .symtab > %t.3
100 # RUN: llvm-objdump %t.h.elf -hsj.symtab > %t.4
102 # RUN: cmp %t.full %t.1
103 # RUN: cmp %t.full %t.2
104 # RUN: cmp %t.full %t.3
105 # RUN: cmp %t.full %t.4
107 ## Test that an unknown section name causes all section output to be suppressed.
108 # RUN: llvm-objdump %t.h.elf -h --section foobar \
109 # RUN:   | FileCheck %s --check-prefix=NO-SECTION
111 # NO-SECTION:      Sections:
112 # NO-SECTION-NEXT: Idx Name Size VMA Type
113 # NO-SECTION-NOT:  {{.}}