[ELF][test] Improve tests
authorFangrui Song <maskray@google.com>
Fri, 1 May 2020 18:04:20 +0000 (11:04 -0700)
committerFangrui Song <maskray@google.com>
Fri, 1 May 2020 18:27:51 +0000 (11:27 -0700)
Prepare for the upcomong change that removes unneeded sh_offset
advancement for empty sections whose PT_LOAD are removed.

lld/test/ELF/linkerscript/empty-sections-expressions.test
lld/test/ELF/linkerscript/nobits-offset.s

index 3f1da48..ebc43f4 100644 (file)
@@ -2,19 +2,25 @@
 # RUN: echo ".text; nop; .data; .byte 0" \
 # RUN:   | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o
 # RUN: ld.lld -o %t --script %s %t.o
-# RUN: llvm-readelf -program-headers %t | FileCheck %s
+# RUN: llvm-readelf -S -l %t | FileCheck %s
 
 ## Check we do not remove the empty output sections used in LOADADDR/ADDR
 ## expressions and hence can evaluate the correct addresses.
 
+# CHECK:      Name   Type     Address          Off    Size
+# CHECK-NEXT:        NULL     0000000000000000 000000 000000
+# CHECK-NEXT: .empty PROGBITS 0000000000080000 001000 000000
+# CHECK-NEXT: .text  PROGBITS 0000000000080000 001000 000001
+# CHECK-NEXT: .data  PROGBITS 0000000000080001 001001 000001
+
 # CHECK:      Program Headers:
 # CHECK-NEXT:  Type Offset   VirtAddr           PhysAddr
 # CHECK-NEXT:  LOAD 0x001000 0x0000000000080000 0x0000000000080000
 # CHECK-NEXT:  LOAD 0x001001 0x0000000000080001 0x0000000000082000
 
 # CHECK:      Section to Segment mapping:
-# CHECK:       00 .empty .text
-# CHECK-NEXT:  01 .data
+# CHECK:       00 .empty .text {{$}}
+# CHECK-NEXT:  01 .data {{$}}
 
 SECTIONS {
  . = 0x00080000;
index 051f3f9..682190c 100644 (file)
 ## sh_offset to sh_addr modulo max-page-size, so that p_vaddr=p_offset (mod
 ## p_align).
 
-# CHECK: Name Type   Address          Off     Size   ES Flg Lk Inf Al
-# CHECK: .bss NOBITS 0000000000000400 001400  000001 00  WA  0   0 1024
+# CHECK:      Name  Type     Address          Off     Size
+# CHECK-NEXT:       NULL     0000000000000000 000000  000000
+# CHECK-NEXT: .text PROGBITS 0000000000000000 001000  000000
+# CHECK-NEXT: .sec1 NOBITS   0000000000000000 001000  000001
+# CHECK-NEXT: .bss  NOBITS   0000000000000400 001400  000001
 
-# CHECK: Type Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
-# CHECK: LOAD 0x001400 0x0000000000000400 0x0000000000000400 0x000000 0x000001 RW  0x1000
+# CHECK:      Type Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
+# CHECK-NEXT: LOAD 0x001400 0x0000000000000400 0x0000000000000400 0x000000 0x000001 RW  0x1000
 
-# CHECK: 00 .bss
+# CHECK:      00 .bss {{$}}
 
 .bss
 .p2align 10