brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · 9abc989 Raw
96 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o3# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/keep.s -o %t1.o4 5## First check that section "keep" is garbage collected without using KEEP6# RUN: echo "SECTIONS { \7# RUN:  .text : { *(.text) } \8# RUN:  .keep : { *(.keep) } \9# RUN:  .temp : { *(.temp) }}" > %t.script10# RUN: ld.lld --gc-sections -o %t --script %t.script %t.o11# RUN: llvm-objdump --section-headers %t | \12# RUN:   FileCheck -check-prefix=SECGC %s13# SECGC:      Sections:14# SECGC-NEXT: Idx Name          Size15# SECGC-NEXT:   0               0000000016# SECGC-NEXT:   1 .text         0000000717# SECGC-NEXT:   2 .temp         0000000418 19## Now apply KEEP command to preserve the section.20# RUN: echo "SECTIONS { \21# RUN:  .text : { *(.text) } \22# RUN:  .keep : { KEEP(*(.keep)) } \23# RUN:  .temp : { *(.temp) }}" > %t.script24# RUN: ld.lld --gc-sections -o %t --script %t.script %t.o25# RUN: llvm-objdump --section-headers %t | \26# RUN:   FileCheck -check-prefix=SECNOGC %s27# SECNOGC:      Sections:28# SECNOGC-NEXT: Idx Name          Size29# SECNOGC-NEXT:   0               0000000030# SECNOGC-NEXT:   1 .text         0000000731# SECNOGC-NEXT:   2 .keep         0000000432# SECNOGC-NEXT:   3 .temp         0000000433 34## A section name matches two entries in the SECTIONS directive. The35## first one doesn't have KEEP, the second one does. If section that have36## KEEP is the first in order then section is NOT collected.37# RUN: echo "SECTIONS { \38# RUN:  . = SIZEOF_HEADERS; \39# RUN:  .keep : { KEEP(*(.keep)) } \40# RUN:  .nokeep : { *(.keep) }}" > %t.script41# RUN: ld.lld --gc-sections -o %t --script %t.script %t.o42# RUN: llvm-objdump --section-headers %t | FileCheck --check-prefix=MIXED1 %s43# MIXED1:      Sections:44# MIXED1-NEXT: Idx Name          Size45# MIXED1-NEXT:   0               0000000046# MIXED1-NEXT:   1 .keep         0000000447# MIXED1-NEXT:   2 .temp         00000004 000000000000012448# MIXED1-NEXT:   3 .text         00000007 000000000000012849# MIXED1-NEXT:   4 .comment      00000008 000000000000000050# MIXED1-NEXT:   5 .symtab       00000060 000000000000000051# MIXED1-NEXT:   6 .shstrtab     00000036 000000000000000052# MIXED1-NEXT:   7 .strtab       00000012 000000000000000053 54## The same, but now section without KEEP is at first place.55## gold and bfd linkers disagree here. gold collects .keep while56## bfd keeps it. Our current behavior is compatible with bfd although57## we can choose either way.58# RUN: echo "SECTIONS { \59# RUN:  . = SIZEOF_HEADERS; \60# RUN:  .nokeep : { *(.keep) } \61# RUN:  .keep : { KEEP(*(.keep)) }}" > %t.script62# RUN: ld.lld --gc-sections -o %t --script %t.script %t.o63# RUN: llvm-objdump --section-headers %t | FileCheck --check-prefix=MIXED2 %s64# MIXED2:      Sections:65# MIXED2-NEXT: Idx Name          Size66# MIXED2-NEXT:   0               0000000067# MIXED2-NEXT:   1 .nokeep       00000004 000000000000012068# MIXED2-NEXT:   2 .temp         00000004 000000000000012469# MIXED2-NEXT:   3 .text         00000007 000000000000012870# MIXED2-NEXT:   4 .comment      00000008 000000000000000071# MIXED2-NEXT:   5 .symtab       00000060 000000000000000072# MIXED2-NEXT:   6 .shstrtab     00000038 000000000000000073# MIXED2-NEXT:   7 .strtab       00000012 000000000000000074 75# Check file pattern for kept sections.76# RUN: echo "SECTIONS { \77# RUN:  . = SIZEOF_HEADERS; \78# RUN:  .keep : { KEEP(*1.o(.keep)) } \79# RUN:  }" > %t.script80# RUN: ld.lld --gc-sections -o %t --script %t.script %t1.o %t.o81# RUN: llvm-objdump -s %t | FileCheck --check-prefix=FILEMATCH %s82# FILEMATCH:        Contents of section .keep:83# FILEMATCH-NEXT:   0120 41414141  AAAA84 85.global _start86_start:87 mov temp, %eax88 89.section .keep, "a"90keep:91 .long 192 93.section .temp, "a"94temp:95 .long 296