brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · d66e524 Raw
97 lines · plain
1# REQUIRES: x862# RUN: split-file %s %t3# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/main.s -o %t.o4 5## Non-SHF_ALLOC sections are placed after all SHF_ALLOC sections. They will6## thus not be contained in a PT_LOAD segment. data2 has a PT_LOAD segment,7## even if it is preceded by a non-SHF_ALLOC section. Non-SHF_ALLOC orphan8## sections have zero addresses.9## NOTE: GNU ld assigns non-zero addresses to non-SHF_ALLOC non-orphan sections.10# RUN: ld.lld -T %t/a.lds %t.o -o %ta11# RUN: llvm-readelf -S -l %ta | FileCheck %s12 13# CHECK:       [Nr] Name      Type     Address          Off    Size   ES Flg Lk14# CHECK-NEXT:  [ 0]           NULL     0000000000000000 000000 000000 00      015# CHECK-NEXT:  [ 1] .bss      NOBITS   0000000000000000 001000 000001 00  WA  016# CHECK-NEXT:  [ 2] data1     PROGBITS 0000000000000001 001001 000001 00  WA  017# CHECK-NEXT:  [ 3] other1    PROGBITS 0000000000000000 001008 000001 00      018# CHECK-NEXT:  [ 4] other2    PROGBITS 0000000000000000 001010 000001 00      019# CHECK-NEXT:  [ 5] data2     PROGBITS 0000000000000002 001002 000001 00  WA  020## max{sortRank(data1),sortRank(data2)} <= sortRank(data3). data3 is placed after the latter.21# CHECK-NEXT:  [ 6] data3     PROGBITS 0000000000000003 001003 000001 00  WA  022# CHECK-NEXT:  [ 7] .text     PROGBITS 0000000000000004 001004 000001 00  AX  023## Non-alloc orphan sections other3, .symtab, .shstrtab and .strtab are placed at the end.24# CHECK-NEXT:  [ 8] other3    PROGBITS 0000000000000000 001020 000001 00      025# CHECK-NEXT:  [ 9] .symtab   SYMTAB   0000000000000000 001028 000030 18     1126# CHECK-NEXT:  [10] .shstrtab STRTAB   0000000000000000 001058 00004d 00      027# CHECK-NEXT:  [11] .strtab   STRTAB   0000000000000000 0010a5 000008 00      028 29# CHECK:       Type       Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align30# CHECK-NEXT:  LOAD       0x001000 0x0000000000000000 0x0000000000000000 0x000004 0x000004 RW  0x100031# CHECK-NEXT:  LOAD       0x001004 0x0000000000000004 0x0000000000000004 0x000001 0x000001 R E 0x100032# CHECK-NEXT:  GNU_STACK  0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  033 34# RUN: ld.lld -T %t/b.lds %t.o -o %tb35# RUN: llvm-readelf -S -l %tb | FileCheck %s --check-prefix=CHECK136 37## --section-start causes the orphan other3 to be considered before .data3.38## The non-alloc other3 does not disable the placement of .data3.39# RUN: ld.lld -T %t/b.lds %t.o -o %tb --section-start=other3=040# RUN: llvm-readelf -S -l %tb | FileCheck %s --check-prefix=CHECK141 42# CHECK1:      [Nr] Name      Type     Address          Off    Size   ES Flg Lk43# CHECK1-NEXT: [ 0]           NULL     0000000000000000 000000 000000 00      044# CHECK1-NEXT: [ 1] .text     PROGBITS 00000000000000b0 0000b0 000001 00  AX  045# CHECK1-NEXT: [ 2] .bss      NOBITS   00000000000000b1 0000b1 000001 00  WA  046# CHECK1-NEXT: [ 3] data1     PROGBITS 00000000000000b2 0000b2 000001 00  WA  047# CHECK1-NEXT: [ 4] other1    PROGBITS 0000000000000000 0000b8 000001 00      048# CHECK1-NEXT: [ 5] other2    PROGBITS 0000000000000000 0000c0 000001 00      049# CHECK1-NEXT: [ 6] data2     PROGBITS 00000000000000b3 0000b3 000001 00  WA  050# CHECK1-NEXT: [ 7] data3     PROGBITS 00000000000000b4 0000b4 000001 00  WA  051# CHECK1-NEXT: [ 8] other3    PROGBITS 0000000000000000 0000d0 000001 00      052# CHECK1-NEXT: [ 9] .symtab   SYMTAB   0000000000000000 0000d8 000030 18     1153# CHECK1-NEXT: [10] .shstrtab STRTAB   0000000000000000 000108 00004d 00      054# CHECK1-NEXT: [11] .strtab   STRTAB   0000000000000000 000155 000008 00      055# CHECK1:      Type       Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align56# CHECK1-NEXT: LOAD       0x000000 0x0000000000000000 0x0000000000000000 0x0000b5 0x0000b5 RWE 0x100057# CHECK1-NEXT: 0x60000000 0x0000b8 0x0000000000000000 0x0000000000000000 0x000009 0x000001     0x858 59#--- a.lds60SECTIONS {61  .bss : { *(.bss) }62  data1 : { *(data1) }63  other1 : { *(other1) }64  other2 : { *(other2) }65  data2 : { *(data2) }66  .text : { *(.text) }67  /DISCARD/ : { *(.comment) }68}69 70#--- b.lds71PHDRS {72  text PT_LOAD FILEHDR PHDRS;73  foo 0x60000000 FLAGS (0);74}75SECTIONS {76  . = SIZEOF_HEADERS;77  .text : { *(.text) } : text78  .bss : { *(.bss) } : text79  data1 : { *(data1) } : text80  other1 : { *(other1) } : foo81  other2 : { *(other2) } : foo82  data2 : { *(data1) } : text83  /DISCARD/ : { *(.comment) }84}85 86#--- main.s87.globl _start88_start: nop89.section data1,"aw"; .byte 090.section data2,"aw"; .byte 091.section data3,"aw"; .byte 092.bss; .byte 093 94.section other1; .p2align 2; .byte 095.section other2; .p2align 3; .byte 096.section other3; .p2align 4; .byte 097