## Test that yaml2obj emits .debug_line section. ## a) Generate the .debug_line section from the "DWARF" entry. ## Generate and verify a little endian DWARF32 .debug_line section. # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.le.o # RUN: llvm-readobj --sections --section-data %t1.le.o | \ # RUN: FileCheck %s -DSIZE=50 -DADDRALIGN=1 --check-prefixes=SHDR,DWARF-LE-CONTENT # SHDR: Index: 1 # SHDR-NEXT: Name: .debug_line (1) # SHDR-NEXT: Type: SHT_PROGBITS (0x1) # SHDR-NEXT: Flags [ (0x0) # SHDR-NEXT: ] # SHDR-NEXT: Address: 0x0 # SHDR-NEXT: Offset: 0x40 # SHDR-NEXT: Size: [[SIZE]] # SHDR-NEXT: Link: 0 # SHDR-NEXT: Info: 0 # SHDR-NEXT: AddressAlignment: [[ADDRALIGN]] # SHDR-NEXT: EntrySize: 0 # DWARF-LE-CONTENT-NEXT: SectionData ( # DWARF-LE-CONTENT-NEXT: 0000: 70000000 02003200 00000102 03040501 ## | | | | | | | | | ## | | | | | | | | +- standard_opcode_lengths[DW_LNS_copy] (1-byte) 0x01 ## | | | | | | | +- opcode_base (1-byte) 0x05 ## | | | | | | +- line_range (1-byte) 0x04 ## | | | | | +- line_base (signed 1-byte) 0x03 ## | | | | +- default_is_stmt (1-byte) 0x02 ## | | | +- minimum_instruction_length (1-byte) 0x01 ## | | +-------- prologue_length (4-byte) 50 ## | +--- version (2-byte) 0x02 ## +------- unit_length (4-byte) 0x70 ## # DWARF-LE-CONTENT-NEXT: 0010: 02030405 06070809 64697231 00646972 ## | | | | | | | | | | ## | | | | | | | | | +----- include_directories[2] "dir2\0" ## | | | | | | | | +---------- include_directories[1] "dir1\0" ## | | | | | | | +- standard_opcode_lengths[DW_LNS_fixed_advance_pc] (1-byte) 0x09 ## | | | | | | +- standard_opcode_lengths[DW_LNS_const_add_pc] (1-byte) 0x08 ## | | | | | +- standard_opcode_lengths[DW_LNS_set_basic_block] (1-byte) 0x07 ## | | | | +- standard_opcode_lengths[DW_LNS_negate_stmt] (1-byte) 0x06 ## | | | +- standard_opcode_lengths[DW_LNS_set_column] (1-byte) 0x05 ## | | +- standard_opcode_lengths[DW_LNS_set_file] (1-byte) 0x04 ## | +- standard_opcode_lengths[DW_LNS_advance_line] (1-byte) 0x03 ## +- standard_opcode_lengths[DW_LNS_advance_pc] (1-byte) 0x02 ## # DWARF-LE-CONTENT-NEXT: 0020: 32000061 2E630001 0203622E 63000203 ## | | | | | | | | | ## | | | | | | | | +- ModTime (ULEB128) 0x03 ## | | | | | | | +- DirIndex (ULEB128) 0x02 ## | | | | | | +-------- file_names[2] "b.c\0" ## | | | | | +- Length (ULEB128) 0x03 ## | | | | +- ModTime (ULEB128) 0x02 ## | | | +- DirIndex (ULEB128) 0x01 ## | | +-------- file_names[1] "a.c\0" ## | +- terminating entry (1-byte) 0x00 ## +--- the last two bytes of "dir2\0" ## # DWARF-LE-CONTENT-NEXT: 0030: 0400 ## | | ## | +- terminating entry (1-byte) 0x00 ## +- Length (ULEB128) 0x04 # DWARF-LE-CONTENT-NEXT: ) --- !ELF FileHeader: Class: ELFCLASS64 Data: [[ENDIAN]] Type: ET_EXEC DWARF: debug_line: - Length: 0x70 Version: 2 PrologueLength: 50 MinInstLength: 1 DefaultIsStmt: 2 LineBase: 3 LineRange: 4 OpcodeBase: 5 StandardOpcodeLengths: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] IncludeDirs: - dir1 - dir2 Files: - Name: "a.c" DirIdx: 1 ModTime: 2 Length: 3 - Name: "b.c" DirIdx: 2 ModTime: 3 Length: 4 ## Generate and verify a big endian DWARF32 .debug_line section. # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o # RUN: llvm-readobj --sections --section-data %t1.be.o | \ # RUN: FileCheck %s -DSIZE=50 -DADDRALIGN=1 --check-prefixes=SHDR,DWARF-BE-CONTENT # DWARF-BE-CONTENT-NEXT: SectionData ( # DWARF-BE-CONTENT-NEXT: 0000: 00000070 00020000 00320102 03040501 ## | | | | | | | | | ## | | | | | | | | +- standard_opcode_lengths[DW_LNS_copy] (1-byte) 0x01 ## | | | | | | | +- opcode_base (1-byte) 0x05 ## | | | | | | +- line_range (1-byte) 0x04 ## | | | | | +- line_base (signed 1-byte) 0x03 ## | | | | +- default_is_stmt (1-byte) 0x02 ## | | | +- minimum_instruction_length (1-byte) 0x01 ## | | +-------- prologue_length (4-byte) 50 ## | +--- version (2-byte) 0x02 ## +------- unit_length (4-byte) 0x70 ## # DWARF-BE-CONTENT-NEXT: 0010: 02030405 06070809 64697231 00646972 ## | | | | | | | | | | ## | | | | | | | | | +----- include_directories[2] "dir2\0" ## | | | | | | | | +---------- include_directories[1] "dir1\0" ## | | | | | | | +- standard_opcode_lengths[DW_LNS_fixed_advance_pc] (1-byte) 0x09 ## | | | | | | +- standard_opcode_lengths[DW_LNS_const_add_pc] (1-byte) 0x08 ## | | | | | +- standard_opcode_lengths[DW_LNS_set_basic_block] (1-byte) 0x07 ## | | | | +- standard_opcode_lengths[DW_LNS_negate_stmt] (1-byte) 0x06 ## | | | +- standard_opcode_lengths[DW_LNS_set_column] (1-byte) 0x05 ## | | +- standard_opcode_lengths[DW_LNS_set_file] (1-byte) 0x04 ## | +- standard_opcode_lengths[DW_LNS_advance_line] (1-byte) 0x03 ## +- standard_opcode_lengths[DW_LNS_advance_pc] (1-byte) 0x02 ## # DWARF-BE-CONTENT-NEXT: 0020: 32000061 2E630001 0203622E 63000203 ## | | | | | | | | | ## | | | | | | | | +- ModTime (ULEB128) 0x03 ## | | | | | | | +- DirIndex (ULEB128) 0x02 ## | | | | | | +-------- file_names[2] "b.c\0" ## | | | | | +- Length (ULEB128) 0x03 ## | | | | +- ModTime (ULEB128) 0x02 ## | | | +- DirIndex (ULEB128) 0x01 ## | | +-------- file_names[1] "a.c\0" ## | +- terminating entry (1-byte) 0x00 ## +--- the last two bytes of "dir2\0" ## # DWARF-BE-CONTENT-NEXT: 0030: 0400 ## | | ## | +- terminating entry (1-byte) 0x00 ## +- Length (ULEB128) 0x04 # DWARF-BE-CONTENT-NEXT: ) ## b) Generate the .debug_line section from raw section content. # RUN: yaml2obj --docnum=2 %s -o %t2.o # RUN: llvm-readobj --sections --section-data %t2.o | \ # RUN: FileCheck %s -DSIZE=3 -DADDRALIGN=0 --check-prefixes=SHDR,ARBITRARY-CONTENT # ARBITRARY-CONTENT: SectionData ( # ARBITRARY-CONTENT-NEXT: 0000: 112233 |."3| # ARBITRARY-CONTENT-NEXT: ) --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC Sections: - Name: .debug_line Type: SHT_PROGBITS Content: "112233" ## c) Generate the .debug_line section when the "Size" is specified. # RUN: yaml2obj --docnum=3 %s -o %t3.o # RUN: llvm-readobj --sections --section-data %t3.o | \ # RUN: FileCheck %s -DSIZE=16 -DADDRALIGN=0 --check-prefixes=SHDR,SIZE # SIZE: SectionData ( # SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |................| # SIZE-NEXT: ) --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC Sections: - Name: .debug_line Type: SHT_PROGBITS Size: 0x10 ## d) Test that yaml2obj emits an error message when both the "Size" and the ## "debug_line" entry are specified at the same time. # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR # ERROR: yaml2obj: error: cannot specify section '.debug_line' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC Sections: - Name: .debug_line Type: SHT_PROGBITS Size: 0x10 DWARF: debug_line: - Length: 0x70 Version: 2 PrologueLength: 50 MinInstLength: 1 DefaultIsStmt: 1 LineBase: 1 LineRange: 14 OpcodeBase: 13 StandardOpcodeLengths: [] ## e) Test that yaml2obj emits an error message when both the "Content" and the ## "debug_line" entry are specified at the same time. # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC Sections: - Name: .debug_line Type: SHT_PROGBITS Content: "00" DWARF: debug_line: - Length: 0x70 Version: 2 PrologueLength: 50 MinInstLength: 1 DefaultIsStmt: 1 LineBase: 1 LineRange: 14 OpcodeBase: 13 StandardOpcodeLengths: [] ## f) Test that all the properties can be overridden by the section header when ## the "debug_line" entry doesn't exist. # RUN: yaml2obj --docnum=6 %s -o %t6.o # RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN # OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al # OVERRIDDEN: [ 1] .debug_line STRTAB 0000000000002020 000050 000011 01 A 2 1 2 # OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 000061 000000 00 0 0 0 --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC Sections: - Name: .debug_line Type: SHT_STRTAB # SHT_PROGBITS by default. Flags: [SHF_ALLOC] # 0 by default. Link: .sec # 0 by default. EntSize: 1 # 0 by default. Info: 1 # 0 by default. AddressAlign: 2 # 0 by default. Address: 0x2020 # 0x00 by default. Offset: 0x50 # 0x40 for the first section. Size: 0x11 # Set the "Size" so that we can reuse the check tag "OVERRIDDEN". - Name: .sec # Linked by .debug_line. Type: SHT_STRTAB ## g) Test that all the properties can be overridden by the section header when ## the "debug_line" entry exists. # RUN: yaml2obj --docnum=7 %s -o %t7.o # RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC Sections: - Name: .debug_line Type: SHT_STRTAB # SHT_PROGBITS by default. Flags: [SHF_ALLOC] # 0 by default. Link: .sec # 0 by default. EntSize: 1 # 0 by default. Info: 1 # 0 by default. AddressAlign: 2 # 1 by default. Address: 0x2020 # 0x00 by default. Offset: 0x50 # 0x40 for the first section. - Name: .sec # Linked by .debug_line. Type: SHT_STRTAB DWARF: debug_line: - Length: 0x70 Version: 2 PrologueLength: 50 MinInstLength: 1 DefaultIsStmt: 1 LineBase: 1 LineRange: 14 OpcodeBase: 13 StandardOpcodeLengths: [] ## h) Test that the address size is inferred from the target machine. # RUN: yaml2obj --docnum=8 -DBITS=64 -DADDR=0x1234567890abcdef %s -o %t8.64-bit.o # RUN: llvm-readelf --hex-dump=.debug_line %t8.64-bit.o | \ # RUN: FileCheck %s --check-prefix=ADDRSIZE -DADDR="efcdab90 78563412" # ADDRSIZE: Hex dump of section '.debug_line': # ADDRSIZE-NEXT: 0x00000000 34120000 02003412 00000101 010e0d00 4.....4......... ## ^------- unit_length (4-byte) ## ^--- version (2-byte) ## ^-------- header_length (4-byte) ## ^- minimum_instruction_length (1-byte) ## ^- default_is_stmt (1-byte) ## ^- line_base (1-byte) ## ^- line_range (1-byte) ## ^- opcode_base (1-byte) ## ^- null byte for terminating include_directories # ADDRSIZE-NEXT: 0x00000010 00000902 [[ADDR]] ## ^- null byte for terminating file_names ## ^- DW_LNS_extended_op ## ^- extended op length (ULEB128) 0x09 ## ^- DW_LNE_set_address ## ^------- address # RUN: yaml2obj --docnum=8 -DBITS=32 -DADDR=0x12345678 %s -o %t8.32-bit.o # RUN: llvm-readelf --hex-dump=.debug_line %t8.32-bit.o | \ # RUN: FileCheck %s --check-prefix=ADDRSIZE -DADDR="78563412" --- !ELF FileHeader: Class: ELFCLASS[[BITS]] Data: ELFDATA2LSB Type: ET_EXEC DWARF: debug_line: - Length: 0x1234 Version: 2 PrologueLength: 0x1234 MinInstLength: 1 DefaultIsStmt: 1 LineBase: 1 LineRange: 14 OpcodeBase: 13 StandardOpcodeLengths: [] Opcodes: - Opcode: DW_LNS_extended_op ExtLen: 9 SubOpcode: DW_LNE_set_address Data: [[ADDR]] ## i) Test that yaml2obj is able to emit correct opcodes. # RUN: yaml2obj --docnum=9 %s -o %t9.o # RUN: llvm-readelf --hex-dump=.debug_line %t9.o | FileCheck %s --check-prefix=OPCODES # OPCODES: Hex dump of section '.debug_line': # OPCODES-NEXT: 0x00000000 34120000 04003412 00000101 01010e0d 4.....4......... ## ^------- unit_length (4-byte) ## ^--- version (2-byte) ## ^-------- header_length (4-byte) ## ^- minimum_instruction_length (1-byte) ## ^- maximum_operations_per_instruction (1-byte) ## ^- default_is_stmt (1-byte) ## ^- line_base (1-byte) ## ^- line_range (1-byte) ## ^- opcode_base (1-byte) # OPCODES-NEXT: 0x00000010 00000102 b42403b4 2404b424 05b42406 .....$..$..$..$. ## ^- null byte for terminating include_directories ## ^- null byte for terminating file_names ## ^- DW_LNS_copy (1-byte) ## ^- DW_LNS_advance_pc ## ^--- operands[0] (ULEB128) 0x1234 ## ^- DW_LNS_advance_line ## ^---- operands[0] (SLEB128) 0x1234 ## ^- DW_LNS_set_file ## ^--- operands[0] (ULEB128) 0x1234 ## ^- DW_LNS_set_column ## ^--- operands[0] (ULEB128) 0x1234 ## ^- DW_LNS_negate_stmt # OPCODES-NEXT: 0x00000020 07080934 120a0b0c b4240009 01000902 ...4.....$...... ## ^- DW_LNS_set_basic_block ## ^- DW_LNS_const_add_pc ## ^- DW_LNS_fixed_advance_pc ## ^---- operands[0] (uhalf, 2-byte) ## ^- DW_LNS_set_prologue_end ## ^- DW_LNS_set_epilogue_begin ## ^- DW_LNS_set_isa ## ^--- operands[0] (ULEB128) 0x1234 ## ^- DW_LNS_extended_op ## ^- extended op length (ULEB128) 0x09 ## ^- DW_LNE_end_sequence ## ^- DW_LNS_extended_op ## ^- extended op length (ULEB128) 0x09 ## ^- DW_LNE_set_address # OPCODES-NEXT: 0x00000030 34120000 00000000 00090361 62636400 4..........abcd. ## ^---------------- operands[0] (8-byte) ## ^- DW_LNS_extended_op ## ^- extended op length (ULEB128) 0x09 ## ^- DW_LNE_define_file ## ^---------- operands[0] "abcd\0" # OPCODES-NEXT: 0x00000040 b424b424 b4240009 04b424 .$.$.$....$ ## ^--- operands[1] (ULEB128) 0x1234 ## ^--- operands[2] (ULEB128) 0x1234 ## ^--- operands[3] (ULEB128) 0x1234 ## ^- DW_LNS_extended_op ## ^- extended op length (ULEB128) 0x09 ## ^- DW_LNE_set_discriminator ## ^--- operands[0] (ULEB128) 0x1234 --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC DWARF: debug_line: - Length: 0x1234 Version: 4 PrologueLength: 0x1234 MinInstLength: 1 MaxOpsPerInst: 1 DefaultIsStmt: 1 LineBase: 1 LineRange: 14 OpcodeBase: 13 StandardOpcodeLengths: [] Opcodes: - Opcode: DW_LNS_copy - Opcode: DW_LNS_advance_pc Data: 0x1234 - Opcode: DW_LNS_advance_line SData: 0x1234 - Opcode: DW_LNS_set_file Data: 0x1234 - Opcode: DW_LNS_set_column Data: 0x1234 - Opcode: DW_LNS_negate_stmt - Opcode: DW_LNS_set_basic_block - Opcode: DW_LNS_const_add_pc - Opcode: DW_LNS_fixed_advance_pc Data: 0x1234 - Opcode: DW_LNS_set_prologue_end - Opcode: DW_LNS_set_epilogue_begin - Opcode: DW_LNS_set_isa Data: 0x1234 - Opcode: DW_LNS_extended_op ExtLen: 0x09 SubOpcode: DW_LNE_end_sequence - Opcode: DW_LNS_extended_op ExtLen: 0x09 SubOpcode: DW_LNE_set_address Data: 0x1234 - Opcode: DW_LNS_extended_op ExtLen: 0x09 SubOpcode: DW_LNE_define_file FileEntry: Name: abcd DirIdx: 0x1234 ModTime: 0x1234 Length: 0x1234 - Opcode: DW_LNS_extended_op ExtLen: 0x09 SubOpcode: DW_LNE_set_discriminator Data: 0x1234 ## j) Test that yaml2obj is able to infer the length and header_length fields. # RUN: yaml2obj --docnum=10 %s -o %t10.o # RUN: llvm-readelf --hex-dump=.debug_line %t10.o | FileCheck %s --check-prefix=INFER-LENGTH # INFER-LENGTH: Hex dump of section '.debug_line': # INFER-LENGTH-NEXT: 0x00000000 2e000000 04002500 00000101 01fb0e04 ......%......... ## ^------- unit_length (4-byte) 0x2e ## ^--- version (2-byte) ## ^-------- header_length (4-byte) 0x25 ## ^- minimum_instruction_length (1-byte) ## ^- maximum_operations_per_instruction (1-byte) ## ^- default_is_stmt (1-byte) ## ^- line_base (1-byte) -5 ## ^- line_range (1-byte) ## ^- opcode_base (1-byte) # INFER-LENGTH-NEXT: 0x00000010 00010174 656d7031 0074656d 70320000 ...temp1.temp2.. ## ^----- standard_opcode_lengths (3-byte) ## ^------------- include_directories[1] "temp1\0" ## ^------------ include_directories[2] "temp1\0" ## ^- include_directories null byte # INFER-LENGTH-NEXT: 0x00000020 612e6300 01000062 2e630002 00000000 a.c....b.c...... ## ^------- file_names[1] file name "a.c\0" ## ^- file_names[1] directory index (ULEB128) 0x01 ## ^- file_names[1] file length (ULEB128) 0x00 ## ^- file_names[1] modification time 0x00 ## ^-------- file_names[2] file name "b.c\0" ## ^- file_names[2] directory index (ULEB128) 0x02 ## ^- file_names[2] file length (ULEB128) 0x00 ## ^- file_names[2] modification time 0x00 ## ^- file_names null byte ## ^- DW_LNS_extended_op # INFER-LENGTH-NEXT: 0x00000030 0101ffff ffff2500 00000000 00000400 ......%......... ## ^- extended op length (ULEB128) 0x01 ## ^- DW_LNE_end_sequence ## ^-------------------------- unit_length (12-byte) ## ^--- version (2-byte) # INFER-LENGTH-NEXT: 0x00000040 18000000 00000000 010101fb 0e040001 ................ ## ^---------------- header_length (8-byte) ## ^- minimum_instruction_length (1-byte) ## ^- maximum_operations_per_instruction (1-byte) ## ^- default_is_stmt (1-byte) ## ^- line_base (1-byte) -5 ## ^- line_range (1-byte) ## ^- opcode_base (1-byte) ## ^--- standard_opcode_lengths (3-byte) # INFER-LENGTH-NEXT: 0x00000050 0174656d 70330000 632e6300 01000000 .temp3..c.c..... ## -- ## ^------------ include_directories[1] "temp3\0" ## ^- include_directories null byte ## ^------- file_names[1] file name "a.c\0" ## ^- file_names[1] directory index (ULEB128) 0x01 ## ^- file_names[1] file length (ULEB128) 0x00 ## ^- file_names[1] modification time 0x00 ## ^- file_names null byte # INFER-LENGTH-NEXT: 0x00000060 000101 ... ## ^- DW_LNS_extended_op ## ^- extended op length (ULEB128) 0x01 ## ^- DW_LNE_end_sequence --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC DWARF: debug_line: - Version: 4 MinInstLength: 1 MaxOpsPerInst: 1 DefaultIsStmt: 1 LineBase: 251 LineRange: 14 OpcodeBase: 4 StandardOpcodeLengths: [ 0, 1, 1 ] IncludeDirs: - temp1 - temp2 Files: - Name: a.c DirIdx: 1 ModTime: 0 Length: 0 - Name: b.c DirIdx: 2 ModTime: 0 Length: 0 Opcodes: - Opcode: DW_LNS_extended_op ExtLen: 1 SubOpcode: DW_LNE_end_sequence - Format: DWARF64 Version: 4 MinInstLength: 1 MaxOpsPerInst: 1 DefaultIsStmt: 1 LineBase: 251 LineRange: 14 OpcodeBase: 4 StandardOpcodeLengths: [ 0, 1, 1 ] IncludeDirs: - temp3 Files: - Name: c.c DirIdx: 1 ModTime: 0 Length: 0 Opcodes: - Opcode: DW_LNS_extended_op ExtLen: 1 SubOpcode: DW_LNE_end_sequence ## k) Test that we can omit the include_directories, file_names and opcodes ## fields of the line table. # RUN: yaml2obj --docnum=11 %s -o %t11.o # RUN: llvm-readelf --hex-dump=.debug_line %t11.o | \ # RUN: FileCheck %s --check-prefix=OMIT-FIELDS # OMIT-FIELDS: Hex dump of section '.debug_line': # OMIT-FIELDS-NEXT: 0x00000000 11000000 04000b00 00000101 01fb0e04 ................ ## ^------- unit_length (4-byte) ## ^--- version (2-byte) ## ^-------- header_length (4-byte) ## ^- minimum_instruction_length (1-byte) ## ^- maximum_operations_per_instruction (1-byte) ## ^- default_is_stmt (1-byte) ## ^- line_base (1-byte) -5 ## ^- line_range (1-byte) ## ^- opcode_base (1-byte) # OMIT-FIELDS-NEXT: 0x00000010 00010100 00 ..... ## ^----- standard_opcode_lengths (3-byte) ## ^- include_directories null byte (1-byte) ## ^- file_names null byte (1-byte) --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC DWARF: debug_line: - Version: 4 MinInstLength: 1 MaxOpsPerInst: 1 DefaultIsStmt: 1 LineBase: 251 LineRange: 14 OpcodeBase: 4 StandardOpcodeLengths: [ 0, 1, 1 ] ## l) Test that we can specify or omit the ExtLen field of extended opcodes. # RUN: yaml2obj --docnum=12 %s -o %t12.o # RUN: llvm-readelf --hex-dump=.debug_line %t12.o | \ # RUN: FileCheck %s --check-prefix=EXTLEN --strict-whitespace # EXTLEN: Hex dump of section '.debug_line': # EXTLEN-NEXT: 0x00000000 20000000 04000800 00000101 01fb0e01 ## ^---------------------------------- line number program header # EXTLEN-NEXT: 0x00000010 0000000c 03616263 6400b424 b424b424 ## ---- ## ^- DW_LNS_extended_op ## ^- extended opcode length (ULEB128) 12 ## ^- DW_LNE_define_file ## ^---------- "abcd\0" ## ^--- directory index (ULEB128) 0x1234 ## ^--- modification time (ULEB128) 0x1234 ## ^--- file length (ULEB128) 0x1234 # EXTLEN-NEXT: 0x00000020 00b42401{{ }} ## ^- DW_LNS_extended_op ## ^--- extended opcode length (ULEB128) 0x1234 ## ^- DW_LNE_end_sequence --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC DWARF: debug_line: - Version: 4 MinInstLength: 1 MaxOpsPerInst: 1 DefaultIsStmt: 1 LineBase: 251 LineRange: 14 OpcodeBase: 1 StandardOpcodeLengths: [] Opcodes: - Opcode: DW_LNS_extended_op ## Omit the ExtLen field. SubOpcode: DW_LNE_define_file FileEntry: Name: abcd DirIdx: 0x1234 ModTime: 0x1234 Length: 0x1234 - Opcode: DW_LNS_extended_op ## Specify the ExtLen field. ExtLen: 0x1234 SubOpcode: DW_LNE_end_sequence ## m) Test how yaml2obj generates the opcode_base and the ## standard_opcode_lengths fields. ## Both the opcode_base and the standard_opcode_lengths fields are not ## specified (DWARFv2). # RUN: yaml2obj --docnum=13 -DVERSION=2 -DMAXOPSPERINST='' %s -o %t13.o # RUN: llvm-readelf --hex-dump=.debug_line %t13.o | \ # RUN: FileCheck %s --check-prefix=OPCODEBASEV2 # OPCODEBASEV2: Hex dump of section '.debug_line': # OPCODEBASEV2-NEXT: 0x00000000 16000000 02001000 00000101 00010a00 ................ ## ^- opcode_base (10) ## ^- standard_opcode_lengths[DW_LNS_copy] = 0 # OPCODEBASEV2-NEXT: 0x00000010 01010101 00000001 0000 .......... ## ^- standard_opcode_lengths[DW_LNS_advance_pc] = 1 ## ^- standard_opcode_lengths[DW_LNS_advance_line] = 1 ## ^- standard_opcode_lengths[DW_LNS_set_file] = 1 ## ^- standard_opcode_lengths[DW_LNS_set_column] = 1 ## ^- standard_opcode_lengths[DW_LNS_negate_stmt] = 0 ## ^- standard_opcode_lengths[DW_LNS_set_basic_block] = 0 ## ^- standard_opcode_lengths[DW_LNS_const_add_pc] = 0 ## ^- standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 ## ^--- terminators for include_directories and file_names --- !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB Type: ET_EXEC DWARF: debug_line: - Version: [[VERSION=4]] MinInstLength: 1 [[MAXOPSPERINST=MaxOpsPerInst: 0]] DefaultIsStmt: 1 LineBase: 0 LineRange: 1 OpcodeBase: [[OPCODEBASE=]] StandardOpcodeLengths: [[STANDARDOPCODELENGTHS=]] ## Both the opcode_base and the standard_opcode_lengths fields are not ## specified (DWARFv3). # RUN: yaml2obj --docnum=13 -DVERSION=3 -DMAXOPSPERINST='' %s -o %t14.o # RUN: llvm-readelf --hex-dump=.debug_line %t14.o | \ # RUN: FileCheck %s --check-prefix=OPCODEBASEV3 # OPCODEBASEV3: Hex dump of section '.debug_line': # OPCODEBASEV3-NEXT: 0x00000000 19000000 03001300 00000101 00010d00 ................ ## ^- opcode_base (13) ## ^- standard_opcode_lengths[DW_LNS_copy] = 0 # OPCODEBASEV3-NEXT: 0x00000010 01010101 00000001 00000100 00 ............. ## ^- standard_opcode_lengths[DW_LNS_advance_pc] = 1 ## ^- standard_opcode_lengths[DW_LNS_advance_line] = 1 ## ^- standard_opcode_lengths[DW_LNS_set_file] = 1 ## ^- standard_opcode_lengths[DW_LNS_set_column] = 1 ## ^- standard_opcode_lengths[DW_LNS_negate_stmt] = 0 ## ^- standard_opcode_lengths[DW_LNS_set_basic_block] = 0 ## ^- standard_opcode_lengths[DW_LNS_const_add_pc] = 0 ## ^- standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 ## ^- standard_opcode_lengths[DW_LNS_set_prologue_end] = 0 ## ^- standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 ## ^- standard_opcode_lengths[DW_LNS_set_isa] = 1 ## ^---- terminators for include_directories and file_names ## Both the opcode_base and the standard_opcode_lengths fields are not ## specified (DWARFv4). # RUN: yaml2obj --docnum=13 %s -o %t15.o # RUN: llvm-readelf --hex-dump=.debug_line %t15.o | \ # RUN: FileCheck %s --check-prefix=OPCODEBASEV4 # OPCODEBASEV4: Hex dump of section '.debug_line': # OPCODEBASEV4-NEXT: 0x00000000 1a000000 04001400 00000100 0100010d ................ ## ^- opcode_base (13) # OPCODEBASEV4-NEXT: 0x00000010 00010101 01000000 01000001 0000 .............. ## ^- standard_opcode_lengths[DW_LNS_copy] = 0 ## ^- standard_opcode_lengths[DW_LNS_advance_pc] = 1 ## ^- standard_opcode_lengths[DW_LNS_advance_line] = 1 ## ^- standard_opcode_lengths[DW_LNS_set_file] = 1 ## ^- standard_opcode_lengths[DW_LNS_set_column] = 1 ## ^- standard_opcode_lengths[DW_LNS_negate_stmt] = 0 ## ^- standard_opcode_lengths[DW_LNS_set_basic_block] = 0 ## ^- standard_opcode_lengths[DW_LNS_const_add_pc] = 0 ## ^- standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 ## ^- standard_opcode_lengths[DW_LNS_set_prologue_end] = 0 ## ^- standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 ## ^- standard_opcode_lengths[DW_LNS_set_isa] = 1 ## ^--- terminators for include_directories and file_names ## Specify the opcode_base field (opcode_base == 0). # RUN: yaml2obj --docnum=13 -DOPCODEBASE=0 %s -o %t16.o # RUN: llvm-readelf --hex-dump=.debug_line %t16.o | \ # RUN: FileCheck %s --check-prefix=ZERO-OPCODEBASE # ZERO-OPCODEBASE: Hex dump of section '.debug_line': # ZERO-OPCODEBASE-NEXT: 0x00000000 0e000000 04000800 00000100 01000100 ................ ## ^- opcode_base (0) # ZERO-OPCODEBASE-NEXT: 0x00000010 0000 .. ## ^--- terminators for include_directories and file_names ## Specify the opcode_base field (opcode_base != 0, opcode_base - 1 < 12). ## The standard_opcode_lengths array will be truncated. # RUN: yaml2obj --docnum=13 -DOPCODEBASE=4 %s -o %t17.o # RUN: llvm-readelf --hex-dump=.debug_line %t17.o | \ # RUN: FileCheck %s --check-prefix=OPCODEBASE # OPCODEBASE: Hex dump of section '.debug_line': # OPCODEBASE-NEXT: 0x00000000 11000000 04000b00 00000100 01000104 ................ ## ^- opcode_base (4) # OPCODEBASE-NEXT: 0x00000010 00010100 00 ..... ## ^----- standard_opcode_lengths (3-byte) ## ^---- terminators for include_directories and file_names ## Specify the opcode_base field (opcode_base != 0, opcode_base - 1 > 12). ## The standard_opcode_lengths array will be extended. # RUN: yaml2obj --docnum=13 -DOPCODEBASE=20 %s -o %t18.o # RUN: llvm-readelf --hex-dump=.debug_line %t18.o | \ # RUN: FileCheck %s --check-prefix=OPCODEBASE1 # OPCODEBASE1: Hex dump of section '.debug_line': # OPCODEBASE1-NEXT: 0x00000000 21000000 04001b00 00000100 01000114 !............... ## ^- opcode_base (20) # OPCODEBASE1-NEXT: 0x00000010 00010101 01000000 01000001 00000000 ................ ## ^------------------------- standard_opcode_lengths defined in DWARFv5 (12-byte) ## ^------- extended standard_opcode_lengths (7-byte) # OPCODEBASE1-NEXT: 0x00000020 00000000 00 ..... ## ------ ## ^---- terminators for include_directories and file_names ## Specify the standard_opcode_lengths field. # RUN: yaml2obj --docnum=13 -DSTANDARDOPCODELENGTHS=[0,1,0] %s -o %t19.o # RUN: llvm-readelf --hex-dump=.debug_line %t19.o | \ # RUN: FileCheck %s --check-prefix=OPCODELENGTHS # OPCODELENGTHS: Hex dump of section '.debug_line': # OPCODELENGTHS-NEXT: 0x00000000 11000000 04000b00 00000100 01000104 ................ ## ^- opcode_base (4) # OPCODELENGTHS-NEXT: 0x00000010 00010000 00 ..... ## ^----- standard_opcode_lengths (3-byte) ## ^---- terminators for include_directories and file_names ## Specify both the opcode_base and the standard_opcode_lengths fields. # RUN: yaml2obj --docnum=13 -DOPCODEBASE=2 -DSTANDARDOPCODELENGTHS=[0,1,0] %s -o %t20.o # RUN: llvm-readelf --hex-dump=.debug_line %t20.o | \ # RUN: FileCheck %s --check-prefix=OPCODEBASE-LENGTHS # OPCODEBASE-LENGTHS: Hex dump of section '.debug_line': # OPCODEBASE-LENGTHS-NEXT: 0x00000000 11000000 04000b00 00000100 01000102 ................ ## ^- opcode_base (2) # OPCODEBASE-LENGTHS-NEXT: 0x00000010 00010000 00 ..... ## ^----- standard_opcode_lengths (3-byte) ## ^---- terminators for include_directories and file_names