Home | History | Annotate | Download | only in MachO
      1 // RUN: llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
      2 
      3         .data
      4 
      5         .org 0x10
      6 L0:
      7         .long 0
      8         .long 0
      9         .long 0
     10         .long 0
     11 
     12 _d:
     13         .long 0
     14 L1:
     15         .long 0
     16 
     17         .text
     18 
     19 // These generate normal x86_64 (external) relocations. They could all use
     20 // SIGNED, but don't for pedantic compatibility with Darwin 'as'.
     21 
     22         // SIGNED1
     23  	movb  $0x12, _d(%rip)
     24 
     25         // SIGNED
     26  	movb  $0x12, _d + 1(%rip)
     27 
     28         // SIGNED4
     29  	movl  $0x12345678, _d(%rip)
     30 
     31         // SIGNED
     32  	movl  $0x12345678, _d + 1(%rip)
     33 
     34         // SIGNED2
     35  	movl  $0x12345678, _d + 2(%rip)
     36 
     37         // SIGNED1
     38  	movl  $0x12345678, _d + 3(%rip)
     39 
     40         // SIGNED
     41  	movl  $0x12345678, _d + 4(%rip)
     42 
     43 	movb  %al, _d(%rip)
     44  	movb  %al, _d + 1(%rip)
     45  	movl  %eax, _d(%rip)
     46  	movl  %eax, _d + 1(%rip)
     47  	movl  %eax, _d + 2(%rip)
     48  	movl  %eax, _d + 3(%rip)
     49  	movl  %eax, _d + 4(%rip)
     50 
     51 // These have to use local relocations. Since that uses an offset into the
     52 // section in x86_64 (as opposed to a scattered relocation), and since the
     53 // linker can only decode this to an atom + offset by scanning the section,
     54 // it is not possible to correctly encode these without SIGNED<N>. This is
     55 // ultimately due to a design flaw in the x86_64 relocation format, it is
     56 // not possible to encode an address (L<foo> + <constant>) which is outside the
     57 // atom containing L<foo>.
     58 
     59         // SIGNED1
     60  	movb  $0x12, L0(%rip)
     61 
     62         // SIGNED
     63  	movb  $0x12, L0 + 1(%rip)
     64 
     65         // SIGNED4
     66  	movl  $0x12345678, L0(%rip)
     67 
     68         // SIGNED
     69  	movl  $0x12345678, L0 + 1(%rip)
     70 
     71         // SIGNED2
     72  	movl  $0x12345678, L0 + 2(%rip)
     73 
     74         // SIGNED1
     75  	movl  $0x12345678, L0 + 3(%rip)
     76 
     77         // SIGNED
     78  	movl  $0x12345678, L0 + 4(%rip)
     79 
     80  	movb  %al, L0(%rip)
     81  	movb  %al, L0 + 1(%rip)
     82  	movl  %eax, L0(%rip)
     83  	movl  %eax, L0 + 1(%rip)
     84  	movl  %eax, L0 + 2(%rip)
     85  	movl  %eax, L0 + 3(%rip)
     86  	movl  %eax, L0 + 4(%rip)
     87 
     88         // SIGNED1
     89  	movb  $0x12, L1(%rip)
     90 
     91         // SIGNED
     92  	movb  $0x12, L1 + 1(%rip)
     93 
     94         // SIGNED4
     95  	movl  $0x12345678, L1(%rip)
     96 
     97         // SIGNED
     98  	movl  $0x12345678, L1 + 1(%rip)
     99 
    100         // SIGNED2
    101  	movl  $0x12345678, L1 + 2(%rip)
    102 
    103         // SIGNED1
    104  	movl  $0x12345678, L1 + 3(%rip)
    105 
    106         // SIGNED
    107  	movl  $0x12345678, L1 + 4(%rip)
    108 
    109  	movb  %al, L1(%rip)
    110  	movb  %al, L1 + 1(%rip)
    111  	movl  %eax, L1(%rip)
    112  	movl  %eax, L1 + 1(%rip)
    113  	movl  %eax, L1 + 2(%rip)
    114  	movl  %eax, L1 + 3(%rip)
    115  	movl  %eax, L1 + 4(%rip)
    116 
    117 // CHECK: ('cputype', 16777223)
    118 // CHECK: ('cpusubtype', 3)
    119 // CHECK: ('filetype', 1)
    120 // CHECK: ('num_load_commands', 3)
    121 // CHECK: ('load_commands_size', 336)
    122 // CHECK: ('flag', 0)
    123 // CHECK: ('reserved', 0)
    124 // CHECK: ('load_commands', [
    125 // CHECK:   # Load Command 0
    126 // CHECK:  (('command', 25)
    127 // CHECK:   ('size', 232)
    128 // CHECK:   ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
    129 // CHECK:   ('vm_addr', 0)
    130 // CHECK:   ('vm_size', 358)
    131 // CHECK:   ('file_offset', 368)
    132 // CHECK:   ('file_size', 358)
    133 // CHECK:   ('maxprot', 7)
    134 // CHECK:   ('initprot', 7)
    135 // CHECK:   ('num_sections', 2)
    136 // CHECK:   ('flags', 0)
    137 // CHECK:   ('sections', [
    138 // CHECK:     # Section 0
    139 // CHECK:    (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
    140 // CHECK:     ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
    141 // CHECK:     ('address', 0)
    142 // CHECK:     ('size', 318)
    143 // CHECK:     ('offset', 368)
    144 // CHECK:     ('alignment', 0)
    145 // CHECK:     ('reloc_offset', 728)
    146 // CHECK:     ('num_reloc', 42)
    147 // CHECK:     ('flags', 0x80000400)
    148 // CHECK:     ('reserved1', 0)
    149 // CHECK:     ('reserved2', 0)
    150 // CHECK:     ('reserved3', 0)
    151 // CHECK:    ),
    152 // CHECK:   ('_relocations', [
    153 // CHECK:     # Relocation 0
    154 // CHECK:     (('word-0', 0x13a),
    155 // CHECK:      ('word-1', 0x1d000000)),
    156 // CHECK:     # Relocation 1
    157 // CHECK:     (('word-0', 0x134),
    158 // CHECK:      ('word-1', 0x1d000000)),
    159 // CHECK:     # Relocation 2
    160 // CHECK:     (('word-0', 0x12e),
    161 // CHECK:      ('word-1', 0x1d000000)),
    162 // CHECK:     # Relocation 3
    163 // CHECK:     (('word-0', 0x128),
    164 // CHECK:      ('word-1', 0x1d000000)),
    165 // CHECK:     # Relocation 4
    166 // CHECK:     (('word-0', 0x122),
    167 // CHECK:      ('word-1', 0x1d000000)),
    168 // CHECK:     # Relocation 5
    169 // CHECK:     (('word-0', 0x11c),
    170 // CHECK:      ('word-1', 0x1d000000)),
    171 // CHECK:     # Relocation 6
    172 // CHECK:     (('word-0', 0x116),
    173 // CHECK:      ('word-1', 0x1d000000)),
    174 // CHECK:     # Relocation 7
    175 // CHECK:     (('word-0', 0x10c),
    176 // CHECK:      ('word-1', 0x1d000000)),
    177 // CHECK:     # Relocation 8
    178 // CHECK:     (('word-0', 0x102),
    179 // CHECK:      ('word-1', 0x6d000000)),
    180 // CHECK:     # Relocation 9
    181 // CHECK:     (('word-0', 0xf8),
    182 // CHECK:      ('word-1', 0x7d000000)),
    183 // CHECK:     # Relocation 10
    184 // CHECK:     (('word-0', 0xee),
    185 // CHECK:      ('word-1', 0x1d000000)),
    186 // CHECK:     # Relocation 11
    187 // CHECK:     (('word-0', 0xe4),
    188 // CHECK:      ('word-1', 0x8d000000)),
    189 // CHECK:     # Relocation 12
    190 // CHECK:     (('word-0', 0xdd),
    191 // CHECK:      ('word-1', 0x1d000000)),
    192 // CHECK:     # Relocation 13
    193 // CHECK:     (('word-0', 0xd6),
    194 // CHECK:      ('word-1', 0x6d000000)),
    195 // CHECK:     # Relocation 14
    196 // CHECK:     (('word-0', 0xd0),
    197 // CHECK:      ('word-1', 0x15000002)),
    198 // CHECK:     # Relocation 15
    199 // CHECK:     (('word-0', 0xca),
    200 // CHECK:      ('word-1', 0x15000002)),
    201 // CHECK:     # Relocation 16
    202 // CHECK:     (('word-0', 0xc4),
    203 // CHECK:      ('word-1', 0x15000002)),
    204 // CHECK:     # Relocation 17
    205 // CHECK:     (('word-0', 0xbe),
    206 // CHECK:      ('word-1', 0x15000002)),
    207 // CHECK:     # Relocation 18
    208 // CHECK:     (('word-0', 0xb8),
    209 // CHECK:      ('word-1', 0x15000002)),
    210 // CHECK:     # Relocation 19
    211 // CHECK:     (('word-0', 0xb2),
    212 // CHECK:      ('word-1', 0x15000002)),
    213 // CHECK:     # Relocation 20
    214 // CHECK:     (('word-0', 0xac),
    215 // CHECK:      ('word-1', 0x15000002)),
    216 // CHECK:     # Relocation 21
    217 // CHECK:     (('word-0', 0xa2),
    218 // CHECK:      ('word-1', 0x15000002)),
    219 // CHECK:     # Relocation 22
    220 // CHECK:     (('word-0', 0x98),
    221 // CHECK:      ('word-1', 0x65000002)),
    222 // CHECK:     # Relocation 23
    223 // CHECK:     (('word-0', 0x8e),
    224 // CHECK:      ('word-1', 0x75000002)),
    225 // CHECK:     # Relocation 24
    226 // CHECK:     (('word-0', 0x84),
    227 // CHECK:      ('word-1', 0x15000002)),
    228 // CHECK:     # Relocation 25
    229 // CHECK:     (('word-0', 0x7a),
    230 // CHECK:      ('word-1', 0x85000002)),
    231 // CHECK:     # Relocation 26
    232 // CHECK:     (('word-0', 0x73),
    233 // CHECK:      ('word-1', 0x15000002)),
    234 // CHECK:     # Relocation 27
    235 // CHECK:     (('word-0', 0x6c),
    236 // CHECK:      ('word-1', 0x65000002)),
    237 // CHECK:     # Relocation 28
    238 // CHECK:     (('word-0', 0x66),
    239 // CHECK:      ('word-1', 0x1d000000)),
    240 // CHECK:     # Relocation 29
    241 // CHECK:     (('word-0', 0x60),
    242 // CHECK:      ('word-1', 0x1d000000)),
    243 // CHECK:     # Relocation 30
    244 // CHECK:     (('word-0', 0x5a),
    245 // CHECK:      ('word-1', 0x1d000000)),
    246 // CHECK:     # Relocation 31
    247 // CHECK:     (('word-0', 0x54),
    248 // CHECK:      ('word-1', 0x1d000000)),
    249 // CHECK:     # Relocation 32
    250 // CHECK:     (('word-0', 0x4e),
    251 // CHECK:      ('word-1', 0x1d000000)),
    252 // CHECK:     # Relocation 33
    253 // CHECK:     (('word-0', 0x48),
    254 // CHECK:      ('word-1', 0x1d000000)),
    255 // CHECK:     # Relocation 34
    256 // CHECK:     (('word-0', 0x42),
    257 // CHECK:      ('word-1', 0x1d000000)),
    258 // CHECK:     # Relocation 35
    259 // CHECK:     (('word-0', 0x38),
    260 // CHECK:      ('word-1', 0x1d000000)),
    261 // CHECK:     # Relocation 36
    262 // CHECK:     (('word-0', 0x2e),
    263 // CHECK:      ('word-1', 0x6d000000)),
    264 // CHECK:     # Relocation 37
    265 // CHECK:     (('word-0', 0x24),
    266 // CHECK:      ('word-1', 0x7d000000)),
    267 // CHECK:     # Relocation 38
    268 // CHECK:     (('word-0', 0x1a),
    269 // CHECK:      ('word-1', 0x1d000000)),
    270 // CHECK:     # Relocation 39
    271 // CHECK:     (('word-0', 0x10),
    272 // CHECK:      ('word-1', 0x8d000000)),
    273 // CHECK:     # Relocation 40
    274 // CHECK:     (('word-0', 0x9),
    275 // CHECK:      ('word-1', 0x1d000000)),
    276 // CHECK:     # Relocation 41
    277 // CHECK:     (('word-0', 0x2),
    278 // CHECK:      ('word-1', 0x6d000000)),
    279 // CHECK:   ])
    280 // CHECK:   ('_section_data', 'c605ffff ffff12c6 05000000 0012c705 fcffffff 78563412 c705fdff ffff7856 3412c705 feffffff 78563412 c705ffff ffff7856 3412c705 00000000 78563412 88050000 00008805 01000000 89050000 00008905 01000000 89050200 00008905 03000000 89050400 0000c605 dd000000 12c605d7 00000012 c705cc00 00007856 3412c705 c3000000 78563412 c705ba00 00007856 3412c705 b1000000 78563412 c705a800 00007856 34128805 9e000000 88059900 00008905 92000000 89058d00 00008905 88000000 89058300 00008905 7e000000 c6050300 000012c6 05040000 0012c705 00000000 78563412 c7050100 00007856 3412c705 02000000 78563412 c7050300 00007856 3412c705 04000000 78563412 88050400 00008805 05000000 89050400 00008905 05000000 89050600 00008905 07000000 89050800 0000')
    281 // CHECK:     # Section 1
    282 // CHECK:    (('section_name', '__data\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
    283 // CHECK:     ('segment_name', '__DATA\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
    284 // CHECK:     ('address', 318)
    285 // CHECK:     ('size', 40)
    286 // CHECK:     ('offset', 686)
    287 // CHECK:     ('alignment', 0)
    288 // CHECK:     ('reloc_offset', 0)
    289 // CHECK:     ('num_reloc', 0)
    290 // CHECK:     ('flags', 0x0)
    291 // CHECK:     ('reserved1', 0)
    292 // CHECK:     ('reserved2', 0)
    293 // CHECK:     ('reserved3', 0)
    294 // CHECK:    ),
    295 // CHECK:   ('_relocations', [
    296 // CHECK:   ])
    297 // CHECK:   ('_section_data', '00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000')
    298 // CHECK:   ])
    299 // CHECK:  ),
    300 // CHECK:   # Load Command 1
    301 // CHECK:  (('command', 2)
    302 // CHECK:   ('size', 24)
    303 // CHECK:   ('symoff', 1064)
    304 // CHECK:   ('nsyms', 1)
    305 // CHECK:   ('stroff', 1080)
    306 // CHECK:   ('strsize', 4)
    307 // CHECK:   ('_string_data', '\x00_d\x00')
    308 // CHECK:   ('_symbols', [
    309 // CHECK:     # Symbol 0
    310 // CHECK:    (('n_strx', 1)
    311 // CHECK:     ('n_type', 0xe)
    312 // CHECK:     ('n_sect', 2)
    313 // CHECK:     ('n_desc', 0)
    314 // CHECK:     ('n_value', 350)
    315 // CHECK:     ('_string', '_d')
    316 // CHECK:    ),
    317 // CHECK:   ])
    318 // CHECK:  ),
    319 // CHECK:   # Load Command 2
    320 // CHECK:  (('command', 11)
    321 // CHECK:   ('size', 80)
    322 // CHECK:   ('ilocalsym', 0)
    323 // CHECK:   ('nlocalsym', 1)
    324 // CHECK:   ('iextdefsym', 1)
    325 // CHECK:   ('nextdefsym', 0)
    326 // CHECK:   ('iundefsym', 1)
    327 // CHECK:   ('nundefsym', 0)
    328 // CHECK:   ('tocoff', 0)
    329 // CHECK:   ('ntoc', 0)
    330 // CHECK:   ('modtaboff', 0)
    331 // CHECK:   ('nmodtab', 0)
    332 // CHECK:   ('extrefsymoff', 0)
    333 // CHECK:   ('nextrefsyms', 0)
    334 // CHECK:   ('indirectsymoff', 0)
    335 // CHECK:   ('nindirectsyms', 0)
    336 // CHECK:   ('extreloff', 0)
    337 // CHECK:   ('nextrel', 0)
    338 // CHECK:   ('locreloff', 0)
    339 // CHECK:   ('nlocrel', 0)
    340 // CHECK:   ('_indirect_symbols', [
    341 // CHECK:   ])
    342 // CHECK:  ),
    343 // CHECK: ])
    344