brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 56ed2c9 Raw
76 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o3 4# RUN: ld.lld %t.o -o %t.out5# RUN: llvm-readelf -x .text %t.out | FileCheck %s6# CHECK: Hex dump of section '.text':7# CHECK-NEXT: 010203048 9## --shuffle-sections= shuffles input sections.10# RUN: ld.lld --shuffle-sections='*=1' %t.o -o %t1.out11# RUN: llvm-readelf -x .text %t1.out | FileCheck %s --check-prefix=SHUFFLE112# SHUFFLE1: Hex dump of section '.text':13# SHUFFLE1-NEXT: 030402cc 0114 15## Test that --shuffle-sections= can be used with --symbol-ordering-file16# RUN: echo "foo" > %t_order.txt17# RUN: echo "_start " >> %t_order.txt18 19# RUN: ld.lld --symbol-ordering-file %t_order.txt --shuffle-sections='*=2' %t.o -o %t2.out20# RUN: llvm-readelf -x .text %t2.out | FileCheck %s --check-prefix=SHUFFLE221# SHUFFLE2: Hex dump of section '.text':22# SHUFFLE2-NEXT: 02cccccc 01030423 24# RUN: ld.lld -z norelro --symbol-ordering-file %t_order.txt --shuffle-sections='*=3' %t.o -o %t3.out25# RUN: llvm-readelf -x .text %t3.out | FileCheck %s --check-prefix=SHUFFLE326# SHUFFLE3: Hex dump of section '.text':27# SHUFFLE3-NEXT: 02cccccc 01040328 29## As a special case, -1 reverses sections as a stable transform.30# RUN: ld.lld --shuffle-sections '*=-1' %t.o -o %t-1.out31# RUN: llvm-readelf -x .text %t-1.out | FileCheck %s --check-prefix=SHUFFLE-132# SHUFFLE-1: Hex dump of section '.text':33# SHUFFLE-1-NEXT: 040302cc 0134 35## .text does not change its order while .text.{foo,bar,zed} are reversed.36# RUN: ld.lld --shuffle-sections '.text.*=-1' %t.o -o %t4.out37# RUN: llvm-readelf -x .text %t4.out | FileCheck %s --check-prefix=SHUFFLE438# SHUFFLE4: Hex dump of section '.text':39# SHUFFLE4-NEXT: 0104030240 41## Reversing twice restores the original order.42# RUN: ld.lld --shuffle-sections '.text.*=-1' --shuffle-sections '.text.*=-1' %t.o -o %t.out43# RUN: llvm-readelf -x .text %t.out | FileCheck %s44 45## Test all possible invalid cases.46# RUN: not ld.lld --shuffle-sections= 2>&1 | FileCheck %s --check-prefix=USAGE -DV=47# RUN: not ld.lld --shuffle-sections=a= 2>&1 | FileCheck %s --check-prefix=USAGE -DV=a=48# RUN: not ld.lld --shuffle-sections==0 2>&1 | FileCheck %s --check-prefix=USAGE -DV==049# RUN: not ld.lld --shuffle-sections=a 2>&1 | FileCheck %s --check-prefix=USAGE -DV=a50 51# USAGE: error: --shuffle-sections=: expected <section_glob>=<seed>, but got '[[V]]'52 53# RUN: not ld.lld --shuffle-sections='['=0 2>&1 | FileCheck %s --check-prefix=INVALID54 55# INVALID: error: --shuffle-sections=: invalid glob pattern, unmatched '[': [56 57## .text has an alignment of 4.58.global _start59_start:60  .byte 161 62.section .text.foo,"ax"63.global foo64foo:65  .byte 266 67.section .text.bar,"ax"68.global bar69bar:70  .byte 371 72.section .text.zed,"ax"73.global zed74zed:75  .byte 476