[lld] c81daab - [ELF][test] Reorganize format-binary.test

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 17:00:24 PDT 2020


Author: Fangrui Song
Date: 2020-04-10T17:00:12-07:00
New Revision: c81daab7d3bf10a36233934ae60261cb2716c987

URL: https://github.com/llvm/llvm-project/commit/c81daab7d3bf10a36233934ae60261cb2716c987
DIFF: https://github.com/llvm/llvm-project/commit/c81daab7d3bf10a36233934ae60261cb2716c987.diff

LOG: [ELF][test] Reorganize format-binary.test

Also drop dependency on the output directory name (lit implementation detail).

Added: 
    

Modified: 
    lld/test/ELF/format-binary.test

Removed: 
    lld/test/ELF/format-binary-non-ascii.s


################################################################################
diff  --git a/lld/test/ELF/format-binary-non-ascii.s b/lld/test/ELF/format-binary-non-ascii.s
deleted file mode 100644
index ce74171dce9a..000000000000
--- a/lld/test/ELF/format-binary-non-ascii.s
+++ /dev/null
@@ -1,15 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t£.o
-
-# RUN: ld.lld -o %t.elf %t£.o --format=binary %t£.o
-# RUN: llvm-readobj --symbols %t.elf | FileCheck %s
-
-# CHECK: Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_non_ascii_s_tmp_{{[_]+}}o_start
-# CHECK: Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_non_ascii_s_tmp_{{[_]+}}o_end
-# CHECK: Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_non_ascii_s_tmp_{{[_]+}}o_size
-
-.text
-.align 4
-.globl _start
-_start:
-    nop

diff  --git a/lld/test/ELF/format-binary.test b/lld/test/ELF/format-binary.test
index fc843345cbb5..70f132686ce9 100644
--- a/lld/test/ELF/format-binary.test
+++ b/lld/test/ELF/format-binary.test
@@ -1,69 +1,50 @@
 # REQUIRES: x86
 
-# RUN: echo -n "Fluffle Puff" > %t.binary
-# RUN: ld.lld -m elf_x86_64 -r -b binary %t.binary -o %t.out
-# RUN: llvm-readobj %t.out -sections -section-data -symbols | FileCheck %s
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: ld.lld %t.o -b binary %t.binary -b default %t.o -shared -o %t.out
-
-# RUN: not ld.lld -b foo > %t.log 2>&1
-# RUN: FileCheck -check-prefix=ERR %s < %t.log
+# RUN: rm -rf %t.dir
+# RUN: mkdir %t.dir
+# RUN: cd %t.dir
+
+# RUN: mkdir d
+# RUN: echo -n "Fluffle Puff" > d/t.txt
+# RUN: ld.lld -m elf_x86_64 -r -b binary d/t.txt -o ro
+# RUN: llvm-readelf -h -S -s -x .data ro | FileCheck --check-prefix=RO %s
+
+# RO:      Machine: Advanced Micro Devices X86-64
+# RO:      Name         Type     Address          Off    Size   ES Flg Lk Inf Al
+# RO-NEXT:              NULL     0000000000000000 000000 000000 00      0   0  0
+# RO-NEXT: .data        PROGBITS 0000000000000000 {{.*}} 00000c 00  WA  0   0  8
+# RO:         Value          Size Type    Bind   Vis      Ndx Name
+# RO:      0000000000000000     0 OBJECT  GLOBAL DEFAULT    1 _binary_d_t_txt_start
+# RO-NEXT: 000000000000000c     0 OBJECT  GLOBAL DEFAULT    1 _binary_d_t_txt_end
+# RO-NEXT: 000000000000000c     0 OBJECT  GLOBAL DEFAULT  ABS _binary_d_t_txt_size
+# RO:      Hex dump of section '.data':
+# RO-NEXT: 0x00000000 466c7566 666c6520 50756666          Fluffle Puff
+
+# RUN: echo 'OUTPUT_FORMAT(elf64-x86-64)' > t.lds
+# RUN: ld.lld -b binary -T t.lds d/t.txt -o exe
+# RUN: llvm-readelf -h -S -s exe | FileCheck --check-prefix=EXE %s
+
+## bfdname can be quoted.
+# RUN: echo 'OUTPUT_FORMAT("elf64-x86-64")' > t1.lds
+# RUN: ld.lld -b binary -T t1.lds d/t.txt -o exe1
+# RUN: llvm-readelf -h -S -s exe | FileCheck --check-prefix=EXE %s
+
+# EXE:      Machine: Advanced Micro Devices X86-64
+# EXE:      [Nr] Name         Type     Address          Off    Size   ES Flg Lk Inf Al
+# EXE:      [ 3] .data        PROGBITS {{.*}}                  00000c 00  WA  0   0  8
+# EXE:      Size Type    Bind   Vis      Ndx Name
+# EXE:         0 OBJECT  GLOBAL DEFAULT    3 _binary_d_t_txt_start
+# EXE-NEXT:    0 OBJECT  GLOBAL DEFAULT    3 _binary_d_t_txt_end
+# EXE-NEXT:    0 OBJECT  GLOBAL DEFAULT  ABS _binary_d_t_txt_size
+
+# RUN: not ld.lld -b foo 2>&1 | FileCheck --check-prefix=ERR %s
 # ERR: error: unknown -format value: foo (supported formats: elf, default, binary)
 
-# CHECK:          Name: .data
-# CHECK-NEXT:     Type: SHT_PROGBITS
-# CHECK-NEXT:     Flags [
-# CHECK-NEXT:       SHF_ALLOC
-# CHECK-NEXT:       SHF_WRITE
-# CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x0
-# CHECK-NEXT:     Offset:
-# CHECK-NEXT:     Size: 12
-# CHECK-NEXT:     Link: 0
-# CHECK-NEXT:     Info: 0
-# CHECK-NEXT:     AddressAlignment:
-# CHECK-NEXT:     EntrySize: 0
-# CHECK-NEXT:     SectionData (
-# CHECK-NEXT:       0000: 466C7566 666C6520 50756666           |Fluffle Puff|
-# CHECK-NEXT:     )
-# CHECK-NEXT:   }
-
-# CHECK:          Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_test_tmp_binary_start
-# CHECK-NEXT:     Value: 0x0
-# CHECK-NEXT:     Size: 0
-# CHECK-NEXT:     Binding: Global
-# CHECK-NEXT:     Type: Object
-# CHECK-NEXT:     Other: 0
-# CHECK-NEXT:     Section: .data
-# CHECK-NEXT:   }
-# CHECK-NEXT:   Symbol {
-# CHECK-NEXT:     Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_test_tmp_binary_end
-# CHECK-NEXT:     Value: 0xC
-# CHECK-NEXT:     Size: 0
-# CHECK-NEXT:     Binding: Global
-# CHECK-NEXT:     Type: Object
-# CHECK-NEXT:     Other: 0
-# CHECK-NEXT:     Section: .data
-# CHECK-NEXT:   }
-# CHECK-NEXT:   Symbol {
-# CHECK-NEXT:     Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_test_tmp_binary_size
-# CHECK-NEXT:     Value: 0xC
-# CHECK-NEXT:     Size: 0
-# CHECK-NEXT:     Binding: Global
-# CHECK-NEXT:     Type: Object
-# CHECK-NEXT:     Other: 0
-# CHECK-NEXT:     Section: Absolute
-# CHECK-NEXT:   }
-
-# RUN: echo 'OUTPUT_FORMAT(elf64-x86-64)' > %t.script
-# RUN: ld.lld -b binary %t.binary -T %t.script -o %t.out
-# RUN: llvm-readobj %t.out -sections -section-data -symbols | FileCheck -check-prefix=X86-64 %s
-
-# X86-64: Format: elf64-x86-64
-
-# RUN: echo 'OUTPUT_FORMAT("elf64-x86-64")' > %t.script
-# RUN: ld.lld -b binary %t.binary -T %t.script -o %t.out
-# RUN: llvm-readobj %t.out -sections -section-data -symbols | FileCheck -check-prefix=X86-64-in-quotes %s
+## Non-isalnum bytes are converted to _. See D37331.
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o d/£.o
+# RUN: ld.lld d/£.o --format=binary d/£.o -o unicode
+# RUN: llvm-nm -p unicode | FileCheck --check-prefix=UNICODE %s
 
-# X86-64-in-quotes: Format: elf64-x86-64
+# UNICODE: D _binary_d_{{_+}}o_start
+# UNICODE: D _binary_d_{{_+}}o_end
+# UNICODE: A _binary_d_{{_+}}o_size


        


More information about the llvm-commits mailing list