brintos

brintos / llvm-project-archived public Read only

0
0
Text · 32.7 KiB · c99a092 Raw
717 lines · yaml
1## Test that yaml2obj emits a .debug_rnglists section when requested.2 3## a) Generate and verify a little endian DWARF32 .debug_rnglists section in a 64-bit object file.4 5# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.le.dwarf32.o6# RUN: llvm-readobj --sections --section-data %t1.le.dwarf32.o | \7# RUN:   FileCheck -DSIZE=99 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-LE8 9#            SHDR: Index: 110#       SHDR-NEXT: Name: .debug_rnglists (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: 24000000 05000800 02000000 08000000  |$...............|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: 11000000 01B42402 B424B424 0003B424  |......$..$.$...$|30##                         ^-------                             offsets[1] (4-byte)31##                                  ^-                          DW_RLE_base_addressx (1-byte)32##                                    ^---                      operands[0] (ULEB128) 0x123433##                                        ^-                    DW_RLE_startx_endx (1-byte)34##                                           ^---               operands[0] (ULEB128) 0x123435##                                               ^---           operands[1] (ULEB128) 0x123436##                                                    ^-        DW_RLE_end_of_list (1-byte)37##                                                      ^-      DW_RLE_startx_length (1-byte)38##                                                        ^---  operands[0] (ULEB128) 0x123439# DWARF32-LE-NEXT:   0020: B42404B4 24B42400 37000000 05000800  |.$..$.$.7.......|40##                         ^---                                 operands[1] (ULEB128) 0x123441##                             ^-                               DW_RLE_offset_pair (1-byte)42##                               ^----                          operands[0] (ULEB128) 0x123443##                                    ^---                      operands[1] (ULEB128) 0x123444##                                        ^-                    DW_RLE_end_of_list (1-byte)45##                                           ^-------           unit_length (4-byte)46##                                                    ^---      version (2-byte)47##                                                        ^-    address_size (1-byte)48##                                                          ^-  segment_selector_size (1-byte)49# DWARF32-LE-NEXT:   0030: 02000000 08000000 23000000 05341200  |........#....4..|50##                         ^-------                             offset_entry_count (4-byte)51##                                  ^-------                    offsets[0] (4-byte)52##                                           ^-------           offsets[1] (4-byte)53##                                                    ^-        DW_RLE_base_address (1-byte)54##                                                      ^-----  operands[0] (8-byte)55# DWARF32-LE-NEXT:   0040: 00000000 00063412 00000000 00003412  |......4.......4.|56##                         -----------57##                                    ^-                        DW_RLE_start_end (1-byte)58##                                      ^-----------------      operands[0] (8-byte)59##                                                        ^---  operands[1] (8-byte)60# DWARF32-LE-NEXT:   0050: 00000000 00000007 34120000 00000000  |........4.......|61##                         -------------62##                                      ^-                      DW_RLE_end_of_list (1-byte)63##                                        ^-                    DW_RLE_start_length (1-byte)64##                                           ^----------------  operands[0] (8-byte)65# DWARF32-LE-NEXT:   0060: B42400                               |.$.|66##                         ^---                                 operands[1] (ULEB128) 0x123467##                             ^-                               DW_RLE_end_of_list (1-byte)68# DWARF32-LE-NEXT: )69 70--- !ELF71FileHeader:72  Class: ELFCLASS6473  Data:  [[ENDIAN]]74  Type:  ET_EXEC75DWARF:76  debug_rnglists:77    - Lists:78        - Entries:79            - Operator: DW_RLE_base_addressx80              Values:   [ 0x1234 ]81            - Operator: DW_RLE_startx_endx82              Values:   [ 0x1234, 0x1234 ]83            - Operator: DW_RLE_end_of_list84        - Entries:85            - Operator: DW_RLE_startx_length86              Values:   [ 0x1234, 0x1234 ]87            - Operator: DW_RLE_offset_pair88              Values:   [ 0x1234, 0x1234 ]89            - Operator: DW_RLE_end_of_list90    - Lists:91        - Entries:92            - Operator: DW_RLE_base_address93              Values:   [ 0x1234 ]94            - Operator: DW_RLE_start_end95              Values:   [ 0x1234, 0x1234 ]96            - Operator: DW_RLE_end_of_list97        - Entries:98            - Operator: DW_RLE_start_length99              Values:   [ 0x1234, 0x1234 ]100            - Operator: DW_RLE_end_of_list101 102## b) Generate and verify a big endian DWARF32 .debug_rnglists section in a 64-bit object file.103 104# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.dwarf32.o105# RUN: llvm-readobj --sections --section-data %t1.be.dwarf32.o | \106# RUN:   FileCheck -DSIZE=99 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-BE107 108# DWARF32-BE-NEXT: SectionData (109# DWARF32-BE-NEXT:   0000: 00000024 00050800 00000002 00000008  |...$............|110##                         ^-------                             unit_length (4-byte)111##                                  ^---                        version (2-byte)112##                                      ^-                      address_size (1-byte)113##                                        ^-                    segment_selector_size (1-byte)114##                                           ^-------           offset_entry_count (4-byte)115##                                                    ^-------  offsets[0] (4-byte)116# DWARF32-BE-NEXT:   0010: 00000011 01B42402 B424B424 0003B424  |......$..$.$...$|117##                         ^-------                             offsets[1] (4-byte)118##                                  ^-                          DW_RLE_base_addressx (1-byte)119##                                    ^---                      operands[0] (ULEB128) 0x1234120##                                        ^-                    DW_RLE_startx_endx (1-byte)121##                                           ^---               operands[0] (ULEB128) 0x1234122##                                               ^---           operands[1] (ULEB128) 0x1234123##                                                    ^-        DW_RLE_end_of_list (1-byte)124##                                                      ^-      DW_RLE_startx_length (1-byte)125##                                                        ^---  operands[0] (ULEB128) 0x1234126# DWARF32-BE-NEXT:   0020: B42404B4 24B42400 00000037 00050800  |.$..$.$....7....|127##                         ^---                                 operands[1] (ULEB128) 0x1234128##                             ^-                               DW_RLE_offset_pair (1-byte)129##                               ^----                          operands[0] (ULEB128) 0x1234130##                                    ^---                      operands[1] (ULEB128) 0x1234131##                                        ^-                    DW_RLE_end_of_list (1-byte)132##                                           ^-------           unit_length (4-byte)133##                                                    ^---      version (2-byte)134##                                                        ^-    address_size (1-byte)135##                                                          ^-  segment_selector_size (1-byte)136# DWARF32-BE-NEXT:   0030: 00000002 00000008 00000023 05000000  |...........#....|137##                         ^-------                             offset_entry_count (4-byte)138##                                  ^-------                    offsets[0] (4-byte)139##                                           ^-------           offsets[1] (4-byte)140##                                                    ^-        DW_RLE_base_address (1-byte)141##                                                      ^-----  operands[0] (8-byte)142# DWARF32-BE-NEXT:   0040: 00000012 34060000 00000000 12340000  |....4........4..|143##                         -----------144##                                    ^-                        DW_RLE_start_end (1-byte)145##                                      ^-----------------      operands[0] (8-byte)146##                                                        ^---  operands[1] (8-byte)147# DWARF32-BE-NEXT:   0050: 00000000 12340007 00000000 00001234  |.....4.........4|148##                         -------------149##                                      ^-                      DW_RLE_end_of_list (1-byte)150##                                        ^-                    DW_RLE_start_length (1-byte)151##                                           ^----------------  operands[0] (8-byte)152# DWARF32-BE-NEXT:   0060: B42400                               |.$.|153##                         ^---                                 operands[1] (ULEB128) 0x1234154##                             ^-                               DW_RLE_end_of_list (1-byte)155# DWARF32-BE-NEXT: )156 157## c) Generate and verify a little endian DWARF64 .debug_rnglists section in a 64-bit object file.158 159# RUN: yaml2obj --docnum=2 -DENDIAN=ELFDATA2LSB %s -o %t2.le.dwarf64.o160# RUN: llvm-readobj --sections --section-data %t2.le.dwarf64.o | \161# RUN:   FileCheck -DSIZE=38 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF64-LE162 163# DWARF64-LE-NEXT: SectionData (164# DWARF64-LE-NEXT:   0000: FFFFFFFF 1A000000 00000000 05000800  |................|165##                         ^-------------------------           unit_length (12-byte)166##                                                    ^---      version (2-byte)167##                                                        ^-    address_size (1-byte)168##                                                          ^-  segment_selector_size (1-byte)169# DWARF64-LE-NEXT:   0010: 02000000 10000000 00000000 11000000  |................|170##                         ^-------                             offset_entry_count (4-byte)171##                                  ^----------------           offsets[0] (8-byte)172##                                                    ^-------  offsets[1] (8-byte)173# DWARF64-LE-NEXT:   0020: 00000000 0000                        |......|174##                         --------175##                                  ^-                          DW_RLE_end_of_list (1-byte)176##                                    ^-                        DW_RLE_end_of_list (1-byte)177# DWARF64-LE-NEXT: )178 179--- !ELF180FileHeader:181  Class: ELFCLASS64182  Data:  [[ENDIAN]]183  Type:  ET_EXEC184DWARF:185  debug_rnglists:186    - Format:  DWARF64187      Lists:188        - Entries:189            - Operator: DW_RLE_end_of_list190        - Entries:191            - Operator: DW_RLE_end_of_list192 193## d) Generate and verify a big endian DWARF64 .debug_rnglists section in a 64-bit object file.194 195# RUN: yaml2obj --docnum=2 -DENDIAN=ELFDATA2MSB %s -o %t2.be.dwarf64.o196# RUN: llvm-readobj --sections --section-data %t2.be.dwarf64.o | \197# RUN:   FileCheck -DSIZE=38 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF64-BE198 199# DWARF64-BE-NEXT: SectionData (200# DWARF64-BE-NEXT:   0000: FFFFFFFF 00000000 0000001A 00050800  |................|201##                         ^-------------------------           unit_length (12-byte)202##                                                    ^---      version (2-byte)203##                                                        ^-    address_size (1-byte)204##                                                          ^-  segment_selector_size (1-byte)205# DWARF64-BE-NEXT:   0010: 00000002 00000000 00000010 00000000  |................|206##                         ^-------                             offset_entry_count (4-byte)207##                                  ^----------------           offsets[0] (8-byte)208##                                                    ^-------  offsets[1] (8-byte)209# DWARF64-BE-NEXT:   0020: 00000011 0000                        |......|210##                         --------211##                                  ^-                          DW_RLE_end_of_list (1-byte)212##                                    ^-                        DW_RLE_end_of_list (1-byte)213# DWARF64-BE-NEXT: )214 215## e) Test that the length, version, segment_selector_size, address_size, offset_entry_count216## and offsets fields can be specified manually.217 218# RUN: yaml2obj --docnum=3 %s -o %t3.o219# RUN: llvm-readelf --hex-dump=.debug_rnglists %t3.o | \220# RUN:   FileCheck %s --check-prefix=OVERWRITE221 222#      OVERWRITE: Hex dump of section '.debug_rnglists':223# OVERWRITE-NEXT: 0x00000000 34120000 06000303 04000000 01000000 4...............224##                           ^-------                            unit_length (4-byte)225##                                    ^---                       version (2-byte)226##                                        ^-                     address_size (1-byte)227##                                          ^-                   segment_selector_size (1-byte)228##                                             ^-------          offset_entry_count (4-byte)229##                                                      ^------- offsets[0] (4-byte)230# OVERWRITE-NEXT: 0x00000010 0000                                ..231 232--- !ELF233FileHeader:234  Class: ELFCLASS64235  Data:  ELFDATA2LSB236  Type:  ET_EXEC237DWARF:238  debug_rnglists:239    - Length:              0x1234240      Version:             6241      AddressSize:         3242      SegmentSelectorSize: 3243      OffsetEntryCount:    4244      Offsets:             [ 0x01 ]245      Lists:246        - Entries:247            - Operator: DW_RLE_end_of_list248        - Entries:249            - Operator: DW_RLE_end_of_list250 251## f) Test that the default value of the address_size field in a 32-bit object file is 4.252 253# RUN: yaml2obj --docnum=4 %s -o %t4.o254# RUN: llvm-readelf --hex-dump=.debug_rnglists %t4.o | \255# RUN:   FileCheck %s --check-prefix=ADDRSIZE32256 257#      ADDRSIZE32: Hex dump of section '.debug_rnglists':258# ADDRSIZE32-NEXT: 0x00000000 22000000 05000400 01000000 04000000 "...............259##                                         ^-                     address_size (1-byte)260# ADDRSIZE32-NEXT: 0x00000010 05341200 00063412 00002143 00000734 .4....4...!C...4261##                            ^-                                  DW_RLE_base_address (1-byte)262##                              ^--------                         operands[0] (4-byte)263##                                       ^-                       DW_RLE_start_end (1-byte)264##                                         ^--------              operands[0] (4-byte)265##                                                  ^--------     operands[1] (4-byte)266##                                                           ^-   DW_RLE_start_length (1-byte)267##                                                             ^- operands[0] (4-byte)268# ADDRSIZE32-NEXT: 0x00000020 120000a1 8601                       ......269##                            ------270##                                  ^------                       operands[1] (ULEB128) 0x4321271 272--- !ELF273FileHeader:274  Class: ELFCLASS32275  Data:  ELFDATA2LSB276  Type:  ET_EXEC277DWARF:278  debug_rnglists:279    - Lists:280        - Entries:281            - Operator: DW_RLE_base_address282              Values:   [ 0x1234 ]283            - Operator: DW_RLE_start_end284              Values:   [ 0x1234, 0x4321 ]285            - Operator: DW_RLE_start_length286              Values:   [ 0x1234, 0x4321 ]287 288## g) Test that the address_size field can be specified manually and the size of289## corresponding operands will be changed accordingly.290 291# RUN: yaml2obj --docnum=5 %s -o %t5.o292# RUN: llvm-readelf --hex-dump=.debug_rnglists %t5.o | \293# RUN:   FileCheck %s --check-prefix=ADDRSIZE294 295#      ADDRSIZE: Hex dump of section '.debug_rnglists':296# ADDRSIZE-NEXT: 0x00000000 22000000 05000400 01000000 04000000 "...............297##                                       ^-                     address_size 0x04298# ADDRSIZE-NEXT: 0x00000010 05341200 00063412 00002143 00000734 .4....4...!C...4299##                          ^-                                  DW_RLE_base_address300##                            ^--------                         operands[0] (4-byte)301##                                     ^-                       DW_RLE_start_end302##                                       ^--------              operands[0] (4-byte)303##                                                ^--------     operands[1] (4-byte)304##                                                         ^-   DW_RLE_start_length305##                                                           ^- operands[0] (4-byte)306# ADDRSIZE-NEXT: 0x00000020 120000b4 2400                       ....$.307##                          ------308##                                ^----                         operands[1] (ULEB128)309##                                     ^-                       DW_RLE_end_of_list310 311--- !ELF312FileHeader:313  Class: ELFCLASS64314  Data:  ELFDATA2LSB315  Type:  ET_EXEC316DWARF:317  debug_rnglists:318    - AddressSize: 4319      Lists:320        - Entries:321            - Operator: DW_RLE_base_address322              Values:   [ 0x1234 ]323            - Operator: DW_RLE_start_end324              Values:   [ 0x1234, 0x4321 ]325            - Operator: DW_RLE_start_length326              Values:   [ 0x1234, 0x1234 ]327            - Operator: DW_RLE_end_of_list328 329## h) Test that yaml2obj emits an error message if we try to assign an invalid value to330## 'AddressSize' when there is an entry whose operands contain address.331 332# RUN: not yaml2obj -DOPERATOR=base_address -DVALUES=[0x01] --docnum=6 %s 2>&1 | \333# RUN:   FileCheck -DOPERATOR=base_address %s --check-prefix=INVALID-ADDRSIZE334 335# RUN: not yaml2obj -DOPERATOR=start_end -DVALUES=[0x01,0x02] --docnum=6 %s 2>&1 | \336# RUN:   FileCheck -DOPERATOR=start_end %s --check-prefix=INVALID-ADDRSIZE337 338# RUN: not yaml2obj -DOPERATOR=start_length -DVALUES=[0x01,0x02] --docnum=6 %s 2>&1 | \339# RUN:   FileCheck -DOPERATOR=start_length %s --check-prefix=INVALID-ADDRSIZE340 341# INVALID-ADDRSIZE: yaml2obj: error: unable to write address for the operator DW_RLE_[[OPERATOR]]: invalid integer write size: 3342 343--- !ELF344FileHeader:345  Class: ELFCLASS64346  Data:  ELFDATA2LSB347  Type:  ET_EXEC348DWARF:349  debug_rnglists:350    - AddressSize: 3351      Lists:352        - Entries:353            - Operator: DW_RLE_[[OPERATOR]]354              Values:   [[VALUES]]355 356## i) Test that an invalid address_size can be used when there are no address-using operators.357 358# RUN: yaml2obj --docnum=7 %s -o %t7.o359# RUN: llvm-readelf --hex-dump=.debug_rnglists %t7.o | \360# RUN:   FileCheck %s --check-prefix=ADDRSIZE-NOERROR361 362#      ADDRSIZE-NOERROR: Hex dump of section '.debug_rnglists':363# ADDRSIZE-NOERROR-NEXT: 0x00000000 0e000000 05000300 01000000 04000000 ................364##                                               ^-                     address_size (1-byte) 0x03365# ADDRSIZE-NOERROR-NEXT: 0x00000010 0101                                ..366 367--- !ELF368FileHeader:369  Class: ELFCLASS64370  Data:  ELFDATA2LSB371  Type:  ET_EXEC372DWARF:373  debug_rnglists:374    - AddressSize: 3375      Lists:376        - Entries:377            - Operator: DW_RLE_base_addressx378              Values:   [ 0x01 ]379 380## j) Test that yaml2obj emits an error message if we specify invalid numbers of operands381## for an operator.382 383# RUN: not yaml2obj -DOPERATOR=end_of_list -DVALUES=[0x01] --docnum=8 %s 2>&1 | \384# RUN:   FileCheck -DOPERATOR=end_of_list -DACTUAL=1 -DEXPECTED=0 %s --check-prefix=INVALID-OPERANDS385 386# RUN: not yaml2obj -DOPERATOR=base_addressx -DVALUES=[] --docnum=8 %s 2>&1 | \387# RUN:   FileCheck -DOPERATOR=base_addressx -DACTUAL=0 -DEXPECTED=1 %s --check-prefix=INVALID-OPERANDS388 389# RUN: not yaml2obj -DOPERATOR=startx_endx -DVALUES=[0x01] --docnum=8 %s 2>&1 | \390# RUN:   FileCheck -DOPERATOR=startx_endx -DACTUAL=1 -DEXPECTED=2 %s --check-prefix=INVALID-OPERANDS391 392# RUN: not yaml2obj -DOPERATOR=startx_length -DVALUES=[0x01] --docnum=8 %s 2>&1 | \393# RUN:   FileCheck -DOPERATOR=startx_length -DACTUAL=1 -DEXPECTED=2 %s --check-prefix=INVALID-OPERANDS394 395# RUN: not yaml2obj -DOPERATOR=offset_pair -DVALUES=[] --docnum=8 %s 2>&1 | \396# RUN:   FileCheck -DOPERATOR=offset_pair -DACTUAL=0 -DEXPECTED=2 %s --check-prefix=INVALID-OPERANDS397 398# RUN: not yaml2obj -DOPERATOR=base_address -DVALUES=[0x01,0x02] --docnum=8 %s 2>&1 | \399# RUN:   FileCheck -DOPERATOR=base_address -DACTUAL=2 -DEXPECTED=1 %s --check-prefix=INVALID-OPERANDS400 401# RUN: not yaml2obj -DOPERATOR=start_end -DVALUES=[0x01,0x02,0x03] --docnum=8 %s 2>&1 | \402# RUN:   FileCheck -DOPERATOR=start_end -DACTUAL=3 -DEXPECTED=2 %s --check-prefix=INVALID-OPERANDS403 404# RUN: not yaml2obj -DOPERATOR=start_length -DVALUES=[0x01] --docnum=8 %s 2>&1 | \405# RUN:   FileCheck -DOPERATOR=start_length -DACTUAL=1 -DEXPECTED=2 %s --check-prefix=INVALID-OPERANDS406 407# INVALID-OPERANDS: yaml2obj: error: invalid number ([[ACTUAL]]) of operands for the operator: DW_RLE_[[OPERATOR]], [[EXPECTED]] expected408 409--- !ELF410FileHeader:411  Class: ELFCLASS64412  Data:  ELFDATA2LSB413  Type:  ET_EXEC414DWARF:415  debug_rnglists:416    - AddressSize: 3417      Lists:418        - Entries:419            - Operator: DW_RLE_[[OPERATOR]]420              Values:   [[VALUES]]421 422## k) Test that an empty list is allowed for a range list table.423 424# RUN: yaml2obj --docnum=9 %s -o %t9.o425# RUN: llvm-readelf --hex-dump=.debug_rnglists %t9.o | \426# RUN:   FileCheck %s --check-prefix=EMPTY-LIST427 428#      EMPTY-LIST: Hex dump of section '.debug_rnglists':429# EMPTY-LIST-NEXT: 0x00000000 08000000 05000800 00000000          ............430##                            ^-------                            unit_length (4-byte)431##                                     ^---                       version (2-byte)432##                                         ^---                   address_size (1-byte)433##                                              ^-------          offset_entry_count (4-byte)434 435--- !ELF436FileHeader:437  Class: ELFCLASS64438  Data:  ELFDATA2LSB439  Type:  ET_EXEC440DWARF:441  debug_rnglists:442    - Lists: []443 444## l) Generate the .debug_rnglists section from raw section content.445 446# RUN: yaml2obj --docnum=10 %s -o %t10.o447# RUN: llvm-readobj --sections --section-data %t10.o | \448# RUN:   FileCheck %s -DSIZE=3 -DADDRALIGN=0 --check-prefixes=SHDR,ARBITRARY-CONTENT449 450#      ARBITRARY-CONTENT: SectionData (451# ARBITRARY-CONTENT-NEXT:   0000: 112233452# ARBITRARY-CONTENT-NEXT: )453 454--- !ELF455FileHeader:456  Class: ELFCLASS64457  Data:  ELFDATA2LSB458  Type:  ET_EXEC459Sections:460  - Name:    .debug_rnglists461    Type:    SHT_PROGBITS462    Content: "112233"463 464## m) Generate the .debug_rnglists section when the "Size" is specified.465 466# RUN: yaml2obj --docnum=11 %s -o %t11.o467# RUN: llvm-readelf --hex-dump=.debug_rnglists %t11.o | \468# RUN:   FileCheck %s --check-prefix=SIZE469 470#       SIZE: Hex dump of section '.debug_rnglists':471#  SIZE-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................472# SIZE-EMPTY:473 474--- !ELF475FileHeader:476  Class: ELFCLASS64477  Data:  ELFDATA2LSB478  Type:  ET_EXEC479Sections:480  - Name: .debug_rnglists481    Type: SHT_PROGBITS482    Size: 0x10483 484## n) Test that yaml2obj emits an error message when both the "Size" and the485## "debug_rnglists" entry are specified at the same time.486 487# RUN: not yaml2obj --docnum=12 %s 2>&1 | FileCheck %s --check-prefix=ERROR488 489# ERROR: yaml2obj: error: cannot specify section '.debug_rnglists' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time490 491--- !ELF492FileHeader:493  Class: ELFCLASS64494  Data:  ELFDATA2LSB495  Type:  ET_EXEC496Sections:497  - Name: .debug_rnglists498    Type: SHT_PROGBITS499    Size: 0x10500DWARF:501  debug_rnglists:502    - Lists: []503 504## o) Test that yaml2obj emits an error message when both the "Content" and the505## "debug_rnglists" entry are specified at the same time.506 507# RUN: not yaml2obj --docnum=13 %s 2>&1 | FileCheck %s --check-prefix=ERROR508 509--- !ELF510FileHeader:511  Class: ELFCLASS64512  Data:  ELFDATA2LSB513  Type:  ET_EXEC514Sections:515  - Name:    .debug_rnglists516    Type:    SHT_PROGBITS517    Content: "00"518DWARF:519  debug_rnglists:520    - Lists: []521 522## p) Test that all the properties can be overridden by the section header when523## the "debug_rnglists" entry doesn't exist.524 525# RUN: yaml2obj --docnum=14 %s -o %t14.o526# RUN: llvm-readelf --sections %t14.o | FileCheck %s --check-prefix=OVERRIDDEN527 528#      OVERRIDDEN: [Nr] Name            Type   Address          Off    Size   ES Flg Lk Inf Al529#      OVERRIDDEN: [ 1] .debug_rnglists STRTAB 0000000000002020 000050 00000c 01   A  2   1  2530# OVERRIDDEN-NEXT: [ 2] .sec            STRTAB 0000000000000000 00005c 000000 00      0   0  0531 532--- !ELF533FileHeader:534  Class: ELFCLASS64535  Data:  ELFDATA2LSB536  Type:  ET_EXEC537Sections:538  - Name:         .debug_rnglists539    Type:         SHT_STRTAB  ## SHT_PROGBITS by default.540    Flags:        [SHF_ALLOC] ## 0 by default.541    Link:         .sec        ## 0 by default.542    EntSize:      1           ## 0 by default.543    Info:         1           ## 0 by default.544    AddressAlign: 2           ## 0 by default.545    Address:      0x2020      ## 0x00 by default.546    Offset:       0x50        ## 0x40 for the first section.547    Size:         0x0c        ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".548  - Name:         .sec        ## Linked by .debug_rnglists.549    Type:         SHT_STRTAB550 551## q) Test that all the properties can be overridden by the section header when552## the "debug_rnglists" entry exists.553 554# RUN: yaml2obj --docnum=15 %s -o %t15.o555# RUN: llvm-readelf --sections %t15.o | FileCheck %s --check-prefix=OVERRIDDEN556 557--- !ELF558FileHeader:559  Class: ELFCLASS64560  Data:  ELFDATA2LSB561  Type:  ET_EXEC562Sections:563  - Name:         .debug_rnglists564    Type:         SHT_STRTAB  ## SHT_PROGBITS by default.565    Flags:        [SHF_ALLOC] ## 0 by default.566    Link:         .sec        ## 0 by default.567    EntSize:      1           ## 0 by default.568    Info:         1           ## 0 by default.569    AddressAlign: 2           ## 1 by default.570    Address:      0x2020      ## 0x00 by default.571    Offset:       0x50        ## 0x40 for the first section.572  - Name:         .sec        ## Linked by .debug_rnglists.573    Type:         SHT_STRTAB574DWARF:575  debug_rnglists:576    - Lists: []577 578## r) Test that the .debug_rnglists section header is emitted if the "debug_rnglists"579## entry is empty.580 581# RUN: yaml2obj --docnum=16 %s -o %t16.o582# RUN: llvm-readobj --sections --section-data %t16.o | \583# RUN:   FileCheck -DSIZE=0 -DADDRALIGN=1 %s --check-prefixes=SHDR,EMPTY-CONTENT584 585# EMPTY-CONTENT-NEXT: SectionData (586# EMPTY-CONTENT-NEXT: )587 588--- !ELF589FileHeader:590  Class: ELFCLASS64591  Data:  ELFDATA2LSB592  Type:  ET_EXEC593DWARF:594  debug_rnglists: []595 596## s) Test that we are able to generate a range list via raw binary data.597 598# RUN: yaml2obj --docnum=17 %s -o %t17.o599# RUN: llvm-readelf --hex-dump=.debug_rnglists %t17.o | \600# RUN:   FileCheck %s --check-prefix=CUSTOM-LIST601 602#      CUSTOM-LIST: Hex dump of section '.debug_rnglists':603# CUSTOM-LIST-NEXT: 0x00000000 29000000 05000800 03000000 0c000000 )...............604##                             ^-------                            unit_length (4-byte)605##                                      ^---                       version (2-byte)606##                                          ^-                     address_size (1-byte)607##                                            ^-                   segment_selector_size (1-byte)608##                                               ^-------          offset_entry_count (4-byte)609##                                                        ^------- offsets[0] (4-byte)610# CUSTOM-LIST-NEXT: 0x00000010 11000000 19000000 02b424b4 24123456 ..........$.$.4V611##                             ^-------                            offsets[1] (4-byte)612##                                      ^-------                   offsets[2] (4-byte)613##                                               ^-                DW_RLE_startx_endx614##                                                 ^---            operands[0] (ULEB128) 0x1234615##                                                     ^----       operands[1] (ULEB128) 0x1234616##                                                          ^----- custom list content617# CUSTOM-LIST-NEXT: 0x00000020 7890abcd efabcdef 12345678 90       x........4Vx.618##                             -----------619##                                        ^-----------------       custom list content620 621--- !ELF622FileHeader:623  Class: ELFCLASS64624  Data:  ELFDATA2LSB625  Type:  ET_EXEC626DWARF:627  debug_rnglists:628    - Lists:629        - Entries:630            - Operator: DW_RLE_startx_endx631              Values:   [ 0x1234, 0x1234 ]632        - Content: '1234567890abcdef'633        - Content: 'abcdef1234567890'634 635## t) Test that yaml2obj emits an error message when 'Content' and 'Entries' are specified636## at the same time.637 638# RUN: not yaml2obj --docnum=18 %s 2>&1 | FileCheck %s --check-prefix=ERR639 640#      ERR: YAML:{{.*}}: error: Entries and Content can't be used together641# ERR-NEXT:         - Entries: []642# ERR-NEXT:           ^643 644--- !ELF645FileHeader:646  Class: ELFCLASS64647  Data:  ELFDATA2LSB648  Type:  ET_EXEC649DWARF:650  debug_rnglists:651    - Lists:652        - Entries: []653          Content: ''654 655## u) Test that when the "OffsetEntryCount" is specified to be 0 and "Offsets" is not specified,656## the offsets array is not emitted.657 658# RUN: yaml2obj --docnum=19 -DENTRYCOUNT=0 %s -o %t19.o659# RUN: llvm-readelf --hex-dump=.debug_rnglists %t19.o | \660# RUN:   FileCheck %s --check-prefix=NO-OFFSETS661 662#      NO-OFFSETS: Hex dump of section '.debug_rnglists':663# NO-OFFSETS-NEXT: 0x00000000 0e000000 05000800 00000000 02010202 ................664##                                              ^-------          offset_entry_count (4-byte)665##                                                       ^-       DW_RLE_startx_endx666##                                                         ^-     operands[0] (ULEB128) 0x01667##                                                           ^-   operands[1] (ULEB128) 0x02668##                                                             ^- DW_RLE_startx_endx669# NO-OFFSETS-NEXT: 0x00000010 0102                                ..670##                            ^-                                  operands[0] (ULEB128) 0x01671##                              ^-                                operands[1] (ULEB128) 0x02672 673--- !ELF674FileHeader:675  Class: ELFCLASS64676  Data:  ELFDATA2LSB677  Type:  ET_EXEC678DWARF:679  debug_rnglists:680    - OffsetEntryCount: [[ENTRYCOUNT=<none>]]681      Offsets:          [[OFFSETS=<none>]]682      Lists:683        - Entries:684            - Operator: DW_RLE_startx_endx685              Values:   [ 0x01, 0x02 ]686        - Entries:687            - Operator: DW_RLE_startx_endx688              Values:   [ 0x01, 0x02 ]689 690## v) Test that when the "Offsets" entry is specified to be empty and the "OffsetEntryCount" is not specified,691## the offsets array will be omitted.692 693# RUN: yaml2obj --docnum=19 -DOFFSETS=[] %s -o %t20.o694# RUN: llvm-readelf --hex-dump=.debug_rnglists %t20.o | \695# RUN:   FileCheck %s --check-prefix=NO-OFFSETS696 697## w) Test that if "Offsets" is specified, the offsets array will be emitted accordingly, even when698## the "OffsetEntryCount" is specified to be 0.699 700# RUN: yaml2obj --docnum=19 -DOFFSETS=[0x01,0x02,0x03] -DENTRYCOUNT=0 %s -o %t21.o701# RUN: llvm-readelf --hex-dump=.debug_rnglists %t21.o | \702# RUN:   FileCheck %s --check-prefix=OFFSETS703 704#      OFFSETS: Hex dump of section '.debug_rnglists':705# OFFSETS-NEXT: 0x00000000 0e000000 05000800 00000000 01000000 ................706##                                           ^-------          offset_entry_count (4-byte)707##                                                    ^------- offsets[0] (4-byte)708# OFFSETS-NEXT: 0x00000010 02000000 03000000 02010202 0102     ..............709##                         ^-------                            offsets[1] (4-byte)710##                                  ^-------                   offsets[2] (4-byte)711##                                           ^-                DW_RLE_startx_endx712##                                             ^-              operands[0] (ULEB128) 0x01713##                                               ^-            operands[1] (ULEB128) 0x02714##                                                 ^-          DW_RLE_startx_endx715##                                                    ^-       operands[0] (ULEB128) 0x01716##                                                      ^-     operands[1] (ULEB128) 0x02717