Index: llvm/trunk/test/tools/llvm-objdump/X86/disasm-specific-funcs-mangled-name.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/disasm-specific-funcs-mangled-name.test +++ llvm/trunk/test/tools/llvm-objdump/X86/disasm-specific-funcs-mangled-name.test @@ -0,0 +1,27 @@ +## Show that the --disassemble-functions switch takes mangled names, not +## demangled names. + +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-objdump -d --disassemble-functions=_Z3foov %t.o | FileCheck %s +# RUN: llvm-objdump -d --disassemble-functions='foo()' %t.o | FileCheck %s --check-prefix=NOFOO +# RUN: llvm-objdump -d -C --disassemble-functions='foo()' %t.o | FileCheck %s --check-prefix=NOFOO +# RUN: llvm-objdump -d --disassemble-functions=foo %t.o | FileCheck %s --check-prefix=NOFOO + +# CHECK: _Z3foov: + +# NOFOO-NOT: foo + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: '90' +Symbols: + - Name: _Z3foov + Section: .text Index: llvm/trunk/test/tools/llvm-objdump/X86/disasm-specific-funcs.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/disasm-specific-funcs.test +++ llvm/trunk/test/tools/llvm-objdump/X86/disasm-specific-funcs.test @@ -1,21 +1,25 @@ -// RUN: yaml2obj -o %t.out %p/Inputs/simple-executable-x86_64.yaml -// RUN: llvm-objdump -d %t.out -disassemble-functions=main | FileCheck %s +## Show that the --diassemble-functions switch disassembles only the specified +## functions. -// CHECK: Disassembly of section .anothertext: -// CHECK-EMPTY: -// CHECK-NEXT: main: -// CHECK-NEXT: 10: 55 pushq %rbp -// CHECK-NEXT: 11: 48 89 e5 movq %rsp, %rbp -// CHECK-NEXT: 14: 48 83 ec 20 subq $32, %rsp -// CHECK-NEXT: 18: 48 8d 04 25 a8 00 00 00 leaq 168, %rax -// CHECK-NEXT: 20: c7 45 fc 00 00 00 00 movl $0, -4(%rbp) -// CHECK-NEXT: 27: 48 89 45 f0 movq %rax, -16(%rbp) -// CHECK-NEXT: 2b: 48 8b 45 f0 movq -16(%rbp), %rax -// CHECK-NEXT: 2f: 8b 08 movl (%rax), %ecx -// CHECK-NEXT: 31: 89 4d ec movl %ecx, -20(%rbp) -// CHECK-NEXT: 34: e8 c7 ff ff ff callq -57 -// CHECK-NEXT: 39: 8b 4d ec movl -20(%rbp), %ecx -// CHECK-NEXT: 3c: 01 c1 addl %eax, %ecx -// CHECK-NEXT: 3e: 89 c8 movl %ecx, %eax -// CHECK-NEXT: 40: 48 83 c4 20 addq $32, %rsp -// CHECK-NEXT: 44: 5d popq %rbp +# RUN: yaml2obj -o %t.out %p/Inputs/simple-executable-x86_64.yaml +# RUN: llvm-objdump -d %t.out --disassemble-functions=main \ +# RUN: | FileCheck %s --check-prefix=MAIN --implicit-check-not=foo --implicit-check-not=somedata +# RUN: llvm-objdump -d %t.out --disassemble-functions=main,foo \ +# RUN: | FileCheck %s --check-prefixes=MAIN,FOO --implicit-check-not=somedata + +# FOO: foo: +# MAIN: main: + +## Unknown symbol name. +# RUN: llvm-objdump -d %t.out --disassemble-functions=baz \ +# RUN: | FileCheck %s --implicit-check-not=Disassembly + +## Data symbol. +# RUN: llvm-objdump -d %t.out --disassemble-functions=a \ +# RUN: | FileCheck %s --implicit-check-not=Disassembly + +## Data symbol + --disassemble-all. +# RUN: llvm-objdump -D %t.out --disassemble-functions=a \ +# RUN: | FileCheck %s --check-prefix=DATA + +# DATA: a: Index: llvm/trunk/test/tools/llvm-objdump/X86/disassemble-invalid-byte-sequences.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/disassemble-invalid-byte-sequences.test +++ llvm/trunk/test/tools/llvm-objdump/X86/disassemble-invalid-byte-sequences.test @@ -0,0 +1,20 @@ +## Show that llvm-objdump handles invalid byte sequences, and continues. + +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-objdump %t.o -d | FileCheck %s + +# CHECK: 0000000000000000 .text: +# CHECK: 0: d9 e2 +# CHECK-NEXT: 2: 90 nop + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'd9e290' Index: llvm/trunk/test/tools/llvm-objdump/X86/disassemble-long-instructions.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/disassemble-long-instructions.test +++ llvm/trunk/test/tools/llvm-objdump/X86/disassemble-long-instructions.test @@ -0,0 +1,17 @@ +## This test shows that llvm-objdump can disassemble a long instruction. +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-objdump -d %t.o | FileCheck %s --strict-whitespace + +# CHECK: 0: 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:(%rax,%rax) + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: '6666666666662E0F1F840000000000' # 15-byte nop Index: llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test +++ llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-symbols.test @@ -0,0 +1,99 @@ +## Show the disassembly behaviour when dynamic symbols are present. +# RUN: yaml2obj %s -o %t + +## Case 1: Both static and dynamic symbols are present. Only static +## symbols are displayed. +# RUN: llvm-objdump -d %t | FileCheck %s --check-prefixes=CHECK,STATIC + +## Case 2: Only the dynamic symbols are present. These should be displayed, if +## they meet the necessary criteria. +# RUN: llvm-objcopy --strip-all %t %t2 +# RUN: llvm-objdump -d %t2 | FileCheck %s --check-prefixes=CHECK,DYN + +# CHECK: Disassembly of section .text: +# CHECK-EMPTY: +# STATIC-NEXT: 0000000000001000 .text: +# DYN-NEXT: 0000000000001000 only_dyn: +# CHECK-NEXT: 1000: +# CHECK-EMPTY: +# STATIC-NEXT: 0000000000001001 both_static: +# DYN-NEXT: 0000000000001001 both_dyn: +# CHECK-NEXT: 1001: +# STATIC-EMPTY: +# STATIC-NEXT: 0000000000001002 only_static: +# CHECK-NEXT: 1002: +# CHECK-NEXT: 1003: +# CHECK-NEXT: 1004: +# CHECK-NEXT: 1005:{{.*}} +# CHECK-NOT: {{.}} + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Address: 0x1000 + Content: 909090909090 +ProgramHeaders: + - Type: PT_LOAD + VAddr: 0x1000 + Sections: + - Section: .text +Symbols: + - Name: both_static + Value: 0x1001 + Section: .text + Binding: STB_GLOBAL + - Name: only_static + Value: 0x1002 + Section: .text + Binding: STB_GLOBAL +DynamicSymbols: + - Name: only_dyn + Value: 0x1000 + Section: .text + Size: 1 + Type: STT_FUNC + Binding: STB_GLOBAL + - Name: both_dyn + Value: 0x1001 + Section: .text + Size: 1 + Type: STT_FUNC + Binding: STB_GLOBAL + ## The rest of the dynamic symbols won't be used for various reasons. + ## FIXME: the first two symbols here should be dumped. + ## See https://bugs.llvm.org/show_bug.cgi?id=41947 + - Name: not_func + Value: 0x1003 + Section: .text + Type: STT_OBJECT + Binding: STB_GLOBAL + - Name: zero_sized + Value: 0x1004 + Section: .text + Type: STT_FUNC + Binding: STB_GLOBAL + - Name: '' # No name + Value: 0x1005 + Section: .text + Size: 1 + Type: STT_FUNC + Binding: STB_GLOBAL + - Name: absolute + Value: 0x1005 + Index: SHN_ABS + Size: 1 + Type: STT_FUNC + Binding: STB_GLOBAL + - Name: undefined + Value: 0x1005 + Index: SHN_UNDEF + Size: 1 + Type: STT_FUNC + Binding: STB_GLOBAL Index: llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-no-symtab.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-no-symtab.test +++ llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-no-symtab.test @@ -0,0 +1,24 @@ +## Show that llvm-objdump can handle a missing symbol table when printing +## references and labels. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-objcopy -R .symtab %t +# RUN: llvm-objdump %t -d | FileCheck %s + +# CHECK: Disassembly of section .text: +# CHECK-EMPTY: +# CHECK-NEXT: 0000000000004000 .text: +# CHECK-NEXT: 4000: e8 42 00 00 00 callq 66 <.text+0x47> + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Address: 0x4000 + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'e842000000' Index: llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-relocs.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-relocs.test +++ llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-relocs.test @@ -0,0 +1,42 @@ +## Show that --disassemble + --reloc prints relocations inline and does not dump +## the relocation sections. + +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-objdump %t.o -d -r | FileCheck %s --implicit-check-not="RELOCATION RECORDS" + +# CHECK: 0: e8 00 00 00 00 callq 0 <.text+0x5> +# CHECK-NEXT: 0000000000000001: R_X86_64_PC32 foo-4 +# CHECK-NEXT: 0000000000000002: R_X86_64_NONE bar+8 +# CHECK-NEXT: 5: e8 00 00 00 00 callq 0 <.text+0xa> +# CHECK-NEXT: 0000000000000006: R_X86_64_PLT32 foo+1 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'e800000000e800000000' + - Name: .rela.text + Type: SHT_RELA + Info: .text + Relocations: + - Offset: 1 + Symbol: foo + Type: R_X86_64_PC32 + Addend: -4 + - Offset: 2 + Symbol: bar + Type: R_X86_64_NONE + Addend: 8 + - Offset: 6 + Symbol: foo + Type: R_X86_64_PLT32 + Addend: 1 +Symbols: + - Name: foo + - Name: bar Index: llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-symbol-labels-exec.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-symbol-labels-exec.test +++ llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-symbol-labels-exec.test @@ -0,0 +1,54 @@ +## Show which labels are printed in disassembly of an executable. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-objdump %t -d | FileCheck %s --implicit-check-not=stt_section \ +# RUN: --implicit-check-not=fourth \ +# RUN: --implicit-check-not=absolute \ +# RUN: --implicit-check-not=other + +# CHECK: 0000000000004000 first: +# CHECK: 0000000000004001 second: +# CHECK: 0000000000004002 third: + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Address: 0x4000 + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: '9090909090' + - Name: .text2 + Type: SHT_PROGBITS + Address: 0x4004 + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Size: 0 +Symbols: + - Name: first # Shows, with second, that symbol sizes are not used to delineate functions. + Value: 0x4000 + Section: .text + Size: 0x2 + - Name: second + Value: 0x4001 + Size: 0x1 + Section: .text + - Name: third # Shows, with fourth, that first symbol is picked. + Value: 0x4002 + Section: .text + - Name: fourth + Value: 0x4002 + Section: .text + - Name: stt_section # Shows that STT_SECTION symbols are ignored even if no other symbol present. + Value: 0x4003 + Type: STT_SECTION + Section: .text + - Name: absolute # Show that absolute symbols are ignored. + Value: 0x4004 + Index: SHN_ABS + - Name: other # Show that symbols from other sections are ignored. + Value: 0x4004 + Section: .text2 Index: llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-symbol-labels-rel.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-symbol-labels-rel.test +++ llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-symbol-labels-rel.test @@ -0,0 +1,58 @@ +## Show which labels are printed in disassembly of a relocatable object. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-objdump %t -d | FileCheck %s --implicit-check-not=stt_section \ +# RUN: --implicit-check-not=first \ +# RUN: --implicit-check-not=second \ +# RUN: --implicit-check-not=third \ +# RUN: --implicit-check-not=fourth \ +# RUN: --implicit-check-not=absolute \ +# RUN: --implicit-check-not=other + +# CHECK: Disassembly of section .text: +# CHECK: 0000000000000000 first: +# CHECK: 0000000000000001 second: +# CHECK: 0000000000000002 third: +# CHECK: Disassembly of section .text2: +# CHECK: 0000000000000004 other: + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: '909090909090' + - Name: .text2 + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: '9090909090' +Symbols: + - Name: first + Value: 0 + Section: .text + Size: 2 + - Name: second # Shows, with first, that symbol sizes are not used to delineate functions. + Value: 1 + Size: 1 + Section: .text + - Name: third # Shows, with fourth, that first symbol is picked. + Value: 2 + Section: .text + - Name: fourth + Value: 2 + Section: .text + - Name: stt_section # Shows that STT_SECTION symbols are ignored even if no other symbol present. + Value: 3 + Type: STT_SECTION + Section: .text + - Name: absolute # Show that absolute symbols are ignored. + Value: 4 + Index: SHN_ABS + - Name: other # Show that symbols in other sections are ignored. + Value: 4 + Section: .text2 Index: llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-symbol-references.yaml =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-symbol-references.yaml +++ llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble-symbol-references.yaml @@ -0,0 +1,101 @@ +## Show that references in disassembly are labelled with the correct symbol. +# RUN: yaml2obj %s --docnum=1 -o %t +# RUN: llvm-objdump %t -d | FileCheck %s --check-prefix=EXEC + +# EXEC: Disassembly of section .text1: +# EXEC: 4000: e8 00 00 00 00 callq 0 +# EXEC: Disassembly of section .text2: +# EXEC: 4005: e8 12 34 56 78 callq 2018915346 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text1 + Type: SHT_PROGBITS + Address: 0x4000 + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'e800000000' # Case 1: Referencing an address with a symbol. + - Name: .text2 + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Address: 0x4005 + Content: 'e812345678' # Case 2: Referencing an address without a symbol. + - Name: .text3 + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Address: 0x400A +Symbols: + - Name: first + Section: .text1 + Value: 0x4000 + - Name: second + Section: .text1 + Value: 0x4005 + - Name: third + Section: .text2 + Value: 0x4005 + - Name: fourth + Section: .text3 + Value: 0x400A + +# RUN: yaml2obj %s --docnum=2 -o %t.o +# RUN: llvm-objdump %t.o -d | FileCheck %s --check-prefix=REL + +# REL: Disassembly of section .text1: +# REL-EMPTY: +# REL-NEXT: 0000000000000000 .text1: +# REL-NEXT: 0: e8 00 00 00 00 callq 0 <.text1+0x5> +# REL-EMPTY: +# REL-NEXT: Disassembly of section .text2: +# REL-EMPTY: +# REL-NEXT: 0000000000000000 .text2: +# REL-NEXT: 0: e8 00 00 00 00 callq 0 +# REL-EMPTY: +# REL-NEXT: Disassembly of section .text3: +# REL-EMPTY: +# REL-NEXT: 0000000000000000 .text3: +# REL-NEXT: 0: e8 00 00 00 00 callq 0 <.text3+0x5> + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text1 + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'e800000000' # Case 1: Instruction is patched by a relocation. + - Name: .rela.text1 + Type: SHT_RELA + Info: .text1 + Relocations: + - Offset: 1 + Type: R_X86_64_PC32 + Symbol: sym3 + - Name: .text2 + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'e800000000' # Case 2: Referencing an address with a matching symbol in that section. + - Name: .text3 + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'e800000000' # Case 3: Referencing an address without a matching symbol in that section. + - Name: .other + Type: SHT_PROGBITS +Symbols: + # Shouldn't be picked, despite matching value, as not in right section. + - Name: sym1 + Section: .other + Value: 5 + # Symbol in correct section, with right value should be picked for disassembly of .text2. + - Name: sym2 + Section: .text2 + Value: 5 + # Symbol referenced by relocation could be picked for disassembly of .text1, but isn't. + - Name: sym3 Index: llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble.test +++ llvm/trunk/test/tools/llvm-objdump/X86/elf-disassemble.test @@ -0,0 +1,50 @@ +## Show that disassembly is printed correctly, for only the desired sections. +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-objdump %t.o --disassemble | FileCheck %s --implicit-check-not=Disassembly +# RUN: llvm-objdump %t.o --disassemble-all | FileCheck %s --check-prefixes=CHECK,ALL + +# CHECK: Disassembly of section .executable: +# CHECK-EMPTY: +# CHECK-NEXT: 0000000000001000 .executable: +# CHECK-NEXT: 0: 90 nop +# ALL-EMPTY: +# ALL-NEXT: Disassembly of section .writable: +# ALL-EMPTY: +# ALL-NEXT: 0000000000002000 .writable: +# ALL-NEXT: 0: c3 retq +# ALL-EMPTY: +# ALL-NEXT: Disassembly of section .readonly: +# ALL-EMPTY: +# ALL-NEXT: 0000000000003000 .readonly: +# ALL-NEXT: 0: 01 00 addl %eax, (%rax) +# ALL-EMPTY: +# ALL-NEXT: Disassembly of section .nobits: +# ALL-EMPTY: +# ALL-NEXT: 0000000000004000 .nobits: +# ALL-NEXT: ... + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .executable + Type: SHT_PROGBITS + Address: 0x1000 + Flags: [SHF_EXECINSTR] + Content: '90' + - Name: .writable + Type: SHT_PROGBITS + Address: 0x2000 + Flags: [SHF_WRITE] + Content: 'c3' + - Name: .readonly + Type: SHT_PROGBITS + Address: 0x3000 + Content: '0100' + - Name: .nobits + Type: SHT_NOBITS + Address: 0x4000 + Size: 4 Index: llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address-relocatable-object.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address-relocatable-object.test +++ llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address-relocatable-object.test @@ -0,0 +1,46 @@ +## Show how --start-address and --stop-address work in a relocatable object. +## They limit the disassembly to the relative offset ranges within sections. +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-objdump -d %t.o --start-address=1 --stop-address=2 | FileCheck %s --check-prefix=COMMON +# RUN: llvm-objdump -d %t.o --start-address=1 | FileCheck %s --check-prefixes=START,COMMON +# RUN: llvm-objdump -d %t.o --stop-address=2 | FileCheck %s --check-prefixes=STOP,COMMON + +# COMMON: Disassembly of section .text: +# COMMON-EMPTY: +# COMMON-NEXT: 0000000000000000 .text: +# STOP-NEXT: 0: 90 nop +# COMMON-NEXT: 1: 90 nop +# START-NEXT: 2: 90 nop +# COMMON-EMPTY: +# COMMON-NEXT: Disassembly of section .text2: +# COMMON-EMPTY: +# COMMON-NEXT: 0000000000000000 .text2: +# STOP-NEXT: 0: c3 retq +# COMMON-NEXT: 1: c3 retq +# START-NEXT: 2: c3 retq +# STOP-EMPTY: +# STOP-NEXT: Disassembly of section .text3: +# STOP-EMPTY: +# STOP-NEXT: 0000000000000000 .text3: +# STOP-NEXT: 0: cc int3 +# COMMON-NOT: {{.}} + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: '909090' + - Name: .text2 + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'c3c3c3' + - Name: .text3 + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'cc' Index: llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address.test +++ llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address.test @@ -1,8 +1,12 @@ // RUN: yaml2obj -o %t.out %p/Inputs/simple-executable-x86_64.yaml // RUN: llvm-objdump -d %t.out --start-address=0x18 --stop-address=0x2f | FileCheck %s -// RUN: llvm-objdump -d %t.out --start-address=0xc --stop-address=0x11 | FileCheck %s --check-prefix "CROSSSECTION" -// RUN: llvm-objdump -d %t.out --start-address=0x40 --stop-address=0x47 | FileCheck %s --check-prefix "CROSSDATA" +// RUN: llvm-objdump -d %t.out --start-address=0xc --stop-address=0x11 | FileCheck %s --check-prefix CROSSSECTION +// RUN: llvm-objdump -d %t.out --start-address=0x40 --stop-address=0x47 | FileCheck %s --check-prefix CROSSDATA +// RUN: llvm-objdump -d %t.out --start-address=0x40 | FileCheck %s --check-prefix START +// RUN: llvm-objdump -d %t.out --stop-address=0x11 | FileCheck %s --check-prefix STOP +// RUN: llvm-objdump -d %t.out --start-address=0xffffffff | FileCheck %s --check-prefix OUT-OF-RANGE +// CHECK-NOT: Disassembly // CHECK: Disassembly of section .anothertext: // CHECK-EMPTY: // CHECK-NEXT: main: @@ -10,8 +14,9 @@ // CHECK-NEXT: 20: c7 45 fc 00 00 00 00 movl $0, -4(%rbp) // CHECK-NEXT: 27: 48 89 45 f0 movq %rax, -16(%rbp) // CHECK-NEXT: 2b: 48 8b 45 f0 movq -16(%rbp), %rax -// CHECK-NOT: 2f: +// CHECK-NOT: {{.}} +// CROSSECTION-NOT: Disassembly // CROSSSECTION: Disassembly of section .text: // CROSSSECTION-EMPTY: // CROSSSECTION-NEXT: foo: @@ -22,12 +27,45 @@ // CROSSSECTION-EMPTY: // CROSSSECTION-NEXT: main: // CROSSSECTION-NEXT: 10: 55 pushq %rbp -// CROSSSECTION-NOT: 11: +// CROSSSECTION-NOT: {{.}} +// CROSSDATA-NOT: Disassembly // CROSSDATA: Disassembly of section .anothertext: // CROSSDATA: main: // CROSSDATA: 40: 48 83 c4 20 addq $32, %rsp // CROSSDATA: 44: 5d popq %rbp // CROSSDATA-DAG: somedata: // CROSSDATA-NEXT: 45: 74 65 te +// CROSSDATA-NOT: {{.}} +// START-NOT: Disassembly +// START: Disassembly of section .anothertext: +// START-EMPTY: +// START-NEXT: 0000000000000010 main: +// START-NEXT: 40: 48 83 c4 20 addq $32, %rsp +// START-NEXT: 44: 5d popq %rbp +// START-EMPTY: +// START-NEXT: 0000000000000045 somedata: +// START-NEXT: 45: 74 65 73 74 20 73 74 72 test str +// START-NEXT: 4d: 00 c3 .. + +// STOP: Disassembly of section .text: +// STOP-EMPTY: +// STOP-NEXT: 0000000000000000 foo: +// STOP-NEXT: 0: 55 pushq %rbp +// STOP-NEXT: 1: 48 89 e5 movq %rsp, %rbp +// STOP-NEXT: 4: 8b 04 25 a8 00 00 00 movl 168, %eax +// STOP-NEXT: b: 5d popq %rbp +// STOP-NEXT: c: c3 retq +// STOP-NEXT: d: 0f 1f 00 nopl (%rax) +// STOP-EMPTY: +// STOP-NEXT: Disassembly of section .anothertext: +// STOP-EMPTY: +// STOP-NEXT: 0000000000000010 main: +// STOP-NEXT: 10: 55 pushq %rbp +// STOP-NOT: {{.}} + +// OUT-OF-RANGE-NOT: Disassembly + +// RUN: not llvm-objdump -d %t.out --start-address=0x40 --stop-address=0x3f 2>&1 | FileCheck %s --check-prefix ERRMSG +// ERRMSG: error: Start address should be less than stop address. Index: llvm/trunk/test/tools/llvm-objdump/X86/stripped-shared.test =================================================================== --- llvm/trunk/test/tools/llvm-objdump/X86/stripped-shared.test +++ llvm/trunk/test/tools/llvm-objdump/X86/stripped-shared.test @@ -1,10 +0,0 @@ -// This test checks that dynamic symbols are used when disassembling elf files. -// RUN: llvm-objdump -d %p/Inputs/stripped-elf.so | FileCheck %s - -# CHECK: .init -# CHECK: .plt -# CHECK: .text -# CHECK: func0 -# CHECK: func1 -# CHECK: func2 -# CHECK: .fini