brintos

brintos / llvm-project-archived public Read only

0
0
Text · 43.9 KiB · c6c93c6 Raw
894 lines · yaml
1## Test that yaml2obj emits a .debug_loclists section when requested.2 3## a) Generate and verify a little endian DWARF32 .debug_loclists section in a 64-bit object file.4 5# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.dwarf32.le.o6# RUN: llvm-readobj --sections --section-data %t1.dwarf32.le.o | \7# RUN:   FileCheck -DSIZE=133 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-LE8 9#            SHDR: Index: 110#       SHDR-NEXT: Name: .debug_loclists (1)11#       SHDR-NEXT: Type: SHT_PROGBITS (0x1)12#       SHDR-NEXT: Flags [ (0x0)13#       SHDR-NEXT: ]14#       SHDR-NEXT: Address: 0x015#       SHDR-NEXT: Offset: 0x4016#       SHDR-NEXT: Size: [[SIZE]]17#       SHDR-NEXT: Link: 018#       SHDR-NEXT: Info: 019#       SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]20#       SHDR-NEXT: EntrySize: 021# DWARF32-LE-NEXT: SectionData (22# DWARF32-LE-NEXT:   0000: 3D000000 05000800 03000000 0C000000  |=...............|23##                         ^-------                             unit_length (4-byte)24##                                  ^---                        version (2-byte)25##                                      ^-                      address_size (1-byte)26##                                        ^-                    segment_selector_size (1-byte)27##                                           ^-------           offset_entry_count (4-byte)28##                                                    ^-------  offsets[0] (4-byte)29# DWARF32-LE-NEXT:   0010: 1B000000 2F000000 01B42402 B424A186  |..../.....$..$..|30##                         ^-------                             offsets[1] (4-byte)31##                                  ^-------                    offsets[2] (4-byte)32##                                           ^-                 DW_LLE_base_addressx33##                                             ^---             operands[0] (ULEB128) 0x123434##                                                 ^-           DW_LLE_startx_endx35##                                                    ^---      operands[0] (ULEB128) 0x123436##                                                        ^---  operands[1] (ULEB128) 0x432137# DWARF32-LE-NEXT:   0020: 010411B4 249F0003 B424A186 0102117D  |....$....$.....}|38##                         --39##                           ^-                                 location descriptions length (ULEB128) 0x0440##                             ^-                               DW_OP_consts41##                               ^----                          operands[0] (SLEB128) +0x123442##                                    ^-                        DW_OP_stack_value43##                                      ^-                      DW_LLE_end_of_list44##                                        ^-                    DW_LLE_startx_length45##                                           ^---               operands[0] (ULEB128) 0x123446##                                               ^------        operands[1] (ULEB128) 0x432147##                                                      ^-      location descriptions length (ULEB128) 0x0248##                                                        ^-    DW_OP_consts49##                                                          ^-  operands[0] (SLEB128) -0x0350# DWARF32-LE-NEXT:   0030: 04B424A1 86010311 B4240005 0311B424  |..$......$.....$|51##                         ^-                                   DW_LLE_offset_pair52##                           ^---                               operands[0] (ULEB128) 0x123453##                               ^------                        operands[1] (ULEB128) 0x432154##                                      ^-                      location descriptions length (ULEB128) 0x0355##                                        ^-                    DW_OP_consts56##                                           ^---               operands[0] (SLEB128) +0x123457##                                               ^-             DW_LLE_end_of_list58##                                                 ^-           DW_LLE_default_location59##                                                    ^-        location descriptions length (ULEB128) 0x0360##                                                      ^-      DW_OP_consts61##                                                        ^---  operands[0] (SLEB128) +0x123462# DWARF32-LE-NEXT:   0040: 00400000 00050008 00020000 00080000  |.@..............|63##                         ^-                                   DW_LLE_end_of_list64##                           ^--------                          unit_length (4-byte)65##                                    ^---                      version (2-byte)66##                                        ^-                    address_size (1-byte)67##                                           ^-                 segment_selector_size (1-byte)68##                                             ^--------        offset_entry_count (4-byte)69##                                                      ^-----  offsets[0] (4-byte)70# DWARF32-LE-NEXT:   0050: 00270000 00063412 00000000 00000734  |.'....4........4|71##                         --72##                           ^--------                          offsets[1] (4-byte)73##                                    ^-                        DW_LLE_base_address74##                                      ^-----------------      operands[0] (8-byte)75##                                                        ^-    DW_LLE_start_end76##                                                          ^-  operands[0] (8-byte)77# DWARF32-LE-NEXT:   0060: 12000000 00000021 43000000 00000003  |.......!C.......|78##                         ---------------79##                                        ^-----------------    operands[1] (8-byte)80##                                                          ^-  location descriptions length (ULEB128) 0x0381# DWARF32-LE-NEXT:   0070: 11B42400 08341200 00000000 00A18601  |..$..4..........|82##                         ^-                                   DW_OP_consts83##                           ^---                               operands[0] (SLEB128) +0x123484##                               ^-                             DW_LLE_end_of_list85##                                  ^-                          DW_LLE_start_length86##                                    ^-----------------        operands[0] (8-byte)87##                                                      ^-----  operands[1] (LEB128) 0x432188# DWARF32-LE-NEXT:   0080: 0311B424 00                          |...$.|89##                         ^-                                   location descriptions length (ULEB128) 0x0390##                           ^-                                 DW_OP_consts91##                             ^---                             operands[0] (SLEB128) +0x123492##                                  ^-                          DW_LLE_end_of_list93# DWARF32-LE-NEXT: )94 95--- !ELF96FileHeader:97  Class: ELFCLASS6498  Data:  [[ENDIAN]]99  Type:  ET_EXEC100DWARF:101  debug_loclists:102    - Lists:103        - Entries:104            - Operator: DW_LLE_base_addressx105              Values:   [ 0x1234 ]106            - Operator: DW_LLE_startx_endx107              Values:   [ 0x1234, 0x4321 ]108              Descriptions:109                - Operator: DW_OP_consts110                  Values:   [ 0x1234 ]111                - Operator: DW_OP_stack_value112            - Operator: DW_LLE_end_of_list113        - Entries:114            - Operator: DW_LLE_startx_length115              Values:   [ 0x1234, 0x4321 ]116              Descriptions:117                - Operator: DW_OP_consts118                  ## Test a negative number (-3).119                  Values:   [ 0xfffffffffffffffd ]120            - Operator: DW_LLE_offset_pair121              Values:   [ 0x1234, 0x4321 ]122              Descriptions:123                - Operator: DW_OP_consts124                  Values:   [ 0x1234 ]125            - Operator: DW_LLE_end_of_list126        - Entries:127            - Operator: DW_LLE_default_location128              Descriptions:129                - Operator: DW_OP_consts130                  Values:   [ 0x1234 ]131            - Operator: DW_LLE_end_of_list132    - Lists:133        - Entries:134            - Operator: DW_LLE_base_address135              Values:   [ 0x1234 ]136            - Operator: DW_LLE_start_end137              Values:   [ 0x1234, 0x4321 ]138              Descriptions:139                - Operator: DW_OP_consts140                  Values:   [ 0x1234 ]141            - Operator: DW_LLE_end_of_list142        - Entries:143            - Operator: DW_LLE_start_length144              Values:   [ 0x1234, 0x4321 ]145              Descriptions:146                - Operator: DW_OP_consts147                  Values:   [ 0x1234 ]148            - Operator: DW_LLE_end_of_list149 150## b) Generate and verify a big endian DWARF32 .debug_loclists section in a 64-bit object file.151 152# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t.dwarf32.be.o153# RUN: llvm-readobj --sections --section-data %t.dwarf32.be.o | \154# RUN:   FileCheck -DSIZE=133 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-BE155 156# DWARF32-BE-NEXT: SectionData (157# DWARF32-BE-NEXT:   0000: 0000003D 00050800 00000003 0000000C  |...=............|158##                         ^-------                             unit_length (4-byte)159##                                  ^---                        version (2-byte)160##                                      ^-                      address_size (1-byte)161##                                        ^-                    segment_selector_size (1-byte)162##                                           ^-------           offset_entry_count (4-byte)163##                                                    ^-------  offsets[0] (4-byte)164# DWARF32-BE-NEXT:   0010: 0000001B 0000002F 01B42402 B424A186  |......./..$..$..|165##                         ^-------                             offsets[1] (4-byte)166##                                  ^-------                    offsets[2] (4-byte)167##                                           ^-                 DW_LLE_base_addressx168##                                             ^---             operands[0] (ULEB128) 0x1234169##                                                 ^-           DW_LLE_startx_endx170##                                                    ^---      operands[0] (ULEB128) 0x1234171##                                                        ^---  operands[1] (ULEB128) 0x4321172# DWARF32-BE-NEXT:   0020: 010411B4 249F0003 B424A186 0102117D  |....$....$.....}|173##                         --174##                           ^-                                 location descriptions length (ULEB128) 0x04175##                             ^-                               DW_OP_consts176##                               ^----                          operands[0] (SLEB128) +0x1234177##                                    ^-                        DW_OP_stack_value178##                                      ^-                      DW_LLE_end_of_list179##                                        ^-                    DW_LLE_startx_length180##                                           ^---               operands[0] (ULEB128) 0x1234181##                                               ^------        operands[1] (ULEB128) 0x4321182##                                                      ^-      location descriptions length (ULEB128) 0x02183##                                                        ^-    DW_OP_consts184##                                                          ^-  operands[0] (SLEB128) -0x03185# DWARF32-BE-NEXT:   0030: 04B424A1 86010311 B4240005 0311B424  |..$......$.....$|186##                         ^-                                   DW_LLE_offset_pair187##                           ^---                               operands[0] (ULEB128) 0x1234188##                               ^------                        operands[1] (ULEB128) 0x4321189##                                      ^-                      location descriptions length (ULEB128) 0x03190##                                        ^-                    DW_OP_consts191##                                           ^---               operands[0] (SLEB128) +0x1234192##                                               ^-             DW_LLE_end_of_list193##                                                 ^-           DW_LLE_default_location194##                                                    ^-        location descriptions length (ULEB128) 0x03195##                                                      ^-      DW_OP_consts196##                                                        ^---  operands[0] (SLEB128) +0x1234197# DWARF32-BE-NEXT:   0040: 00000000 40000508 00000000 02000000  |....@...........|198##                         ^-                                   DW_LLE_end_of_list199##                           ^--------                          unit_length (4-byte)200##                                    ^---                      version (2-byte)201##                                        ^-                    address_size (1-byte)202##                                           ^-                 segment_selector_size (1-byte)203##                                             ^--------        offset_entry_count (4-byte)204##                                                      ^-----  offsets[0] (4-byte)205# DWARF32-BE-NEXT:   0050: 08000000 27060000 00000000 12340700  |....'........4..|206##                         --207##                           ^--------                          offsets[1] (4-byte)208##                                    ^-                        DW_LLE_base_address209##                                      ^-----------------      operands[0] (8-byte)210##                                                        ^-    DW_LLE_start_end211##                                                          ^-  operands[0] (8-byte)212# DWARF32-BE-NEXT:   0060: 00000000 00123400 00000000 00432103  |......4......C!.|213##                         ---------------214##                                        ^-----------------    operands[1] (8-byte)215##                                                          ^-  location descriptions length (ULEB128) 0x03216# DWARF32-BE-NEXT:   0070: 11B42400 08000000 00000012 34A18601  |..$.........4...|217##                         ^-                                   DW_OP_consts218##                           ^---                               operands[0] (SLEB128) +0x1234219##                               ^-                             DW_LLE_end_of_list220##                                  ^-                          DW_LLE_start_length221##                                    ^-----------------        operands[0] (8-byte)222##                                                      ^-----  operands[1] (LEB128) 0x4321223# DWARF32-BE-NEXT:   0080: 0311B424 00                          |...$.|224##                         ^-                                   location descriptions length (ULEB128) 0x03225##                           ^-                                 DW_OP_consts226##                             ^---                             operands[0] (SLEB128) +0x1234227##                                  ^-                          DW_LLE_end_of_list228# DWARF32-BE-NEXT: )229 230## c) Generate and verify a little endian DWARF64 .debug_loclists section in a 64-bit object file.231 232# RUN: yaml2obj --docnum=2 -DENDIAN=ELFDATA2LSB %s -o %t2.dwarf64.le.o233# RUN: llvm-readobj --sections --section-data %t2.dwarf64.le.o | \234# RUN:   FileCheck -DSIZE=47 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF64-LE235 236# DWARF64-LE-NEXT: SectionData (237# DWARF64-LE-NEXT:   0000: FFFFFFFF 23000000 00000000 05000800  |....#...........|238##                         ^-------------------------           unit_length (12-byte)239##                                                    ^---      version (2-byte)240##                                                        ^-    address_size (1-byte)241##                                                          ^-  segment_selector_size (1-byte)242# DWARF64-LE-NEXT:   0010: 02000000 10000000 00000000 1A000000  |................|243##                         ^-------                             offset_entry_count (4-byte)244##                                  ^----------------           offsets[0] (8-byte)245##                                                    ^-------  offsets[1] (8-byte)246# DWARF64-LE-NEXT:   0020: 00000000 02B424A1 86010311 B42400    |......$......$.|247##                         --------248##                                  ^-                          DW_LLE_startx_endx249##                                    ^---                      operands[0] (ULEB128) 0x1234250##                                        ^------               operands[1] (ULEB128) 0x4321251##                                               ^-             location descriptions length (ULEB128) 0x03252##                                                 ^-           DW_OP_consts253##                                                    ^---      operands[0] (SLEB128) +0x1234254##                                                        ^-    DW_LLE_end_of_list255# DWARF64-LE-NEXT: )256 257--- !ELF258FileHeader:259  Class: ELFCLASS64260  Data:  [[ENDIAN]]261  Type:  ET_EXEC262DWARF:263  debug_loclists:264    - Format:  DWARF64265      Lists:266        - Entries:267            - Operator: DW_LLE_startx_endx268              Values:   [ 0x1234, 0x4321 ]269              Descriptions:270                - Operator: DW_OP_consts271                  Values:   [ 0x1234 ]272        - Entries:273            - Operator: DW_LLE_end_of_list274 275## d) Generate and verify a big endian DWARF64 .debug_loclists section in a 64-bit object file.276 277# RUN: yaml2obj --docnum=2 -DENDIAN=ELFDATA2MSB %s -o %t2.dwarf64.be.o278# RUN: llvm-readobj --sections --section-data %t2.dwarf64.be.o | \279# RUN:   FileCheck -DSIZE=47 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF64-BE280 281# DWARF64-BE-NEXT: SectionData (282# DWARF64-BE-NEXT:   0000: FFFFFFFF 00000000 00000023 00050800  |...........#....|283##                         ^-------------------------           unit_length (12-byte)284##                                                    ^---      version (2-byte)285##                                                        ^-    address_size (1-byte)286##                                                          ^-  segment_selector_size (1-byte)287# DWARF64-BE-NEXT:   0010: 00000002 00000000 00000010 00000000  |................|288##                         ^-------                             offset_entry_count (4-byte)289##                                  ^----------------           offsets[0] (8-byte)290##                                                    ^-------  offsets[1] (8-byte)291# DWARF64-BE-NEXT:   0020: 0000001A 02B424A1 86010311 B42400    |......$......$.|292##                         --------293##                                  ^-                          DW_LLE_startx_endx294##                                    ^---                      operands[0] (ULEB128) 0x1234295##                                        ^------               operands[1] (ULEB128) 0x4321296##                                               ^-             location descriptions length (ULEB128) 0x03297##                                                 ^-           DW_OP_consts298##                                                    ^---      operands[0] (SLEB128) +0x1234299##                                                        ^-    DW_LLE_end_of_list300# DWARF64-BE-NEXT: )301 302## e) Test that the length, version, segment_selector_size, address_size, offset_entry_count,303## offsets and location descriptions length fields can be specified manually.304 305# RUN: yaml2obj --docnum=3 %s -o %t3.o306# RUN: llvm-readelf --hex-dump=.debug_loclists %t3.o | \307# RUN:   FileCheck %s --check-prefix=OVERWRITE308 309#      OVERWRITE: Hex dump of section '.debug_loclists':310# OVERWRITE-NEXT: 0x00000000 34120000 06000303 04000000 01000000 4...............311##                           ^-------                            unit_length (4-byte) 0x1234312##                                    ^---                       version (2-byte) 0x06313##                                        ^-                     address_size (1-byte) 0x03314##                                          ^-                   segment_selector_size (1-byte) 0x03315##                                             ^-------          offset_entry_count (4-byte) 0x04316##                                                      ^------- offsets[0] (4-byte) 0x01317# OVERWRITE-NEXT: 0x00000010 02b424a1 8601a186 019f00            ..$........318##                           ^-                                  DW_LLE_startx_endx319##                             ^---                              operands[0] (ULEB128) 0x1234320##                                 ^------                       operands[1] (ULEB128) 0x4321321##                                        ^------                location descriptions length (ULEB128) 0x4321322##                                               ^-              DW_OP_stack_value323##                                                 ^-            DW_LLE_end_of_list324 325--- !ELF326FileHeader:327  Class: ELFCLASS64328  Data:  ELFDATA2LSB329  Type:  ET_EXEC330DWARF:331  debug_loclists:332    - Length:              0x1234333      Version:             6334      AddressSize:         3335      SegmentSelectorSize: 3336      OffsetEntryCount:    4337      Offsets:             [ 0x01 ]338      Lists:339        - Entries:340            - Operator:           DW_LLE_startx_endx341              Values:             [ 0x1234, 0x4321 ]342              DescriptionsLength: 0x4321343              Descriptions:344                - Operator: DW_OP_stack_value345        - Entries:346            - Operator: DW_LLE_end_of_list347 348## f) Test that location descriptions can be omitted from the YAML description.349 350# RUN: yaml2obj --docnum=4 %s -o %t4.o351# RUN: llvm-readelf --hex-dump=.debug_loclists %t4.o | \352# RUN:   FileCheck %s --check-prefix=OMIT-DESCRIPTIONS353 354#      OMIT-DESCRIPTIONS: Hex dump of section '.debug_loclists':355# OMIT-DESCRIPTIONS-NEXT: 0x00000000 42000000 05000800 01000000 04000000 B...............356# OMIT-DESCRIPTIONS-NEXT: 0x00000010 02b424a1 86010003 b424a186 010004b4 ..$......$......357##                                  ^-                                  DW_LLE_startx_endx358##                                    ^---                              operands[0] (ULEB128) 0x1234359##                                        ^------                       operands[1] (ULEB128) 0x4321360##                                               ^-                     location descriptions length (ULEB128) 0x00361##                                                 ^-                   DW_LLE_startx_length362##                                                    ^---              operands[0] (ULEB128) 0x1234363##                                                        ^------       operands[1] (ULEB128) 0x4321364##                                                               ^-     location descriptions length (ULEB128) 0x00365##                                                                 ^-   DW_LLE_offset_pair366##                                                                   ^- operands[0] (ULEB128) 0x1234367# OMIT-DESCRIPTIONS-NEXT: 0x00000020 24a18601 00050007 34120000 00000000 $.......4.......368##                                  --369##                                    ^-----                            operands[1] (ULEB128) 0x4321370##                                           ^-                         location descriptions length (ULEB128) 0x00371##                                             ^-                       DW_LLE_default_location372##                                               ^-                     location descriptions length (ULEB128) 0x00373##                                                 ^-                   DW_LLE_start_end374##                                                    ^---------------- operands[0] (8-byte)375# OMIT-DESCRIPTIONS-NEXT: 0x00000030 21430000 00000000 00083412 00000000 !C........4.....376##                                  ^----------------                   operands[1] (8-byte)377##                                                    ^-                location descriptions length (ULEB128) 0x00378##                                                      ^-              DW_LLE_start_length379##                                                        ^------------ operands[0] (8-byte)380# OMIT-DESCRIPTIONS-NEXT: 0x00000040 0000a186 0100                       ......381##                                  ----382##                                      ^------                         operands[1] (ULEB128) 0x4321383##                                             ^-                       location descriptions length (ULEB128) 0x00384 385--- !ELF386FileHeader:387  Class: ELFCLASS64388  Data:  ELFDATA2LSB389  Type:  ET_EXEC390DWARF:391  debug_loclists:392    - Lists:393        - Entries:394            - Operator: DW_LLE_startx_endx395              Values:   [ 0x1234, 0x4321 ]396            - Operator: DW_LLE_startx_length397              Values:   [ 0x1234, 0x4321 ]398            - Operator: DW_LLE_offset_pair399              Values:   [ 0x1234, 0x4321 ]400            - Operator: DW_LLE_default_location401            - Operator: DW_LLE_start_end402              Values:   [ 0x1234, 0x4321 ]403            - Operator: DW_LLE_start_length404              Values:   [ 0x1234, 0x4321 ]405 406## g) Test that the default value of the address_size field in a 32-bit object file is 4.407 408# RUN: yaml2obj --docnum=5 %s -o %t5.o409# RUN: llvm-readelf --hex-dump=.debug_loclists %t5.o | \410# RUN:   FileCheck %s --check-prefix=ADDRSIZE32411 412#      ADDRSIZE32: Hex dump of section '.debug_loclists':413# ADDRSIZE32-NEXT: 0x00000000 24000000 05000400 01000000 04000000 $...............414##                                         ^-                     address_size (1-byte) 0x04415# ADDRSIZE32-NEXT: 0x00000010 06341200 00073412 00002143 00000008 .4....4...!C....416##                            ^-                                  DW_LLE_base_address417##                              ^--------                         operands[0] (4-byte)418##                                       ^-                       DW_LLE_start_end419##                                         ^--------              operands[0] (4-byte)420##                                                  ^--------     operands[1] (4-byte)421##                                                           ^-   counted location description422##                                                             ^- DW_LLE_start_length423# ADDRSIZE32-NEXT: 0x00000020 34120000 a1860100                   4.......424##                            ^-------                            operands[0] (4-byte)425##                                     ^-----                     operands[1] (ULEB128) 0x4321426##                                           ^-                   counted location description427 428--- !ELF429FileHeader:430  Class: ELFCLASS32431  Data:  ELFDATA2LSB432  Type:  ET_EXEC433DWARF:434  debug_loclists:435    - Lists:436        - Entries:437            - Operator: DW_LLE_base_address438              Values:   [ 0x1234 ]439            - Operator: DW_LLE_start_end440              Values:   [ 0x1234, 0x4321 ]441            - Operator: DW_LLE_start_length442              Values:   [ 0x1234, 0x4321 ]443 444## h) Test that the address_size field can be specified manually and the size of445## corresponding operands will be changed accordingly.446 447# RUN: yaml2obj --docnum=6 %s -o %t6.o448# RUN: llvm-readelf --hex-dump=.debug_loclists %t6.o | \449# RUN:   FileCheck %s --check-prefix=ADDRSIZE32450 451--- !ELF452FileHeader:453  Class: ELFCLASS64454  Data:  ELFDATA2LSB455  Type:  ET_EXEC456DWARF:457  debug_loclists:458    - AddressSize: 4459      Lists:460        - Entries:461            - Operator: DW_LLE_base_address462              Values:   [ 0x1234 ]463            - Operator: DW_LLE_start_end464              Values:   [ 0x1234, 0x4321 ]465            - Operator: DW_LLE_start_length466              Values:   [ 0x1234, 0x4321 ]467 468## i) Test that yaml2obj emits an error message if we try to assign an invalid value to469## 'AddressSize' when there is an entry whose operands contain address.470 471# RUN: not yaml2obj -DOPERATOR=base_address -DVALUES=[0x01] --docnum=7 %s 2>&1 | \472# RUN:   FileCheck -DOPERATOR=base_address %s --check-prefix=INVALID-ADDRSIZE473 474# RUN: not yaml2obj -DOPERATOR=start_end -DVALUES=[0x01,0x02] --docnum=7 %s 2>&1 | \475# RUN:   FileCheck -DOPERATOR=start_end %s --check-prefix=INVALID-ADDRSIZE476 477# RUN: not yaml2obj -DOPERATOR=start_length -DVALUES=[0x01,0x02] --docnum=7 %s 2>&1 | \478# RUN:   FileCheck -DOPERATOR=start_length %s --check-prefix=INVALID-ADDRSIZE479 480# INVALID-ADDRSIZE: yaml2obj: error: unable to write address for the operator DW_LLE_[[OPERATOR]]: invalid integer write size: 3481 482--- !ELF483FileHeader:484  Class: ELFCLASS64485  Data:  ELFDATA2LSB486  Type:  ET_EXEC487DWARF:488  debug_loclists:489    - AddressSize: 3490      Lists:491        - Entries:492            - Operator: DW_LLE_[[OPERATOR]]493              Values:   [[VALUES]]494 495## j) Test that yaml2obj emits an error message if we specify invalid numbers of operands496## for a location list encoding.497 498# RUN: not yaml2obj -DOPERATOR=end_of_list -DVALUES=[0x01] --docnum=8 %s 2>&1 | \499# RUN:   FileCheck -DOPERATOR=end_of_list -DACTUAL=1 -DEXPECTED=0 %s --check-prefix=INVALID-LLE-OPERANDS500 501# RUN: not yaml2obj -DOPERATOR=base_addressx -DVALUES=[] --docnum=8 %s 2>&1 | \502# RUN:   FileCheck -DOPERATOR=base_addressx -DACTUAL=0 -DEXPECTED=1 %s --check-prefix=INVALID-LLE-OPERANDS503 504# RUN: not yaml2obj -DOPERATOR=startx_endx -DVALUES=[0x01] --docnum=8 %s 2>&1 | \505# RUN:   FileCheck -DOPERATOR=startx_endx -DACTUAL=1 -DEXPECTED=2 %s --check-prefix=INVALID-LLE-OPERANDS506 507# RUN: not yaml2obj -DOPERATOR=startx_length -DVALUES=[0x01] --docnum=8 %s 2>&1 | \508# RUN:   FileCheck -DOPERATOR=startx_length -DACTUAL=1 -DEXPECTED=2 %s --check-prefix=INVALID-LLE-OPERANDS509 510# RUN: not yaml2obj -DOPERATOR=offset_pair -DVALUES=[] --docnum=8 %s 2>&1 | \511# RUN:   FileCheck -DOPERATOR=offset_pair -DACTUAL=0 -DEXPECTED=2 %s --check-prefix=INVALID-LLE-OPERANDS512 513# RUN: not yaml2obj -DOPERATOR=default_location -DVALUES=[0x01] --docnum=8 %s 2>&1 | \514# RUN:   FileCheck -DOPERATOR=default_location -DACTUAL=1 -DEXPECTED=0 %s --check-prefix=INVALID-LLE-OPERANDS515 516# RUN: not yaml2obj -DOPERATOR=base_address -DVALUES=[0x01,0x02] --docnum=8 %s 2>&1 | \517# RUN:   FileCheck -DOPERATOR=base_address -DACTUAL=2 -DEXPECTED=1 %s --check-prefix=INVALID-LLE-OPERANDS518 519# RUN: not yaml2obj -DOPERATOR=start_end -DVALUES=[0x01,0x02,0x03] --docnum=8 %s 2>&1 | \520# RUN:   FileCheck -DOPERATOR=start_end -DACTUAL=3 -DEXPECTED=2 %s --check-prefix=INVALID-LLE-OPERANDS521 522# RUN: not yaml2obj -DOPERATOR=start_length -DVALUES=[0x01] --docnum=8 %s 2>&1 | \523# RUN:   FileCheck -DOPERATOR=start_length -DACTUAL=1 -DEXPECTED=2 %s --check-prefix=INVALID-LLE-OPERANDS524 525# INVALID-LLE-OPERANDS: yaml2obj: error: invalid number ([[ACTUAL]]) of operands for the operator: DW_LLE_[[OPERATOR]], [[EXPECTED]] expected526 527--- !ELF528FileHeader:529  Class: ELFCLASS64530  Data:  ELFDATA2LSB531  Type:  ET_EXEC532DWARF:533  debug_loclists:534    - Lists:535        - Entries:536            - Operator: DW_LLE_[[OPERATOR]]537              Values:   [[VALUES]]538 539## k) Test that yaml2obj emits an error message if we specify invalid numbers of operands540## for a DWARF expression operator.541 542# RUN: not yaml2obj --docnum=9 -DOPERATOR=consts -DVALUES=[0x01,0x02] %s 2>&1 | \543# RUN:   FileCheck -DACTUAL=2 -DEXPECTED=1 -DOPERATOR=consts %s --check-prefix=INVALID-OP-OPERANDS544 545# RUN: not yaml2obj --docnum=9 -DOPERATOR=stack_value -DVALUES=[0x01] %s 2>&1 | \546# RUN:   FileCheck -DACTUAL=1 -DEXPECTED=0 -DOPERATOR=stack_value %s --check-prefix=INVALID-OP-OPERANDS547 548# INVALID-OP-OPERANDS: yaml2obj: error: invalid number ([[ACTUAL]]) of operands for the operator: DW_OP_[[OPERATOR]], [[EXPECTED]] expected549 550--- !ELF551FileHeader:552  Class: ELFCLASS64553  Data:  ELFDATA2LSB554  Type:  ET_EXEC555DWARF:556  debug_loclists:557    - Lists:558        - Entries:559            - Operator: DW_LLE_startx_endx560              Values:   [ 0x01, 0x02 ]561              Descriptions:562                - Operator: DW_OP_[[OPERATOR]]563                  Values:   [[VALUES]]564 565## l) Test that an empty list is allowed for a location list table.566 567# RUN: yaml2obj --docnum=10 %s -o %t10.o568# RUN: llvm-readelf --hex-dump=.debug_loclists %t10.o | \569# RUN:   FileCheck %s --check-prefix=EMPTY-LIST570 571#      EMPTY-LIST: Hex dump of section '.debug_loclists':572# EMPTY-LIST-NEXT: 0x00000000 08000000 05000800 00000000 ............573##                            ^-------                   unit_length (4-byte)574##                                     ^---              version (2-byte)575##                                         ^-            address_size (1-byte)576##                                           ^-          segment_selector_size (1-byte)577##                                              ^------- offset_entry_count (4-byte)578 579--- !ELF580FileHeader:581  Class: ELFCLASS64582  Data:  ELFDATA2LSB583  Type:  ET_EXEC584DWARF:585  debug_loclists:586    - Lists: []587 588## m) Generate the .debug_loclists section from raw section content.589 590# RUN: yaml2obj --docnum=11 %s -o %t11.o591# RUN: llvm-readobj --sections --section-data %t11.o | \592# RUN:   FileCheck %s -DSIZE=3 -DADDRALIGN=0 --check-prefixes=SHDR,ARBITRARY-CONTENT593 594#      ARBITRARY-CONTENT: SectionData (595# ARBITRARY-CONTENT-NEXT:   0000: 112233596# ARBITRARY-CONTENT-NEXT: )597 598--- !ELF599FileHeader:600  Class: ELFCLASS64601  Data:  ELFDATA2LSB602  Type:  ET_EXEC603Sections:604  - Name:    .debug_loclists605    Type:    SHT_PROGBITS606    Content: "112233"607 608## n) Generate the .debug_loclists section when the "Size" is specified.609 610# RUN: yaml2obj --docnum=12 %s -o %t12.o611# RUN: llvm-readelf --hex-dump=.debug_loclists %t12.o | \612# RUN:   FileCheck %s --check-prefix=SIZE613 614#       SIZE: Hex dump of section '.debug_loclists':615#  SIZE-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................616# SIZE-EMPTY:617 618--- !ELF619FileHeader:620  Class: ELFCLASS64621  Data:  ELFDATA2LSB622  Type:  ET_EXEC623Sections:624  - Name: .debug_loclists625    Type: SHT_PROGBITS626    Size: 0x10627 628## o) Test that yaml2obj emits an error message when both the "Size" and the629## "debug_loclists" entry are specified at the same time.630 631# RUN: not yaml2obj --docnum=13 %s 2>&1 | FileCheck %s --check-prefix=ERROR632 633# ERROR: yaml2obj: error: cannot specify section '.debug_loclists' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time634 635--- !ELF636FileHeader:637  Class: ELFCLASS64638  Data:  ELFDATA2LSB639  Type:  ET_EXEC640Sections:641  - Name: .debug_loclists642    Type: SHT_PROGBITS643    Size: 0x10644DWARF:645  debug_loclists:646    - Lists: []647 648## p) Test that yaml2obj emits an error message when both the "Content" and the649## "debug_loclists" entry are specified at the same time.650 651# RUN: not yaml2obj --docnum=14 %s 2>&1 | FileCheck %s --check-prefix=ERROR652 653--- !ELF654FileHeader:655  Class: ELFCLASS64656  Data:  ELFDATA2LSB657  Type:  ET_EXEC658Sections:659  - Name:    .debug_loclists660    Type:    SHT_PROGBITS661    Content: "00"662DWARF:663  debug_loclists:664    - Lists: []665 666## q) Test that all the properties can be overridden by the section header when667## the "debug_loclists" entry doesn't exist.668 669# RUN: yaml2obj --docnum=15 %s -o %t15.o670# RUN: llvm-readelf --sections %t15.o | FileCheck %s --check-prefix=OVERRIDDEN671 672#      OVERRIDDEN: [Nr] Name            Type   Address          Off    Size   ES Flg Lk Inf Al673#      OVERRIDDEN: [ 1] .debug_loclists STRTAB 0000000000002020 000050 00000c 01   A  2   1  2674# OVERRIDDEN-NEXT: [ 2] .sec            STRTAB 0000000000000000 00005c 000000 00      0   0  0675 676--- !ELF677FileHeader:678  Class: ELFCLASS64679  Data:  ELFDATA2LSB680  Type:  ET_EXEC681Sections:682  - Name:         .debug_loclists683    Type:         SHT_STRTAB  ## SHT_PROGBITS by default.684    Flags:        [SHF_ALLOC] ## 0 by default.685    Link:         .sec        ## 0 by default.686    EntSize:      1           ## 0 by default.687    Info:         1           ## 0 by default.688    AddressAlign: 2           ## 0 by default.689    Address:      0x2020      ## 0x00 by default.690    Offset:       0x50        ## 0x40 for the first section.691    Size:         0x0c        ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".692  - Name:         .sec        ## Linked by .debug_loclists.693    Type:         SHT_STRTAB694 695## r) Test that all the properties can be overridden by the section header when696## the "debug_loclists" entry exists.697 698# RUN: yaml2obj --docnum=16 %s -o %t16.o699# RUN: llvm-readelf --sections %t16.o | FileCheck %s --check-prefix=OVERRIDDEN700 701--- !ELF702FileHeader:703  Class: ELFCLASS64704  Data:  ELFDATA2LSB705  Type:  ET_EXEC706Sections:707  - Name:         .debug_loclists708    Type:         SHT_STRTAB  ## SHT_PROGBITS by default.709    Flags:        [SHF_ALLOC] ## 0 by default.710    Link:         .sec        ## 0 by default.711    EntSize:      1           ## 0 by default.712    Info:         1           ## 0 by default.713    AddressAlign: 2           ## 1 by default.714    Address:      0x2020      ## 0x00 by default.715    Offset:       0x50        ## 0x40 for the first section.716  - Name:         .sec        ## Linked by .debug_loclists.717    Type:         SHT_STRTAB718DWARF:719  debug_loclists:720    - Lists: []721 722## s) Test that the .debug_loclists section header is emitted if the "debug_loclists"723## entry is empty.724 725# RUN: yaml2obj --docnum=17 %s -o %t17.o726# RUN: llvm-readobj --sections --section-data %t17.o | \727# RUN:   FileCheck -DSIZE=0 -DADDRALIGN=1 %s --check-prefixes=SHDR,EMPTY-CONTENT728 729# EMPTY-CONTENT-NEXT: SectionData (730# EMPTY-CONTENT-NEXT: )731 732--- !ELF733FileHeader:734  Class: ELFCLASS64735  Data:  ELFDATA2LSB736  Type:  ET_EXEC737DWARF:738  debug_loclists: []739 740## t) Test that yaml2obj emits an error message if we use an unimplemented DWARF expression741## operator.742 743# RUN: not yaml2obj --docnum=18 -DOP=0x01 %s 2>&1 | \744# RUN:   FileCheck -DOP=0x1 %s --check-prefix=UNSUPPORTED-OP745 746# UNSUPPORTED-OP: yaml2obj: error: DWARF expression: [[OP]] is not supported747 748# RUN: not yaml2obj --docnum=18 -DOP=DW_OP_entry_value %s 2>&1 | \749# RUN:   FileCheck -DOP=DW_OP_entry_value %s --check-prefix=UNSUPPORTED-OP750 751 752--- !ELF753FileHeader:754  Class: ELFCLASS64755  Data:  ELFDATA2LSB756  Type:  ET_EXEC757DWARF:758  debug_loclists:759    - Lists:760        - Entries:761            - Operator: DW_LLE_default_location762              Descriptions:763                - Operator: [[OP]]764 765## u) Test that we are able to generate a location list via raw binary data.766 767# RUN: yaml2obj --docnum=19 %s -o %t19.o768# RUN: llvm-readelf --hex-dump=.debug_loclists %t19.o | \769# RUN:   FileCheck %s --check-prefix=CUSTOM-LIST770 771#      CUSTOM-LIST: Hex dump of section '.debug_loclists':772# CUSTOM-LIST-NEXT: 0x00000000 2a000000 05000800 03000000 0c000000 *...............773##                             ^-------                            unit_length (4-byte)774##                                      ^---                       version (2-byte)775##                                          ^-                     address_size (1-byte)776##                                            ^-                   segment_selector_size (1-byte)777##                                               ^-------          offset_entry_count (4-byte)778##                                                        ^------- offsets[0] (4-byte)779# CUSTOM-LIST-NEXT: 0x00000010 12000000 1a000000 02b424b4 24001234 ..........$.$..4780##                             ^-------                            offsets[1] (4-byte)781##                                      ^-------                   offsets[2] (4-byte)782##                                               ^-                DW_LLE_startx_endx783##                                                 ^---            operands[0] (ULEB128) 0x1234784##                                                     ^----       operands[1] (ULEB128) 0x1234785##                                                          ^-     location descriptions length (ULEB128) 0x00786##                                                            ^--- custom list content787# CUSTOM-LIST-NEXT: 0x00000020 567890ab cdefabcd ef123456 7890     Vx........4Vx.788##                             -------------789##                                          ^-----------------     custom list content790 791--- !ELF792FileHeader:793  Class: ELFCLASS64794  Data:  ELFDATA2LSB795  Type:  ET_EXEC796DWARF:797  debug_loclists:798    - Lists:799        - Entries:800            - Operator: DW_LLE_startx_endx801              Values:   [ 0x1234, 0x1234 ]802        - Content: '1234567890abcdef'803        - Content: 'abcdef1234567890'804 805## v) Test that yaml2obj emits an error message when 'Content' and 'Entries' are specified806## at the same time.807 808# RUN: not yaml2obj --docnum=20 %s 2>&1 | FileCheck %s --check-prefix=ERR809 810#      ERR: YAML:{{.*}}: error: Entries and Content can't be used together811# ERR-NEXT:         - Entries: []812# ERR-NEXT:           ^813 814--- !ELF815FileHeader:816  Class: ELFCLASS64817  Data:  ELFDATA2LSB818  Type:  ET_EXEC819DWARF:820  debug_loclists:821    - Lists:822        - Entries: []823          Content: ''824 825## w) Test that when the "OffsetEntryCount" is specified to be 0 and "Offsets" is not specified,826## the offsets array is not emitted.827 828# RUN: yaml2obj --docnum=21 -DOFFSETENTRIES=0 %s -o %t21.o829# RUN: llvm-readelf --hex-dump=.debug_loclists %t21.o | \830# RUN:   FileCheck %s --check-prefix=NO-OFFSETS831 832#      NO-OFFSETS: Hex dump of section '.debug_loclists':833# NO-OFFSETS-NEXT: 0x00000000 0e000000 05000800 00000000 01010201 ................834##                            ^-------                            unit_length (4-byte)835##                                     ^---                       version (2-byte)836##                                         ^-                     address_size (1-byte)837##                                           ^-                   segment_selector_size (1-byte)838##                                              ^-------          offset_entry_count (4-byte)839##                                                       ^-       DW_LLE_base_addressx840##                                                         ^-     operands[0] (ULEB128) 0x01841##                                                           ^-   DW_LLE_startx_endx842##                                                             ^- operands[0] (ULEB128) 0x01843# NO-OFFSETS-NEXT: 0x00000010 0200                                ..844##                            ^-                                  operands[1] (ULEB128) 0x02845##                              ^-                                location descriptions length (ULEB128) 0x00846 847--- !ELF848FileHeader:849  Class: ELFCLASS64850  Data:  ELFDATA2LSB851  Type:  ET_EXEC852DWARF:853  debug_loclists:854    - OffsetEntryCount: [[OFFSETENTRIES=<none>]]855      Offsets:          [[OFFSETS=<none>]]856      Lists:857        - Entries:858            - Operator: DW_LLE_base_addressx859              Values:   [ 0x01 ]860            - Operator: DW_LLE_startx_endx861              Values:   [ 0x01, 0x02 ]862 863## x) Test that when the "Offsets" entry is specified to be empty and the "OffsetEntryCount" is not specified,864## the offsets array will be omitted.865 866# RUN: yaml2obj --docnum=21 -DOFFSETS=[] %s -o %t22.o867# RUN: llvm-readelf --hex-dump=.debug_loclists %t22.o | \868# RUN:   FileCheck %s --check-prefix=NO-OFFSETS869 870## y) Test that if "Offsets" is specified, the offsets array will be emitted accordingly, even when871## the "OffsetEntryCount" is specified to be 0.872 873# RUN: yaml2obj --docnum=21 -DOFFSETENTRIES=0 -DOFFSETS=[0x01,0x02,0x03] %s -o %t23.o874# RUN: llvm-readelf --hex-dump=.debug_loclists %t23.o | \875# RUN:   FileCheck %s --check-prefix=OFFSETS876 877#      OFFSETS: Hex dump of section '.debug_loclists':878# OFFSETS-NEXT: 0x00000000 0e000000 05000800 00000000 01000000 ................879##                         ^-------                            unit_length (4-byte)880##                                  ^---                       version (2-byte)881##                                      ^-                     address_size (1-byte)882##                                        ^-                   segment_selector_size (1-byte)883##                                           ^-------          offset_entry_count (4-byte)884##                                                    ^------- offsets[0] (4-byte)885# OFFSETS-NEXT: 0x00000010 02000000 03000000 01010201 0200     ..............886##                         ^-------                            offsets[1] (4-byte)887##                                  ^-------                   offsets[2] (4-byte)888##                                           ^-                DW_LLE_base_addressx889##                                             ^-              operands[0] (ULEB128) 0x01890##                                               ^-            DW_LLE_startx_endx891##                                                 ^-          operands[0] (ULEB128) 0x01892##                                                    ^-       operands[1] (ULEB128) 0x02893##                                                      ^-     location descriptions length (ULEB128) 0x00894