1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o 3# RUN: ld.lld -r %t.o -o %t 4 5## Check we are able to link against relocatable file produced. 6# RUN: ld.lld %t -o %t.out 7 8## Check we emit a valid ELF header when 9## sections amount is greater than SHN_LORESERVE. 10# RUN: llvm-readobj --file-headers %t | FileCheck %s --check-prefix=HDR 11# HDR: ElfHeader { 12# HDR: SectionHeaderCount: 0 (65544) 13# HDR-NEXT: StringTableSectionIndex: 65535 (65542) 14 15## Check that: 16## 1) 65541 is the index of .shstrtab section. 17## 2) .symtab_shndx is linked with .symtab. 18## 3) .symtab_shndx entry size and alignment == 4. 19## 4) .symtab_shndx has size equal to 20## (sizeof(.symtab) / entsize(.symtab)) * entsize(.symtab_shndx) = 0x4 * 0x180078 / 0x18 == 0x040014 21 22# RUN: llvm-readelf -S -s %t | FileCheck %s 23# [Nr] Name Type Address Off Size ES Flg Lk Inf Al 24# CHECK: [65539] .note.GNU-stack PROGBITS 0000000000000000 000040 000000 00 0 0 1 25# CHECK: [65540] .symtab SYMTAB 0000000000000000 000040 180078 18 65543 65539 8 26# CHECK: [65541] .symtab_shndx SYMTAB SECTION INDICES 0000000000000000 1800b8 040014 04 65540 0 4 27# CHECK: [65542] .shstrtab STRTAB 0000000000000000 1c00cc 0f0044 00 0 0 1 28# CHECK: [65543] .strtab STRTAB 0000000000000000 2b0110 00000c 00 0 0 1 29 30# 5) Check we are able to represent symbol foo with section (.bar) index > 0xFF00 (SHN_LORESERVE). 31# CHECK: GLOBAL DEFAULT 65538 foo 32 33.macro gen_sections4 x 34 .section a\x 35 .section b\x 36 .section c\x 37 .section d\x 38.endm 39 40.macro gen_sections8 x 41 gen_sections4 a\x 42 gen_sections4 b\x 43.endm 44 45.macro gen_sections16 x 46 gen_sections8 a\x 47 gen_sections8 b\x 48.endm 49 50.macro gen_sections32 x 51 gen_sections16 a\x 52 gen_sections16 b\x 53.endm 54 55.macro gen_sections64 x 56 gen_sections32 a\x 57 gen_sections32 b\x 58.endm 59 60.macro gen_sections128 x 61 gen_sections64 a\x 62 gen_sections64 b\x 63.endm 64 65.macro gen_sections256 x 66 gen_sections128 a\x 67 gen_sections128 b\x 68.endm 69 70.macro gen_sections512 x 71 gen_sections256 a\x 72 gen_sections256 b\x 73.endm 74 75.macro gen_sections1024 x 76 gen_sections512 a\x 77 gen_sections512 b\x 78.endm 79 80.macro gen_sections2048 x 81 gen_sections1024 a\x 82 gen_sections1024 b\x 83.endm 84 85.macro gen_sections4096 x 86 gen_sections2048 a\x 87 gen_sections2048 b\x 88.endm 89 90.macro gen_sections8192 x 91 gen_sections4096 a\x 92 gen_sections4096 b\x 93.endm 94 95.macro gen_sections16384 x 96 gen_sections8192 a\x 97 gen_sections8192 b\x 98.endm 99 100gen_sections16384 a 101gen_sections16384 b 102gen_sections16384 c 103gen_sections16384 d 104 105.section .bar 106.global foo 107foo: 108 109.section .text, "ax" 110.global _start 111_start: 112