brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.7 KiB · b2b7ead Raw
177 lines · yaml
1# RUN: yaml2obj --docnum=1 %s -o %t2# RUN: llvm-readobj -l %t | FileCheck %s3 4--- !ELF5FileHeader:6  Class: ELFCLASS647  Data:  ELFDATA2LSB8  Type:  ET_EXEC9Sections:10  - Name:            .text11    Type:            SHT_PROGBITS12    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]13    AddressAlign:    0x000000000000100014    Content:         "00000000"15  - Name:            .init16    Type:            SHT_PROGBITS17    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]18    Content:         "00000000"19    AddressAlign:    0x000000000000001020  - Name:            .data21    Type:            SHT_PROGBITS22    Flags:           [ SHF_ALLOC ]23    Content:         "00000000"24    AddressAlign:    0x000000000000100025ProgramHeaders:26  - Type:     PT_LOAD27    Flags:    [ PF_X, PF_R ]28    VAddr:    0xAAAA100029    PAddr:    0xFFFF100030    FirstSec: .text31    LastSec:  .init32  - Type:     PT_LOAD33    Flags:    [ PF_R ]34    VAddr:    0xAAAA200035    PAddr:    0xFFFF200036    FirstSec: .data37    LastSec:  .data38  - Type: PT_GNU_EH_FRAME39  - Type: PT_GNU_STACK40  - Type: PT_GNU_RELRO41  - Type: PT_GNU_PROPERTY42  - Type: PT_GNU_SFRAME43 44#CHECK:     ProgramHeaders [45#CHECK-NEXT:   ProgramHeader {46#CHECK-NEXT:    Type: PT_LOAD47#CHECK-NEXT:    Offset: 0x100048#CHECK-NEXT:    VirtualAddress: 0xAAAA100049#CHECK-NEXT:    PhysicalAddress: 0xFFFF100050#CHECK-NEXT:    FileSize: 2051#CHECK-NEXT:    MemSize: 2052#CHECK-NEXT:    Flags [53#CHECK-NEXT:      PF_R54#CHECK-NEXT:      PF_X55#CHECK-NEXT:    ]56#CHECK-NEXT:    Alignment: 409657#CHECK-NEXT:  }58#CHECK-NEXT:  ProgramHeader {59#CHECK-NEXT:    Type: PT_LOAD60#CHECK-NEXT:    Offset: 0x200061#CHECK-NEXT:    VirtualAddress: 0xAAAA200062#CHECK-NEXT:    PhysicalAddress: 0xFFFF200063#CHECK-NEXT:    FileSize: 464#CHECK-NEXT:    MemSize: 465#CHECK-NEXT:    Flags [66#CHECK-NEXT:      PF_R67#CHECK-NEXT:    ]68#CHECK-NEXT:    Alignment: 409669#CHECK-NEXT:  }70#CHECK-NEXT:  ProgramHeader {71#CHECK-NEXT:    Type: PT_GNU_EH_FRAME (0x6474E550)72#CHECK:       }73#CHECK-NEXT:  ProgramHeader {74#CHECK-NEXT:    Type: PT_GNU_STACK (0x6474E551)75#CHECK:       }76#CHECK-NEXT:  ProgramHeader {77#CHECK-NEXT:    Type: PT_GNU_RELRO (0x6474E552)78#CHECK:       }79#CHECK-NEXT:  ProgramHeader {80#CHECK-NEXT:    Type: PT_GNU_PROPERTY (0x6474E553)81#CHECK:       }82#CHECK-NEXT:  ProgramHeader {83#CHECK-NEXT:    Type: PT_GNU_SFRAME (0x6474E554)84#CHECK:       }85#CHECK-NEXT:]86 87## Check we do not allow referencing sections that do not exist.88# RUN: not yaml2obj -DFIRST=".unknown1" -DLAST=".unknown2" --docnum=2 %s 2>&1 | \89# RUN:   FileCheck %s --check-prefix=UNKNOWN-ERR90 91# UNKNOWN-ERR: error: unknown section or fill referenced: '.unknown1' by the 'FirstSec' key of the program header with index 092# UNKNOWN-ERR: error: unknown section or fill referenced: '.unknown2' by the 'LastSec' key of the program header with index 093 94--- !ELF95FileHeader:96  Class: ELFCLASS6497  Data:  ELFDATA2LSB98  Type:  ET_EXEC99Sections:100  - Name:   .foo101    Type:   SHT_PROGBITS102    Offset: 0x100103    Size:   0x10104  - Name:   .bar105    Type:   SHT_PROGBITS106    Offset: 0x200107    Size:   0x20108  - Name:   .zed109    Type:   SHT_PROGBITS110    Offset: 0x300111    Size:   0x30112  - Name:   .fill1113    Type:   Fill114    Offset: 0x400115    Size:   0x40116  - Name:   .fill2117    Type:   Fill118    Offset: 0x500119    Size:   0x50120ProgramHeaders:121  - Type:     PT_LOAD122    FirstSec: [[FIRST=<none>]]123    LastSec:  [[LAST=<none>]]124 125## Check we report an error when the index of the section specified by the "FirstSec" key126## is greater than the index of the section specified by the "LastSec" key.127 128# RUN: not yaml2obj -DFIRST=".bar" -DLAST=".foo" --docnum=2 %s 2>&1 | \129# RUN:   FileCheck %s --check-prefix=ORDER-ERR130 131# ORDER-ERR: error: program header with index 0: the section index of .bar is greater than the index of .foo132 133## Check that we can't use the "LastSec" key without the "FirstSec" key.134 135# RUN: not yaml2obj -DLAST=".foo" --docnum=2 %s 2>&1 | \136# RUN:   FileCheck %s --check-prefix=ONLY-LAST-ERR137 138# ONLY-LAST-ERR: error: the "LastSec" key can't be used without the "FirstSec" key139 140## Check that we can't use the "FirstSec" key without the "LastSec" key.141 142# RUN: not yaml2obj -DFIRST=".foo" --docnum=2 %s 2>&1 | \143# RUN:   FileCheck %s --check-prefix=ONLY-FIRST-ERR144 145# ONLY-FIRST-ERR: error: the "FirstSec" key can't be used without the "LastSec" key146 147## Check we create an empty segment when neither "FirstSec" nor "LastSec" are specified.148 149# RUN: yaml2obj --docnum=2 %s -o %t3150# RUN: llvm-readelf --program-headers %t3 | FileCheck %s --check-prefix=EMPTY-SEGMENT151 152# EMPTY-SEGMENT:       Type Offset   VirtAddr           PhysAddr           FileSiz  MemSiz153# EMPTY-SEGMENT:       LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000154# EMPTY-SEGMENT-EMPTY:155 156## Check that we include all sections between FirstSec and LastSec in the segment when both keys are used.157 158# RUN: yaml2obj --docnum=2 -DFIRST=".foo" -DLAST=".zed" %s -o %t4159# RUN: llvm-readelf --program-headers %t4 | FileCheck %s --check-prefix=BOTH160 161# BOTH:      Type Offset   VirtAddr           PhysAddr           FileSiz  MemSiz162# BOTH-NEXT: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000230 0x000230163 164## Check that we include fills that are between FirstSec and LastSec in the segment when both keys are used.165 166# RUN: yaml2obj --docnum=2 -DFIRST=".foo" -DLAST=".fill1" %s -o %t5a167# RUN: llvm-readelf --program-headers %t5a | FileCheck %s --check-prefix=FILL1168 169# FILL1: Type Offset   VirtAddr           PhysAddr           FileSiz  MemSiz170# FILL1: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000340 0x000340171 172# RUN: yaml2obj --docnum=2 -DFIRST=".foo" -DLAST=".fill2" %s -o %t5b173# RUN: llvm-readelf --program-headers %t5b | FileCheck %s --check-prefix=FILL2174 175# FILL2: Type Offset   VirtAddr           PhysAddr           FileSiz  MemSiz176# FILL2: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000450 0x000450177