1# REQUIRES: zlib, x86 2 3# RUN: yaml2obj --docnum=1 %s -o %t.o 4# RUN: ld.lld %t.o %t.o -o %t2 5# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s 6 7# RUN: yaml2obj --docnum=2 %s -o %t.o 8# RUN: ld.lld %t.o %t.o -o %t2 9# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s 10 11# CHECK: Name: .debug_info 12# CHECK-NEXT: Type: SHT_PROGBITS 13# CHECK-NEXT: Flags [ 14# CHECK-NEXT: ] 15# CHECK-NEXT: Address: 0x0 16# CHECK-NEXT: Offset: 0xE8 17# CHECK-NEXT: Size: 108 18# CHECK-NEXT: Link: 0 19# CHECK-NEXT: Info: 0 20# CHECK-NEXT: AddressAlignment: 1 21# CHECK-NEXT: EntrySize: 0 22# CHECK-NEXT: SectionData ( 23# CHECK-NEXT: 0000: {{.*}} |ABCDEFGHIJKLMNOP| 24# CHECK-NEXT: 0010: {{.*}} |QRSTUVWXYZ.ABCDE| 25# CHECK-NEXT: 0020: {{.*}} |FGHIJKLMNOPQRSTU| 26# CHECK-NEXT: 0030: {{.*}} |VWXYZ.ABCDEFGHIJ| 27# CHECK-NEXT: 0040: {{.*}} |KLMNOPQRSTUVWXYZ| 28# CHECK-NEXT: 0050: {{.*}} |.ABCDEFGHIJKLMNO| 29# CHECK-NEXT: 0060: {{.*}} |PQRSTUVWXYZ.| 30# CHECK-NEXT: ) 31# CHECK-NEXT: } 32 33## YAML below is produced from the following code. AddressAlign of .debug_info is 8, 34## while compressed header has ch_addralign = 1. LLD had a bug and did not use the 35## value of ch_addralign at all. We produced broken section content. 36## 37## .section .debug_info,"",@progbits 38## .string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 39## .string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 40 41--- !ELF 42FileHeader: 43 Class: ELFCLASS64 44 Data: ELFDATA2LSB 45 Type: ET_REL 46 Machine: EM_X86_64 47Sections: 48 - Name: .debug_info 49 Type: SHT_PROGBITS 50 Flags: [ SHF_COMPRESSED ] 51 AddressAlign: 0x0000000000000008 52 Content: 010000000000000036000000000000000100000000000000789C73747276717573F7F0F4F2F6F1F5F30F080C0A0E090D0B8F888C6270C42D0500ADA00FBF 53 54## YAML below is the same as above, with a single change: ch_addralign field of the compressed 55## header was set to 0. This is allowed by the standard, we have to support it. 56--- !ELF 57FileHeader: 58 Class: ELFCLASS64 59 Data: ELFDATA2LSB 60 Type: ET_REL 61 Machine: EM_X86_64 62Sections: 63 - Name: .debug_info 64 Type: SHT_PROGBITS 65 Flags: [ SHF_COMPRESSED ] 66 AddressAlign: 0x0000000000000008 67 Content: 010000000000000036000000000000000000000000000000789C73747276717573F7F0F4F2F6F1F5F30F080C0A0E090D0B8F888C6270C42D0500ADA00FBF 68