[lld] 2d19270 - [ELF][test] Improve linkerscript/linkorder.s

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 09:36:33 PDT 2020


Author: Fangrui Song
Date: 2020-03-30T09:34:29-07:00
New Revision: 2d19270efcf01672c8eaab1ccb0e5b89ea953cc9

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

LOG: [ELF][test] Improve linkerscript/linkorder.s

Added: 
    

Modified: 
    lld/test/ELF/linkerscript/linkorder.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/linkerscript/linkorder.s b/lld/test/ELF/linkerscript/linkorder.s
index 042e8b3293fe..060b82900a18 100644
--- a/lld/test/ELF/linkerscript/linkorder.s
+++ b/lld/test/ELF/linkerscript/linkorder.s
@@ -1,33 +1,63 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
 
-# RUN: echo "SECTIONS { .rodata : {*(.rodata*)} .text : {*(.text.bar) *(.text.foo)} }" > %t.script
-# RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-objdump -s %t | FileCheck %s
+## Contiguous SHF_LINK_ORDER sections.
+# RUN: echo 'SECTIONS { .rodata : {BYTE(0) *(.rodata*) BYTE(3)} \
+# RUN:   .text : {*(.text.bar) *(.text.foo)} }' > %t.lds
+# RUN: ld.lld -T %t.lds %t.o -o %t
+# RUN: llvm-readelf -S -x .rodata -x .text %t | FileCheck %s
 
-# RUN: echo "SECTIONS { .rodata : {*(.rodata*)} .text : {*(.text.foo) *(.text.bar)} }" > %t.script
-# RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-objdump -s %t | FileCheck --check-prefix=INV %s
+# CHECK:      Hex dump of section '.rodata':
+# CHECK-NEXT: 00020103
+# CHECK:      Hex dump of section '.text':
+# CHECK-NEXT: 0201
 
+# RUN: echo 'SECTIONS { .rodata : {BYTE(0) *(.rodata*) BYTE(3)} \
+# RUN:  .text : {*(.text.foo) *(.text.bar)} }' > %t1.lds
+# RUN: ld.lld -T %t1.lds %t.o -o %t1
+# RUN: llvm-readelf -S -x .rodata -x .text %t1 | FileCheck --check-prefix=CHECK1 %s
 
-# CHECK:      Contents of section .rodata:
-# CHECK-NEXT: 02000000 00000000 01000000 00000000
-# CHECK:      Contents of section .text:
-# CHECK-NEXT: 02000000 00000000 01000000 00000000
+# CHECK1:      Hex dump of section '.rodata':
+# CHECK1-NEXT: 00010203
+# CHECK1:      Hex dump of section '.text':
+# CHECK1-NEXT: 0102
 
-# INV:      Contents of section .rodata:
-# INV-NEXT: 01000000 00000000 02000000 00000000
-# INV:      Contents of section .text:
-# INV-NEXT: 01000000 00000000 02000000 00000000
+## Adjacent input sections descriptions are contiguous.
+## Orphan section .text.bar precedes .text.foo, so swap the order of .rodata.*
+# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) *(.rodata.bar)} }' > %t2.lds
+# RUN: ld.lld -T %t2.lds %t.o -o %t2
+# RUN: llvm-readelf -S -x .rodata %t2 | FileCheck --check-prefix=CHECK2 %s
+
+# CHECK2:      [ 1] .rodata   {{.*}} AL 4
+# CHECK2:      [ 4] .text.bar {{.*}} AX 0
+# CHECK2:      Hex dump of section '.rodata':
+# CHECK2-NEXT: 0201
+
+## Non-contiguous SHF_LINK_ORDER sections, separated by a BYTE.
+# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) BYTE(0) *(.rodata.bar)} }' > %terr1.lds
+# RUN: ld.lld -T %terr1.lds %t.o -o /dev/null
+
+## Non-contiguous SHF_LINK_ORDER sections, separated by a non-SHF_LINK_ORDER section.
+# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) *(.text) *(.rodata.bar)} }' > %terr2.lds
+# RUN: not ld.lld -T %terr2.lds %t.o -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
+
+## Non-contiguous SHF_LINK_ORDER sections, separated by a symbol assignment.
+# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) a = .; *(.rodata.bar)} }' > %terr3.lds
+# RUN: ld.lld -T %terr3.lds %t.o -o /dev/null
+
+# ERR: error: incompatible section flags for .rodata
 
 .global _start
 _start:
 
+.section .ro,"a"
+.byte 0
+
 .section .text.bar,"a", at progbits
-.quad 2
+.byte 2
 .section .text.foo,"a", at progbits
-.quad 1
+.byte 1
 .section .rodata.foo,"ao", at progbits,.text.foo
-.quad 1
+.byte 1
 .section .rodata.bar,"ao", at progbits,.text.bar
-.quad 2
+.byte 2


        


More information about the llvm-commits mailing list