112 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o3# RUN: ld.lld -r %t.o -o %t4 5## Check we are able to link against relocatable file produced.6# RUN: ld.lld %t -o %t.out7 8## Check we emit a valid ELF header when9## sections amount is greater than SHN_LORESERVE.10# RUN: llvm-readobj --file-headers %t | FileCheck %s --check-prefix=HDR11# 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 to20## (sizeof(.symtab) / entsize(.symtab)) * entsize(.symtab_shndx) = 0x4 * 0x180078 / 0x18 == 0x04001421 22# RUN: llvm-readelf -S -s %t | FileCheck %s23# [Nr] Name Type Address Off Size ES Flg Lk Inf Al24# CHECK: [65539] .note.GNU-stack PROGBITS 0000000000000000 000040 000000 00 0 0 125# CHECK: [65540] .symtab SYMTAB 0000000000000000 000040 180078 18 65543 65539 826# CHECK: [65541] .symtab_shndx SYMTAB SECTION INDICES 0000000000000000 1800b8 040014 04 65540 0 427# CHECK: [65542] .shstrtab STRTAB 0000000000000000 1c00cc 0f0044 00 0 0 128# CHECK: [65543] .strtab STRTAB 0000000000000000 2b0110 00000c 00 0 0 129 30# 5) Check we are able to represent symbol foo with section (.bar) index > 0xFF00 (SHN_LORESERVE).31# CHECK: GLOBAL DEFAULT 65538 foo32 33.macro gen_sections4 x34 .section a\x35 .section b\x36 .section c\x37 .section d\x38.endm39 40.macro gen_sections8 x41 gen_sections4 a\x42 gen_sections4 b\x43.endm44 45.macro gen_sections16 x46 gen_sections8 a\x47 gen_sections8 b\x48.endm49 50.macro gen_sections32 x51 gen_sections16 a\x52 gen_sections16 b\x53.endm54 55.macro gen_sections64 x56 gen_sections32 a\x57 gen_sections32 b\x58.endm59 60.macro gen_sections128 x61 gen_sections64 a\x62 gen_sections64 b\x63.endm64 65.macro gen_sections256 x66 gen_sections128 a\x67 gen_sections128 b\x68.endm69 70.macro gen_sections512 x71 gen_sections256 a\x72 gen_sections256 b\x73.endm74 75.macro gen_sections1024 x76 gen_sections512 a\x77 gen_sections512 b\x78.endm79 80.macro gen_sections2048 x81 gen_sections1024 a\x82 gen_sections1024 b\x83.endm84 85.macro gen_sections4096 x86 gen_sections2048 a\x87 gen_sections2048 b\x88.endm89 90.macro gen_sections8192 x91 gen_sections4096 a\x92 gen_sections4096 b\x93.endm94 95.macro gen_sections16384 x96 gen_sections8192 a\x97 gen_sections8192 b\x98.endm99 100gen_sections16384 a101gen_sections16384 b102gen_sections16384 c103gen_sections16384 d104 105.section .bar106.global foo107foo:108 109.section .text, "ax"110.global _start111_start:112