1## Ensures that implicitly added sections can be ordered within Sections. 2 3# RUN: yaml2obj --docnum=1 %s -o %t1 4# RUN: llvm-readobj --sections %t1 | FileCheck %s --check-prefix=SECTION 5# RUN: llvm-nm --dynamic %t1 | FileCheck %s --check-prefix=SYMBOL 6 7--- !ELF 8FileHeader: 9 Class: ELFCLASS64 10 Data: ELFDATA2LSB 11 Type: ET_DYN 12Sections: 13 - Name: .data 14 Type: SHT_PROGBITS 15 Flags: [ SHF_ALLOC, SHF_WRITE ] 16DynamicSymbols: 17 - Name: dynlocal 18 Type: STT_OBJECT 19 Section: .data 20 Binding: STB_LOCAL 21 - Name: dynglobal 22 Type: STT_OBJECT 23 Section: .data 24 Binding: STB_GLOBAL 25 - Name: dynweak 26 Type: STT_OBJECT 27 Section: .data 28 Binding: STB_WEAK 29 30# SECTION: Name: .dynsym 31# SECTION-NEXT: Type: SHT_DYNSYM 32# SECTION-NEXT: Flags 33# SECTION-NEXT: SHF_ALLOC 34# SECTION: Name: .dynstr 35# SECTION-NEXT: Type: SHT_STRTAB 36# SECTION-NEXT: Flags 37# SECTION-NEXT: SHF_ALLOC 38 39# SYMBOL-DAG: d dynlocal 40# SYMBOL-DAG: D dynglobal 41# SYMBOL-DAG: V dynweak 42 43## Check we can use numeric values to refer to sections. 44 45# RUN: yaml2obj --docnum=2 -DSEC=0xff %s -o %t2 46# RUN: llvm-readobj --dyn-symbols %t2 2>&1 | FileCheck -DFILE=%t2 %s --check-prefix=NUM 47 48# NUM: Name: foo 49# NUM: Section: 50# NUM-SAME: .data (0x1) 51 52# NUM: Name: bar 53# NUM: Section: 54# NUM-SAME: .dynsym (0x2) 55 56# NUM: Name: zed1 57# NUM: warning: '[[FILE]]': invalid section index: 255 58# NUM: Section: 59# NUM-SAME: <?> (0xFF) 60 61# NUM: Name: zed2 62# NUM: Section: 63# NUM-SAME: Undefined (0x0) 64 65--- !ELF 66FileHeader: 67 Class: ELFCLASS64 68 Data: ELFDATA2LSB 69 Type: ET_DYN 70Sections: 71 - Name: .data 72 Type: SHT_PROGBITS 73DynamicSymbols: 74 - Name: foo 75 Section: 1 76 - Name: bar 77 Section: 2 78 - Name: zed1 79 Section: [[SEC=<none>]] 80## The case when no "Section" key is set. 81 - Name: zed2 82 83## Check that by default no section is set. 84 85# RUN: yaml2obj --docnum=2 %s -o %t2.none 86# RUN: llvm-readobj --dyn-symbols %t2.none 2>&1 | \ 87# RUN: FileCheck -DFILE=%t2.none %s --check-prefix=NONE 88 89# NONE: Name: zed1 90# NONE: Section: 91# NONE-SAME: Undefined (0x0) 92# NONE: Name: zed2 93# NONE: Section: 94# NONE-SAME: Undefined (0x0) 95 96## Check we report errors when unknown sections are referenced by dynamic symbols. 97 98# RUN: not yaml2obj --docnum=3 %s 2>&1 | FileCheck -DFILE=%t3 %s --check-prefix=ERR 99 100# ERR: error: unknown section referenced: '.sec1' by YAML symbol 'foo' 101# ERR: error: unknown section referenced: '.sec2' by YAML symbol 'bar' 102# ERR: error: unknown section referenced: '' by YAML symbol 'zed' 103 104--- !ELF 105FileHeader: 106 Class: ELFCLASS64 107 Data: ELFDATA2LSB 108 Type: ET_DYN 109Sections: 110 - Name: .data 111 Type: SHT_PROGBITS 112DynamicSymbols: 113 - Name: foo 114 Section: .sec1 115 - Name: bar 116 Section: .sec2 117 - Name: zed 118 Section: '' 119