Index: llvm/trunk/test/tools/llvm-size/X86/elf-sizes.test =================================================================== --- llvm/trunk/test/tools/llvm-size/X86/elf-sizes.test +++ llvm/trunk/test/tools/llvm-size/X86/elf-sizes.test @@ -1,55 +0,0 @@ -# RUN: yaml2obj %s > %t.o -# RUN: llvm-size -B %t.o | FileCheck %s - -!ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_EXEC - Machine: EM_X86_64 -Sections: - - Name: .bss - Type: SHT_NOBITS - Flags: [ SHF_ALLOC, SHF_WRITE ] - Size: 1 - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - Size: 2 - - Name: .unusual_name_for_code - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - Size: 64 - - Name: .eh_frame - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC ] - Size: 4 - - Name: .data - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_WRITE ] - Size: 8 - - Name: .moar_stuff - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_WRITE ] - Size: 128 - - Name: .text.but_not_really - Type: SHT_PROGBITS - Flags: [ ] - Size: 256 - - Name: .debug_info - Type: SHT_PROGBITS - Flags: [ ] - Size: 16 - - Name: .init_array - Type: SHT_INIT_ARRAY - Flags: [ SHF_ALLOC, SHF_WRITE ] - Size: 32 - -# text is .text, .eh_frame, .unusual_name_for_code: 2 + 4 + 64 = 70 -# data is .data, .init_array, .moar_stuff: 8 + 32 + 128 = 168 -# bss is .bss: 1 -# total: 239 -# unaccounted for (not affecting total) is .debug_info, .text.but_not_really - -# CHECK: text data bss dec -# CHECK: 70 168 1 239 Index: llvm/trunk/test/tools/llvm-size/X86/format-berkeley-tabs.s =================================================================== --- llvm/trunk/test/tools/llvm-size/X86/format-berkeley-tabs.s +++ llvm/trunk/test/tools/llvm-size/X86/format-berkeley-tabs.s @@ -1,15 +0,0 @@ -// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux -// RUN: llvm-size -B -t %t.o | FileCheck %s --strict-whitespace - - .text - .zero 4 - .data - .long foo - .bss - .zero 4 - -// Note: this test enables --strict-whitespace to check for literal tabs -// between each field. -// CHECK: text {{ *}}data {{ *}}bss {{ *}}dec {{ *}}hex {{ *}}filename -// CHECK-NEXT: 4 {{ *}}4 {{ *}}4 {{ *}}12 {{ *}}c {{ *}}{{[ -\(\)_A-Za-z0-9.\\/:]+}} -// CHECK-NEXT: 4 {{ *}}4 {{ *}}4 {{ *}}12 {{ *}}c {{ *}}(TOTALS) Index: llvm/trunk/test/tools/llvm-size/X86/ignore-sections.s =================================================================== --- llvm/trunk/test/tools/llvm-size/X86/ignore-sections.s +++ llvm/trunk/test/tools/llvm-size/X86/ignore-sections.s @@ -1,29 +0,0 @@ -// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux -// RUN: llvm-size -A %t.o | FileCheck --check-prefix="SYSV" %s -// RUN: llvm-size -B -t %t.o| FileCheck --check-prefix="BSD" %s - - .text - .zero 4 - .data - .long foo - .bss - .zero 4 - .ident "foo" - .section foo - .long 42 - .cfi_startproc - .cfi_endproc - -// SYSV: {{[ -\(\)_A-Za-z0-9.\\/:]+}} : -// SYSV-NEXT: section size addr -// SYSV-NEXT: .text 4 0 -// SYSV-NEXT: .data 4 0 -// SYSV-NEXT: .bss 4 0 -// SYSV-NEXT: .comment 5 0 -// SYSV-NEXT: foo 4 0 -// SYSV-NEXT: .eh_frame 48 0 -// SYSV-NEXT: Total 69 - -// BSD: text data bss dec hex filename -// BSD-NEXT: 52 4 4 60 3c {{[ -\(\)_A-Za-z0-9.\\/:]+}} -// BSD-NEXT: 52 4 4 60 3c (TOTALS) Index: llvm/trunk/test/tools/llvm-size/X86/lit.local.cfg =================================================================== --- llvm/trunk/test/tools/llvm-size/X86/lit.local.cfg +++ llvm/trunk/test/tools/llvm-size/X86/lit.local.cfg @@ -1,2 +0,0 @@ -if not 'X86' in config.root.targets: - config.unsupported = True Index: llvm/trunk/test/tools/llvm-size/X86/test-common.s =================================================================== --- llvm/trunk/test/tools/llvm-size/X86/test-common.s +++ llvm/trunk/test/tools/llvm-size/X86/test-common.s @@ -1,29 +0,0 @@ -// #Check that with common switch commons are added to bss or -// #Shown as *COM* otherwise their size is discounted -// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux -// RUN: llvm-size -A --common %t.o | FileCheck --check-prefix=SYSV %s -// RUN: llvm-size -B --common %t.o | FileCheck --check-prefix=BSD %s -// RUN: llvm-size -A %t.o | FileCheck --check-prefix=SYSVNOCOMM %s -// RUN: llvm-size -B %t.o | FileCheck --check-prefix=BSDNOCOMM %s - .type x,@object - .comm x,4,4 - .type y,@object - .comm y,4,4 - .type z,@object - .comm z,4,4 -// SYSV: {{[ -\(\)_A-Za-z0-9.\\/:]+}} : -// SYSV-NEXT: section size addr -// SYSV-NEXT: .text 0 0 -// SYSV-NEXT: *COM* 12 0 -// SYSV-NEXT: Total 12 - -// SYSVNOCOMM: {{[ -\(\)_A-Za-z0-9.\\/:]+}} : -// SYSVNOCOMM-NEXT: section size addr -// SYSVNOCOMM-NEXT: .text 0 0 -// SYSVNOCOMM-NEXT: Total 0 - -// BSD: text data bss dec hex filename -// BSD-NEXT: 0 0 12 12 c {{[ -\(\)_A-Za-z0-9.\\/:]+}} - -// BSDNOCOMM: text data bss dec hex filename -// BSDNOCOMM-NEXT: 0 0 0 0 0 {{[ -\(\)_A-Za-z0-9.\\/:]+}} Index: llvm/trunk/test/tools/llvm-size/archive.test =================================================================== --- llvm/trunk/test/tools/llvm-size/archive.test +++ llvm/trunk/test/tools/llvm-size/archive.test @@ -0,0 +1,125 @@ +## Show how llvm-size behaves when passed in an archive. + +# RUN: yaml2obj %s --docnum=1 -o %t1 +# RUN: yaml2obj %s --docnum=2 -o %t2 + +## Case 1: Empty archive. No output expected. +# RUN: rm -f %t1.a +# RUN: llvm-ar rc %t1.a + +# RUN: llvm-size -B %t1.a | count 0 +## Sysv output prints a single blank line in this case. +# RUN: llvm-size -A %t1.a | FileCheck %s --implicit-check-not={{.}} + +## Case 2: Single member. +# RUN: rm -f %t2.a +# RUN: llvm-ar rc %t2.a %t1 + +# RUN: llvm-size -B %t2.a | FileCheck %s -DARCHIVE=%t2.a --check-prefix=BERKELEY-1 +# RUN: llvm-size -A %t2.a | FileCheck %s -DARCHIVE=%t2.a --check-prefix=SYSV-1 + +## Case 3: Multiple members. +# RUN: rm -f %t3.a +# RUN: llvm-ar rc %t3.a %t1 %t2 + +# RUN: llvm-size -B %t3.a | FileCheck %s -DARCHIVE=%t3.a --check-prefixes=BERKELEY-1,BERKELEY-2 +# RUN: llvm-size -A %t3.a | FileCheck %s -DARCHIVE=%t3.a --check-prefixes=SYSV-1,SYSV-2 + +## Case 4: Mixing archives and non-archives produces sensible output: +# RUN: llvm-size -B %t1 %t2.a %t2 %t3.a \ +# RUN: | FileCheck %s -DARCHIVE=%t3.a -DARCHIVE2=%t2.a -DFILE1=%t1 -DFILE2=%t2 \ +# RUN: --check-prefixes=BERKELEY-1,BERKELEY-2,BERKELEY-3 +# RUN: llvm-size -A %t1 %t2.a %t2 %t3.a \ +# RUN: | FileCheck %s -DARCHIVE=%t3.a -DARCHIVE2=%t2.a -DFILE1=%t1 -DFILE2=%t2 \ +# RUN: --check-prefixes=SYSV-1,SYSV-2,SYSV-3 + +# BERKELEY-1: text data bss dec hex filename +# BERKELEY-3-NEXT: 1 2 4 7 7 [[FILE1]] +# BERKELEY-3-NEXT: 1 2 4 7 7 archive.test.tmp1 (ex [[ARCHIVE2]]) +# BERKELEY-3-NEXT: 8 16 32 56 38 [[FILE2]] +# BERKELEY-1-NEXT: 1 2 4 7 7 archive.test.tmp1 (ex [[ARCHIVE]]) +# BERKELEY-2-NEXT: 8 16 32 56 38 archive.test.tmp2 (ex [[ARCHIVE]]) +# BERKELEY-1-NOT:{{.}} + +# SYSV-3: [[FILE1]] : +# SYSV-3-NEXT: section size addr +# SYSV-3-NEXT: .text 1 4 +# SYSV-3-NEXT: .data 2 2 +# SYSV-3-NEXT: .bss 4 1 +# SYSV-3-NEXT: Total 7 +# SYSV-3-EMPTY: +# SYSV-3-NEXT: archive.test.tmp1 (ex [[ARCHIVE2]]): +# SYSV-3-NEXT: section size addr +# SYSV-3-NEXT: .text 1 4 +# SYSV-3-NEXT: .data 2 2 +# SYSV-3-NEXT: .bss 4 1 +# SYSV-3-NEXT: Total 7 +# SYSV-3-EMPTY: +# SYSV-3-NEXT: [[FILE2]] : +# SYSV-3-NEXT: section size addr +# SYSV-3-NEXT: .text 8 32 +# SYSV-3-NEXT: .data 16 16 +# SYSV-3-NEXT: .bss 32 8 +# SYSV-3-NEXT: Total 56 +# SYSV-3-EMPTY: + +# SYSV-1: archive.test.tmp1 (ex [[ARCHIVE]]): +# SYSV-1-NEXT: section size addr +# SYSV-1-NEXT: .text 1 4 +# SYSV-1-NEXT: .data 2 2 +# SYSV-1-NEXT: .bss 4 1 +# SYSV-1-NEXT: Total 7 + +# SYSV-2-NEXT: archive.test.tmp2 (ex [[ARCHIVE]]): +# SYSV-2-NEXT: section size addr +# SYSV-2-NEXT: .text 8 32 +# SYSV-2-NEXT: .data 16 16 +# SYSV-2-NEXT: .bss 32 8 +# SYSV-2-NEXT: Total 56 +# SYSV-1-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] + Size: 1 + Address: 4 + - Name: .data + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 2 + Address: 2 + - Name: .bss + Type: SHT_NOBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 4 + Address: 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] + Size: 8 + Address: 32 + - Name: .data + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 16 + Address: 16 + - Name: .bss + Type: SHT_NOBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 32 + Address: 8 Index: llvm/trunk/test/tools/llvm-size/basic.test =================================================================== --- llvm/trunk/test/tools/llvm-size/basic.test +++ llvm/trunk/test/tools/llvm-size/basic.test @@ -1,2 +0,0 @@ -RUN: not llvm-size %t.blah 2>&1 | FileCheck --check-prefix=ENOENT %s -ENOENT: {{.*}}llvm-size{{(\.EXE|\.exe)?}}: {{.*}}basic.test.tmp.blah {{[Nn]}}o such file or directory Index: llvm/trunk/test/tools/llvm-size/common.test =================================================================== --- llvm/trunk/test/tools/llvm-size/common.test +++ llvm/trunk/test/tools/llvm-size/common.test @@ -0,0 +1,44 @@ +## Check that with the common switch common symbols are added to bss (Berkeley +## output) or shown as *COM* (sysv output). Otherwise their size is ignored. + +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-size -A --common %t.o | FileCheck --check-prefix=SYSV %s +# RUN: llvm-size -B --common %t.o | FileCheck --check-prefix=BSD %s +# RUN: llvm-size -A %t.o | FileCheck --check-prefix=SYSVNOCOMM %s +# RUN: llvm-size -B %t.o | FileCheck --check-prefix=BSDNOCOMM %s + +# SYSV: {{.*}}.o : +# SYSV-NEXT: section size addr +# SYSV-NEXT: .text 0 0 +# SYSV-NEXT: *COM* 8 0 +# SYSV-NEXT: Total 8 + +# SYSVNOCOMM: {{.*}}.o : +# SYSVNOCOMM-NEXT: section size addr +# SYSVNOCOMM-NEXT: .text 0 0 +# SYSVNOCOMM-NEXT: Total 0 + +# BSD: text data bss dec hex filename +# BSD-NEXT: 0 0 8 8 8 {{.*}}.o + +# BSDNOCOMM: text data bss dec hex filename +# BSDNOCOMM-NEXT: 0 0 0 0 0 {{.*}}.o + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS +Symbols: + - Name: y + Type: STT_OBJECT + Size: 4 + Index: SHN_COMMON + - Name: z + Type: STT_OBJECT + Size: 4 + Index: SHN_COMMON Index: llvm/trunk/test/tools/llvm-size/darwin-m.test =================================================================== --- llvm/trunk/test/tools/llvm-size/darwin-m.test +++ llvm/trunk/test/tools/llvm-size/darwin-m.test @@ -1,11 +1,123 @@ -RUN: llvm-size -m %p/Inputs/darwin-m.o | FileCheck --check-prefix="DARWIN" %s -RUN: llvm-size -m %p/Inputs/darwin-m.o %p/Inputs/darwin-m1.o | FileCheck --check-prefix="DARWIN2" %s +## Show that -m/--format=darwin produces darwin-style output. -DARWIN: Segment : 8 -DARWIN-NEXT: Section (__TEXT, __text): 4 -DARWIN-NEXT: Section (__DATA, __data): 4 -DARWIN-NEXT: total 8 -DARWIN-NEXT: total 8 +# RUN: yaml2obj %s --docnum=1 -o %t +# RUN: yaml2obj %s --docnum=2 -o %t2 +# RUN: llvm-size -m %t \ +# RUN: | FileCheck --check-prefix=DARWIN %s --implicit-check-not={{.}} \ +# RUN: --strict-whitespace --match-full-lines +# RUN: llvm-size -m %t %t2 \ +# RUN: | FileCheck --check-prefixes=DARWIN,DARWIN2 %s --implicit-check-not={{.}} \ +# RUN: -DFILE1=%t -DFILE2=%t2 --strict-whitespace --match-full-lines +# RUN: llvm-size --format=darwin %t \ +# RUN: | FileCheck --check-prefix=DARWIN %s --implicit-check-not={{.}} \ +# RUN: --strict-whitespace --match-full-lines +# RUN: llvm-size --format=darwin %t %t2 \ +# RUN: | FileCheck --check-prefixes=DARWIN,DARWIN2 %s --implicit-check-not={{.}} \ +# RUN: -DFILE1=%t -DFILE2=%t2 --strict-whitespace --match-full-lines -DARWIN2: Inputs/darwin-m.o: -DARWIN2: Inputs/darwin-m1.o: +# DARWIN2:[[FILE1]]: +# DARWIN:Segment : 12 +# DARWIN-NEXT: Section (__TEXT, __text): 4 +# DARWIN-NEXT: Section (__DATA, __data): 8 +# DARWIN-NEXT: total 12 +# DARWIN-NEXT:total 12 +# DARWIN2:[[FILE2]]: +# DARWIN2-NEXT:Segment : 48 +# DARWIN2-NEXT: Section (__TEXT, __text): 16 +# DARWIN2-NEXT: Section (__DATA, __data): 32 +# DARWIN2-NEXT: total 48 +# DARWIN2-NEXT:total 48 + +--- !mach-o +FileHeader: + magic: 0xFEEDFACE + cputype: 0x0000000C + cpusubtype: 0x00000009 + filetype: 0x00000001 + ncmds: 1 + sizeofcmds: 192 + flags: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT + cmdsize: 192 + segname: '' + vmaddr: 0 + vmsize: 12 + fileoff: 220 + filesize: 12 + maxprot: 7 + initprot: 7 + nsects: 2 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000000000000 + size: 4 + offset: 0x000000DC + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __data + segname: __DATA + addr: 0x0000000000000004 + size: 8 + offset: 0x000000E0 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + +--- !mach-o +FileHeader: + magic: 0xFEEDFACE + cputype: 0x0000000C + cpusubtype: 0x00000009 + filetype: 0x00000001 + ncmds: 1 + sizeofcmds: 192 + flags: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT + cmdsize: 192 + segname: '' + vmaddr: 0 + vmsize: 48 + fileoff: 220 + filesize: 48 + maxprot: 7 + initprot: 7 + nsects: 2 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000000000000 + size: 16 + offset: 0x000000DC + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __data + segname: __DATA + addr: 0x0000000000000010 + size: 32 + offset: 0x000000EC + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 Index: llvm/trunk/test/tools/llvm-size/elf-berkeley.test =================================================================== --- llvm/trunk/test/tools/llvm-size/elf-berkeley.test +++ llvm/trunk/test/tools/llvm-size/elf-berkeley.test @@ -0,0 +1,66 @@ +## Show that llvm-sizes works correctly on a typical ELF input for Berkeley +## format. It also shows that the formatting is correct (including using tabs as +## field separators). + +# RUN: yaml2obj %s > %t.o + +# RUN: llvm-size -B %t.o \ +# RUN: | FileCheck %s --match-full-lines --strict-whitespace -DFILE=%t.o --implicit-check-not={{.}} +# RUN: llvm-size --format=berkeley %t.o \ +# RUN: | FileCheck %s --match-full-lines --strict-whitespace -DFILE=%t.o --implicit-check-not={{.}} + +## Also show that the default output format is Berkeley. +# RUN: llvm-size %t.o \ +# RUN: | FileCheck %s --match-full-lines --strict-whitespace -DFILE=%t.o --implicit-check-not={{.}} + +## text is .text, .eh_frame, .unusual_name_for_code: 2 + 4 + 64 = 70 +## data is .data, .init_array, .moar_stuff: 8 + 32 + 128 = 168 +## bss is .bss: 1 +## total: 239 +## unaccounted for (not affecting total) is .debug_info, .text.but_not_really +# CHECK: text data bss dec hex filename +# CHECK-NEXT: 70 168 1 239 ef [[FILE]] + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .bss + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + Size: 1 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Size: 2 + - Name: .unusual_name_for_code + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Size: 64 + - Name: .eh_frame + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Size: 4 + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + Size: 8 + - Name: .moar_stuff + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + Size: 128 + - Name: .text.but_not_really + Type: SHT_PROGBITS + Flags: [ ] + Size: 256 + - Name: .debug_info + Type: SHT_PROGBITS + Flags: [ ] + Size: 16 + - Name: .init_array + Type: SHT_INIT_ARRAY + Flags: [ SHF_ALLOC, SHF_WRITE ] + Size: 32 Index: llvm/trunk/test/tools/llvm-size/elf-m.test =================================================================== --- llvm/trunk/test/tools/llvm-size/elf-m.test +++ llvm/trunk/test/tools/llvm-size/elf-m.test @@ -0,0 +1,18 @@ +## Show that llvm-size falls back to Berkeley output if --format=darwin is +## specified and the input is not Mach-O. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-size -m %t | FileCheck %s +# RUN: llvm-size --format=darwin %t | FileCheck %s + +## FIXME: The input filename should be printed but isn't currently due to +## https://bugs.llvm.org/show_bug.cgi?id=42971. +# CHECK: text data bss dec hex filename +# CHECK-NEXT: 0 0 0 0 0 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 Index: llvm/trunk/test/tools/llvm-size/elf-sysv.test =================================================================== --- llvm/trunk/test/tools/llvm-size/elf-sysv.test +++ llvm/trunk/test/tools/llvm-size/elf-sysv.test @@ -0,0 +1,129 @@ +## Show that llvm-sizes works correctly on a typical ELF input for sysv +## format. It also shows that the formatting is correct. + +## FIXME: The rules demonstrated by this test are not quite what GNU size +## follows. See https://bugs.llvm.org/show_bug.cgi?id=42934. + +# RUN: yaml2obj %s > %t.o +# RUN: llvm-size --format=sysv %t.o \ +# RUN: | FileCheck %s --match-full-lines --strict-whitespace -DFILE=%t.o --implicit-check-not={{.}} +# RUN: llvm-size -A %t.o \ +# RUN: | FileCheck %s --match-full-lines --strict-whitespace -DFILE=%t.o --implicit-check-not={{.}} + +# CHECK:[[FILE]] : +# CHECK-NEXT:section size addr +# CHECK-NEXT:.progbits 1 2097152 +# CHECK-NEXT:.symtab_shndx 4 524288 +# CHECK-NEXT:.hash 64 65536 +# CHECK-NEXT:.dynamic 128 32768 +# CHECK-NEXT:.note 256 16384 +# CHECK-NEXT:.nobits 512 8192 +# CHECK-NEXT:.shlib 2048 2048 +# CHECK-NEXT:.dynsym 4096 1024 +# CHECK-NEXT:.init_array 8192 512 +# CHECK-NEXT:.fini_array 16384 256 +# CHECK-NEXT:.preinit_array 32768 128 +# CHECK-NEXT:.group 65536 64 +# CHECK-NEXT:.relr 131072 32 +# CHECK-NEXT:.os_specific 262144 16 +# CHECK-NEXT:.proc_specific 524288 8 +# CHECK-NEXT:.user_specific 1048576 4 +# CHECK-NEXT:Total 2096069 + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .progbits + Type: SHT_PROGBITS + ShSize: 0x1 + Address: 0x200000 + - Name: .strtab + Type: SHT_STRTAB + ShSize: 0x2 + Address: 0x100000 + - Name: .symtab_shndx + Link: .symtab + Type: SHT_SYMTAB_SHNDX + ShSize: 0x4 + Address: 0x80000 + Entries: + - Name: .symtab + Type: SHT_SYMTAB + ## .symtab's size has to be based on .symtab_shndx's size, hence the + ## size not following the pattern of the other sections. + ShSize: 0x18 + Address: 0x40000 + - Name: .rela + Type: SHT_RELA + ShSize: 0x20 + Address: 0x20000 + - Name: .hash + Type: SHT_HASH + ShSize: 0x40 + Address: 0x10000 + - Name: .dynamic + Type: SHT_DYNAMIC + ShSize: 0x80 + Address: 0x8000 + - Name: .note + Type: SHT_NOTE + ShSize: 0x100 + Address: 0x4000 + - Name: .nobits + Type: SHT_NOBITS + ShSize: 0x200 + Address: 0x2000 + - Name: .rel + Type: SHT_REL + ShSize: 0x400 + Address: 0x1000 + - Name: .shlib + Type: SHT_SHLIB + ShSize: 0x800 + Address: 0x800 + - Name: .dynsym + Type: SHT_DYNSYM + ShSize: 0x1000 + Address: 0x400 + - Name: .init_array + Type: SHT_INIT_ARRAY + ShSize: 0x2000 + Address: 0x200 + - Name: .fini_array + Type: SHT_FINI_ARRAY + ShSize: 0x4000 + Address: 0x100 + - Name: .preinit_array + Type: SHT_PREINIT_ARRAY + ShSize: 0x8000 + Address: 0x80 + - Name: .group + Type: SHT_GROUP + ShSize: 0x10000 + Address: 0x40 + Info: 0 + Members: + - Name: .relr + Type: SHT_RELR + ShSize: 0x20000 + Address: 0x20 + - Name: .os_specific + Type: 0x61234567 + ShSize: 0x40000 + Address: 0x10 + - Name: .proc_specific + Type: 0x71234567 + ShSize: 0x80000 + Address: 0x8 + - Name: .user_specific + Type: 0x81234567 + ShSize: 0x100000 + Address: 0x4 + - Name: .null + Type: SHT_NULL + ShSize: 0x200000 + Address: 0x2 Index: llvm/trunk/test/tools/llvm-size/help.test =================================================================== --- llvm/trunk/test/tools/llvm-size/help.test +++ llvm/trunk/test/tools/llvm-size/help.test @@ -1,7 +1,15 @@ -RUN: llvm-size -h | FileCheck %s -RUN: llvm-size --help | FileCheck %s +## Show that help text is printed correctly when requested. + +RUN: llvm-size -h | FileCheck %s --check-prefixes=CHECK,CATEG +RUN: llvm-size --help | FileCheck %s --check-prefixes=CHECK,CATEG +RUN: llvm-size --help-list \ +RUN: | FileCheck %s --check-prefixes=CHECK,LIST CHECK: OVERVIEW: llvm object size dumper CHECK: USAGE: llvm-size{{(.exe)?}} [options] {{$}} CHECK: OPTIONS: +CATEG: Generic Options: +LIST-NOT: Generic Options: +CATEG: llvm-size Options: +LIST-NOT: llvm-size Options: CHECK: @FILE Index: llvm/trunk/test/tools/llvm-size/invalid-input.test =================================================================== --- llvm/trunk/test/tools/llvm-size/invalid-input.test +++ llvm/trunk/test/tools/llvm-size/invalid-input.test @@ -0,0 +1,22 @@ +## Show that llvm-size reports an error when passed an input file in an +## unknown format. + +## FIXME: The error messages tested here are not consistently formatted, and the +## second one doesn't even return with a non-zero exit code. +## See https://bugs.llvm.org/show_bug.cgi?id=42970. + +# RUN: not llvm-size %s 2>&1 | FileCheck %s -DFILE=%s --check-prefix=UNRECOGNIZED +# UNRECOGNIZED: {{.*}}llvm-size{{(.*)}}: [[FILE]] The file was not recognized as a valid object file + +## Show that llvm-size reports an error when passed an input file in an +## unsupported format. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-size %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=NOTSUPPORTED +# NOTSUPPORTED: {{.*}}llvm-size{{(.*)}}: [[FILE]]: Unrecognized file type. + +--- !minidump +Streams: + - Type: LinuxAuxv + Size: 7 + Content: 11223344556600 Index: llvm/trunk/test/tools/llvm-size/long-format.test =================================================================== --- llvm/trunk/test/tools/llvm-size/long-format.test +++ llvm/trunk/test/tools/llvm-size/long-format.test @@ -0,0 +1,58 @@ +## Show that the -l option produces more verbose address and offset information +## for darwin format. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-size %t -m -l | FileCheck %s + +# CHECK: Segment : 12 (vmaddr 0x0 fileoff 220) +# CHECK-NEXT: Section (__TEXT, __text): 4 (addr 0x0 offset 220) +# CHECK-NEXT: Section (__DATA, __data): 8 (addr 0x4 offset 224) +# CHECK-NEXT: total 12 +# CHECK-NEXT: total 12 + +--- !mach-o +FileHeader: + magic: 0xFEEDFACE + cputype: 0x0000000C + cpusubtype: 0x00000009 + filetype: 0x00000001 + ncmds: 1 + sizeofcmds: 192 + flags: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT + cmdsize: 192 + segname: '' + vmaddr: 0 + vmsize: 12 + fileoff: 220 + filesize: 12 + maxprot: 7 + initprot: 7 + nsects: 2 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000000000000 + size: 4 + offset: 0x000000DC + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __data + segname: __DATA + addr: 0x0000000000000004 + size: 8 + offset: 0x000000E0 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 Index: llvm/trunk/test/tools/llvm-size/macho-berkeley.test =================================================================== --- llvm/trunk/test/tools/llvm-size/macho-berkeley.test +++ llvm/trunk/test/tools/llvm-size/macho-berkeley.test @@ -0,0 +1,55 @@ +## Show that llvm-size can print Mach-O files using berkeley-style output. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-size %t -B \ +# RUN: | FileCheck %s --implicit-check-not={{.}} --strict-whitespace + +# CHECK: __TEXT __DATA __OBJC others dec hex +# CHECK-NEXT: 4 8 0 0 12 c {{$}} + +--- !mach-o +FileHeader: + magic: 0xFEEDFACE + cputype: 0x0000000C + cpusubtype: 0x00000009 + filetype: 0x00000001 + ncmds: 1 + sizeofcmds: 192 + flags: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT + cmdsize: 192 + segname: '' + vmaddr: 0 + vmsize: 12 + fileoff: 220 + filesize: 12 + maxprot: 7 + initprot: 7 + nsects: 2 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000000000000 + size: 4 + offset: 0x000000DC + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __data + segname: __DATA + addr: 0x0000000000000004 + size: 8 + offset: 0x000000E0 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 Index: llvm/trunk/test/tools/llvm-size/macho-sysv.test =================================================================== --- llvm/trunk/test/tools/llvm-size/macho-sysv.test +++ llvm/trunk/test/tools/llvm-size/macho-sysv.test @@ -0,0 +1,58 @@ +## Show that llvm-size can print Mach-O files using sysv-style output. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-size %t -A \ +# RUN: | FileCheck %s --implicit-check-not={{.}} --strict-whitespace -DFILE=%t + +# CHECK: [[FILE]] : +# CHECK-NEXT: section size addr +# CHECK-NEXT: __text 4 0 +# CHECK-NEXT: __data 8 4 +# CHECK-NEXT: Total 12 + +--- !mach-o +FileHeader: + magic: 0xFEEDFACE + cputype: 0x0000000C + cpusubtype: 0x00000009 + filetype: 0x00000001 + ncmds: 1 + sizeofcmds: 192 + flags: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT + cmdsize: 192 + segname: '' + vmaddr: 0 + vmsize: 12 + fileoff: 220 + filesize: 12 + maxprot: 7 + initprot: 7 + nsects: 2 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000000000000 + size: 4 + offset: 0x000000DC + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x80000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __data + segname: __DATA + addr: 0x0000000000000004 + size: 8 + offset: 0x000000E0 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x00000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 Index: llvm/trunk/test/tools/llvm-size/multiple-inputs.test =================================================================== --- llvm/trunk/test/tools/llvm-size/multiple-inputs.test +++ llvm/trunk/test/tools/llvm-size/multiple-inputs.test @@ -0,0 +1,72 @@ +## Show how llvm-size behaves when passed in multiple inputs. + +# RUN: yaml2obj %s --docnum=1 -o %t1 +# RUN: yaml2obj %s --docnum=2 -o %t2 +# RUN: llvm-size -B %t1 %t2 | FileCheck %s -DFILE1=%t1 -DFILE2=%t2 --check-prefix=BERKELEY +# RUN: llvm-size -A %t1 %t2 | FileCheck %s -DFILE1=%t1 -DFILE2=%t2 --check-prefix=SYSV + +# BERKELEY: text data bss dec hex filename +# BERKELEY-NEXT: 1 2 4 7 7 [[FILE1]] +# BERKELEY-NEXT: 8 16 32 56 38 [[FILE2]] +# BERKELEY-NOT:{{.}} + +# SYSV: [[FILE1]] : +# SYSV-NEXT: section size addr +# SYSV-NEXT: .text 1 4 +# SYSV-NEXT: .data 2 2 +# SYSV-NEXT: .bss 4 1 +# SYSV-NEXT: Total 7 +# SYSV-EMPTY: +# SYSV-NEXT: [[FILE2]] : +# SYSV-NEXT: section size addr +# SYSV-NEXT: .text 8 32 +# SYSV-NEXT: .data 16 16 +# SYSV-NEXT: .bss 32 8 +# SYSV-NEXT: Total 56 +# SYSV-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] + Size: 1 + Address: 4 + - Name: .data + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 2 + Address: 2 + - Name: .bss + Type: SHT_NOBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 4 + Address: 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] + Size: 8 + Address: 32 + - Name: .data + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 16 + Address: 16 + - Name: .bss + Type: SHT_NOBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 32 + Address: 8 Index: llvm/trunk/test/tools/llvm-size/no-input.test =================================================================== --- llvm/trunk/test/tools/llvm-size/no-input.test +++ llvm/trunk/test/tools/llvm-size/no-input.test @@ -0,0 +1,26 @@ +## Show that llvm-size emits an error if passed in a non-existent file. + +# RUN: not llvm-size %t.blah 2>&1 | FileCheck %s -DFILE=%t.blah --check-prefix=ENOENT +# ENOENT: {{.*}}llvm-size{{.*}}: [[FILE]] {{[Nn]}}o such file or directory + +## Show that llvm-size reads a.out if not passed any file. + +# RUN: rm -rf %t && mkdir -p %t +# RUN: cd %t +# RUN: yaml2obj %s -o a.out +# RUN: llvm-size 2>&1 | FileCheck %s -DFILE=a.out + +# CHECK: text data bss dec hex filename +# CHECK-NEXT: 42 0 0 42 2a a.out + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Size: 42 Index: llvm/trunk/test/tools/llvm-size/radix.test =================================================================== --- llvm/trunk/test/tools/llvm-size/radix.test +++ llvm/trunk/test/tools/llvm-size/radix.test @@ -0,0 +1,167 @@ +## Show that llvm-size prints sizes in different radixes when requested. + +# RUN: yaml2obj %s --docnum=1 -o %t1.o +# RUN: yaml2obj %s --docnum=2 -o %t2.o + +## Case 1: Octal radix (Berkeley). +# RUN: llvm-size %t1.o %t2.o --totals -B --radix=8 \ +# RUN: | FileCheck %s --check-prefix=OCT-BERK -DFILE1=%t1.o -DFILE2=%t2.o +# RUN: llvm-size %t1.o %t2.o --totals -B -o \ +# RUN: | FileCheck %s --check-prefix=OCT-BERK -DFILE1=%t1.o -DFILE2=%t2.o + +# OCT-BERK: text data bss oct hex filename +# OCT-BERK-NEXT: 01 02 04 7 7 [[FILE1]] +# OCT-BERK-NEXT: 010 020 040 70 38 [[FILE2]] +# OCT-BERK-NEXT: 011 022 044 77 3f (TOTALS) + +## Case 2: Decimal radix (Berkeley). +# RUN: llvm-size %t1.o %t2.o --totals -B --radix=10 \ +# RUN: | FileCheck %s --check-prefix=DEC-BERK -DFILE1=%t1.o -DFILE2=%t2.o +# RUN: llvm-size %t1.o %t2.o --totals -B -d \ +# RUN: | FileCheck %s --check-prefix=DEC-BERK -DFILE1=%t1.o -DFILE2=%t2.o + +# DEC-BERK: text data bss dec hex filename +# DEC-BERK-NEXT: 1 2 4 7 7 [[FILE1]] +# DEC-BERK-NEXT: 8 16 32 56 38 [[FILE2]] +# DEC-BERK-NEXT: 9 18 36 63 3f (TOTALS) + +## Case 3: Hexadecimal radix (Berkeley). +# RUN: llvm-size %t1.o %t2.o --totals -B --radix=16 \ +# RUN: | FileCheck %s --check-prefix=HEX-BERK -DFILE1=%t1.o -DFILE2=%t2.o +# RUN: llvm-size %t1.o %t2.o --totals -B -x \ +# RUN: | FileCheck %s --check-prefix=HEX-BERK -DFILE1=%t1.o -DFILE2=%t2.o + +# HEX-BERK: text data bss dec hex filename +# HEX-BERK-NEXT: 0x1 0x2 0x4 7 7 [[FILE1]] +# HEX-BERK-NEXT: 0x8 0x10 0x20 56 38 [[FILE2]] +# HEX-BERK-NEXT: 0x9 0x12 0x24 63 3f (TOTALS) + +## Case 4: Octal radix (sysv). +# RUN: llvm-size %t1.o %t2.o -A --radix=8 \ +# RUN: | FileCheck %s --check-prefix=OCT-SYSV -DFILE1=%t1.o -DFILE2=%t2.o +# RUN: llvm-size %t1.o %t2.o -A -o \ +# RUN: | FileCheck %s --check-prefix=OCT-SYSV -DFILE1=%t1.o -DFILE2=%t2.o + +# OCT-SYSV: [[FILE1]] : +# OCT-SYSV-NEXT: section size addr +# OCT-SYSV-NEXT: .text 01 04 +# OCT-SYSV-NEXT: .data 02 02 +# OCT-SYSV-NEXT: .bss 04 01 +# OCT-SYSV-NEXT: Total 07 +# OCT-SYSV-EMPTY: +# OCT-SYSV-NEXT: [[FILE2]] : +# OCT-SYSV-NEXT: section size addr +# OCT-SYSV-NEXT: .blob 010 040 +# OCT-SYSV-NEXT: .blab 020 020 +# OCT-SYSV-NEXT: .blib 040 010 +# OCT-SYSV-NEXT: Total 070 + +## Case 5: Decimal radix (sysv). +# RUN: llvm-size %t1.o %t2.o -A --radix=10 \ +# RUN: | FileCheck %s --check-prefix=DEC-SYSV -DFILE1=%t1.o -DFILE2=%t2.o +# RUN: llvm-size %t1.o %t2.o -A -d \ +# RUN: | FileCheck %s --check-prefix=DEC-SYSV -DFILE1=%t1.o -DFILE2=%t2.o + +# DEC-SYSV: [[FILE1]] : +# DEC-SYSV-NEXT: section size addr +# DEC-SYSV-NEXT: .text 1 4 +# DEC-SYSV-NEXT: .data 2 2 +# DEC-SYSV-NEXT: .bss 4 1 +# DEC-SYSV-NEXT: Total 7 +# DEC-SYSV-EMPTY: +# DEC-SYSV-NEXT: [[FILE2]] : +# DEC-SYSV-NEXT: section size addr +# DEC-SYSV-NEXT: .blob 8 32 +# DEC-SYSV-NEXT: .blab 16 16 +# DEC-SYSV-NEXT: .blib 32 8 +# DEC-SYSV-NEXT: Total 56 + +## Case 6: Hexadecimal radix (sysv). +# RUN: llvm-size %t1.o %t2.o -A --radix=16 \ +# RUN: | FileCheck %s --check-prefix=HEX-SYSV -DFILE1=%t1.o -DFILE2=%t2.o +# RUN: llvm-size %t1.o %t2.o -A -x \ +# RUN: | FileCheck %s --check-prefix=HEX-SYSV -DFILE1=%t1.o -DFILE2=%t2.o + +# HEX-SYSV: [[FILE1]] : +# HEX-SYSV-NEXT: section size addr +# HEX-SYSV-NEXT: .text 0x1 0x4 +# HEX-SYSV-NEXT: .data 0x2 0x2 +# HEX-SYSV-NEXT: .bss 0x4 0x1 +# HEX-SYSV-NEXT: Total 0x7 +# HEX-SYSV-EMPTY: +# HEX-SYSV-NEXT: [[FILE2]] : +# HEX-SYSV-NEXT: section size addr +# HEX-SYSV-NEXT: .blob 0x8 0x20 +# HEX-SYSV-NEXT: .blab 0x10 0x10 +# HEX-SYSV-NEXT: .blib 0x20 0x8 +# HEX-SYSV-NEXT: Total 0x38 + +## Case 7: Default Berkeley is decimal. +# RUN: llvm-size %t1.o %t2.o --totals -B \ +# RUN: | FileCheck %s --check-prefix=DEC-BERK -DFILE1=%t1.o -DFILE2=%t2.o + +## Case 8: Default sysv is decimal. +# RUN: llvm-size %t1.o %t2.o -A \ +# RUN: | FileCheck %s --check-prefix=DEC-SYSV -DFILE1=%t1.o -DFILE2=%t2.o + +## Case 9: Bad values. +# RUN: not llvm-size %t1.o --radix=0 2>&1 \ +# RUN: | FileCheck %s --check-prefix=BAD-VAL -DNUM=0 +# RUN: not llvm-size %t1.o --radix=1 2>&1 \ +# RUN: | FileCheck %s --check-prefix=BAD-VAL -DNUM=1 +# RUN: not llvm-size %t1.o --radix=2 2>&1 \ +# RUN: | FileCheck %s --check-prefix=BAD-VAL -DNUM=2 +# RUN: not llvm-size %t1.o --radix=32 2>&1 \ +# RUN: | FileCheck %s --check-prefix=BAD-VAL -DNUM=32 +# RUN: not llvm-size %t1.o --radix=-1 2>&1 \ +# RUN: | FileCheck %s --check-prefix=BAD-VAL -DNUM=-1 +# RUN: not llvm-size %t1.o --radix=bad 2>&1 \ +# RUN: | FileCheck %s --check-prefix=BAD-VAL -DNUM=bad + +# BAD-VAL: {{.*}}llvm-size{{.*}}: for the --radix option: Cannot find option named '[[NUM]]'! + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Size: 1 + Address: 4 + - Name: .data + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 2 + Address: 2 + - Name: .bss + Type: SHT_NOBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 4 + Address: 1 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .blob + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Size: 8 + Address: 32 + - Name: .blab + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 16 + Address: 16 + - Name: .blib + Type: SHT_NOBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 32 + Address: 8 Index: llvm/trunk/test/tools/llvm-size/response-file.test =================================================================== --- llvm/trunk/test/tools/llvm-size/response-file.test +++ llvm/trunk/test/tools/llvm-size/response-file.test @@ -0,0 +1,21 @@ +## Show that llvm-size can consume a response file. + +# RUN: echo "-t %t" > %t.rsp +# RUN: yaml2obj %s -o %t +# RUN: llvm-size -x @%t.rsp | FileCheck %s -DFILE=%t + +# CHECK: text data bss dec hex filename +# CHECK-NEXT: 0x10 0 0 16 10 [[FILE]] +# CHECK-NEXT: 0x10 0 0 16 10 (TOTALS) + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Size: 0x10 + Flags: [SHF_ALLOC, SHF_EXECINSTR] Index: llvm/trunk/test/tools/llvm-size/stdin.test =================================================================== --- llvm/trunk/test/tools/llvm-size/stdin.test +++ llvm/trunk/test/tools/llvm-size/stdin.test @@ -0,0 +1,31 @@ +## Show that llvm-size reads stdin if the input file is '-'. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-size -B - < %t | FileCheck %s --check-prefix=BERKELEY +# RUN: llvm-size -A - < %t | FileCheck %s --check-prefix=SYSV + +# BERKELEY: 1 2 4 7 7 +# SYSV: : + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Size: 1 + Address: 4 + - Name: .data + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 2 + Address: 2 + - Name: .bss + Type: SHT_NOBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 4 + Address: 1 Index: llvm/trunk/test/tools/llvm-size/totals.test =================================================================== --- llvm/trunk/test/tools/llvm-size/totals.test +++ llvm/trunk/test/tools/llvm-size/totals.test @@ -0,0 +1,57 @@ +## Show that llvm-size prints the total sizes when --totals is specified. + +# RUN: rm -f %t.a +# RUN: yaml2obj %s --docnum=1 -o %t.o +# RUN: yaml2obj %s --docnum=2 -o %t2.o +# RUN: llvm-ar rc %t.a %t.o %t2.o +# RUN: llvm-size --totals %t.o %t.a %t2.o \ +# RUN: | FileCheck %s -DFILE1=%t.o -DFILE2=%t2.o -DARCHIVE=%t.a +# RUN: llvm-size -t %t.o %t.a %t2.o \ +# RUN: | FileCheck %s -DFILE1=%t.o -DFILE2=%t2.o -DARCHIVE=%t.a + +# CHECK: text data bss dec hex filename +# CHECK-NEXT: [[FILE1]] +# CHECK-NEXT: {{.*}}.o (ex [[ARCHIVE]]) +# CHECK-NEXT: {{.*}}2.o (ex [[ARCHIVE]]) +# CHECK-NEXT: [[FILE2]] +# CHECK-NEXT: 18 36 72 126 7e (TOTALS) + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Size: 1 + - Name: .data + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 2 + - Name: .bss + Type: SHT_NOBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 4 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Size: 8 + - Name: .data + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 16 + - Name: .bss + Type: SHT_NOBITS + Flags: [SHF_ALLOC, SHF_WRITE] + Size: 32 Index: llvm/trunk/test/tools/llvm-size/unknown-format.test =================================================================== --- llvm/trunk/test/tools/llvm-size/unknown-format.test +++ llvm/trunk/test/tools/llvm-size/unknown-format.test @@ -0,0 +1,4 @@ +## Show that the an error is emitted if an unknown value is passed to --format. + +# RUN: not llvm-size --format=unknown 2>&1 | FileCheck %s +# CHECK: {{.*}}llvm-size{{.*}}: for the --format option: Cannot find option named 'unknown'! Index: llvm/trunk/test/tools/llvm-size/version.test =================================================================== --- llvm/trunk/test/tools/llvm-size/version.test +++ llvm/trunk/test/tools/llvm-size/version.test @@ -0,0 +1,4 @@ +## Show that --version works for llvm-size. + +RUN: llvm-size --version | FileCheck %s +CHECK: version