parse-literals.yaml 3.5 KB
# RUN: ld64.lld -arch x86_64 -r -print_atoms %s -o %t  | FileCheck %s
#
# Test parsing of literal sections.
#

--- !mach-o
arch:            x86_64
file-type:       MH_OBJECT
flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
has-UUID:        false
OS:              unknown
sections:
  - segment:         __TEXT
    section:         __cstring
    type:            S_CSTRING_LITERALS
    attributes:      [  ]
    alignment:       1
    address:         0x0000000000000100
    content:         [ 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x00, 0x74, 0x68,
                       0x65, 0x72, 0x65, 0x00, 0x77, 0x6F, 0x72, 0x6C,
                       0x00 ]
  - segment:         __TEXT
    section:         __literal4
    type:            S_4BYTE_LITERALS
    attributes:      [  ]
    alignment:       1
    address:         0x0000000000000114
    content:         [ 0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14,
                       0x28, 0x29, 0x2A, 0x2B ]
  - segment:         __TEXT
    section:         __literal8
    type:            S_8BYTE_LITERALS
    attributes:      [  ]
    alignment:       1
    address:         0x0000000000000120
    content:         [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                       0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F ]
  - segment:         __TEXT
    section:         __literal16
    type:            S_16BYTE_LITERALS
    attributes:      [  ]
    alignment:       1
    address:         0x0000000000000130
    content:         [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                       0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00 ]
  - segment:         __TEXT
    section:         __ustring
    type:            S_REGULAR
    attributes:      [  ]
    alignment:       1
    address:         0x0000000000000100
    content:         [ 0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00,
                       0x6F, 0x00, 0x00, 0x00, 0x74, 0x00, 0x68, 0x00,
                       0x65, 0x00, 0x72, 0x00, 0x00, 0x00 ]
...


# CHECK:defined-atoms:
# CHECK:  - scope:           hidden
# CHECK:    type:            c-string
# CHECK:    content:         [ 68, 65, 6C, 6C, 6F, 00 ]
# CHECK:  - scope:           hidden
# CHECK:    type:            c-string
# CHECK:    content:         [ 74, 68, 65, 72, 65, 00 ]
# CHECK:  - scope:           hidden
# CHECK:    type:            c-string
# CHECK:    content:         [ 77, 6F, 72, 6C, 00 ]
# CHECK:  - scope:           hidden
# CHECK:    type:            utf16-string
# CHECK:    content:         [ 68, 00, 65, 00, 6C, 00, 6C, 00, 6F, 00, 00, 00 ]
# CHECK:  - scope:           hidden
# CHECK:    type:            utf16-string
# CHECK:    content:         [ 74, 00, 68, 00, 65, 00, 72, 00, 00, 00 ]
# CHECK:  - scope:           hidden
# CHECK:    type:            const-4-byte
# CHECK:    content:         [ 01, 02, 03, 04 ]
# CHECK:  - scope:           hidden
# CHECK:    type:            const-4-byte
# CHECK:    content:         [ 11, 12, 13, 14 ]
# CHECK:  - scope:           hidden
# CHECK:    type:            const-4-byte
# CHECK:    content:         [ 28, 29, 2A, 2B ]
# CHECK:  - scope:           hidden
# CHECK:    type:            const-8-byte
# CHECK:    content:         [ 01, 02, 03, 04, 05, 06, 07, 08 ]
# CHECK:  - scope:           hidden
# CHECK:    type:            const-8-byte
# CHECK:    content:         [ 28, 29, 2A, 2B, 2C, 2D, 2E, 2F ]
# CHECK:  - scope:           hidden
# CHECK:    type:            const-16-byte
# CHECK:    content:         [ 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C,
# CHECK:                       0D, 0E, 0F, 00 ]