@@ -668,3 +668,163 @@ DWARF:
668
668
# # Specify the ExtLen field.
669
669
ExtLen : 0x1234
670
670
SubOpcode : DW_LNE_end_sequence
671
+
672
+ # # m) Test how yaml2obj generates the opcode_base and the
673
+ # # standard_opcode_lengths fields.
674
+
675
+ # # Both the opcode_base and the standard_opcode_lengths fields are not
676
+ # # specified (DWARFv2).
677
+
678
+ # RUN: yaml2obj --docnum=13 -DVERSION=2 -DMAXOPSPERINST='' %s -o %t13.o
679
+ # RUN: llvm-readelf --hex-dump=.debug_line %t13.o | \
680
+ # RUN: FileCheck %s --check-prefix=OPCODEBASEV2
681
+
682
+ # OPCODEBASEV2: Hex dump of section '.debug_line':
683
+ # OPCODEBASEV2-NEXT: 0x00000000 16000000 02001000 00000101 00010a00 ................
684
+ # # ^- opcode_base (10)
685
+ # # ^- standard_opcode_lengths[DW_LNS_copy] = 0
686
+ # OPCODEBASEV2-NEXT: 0x00000010 01010101 00000001 0000 ..........
687
+ # # ^- standard_opcode_lengths[DW_LNS_advance_pc] = 1
688
+ # # ^- standard_opcode_lengths[DW_LNS_advance_line] = 1
689
+ # # ^- standard_opcode_lengths[DW_LNS_set_file] = 1
690
+ # # ^- standard_opcode_lengths[DW_LNS_set_column] = 1
691
+ # # ^- standard_opcode_lengths[DW_LNS_negate_stmt] = 0
692
+ # # ^- standard_opcode_lengths[DW_LNS_set_basic_block] = 0
693
+ # # ^- standard_opcode_lengths[DW_LNS_const_add_pc] = 0
694
+ # # ^- standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
695
+ # # ^--- terminators for include_directories and file_names
696
+
697
+ --- !ELF
698
+ FileHeader :
699
+ Class : ELFCLASS64
700
+ Data : ELFDATA2LSB
701
+ Type : ET_EXEC
702
+ DWARF :
703
+ debug_line :
704
+ - Version : [[VERSION=4]]
705
+ MinInstLength : 1
706
+ [[MAXOPSPERINST=MaxOpsPerInst : 0]]
707
+ DefaultIsStmt : 1
708
+ LineBase : 0
709
+ LineRange : 1
710
+ OpcodeBase : [[OPCODEBASE=<none>]]
711
+ StandardOpcodeLengths : [[STANDARDOPCODELENGTHS=<none>]]
712
+
713
+ # # Both the opcode_base and the standard_opcode_lengths fields are not
714
+ # # specified (DWARFv3).
715
+
716
+ # RUN: yaml2obj --docnum=13 -DVERSION=3 -DMAXOPSPERINST='' %s -o %t14.o
717
+ # RUN: llvm-readelf --hex-dump=.debug_line %t14.o | \
718
+ # RUN: FileCheck %s --check-prefix=OPCODEBASEV3
719
+
720
+ # OPCODEBASEV3: Hex dump of section '.debug_line':
721
+ # OPCODEBASEV3-NEXT: 0x00000000 19000000 03001300 00000101 00010d00 ................
722
+ # # ^- opcode_base (13)
723
+ # # ^- standard_opcode_lengths[DW_LNS_copy] = 0
724
+ # OPCODEBASEV3-NEXT: 0x00000010 01010101 00000001 00000100 00 .............
725
+ # # ^- standard_opcode_lengths[DW_LNS_advance_pc] = 1
726
+ # # ^- standard_opcode_lengths[DW_LNS_advance_line] = 1
727
+ # # ^- standard_opcode_lengths[DW_LNS_set_file] = 1
728
+ # # ^- standard_opcode_lengths[DW_LNS_set_column] = 1
729
+ # # ^- standard_opcode_lengths[DW_LNS_negate_stmt] = 0
730
+ # # ^- standard_opcode_lengths[DW_LNS_set_basic_block] = 0
731
+ # # ^- standard_opcode_lengths[DW_LNS_const_add_pc] = 0
732
+ # # ^- standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
733
+ # # ^- standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
734
+ # # ^- standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
735
+ # # ^- standard_opcode_lengths[DW_LNS_set_isa] = 1
736
+ # # ^---- terminators for include_directories and file_names
737
+
738
+ # # Both the opcode_base and the standard_opcode_lengths fields are not
739
+ # # specified (DWARFv4).
740
+
741
+ # RUN: yaml2obj --docnum=13 %s -o %t15.o
742
+ # RUN: llvm-readelf --hex-dump=.debug_line %t15.o | \
743
+ # RUN: FileCheck %s --check-prefix=OPCODEBASEV4
744
+
745
+ # OPCODEBASEV4: Hex dump of section '.debug_line':
746
+ # OPCODEBASEV4-NEXT: 0x00000000 1a000000 04001400 00000100 0100010d ................
747
+ # # ^- opcode_base (13)
748
+ # OPCODEBASEV4-NEXT: 0x00000010 00010101 01000000 01000001 0000 ..............
749
+ # # ^- standard_opcode_lengths[DW_LNS_copy] = 0
750
+ # # ^- standard_opcode_lengths[DW_LNS_advance_pc] = 1
751
+ # # ^- standard_opcode_lengths[DW_LNS_advance_line] = 1
752
+ # # ^- standard_opcode_lengths[DW_LNS_set_file] = 1
753
+ # # ^- standard_opcode_lengths[DW_LNS_set_column] = 1
754
+ # # ^- standard_opcode_lengths[DW_LNS_negate_stmt] = 0
755
+ # # ^- standard_opcode_lengths[DW_LNS_set_basic_block] = 0
756
+ # # ^- standard_opcode_lengths[DW_LNS_const_add_pc] = 0
757
+ # # ^- standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
758
+ # # ^- standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
759
+ # # ^- standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
760
+ # # ^- standard_opcode_lengths[DW_LNS_set_isa] = 1
761
+ # # ^--- terminators for include_directories and file_names
762
+
763
+ # # Specify the opcode_base field (opcode_base == 0).
764
+
765
+ # RUN: yaml2obj --docnum=13 -DOPCODEBASE=0 %s -o %t16.o
766
+ # RUN: llvm-readelf --hex-dump=.debug_line %t16.o | \
767
+ # RUN: FileCheck %s --check-prefix=ZERO-OPCODEBASE
768
+
769
+ # ZERO-OPCODEBASE: Hex dump of section '.debug_line':
770
+ # ZERO-OPCODEBASE-NEXT: 0x00000000 0e000000 04000800 00000100 01000100 ................
771
+ # # ^- opcode_base (0)
772
+ # ZERO-OPCODEBASE-NEXT: 0x00000010 0000 ..
773
+ # # ^--- terminators for include_directories and file_names
774
+
775
+ # # Specify the opcode_base field (opcode_base != 0, opcode_base - 1 < 12).
776
+ # # The standard_opcode_lengths array will be truncated.
777
+
778
+ # RUN: yaml2obj --docnum=13 -DOPCODEBASE=4 %s -o %t17.o
779
+ # RUN: llvm-readelf --hex-dump=.debug_line %t17.o | \
780
+ # RUN: FileCheck %s --check-prefix=OPCODEBASE
781
+
782
+ # OPCODEBASE: Hex dump of section '.debug_line':
783
+ # OPCODEBASE-NEXT: 0x00000000 11000000 04000b00 00000100 01000104 ................
784
+ # # ^- opcode_base (4)
785
+ # OPCODEBASE-NEXT: 0x00000010 00010100 00 .....
786
+ # # ^----- standard_opcode_lengths (3-byte)
787
+ # # ^---- terminators for include_directories and file_names
788
+
789
+ # # Specify the opcode_base field (opcode_base != 0, opcode_base - 1 > 12).
790
+ # # The standard_opcode_lengths array will be extended.
791
+
792
+ # RUN: yaml2obj --docnum=13 -DOPCODEBASE=20 %s -o %t18.o
793
+ # RUN: llvm-readelf --hex-dump=.debug_line %t18.o | \
794
+ # RUN: FileCheck %s --check-prefix=OPCODEBASE1
795
+
796
+ # OPCODEBASE1: Hex dump of section '.debug_line':
797
+ # OPCODEBASE1-NEXT: 0x00000000 21000000 04001b00 00000100 01000114 !...............
798
+ # # ^- opcode_base (20)
799
+ # OPCODEBASE1-NEXT: 0x00000010 00010101 01000000 01000001 00000000 ................
800
+ # # ^------------------------- standard_opcode_lengths defined in DWARFv5 (12-byte)
801
+ # # ^------- extended standard_opcode_lengths (7-byte)
802
+ # OPCODEBASE1-NEXT: 0x00000020 00000000 00 .....
803
+ # # ------
804
+ # # ^---- terminators for include_directories and file_names
805
+
806
+ # # Specify the standard_opcode_lengths field.
807
+
808
+ # RUN: yaml2obj --docnum=13 -DSTANDARDOPCODELENGTHS=[0,1,0] %s -o %t19.o
809
+ # RUN: llvm-readelf --hex-dump=.debug_line %t19.o | \
810
+ # RUN: FileCheck %s --check-prefix=OPCODELENGTHS
811
+
812
+ # OPCODELENGTHS: Hex dump of section '.debug_line':
813
+ # OPCODELENGTHS-NEXT: 0x00000000 11000000 04000b00 00000100 01000104 ................
814
+ # # ^- opcode_base (4)
815
+ # OPCODELENGTHS-NEXT: 0x00000010 00010000 00 .....
816
+ # # ^----- standard_opcode_lengths (3-byte)
817
+ # # ^---- terminators for include_directories and file_names
818
+
819
+ # # Specify both the opcode_base and the standard_opcode_lengths fields.
820
+
821
+ # RUN: yaml2obj --docnum=13 -DOPCODEBASE=2 -DSTANDARDOPCODELENGTHS=[0,1,0] %s -o %t20.o
822
+ # RUN: llvm-readelf --hex-dump=.debug_line %t20.o | \
823
+ # RUN: FileCheck %s --check-prefix=OPCODEBASE-LENGTHS
824
+
825
+ # OPCODEBASE-LENGTHS: Hex dump of section '.debug_line':
826
+ # OPCODEBASE-LENGTHS-NEXT: 0x00000000 11000000 04000b00 00000100 01000102 ................
827
+ # # ^- opcode_base (2)
828
+ # OPCODEBASE-LENGTHS-NEXT: 0x00000010 00010000 00 .....
829
+ # # ^----- standard_opcode_lengths (3-byte)
830
+ # # ^---- terminators for include_directories and file_names
0 commit comments