reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
# RUN: ld64.lld -arch arm64 -r -print_atoms %s -o %t | FileCheck %s \
# RUN:  && ld64.lld -arch arm64 -r -print_atoms %t -o %t2 | FileCheck %s
#
# Test parsing and writing of arm64 text relocations.
#
# The first step tests if the supplied mach-o file is parsed into the correct
# set of references.  The second step verifies relocations can be round-tripped
# by writing to a new .o file, then parsing that file which should result in
# the same references.
#
#_test:


--- !mach-o
arch:            arm64
file-type:       MH_OBJECT
flags:           [  ]
has-UUID:        false
OS:              unknown
sections:
  - segment:         __TEXT
    section:         __text
    type:            S_REGULAR
    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
    address:         0x0000000000000000
    content:         [ 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x94,
                       0x01, 0x00, 0x00, 0x90, 0x20, 0x00, 0x40, 0x39,
                       0x20, 0x00, 0x40, 0x79, 0x20, 0x00, 0x40, 0xB9,
                       0x20, 0x00, 0x40, 0xF9, 0x20, 0x00, 0xC0, 0x3D,
                       0x01, 0x00, 0x00, 0x90, 0x20, 0x00, 0x40, 0xB9,
                       0x01, 0x00, 0x00, 0x90, 0x20, 0x00, 0x40, 0xF9,
                       0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x40, 0xF9 ]
    relocations:
      - offset:          0x00000034
        type:            ARM64_RELOC_TLVP_LOAD_PAGEOFF12
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          5
      - offset:          0x00000030
        type:            ARM64_RELOC_TLVP_LOAD_PAGE21
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          5
      - offset:          0x0000002C
        type:            ARM64_RELOC_GOT_LOAD_PAGEOFF12
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          6
      - offset:          0x00000028
        type:            ARM64_RELOC_GOT_LOAD_PAGE21
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          6
      - offset:          0x00000024
        type:            ARM64_RELOC_ADDEND
        length:          2
        pc-rel:          false
        extern:          false
        symbol:          16
      - offset:          0x00000024
        type:            ARM64_RELOC_PAGEOFF12
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000020
        type:            ARM64_RELOC_ADDEND
        length:          2
        pc-rel:          false
        extern:          false
        symbol:          16
      - offset:          0x00000020
        type:            ARM64_RELOC_PAGE21
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          2
      - offset:          0x0000001C
        type:            ARM64_RELOC_PAGEOFF12
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000018
        type:            ARM64_RELOC_PAGEOFF12
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000014
        type:            ARM64_RELOC_PAGEOFF12
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000010
        type:            ARM64_RELOC_PAGEOFF12
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x0000000C
        type:            ARM64_RELOC_PAGEOFF12
        length:          2
        pc-rel:          false
        extern:          true
        symbol:          2
      - offset:          0x00000008
        type:            ARM64_RELOC_PAGE21
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          2
      - offset:          0x00000004
        type:            ARM64_RELOC_ADDEND
        length:          2
        pc-rel:          false
        extern:          false
        symbol:          8
      - offset:          0x00000004
        type:            ARM64_RELOC_BRANCH26
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          4
      - offset:          0x00000000
        type:            ARM64_RELOC_BRANCH26
        length:          2
        pc-rel:          true
        extern:          true
        symbol:          4
  - segment:         __DATA
    section:         __data
    type:            S_REGULAR
    attributes:      [  ]
    alignment:       2
    address:         0x0000000000000038
    content:         [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]
local-symbols:
  - name:            ltmp0
    type:            N_SECT
    sect:            1
    value:           0x0000000000000000
  - name:            _func
    type:            N_SECT
    sect:            1
    value:           0x0000000000000000
  - name:            _v1
    type:            N_SECT
    sect:            2
    value:           0x0000000000000038
  - name:            ltmp1
    type:            N_SECT
    sect:            2
    value:           0x0000000000000038
undefined-symbols:
  - name:            _foo
    type:            N_UNDF
    scope:           [ N_EXT ]
    value:           0x0000000000000000
  - name:            _tlv
    type:            N_UNDF
    scope:           [ N_EXT ]
    value:           0x0000000000000000
  - name:            _v2
    type:            N_UNDF
    scope:           [ N_EXT ]
    value:           0x0000000000000000
...

# CHECK: defined-atoms:
# CHECK:   - name:            _v1
# CHECK:     type:            data
# CHECK:     content:         [ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
# CHECK:                        00, 00, 00, 00 ]
# CHECK:   - name:            _func
# CHECK:     content:         [ 00, 00, 00, 94, 00, 00, 00, 94, 01, 00, 00, 90,
# CHECK:                        20, 00, 40, 39, 20, 00, 40, 79, 20, 00, 40, B9,
# CHECK:                        20, 00, 40, F9, 20, 00, C0, 3D, 01, 00, 00, 90,
# CHECK:                        20, 00, 40, B9, 01, 00, 00, 90, 20, 00, 40, F9,
# CHECK:                        00, 00, 00, 90, 00, 00, 40, F9 ]
# CHECK:     references:
# CHECK:       - kind:            branch26
# CHECK:         offset:          0
# CHECK:         target:          _foo
# CHECK:       - kind:            branch26
# CHECK:         offset:          4
# CHECK:         target:          _foo
# CHECK:         addend:          8
# CHECK:       - kind:            page21
# CHECK:         offset:          8
# CHECK:         target:          _v1
# CHECK:       - kind:            offset12
# CHECK:         offset:          12
# CHECK:         target:          _v1
# CHECK:       - kind:            offset12scale2
# CHECK:         offset:          16
# CHECK:         target:          _v1
# CHECK:       - kind:            offset12scale4
# CHECK:         offset:          20
# CHECK:         target:          _v1
# CHECK:       - kind:            offset12scale8
# CHECK:         offset:          24
# CHECK:         target:          _v1
# CHECK:       - kind:            offset12scale16
# CHECK:         offset:          28
# CHECK:         target:          _v1
# CHECK:       - kind:            page21
# CHECK:         offset:          32
# CHECK:         target:          _v1
# CHECK:         addend:          16
# CHECK:       - kind:            offset12scale4
# CHECK:         offset:          36
# CHECK:         target:          _v1
# CHECK:         addend:          16
# CHECK:       - kind:            gotPage21
# CHECK:         offset:          40
# CHECK:         target:          _v2
# CHECK:       - kind:            gotOffset12
# CHECK:         offset:          44
# CHECK:         target:          _v2
# CHECK:       - kind:            tlvPage21
# CHECK:         offset:          48
# CHECK:         target:          _tlv
# CHECK:       - kind:            tlvOffset12
# CHECK:         offset:          52
# CHECK:         target:          _tlv
# CHECK: undefined-atoms:
# CHECK:   - name:            _foo
# CHECK:   - name:            _tlv
# CHECK:   - name:            _v2