[llvm-branch-commits] [lld] b2881de - [ELF][test] Improve linkerscript/linkorder.s

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Apr 14 22:36:19 PDT 2020


Author: Fangrui Song
Date: 2020-04-14T22:35:18-07:00
New Revision: b2881de649ca27bd00942a4dc6b0e3a0f7e7f32f

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

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

(cherry picked from commit 2d19270efcf01672c8eaab1ccb0e5b89ea953cc9)

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 44547b8ab002..118c2e6b073d 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 { .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 { .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 3
+# CHECK2:      [ 3] .text     {{.*}} 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-branch-commits mailing list