1# REQUIRES: ppc 2# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o 3# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-sort-small-cm-relocs-input2.s -o %t2.o 4# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-sort-small-cm-relocs-input3.s -o %t3.o 5# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-sort-small-cm-relocs-input4.s -o %t4.o 6 7# RUN: ld.lld %t1.o %t2.o %t3.o %t4.o -o %t -Map=%t.map 8# RUN: FileCheck %s < %t.map 9 10# Test an alternate link order. 11# RUN: ld.lld %t2.o %t3.o %t4.o %t1.o -o %t -Map=%t.map 12# RUN: FileCheck %s -check-prefix=ALTERNATE < %t.map 13 14# If a linker script has a sections command then allow that to override the 15# default sorting behavior. 16# RUN: echo "SECTIONS { \ 17# RUN: .toc : { \ 18# RUN: *ppc64-sort-small-cm-relocs.s.tmp4.o(.toc*) \ 19# RUN: *ppc64-sort-small-cm-relocs.s.tmp1.o(.toc*) \ 20# RUN: *(.toc*) \ 21# RUN: } \ 22# RUN: } " > %t.script 23# RUN: ld.lld %t1.o %t2.o %t3.o %t4.o -o %t -script %t.script -Map=%t.map 24# RUN: FileCheck %s -check-prefix=SEC-CMD < %t.map 25 26# RUN: echo "SECTIONS { .text : {*(.text*)} } " > %t.script 27# RUN: ld.lld %t1.o %t2.o %t3.o %t4.o -o %t -script %t.script -Map=%t.map 28# RUN: FileCheck %s -check-prefix=SEC-CMD2 < %t.map 29 30# Default sort if the linker script does not have a sections command. 31# RUN: echo "" > %t.script 32# RUN: ld.lld %t1.o %t2.o %t3.o %t4.o -o %t -script %t.script -Map=%t.map 33# RUN: FileCheck %s -check-prefix=NOSEC < %t.map 34 .text 35 36 .global _start 37 .type _start,@function 38_start: 39 li 3, 55 40 blr 41 42 .type a,@object 43 .data 44 .global a 45a: 46 .long 10 47 .size a, 4 48 49 .type c,@object 50 .data 51 .global c 52c: 53 .long 55 54 .size c, 4 55 56 .type d,@object 57 .global d 58d: 59 .long 33 60 .size d, 4 61 62 # .toc section contains only some constants. 63 .section .toc,"aw",@progbits 64 .quad 0xa1a1a1a1a1a1a1a1 65 .quad 0xb2b2b2b2b2b2b2b2 66 67# Input files tmp3.o and tmp4.o contain small code model relocs. 68 69# CHECK: .got 70# CHECK-NEXT: <internal>:(.got) 71# CHECK-NEXT: .toc 72# CHECK-NEXT: {{.*}}3.o:(.toc) 73# CHECK-NEXT: {{.*}}4.o:(.toc) 74# CHECK-NEXT: {{.*}}1.o:(.toc) 75# CHECK-NEXT: {{.*}}2.o:(.toc) 76 77# ALTERNATE: .got 78# ALTERNATE-NEXT: <internal>:(.got) 79# ALTERNATE-NEXT: .toc 80# ALTERNATE-NEXT: {{.*}}3.o:(.toc) 81# ALTERNATE-NEXT: {{.*}}4.o:(.toc) 82# ALTERNATE-NEXT: {{.*}}2.o:(.toc) 83# ALTERNATE-NEXT: {{.*}}1.o:(.toc) 84 85# SEC-CMD: .got 86# SEC-CMD-NEXT: <internal>:(.got) 87# SEC-CMD-NEXT: .toc 88# SEC-CMD-NEXT: {{.*}}4.o:(.toc) 89# SEC-CMD-NEXT: {{.*}}1.o:(.toc) 90# SEC-CMD-NEXT: {{.*}}2.o:(.toc) 91# SEC-CMD-NEXT: {{.*}}3.o:(.toc) 92 93# SEC-CMD2: .got 94# SEC-CMD2-NEXT: <internal>:(.got) 95# SEC-CMD2-NEXT: .toc 96# SEC-CMD2-NEXT: {{.*}}1.o:(.toc) 97# SEC-CMD2-NEXT: {{.*}}2.o:(.toc) 98# SEC-CMD2-NEXT: {{.*}}3.o:(.toc) 99# SEC-CMD2-NEXT: {{.*}}4.o:(.toc) 100 101# NOSEC: .got 102# NOSEC-NEXT: <internal>:(.got) 103# NOSEC-NEXT: .toc 104# NOSEC-NEXT: {{.*}}3.o:(.toc) 105# NOSEC-NEXT: {{.*}}4.o:(.toc) 106# NOSEC-NEXT: {{.*}}1.o:(.toc) 107# NOSEC-NEXT: {{.*}}2.o:(.toc) 108 109