David Fang | b88cdf6 | 2013-08-08 20:14:40 +0000 | [diff] [blame^] | 1 | ; This tests for the basic implementation of PPCMachObjectWriter.cpp, |
| 2 | ; which is responsible for writing mach-o relocation entries for (PIC) |
| 3 | ; PowerPC objects. |
| 4 | ; NOTE: Darwin PPC asm syntax is not yet supported by PPCAsmParser, |
| 5 | ; so this test case uses ELF PPC asm syntax to produce a mach-o object. |
| 6 | ; Once PPCAsmParser supports darwin asm syntax, this test case should |
| 7 | ; be updated accordingly. |
| 8 | |
| 9 | ; RUN: llvm-mc -filetype=obj -relocation-model=pic -mcpu=g4 -triple=powerpc-apple-darwin8 %s -o - | llvm-readobj -relocations | FileCheck -check-prefix=DARWIN-G4-DUMP %s |
| 10 | |
| 11 | ; .machine ppc7400 |
| 12 | .section __TEXT,__textcoal_nt,coalesced,pure_instructions |
| 13 | .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 |
| 14 | .section __TEXT,__text,regular,pure_instructions |
| 15 | .globl _main |
| 16 | .align 4 |
| 17 | _main: ; @main |
| 18 | ; BB#0: ; %entry |
| 19 | mflr 0 |
| 20 | stw 31, -4(1) |
| 21 | stw 0, 8(1) |
| 22 | stwu 1, -80(1) |
| 23 | bl L0$pb |
| 24 | L0$pb: |
| 25 | mr 31, 1 |
| 26 | li 5, 0 |
| 27 | mflr 2 |
| 28 | stw 3, 68(31) |
| 29 | stw 5, 72(31) |
| 30 | stw 4, 64(31) |
| 31 | addis 2, 2, (L_.str-L0$pb)@ha |
| 32 | la 3, (L_.str-L0$pb)@l(2) |
| 33 | bl L_puts$stub |
| 34 | li 3, 0 |
| 35 | addi 1, 1, 80 |
| 36 | lwz 0, 8(1) |
| 37 | lwz 31, -4(1) |
| 38 | mtlr 0 |
| 39 | blr |
| 40 | |
| 41 | .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 |
| 42 | .align 4 |
| 43 | L_puts$stub: |
| 44 | .indirect_symbol _puts |
| 45 | mflr 0 |
| 46 | bcl 20, 31, L_puts$stub$tmp |
| 47 | L_puts$stub$tmp: |
| 48 | mflr 11 |
| 49 | addis 11, 11, (L_puts$lazy_ptr-L_puts$stub$tmp)@ha |
| 50 | mtlr 0 |
| 51 | lwzu 12, (L_puts$lazy_ptr-L_puts$stub$tmp)@l(11) |
| 52 | mtctr 12 |
| 53 | bctr |
| 54 | .section __DATA,__la_symbol_ptr,lazy_symbol_pointers |
| 55 | L_puts$lazy_ptr: |
| 56 | .indirect_symbol _puts |
| 57 | .long dyld_stub_binding_helper |
| 58 | |
| 59 | .subsections_via_symbols |
| 60 | .section __TEXT,__cstring,cstring_literals |
| 61 | L_.str: ; @.str |
| 62 | .asciz "Hello, world!" |
| 63 | |
| 64 | ; DARWIN-G4-DUMP:Format: Mach-O 32-bit ppc |
| 65 | ; DARWIN-G4-DUMP:Arch: powerpc |
| 66 | ; DARWIN-G4-DUMP:AddressSize: 32bit |
| 67 | ; DARWIN-G4-DUMP:Relocations [ |
| 68 | ; DARWIN-G4-DUMP: Section __text { |
| 69 | ; DARWIN-G4-DUMP: 0x34 1 2 0 PPC_RELOC_BR24 0 - |
| 70 | ; DARWIN-G4-DUMP: 0x30 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 _main |
| 71 | ; DARWIN-G4-DUMP: 0x0 0 2 n/a PPC_RELOC_PAIR 1 _main |
| 72 | ; DARWIN-G4-DUMP: 0x2C 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 _main |
| 73 | ; DARWIN-G4-DUMP: 0x60 0 2 n/a PPC_RELOC_PAIR 1 _main |
| 74 | ; DARWIN-G4-DUMP: } |
| 75 | ; DARWIN-G4-DUMP: Section __picsymbolstub1 { |
| 76 | ; DARWIN-G4-DUMP: 0x14 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 _main |
| 77 | ; DARWIN-G4-DUMP: 0x0 0 2 n/a PPC_RELOC_PAIR 1 _main |
| 78 | ; DARWIN-G4-DUMP: 0xC 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 _main |
| 79 | ; DARWIN-G4-DUMP: 0x18 0 2 n/a PPC_RELOC_PAIR 1 _main |
| 80 | ; DARWIN-G4-DUMP: } |
| 81 | ; DARWIN-G4-DUMP: Section __la_symbol_ptr { |
| 82 | ; DARWIN-G4-DUMP: 0x0 0 2 1 PPC_RELOC_VANILLA 0 dyld_stub_binding_helper |
| 83 | ; DARWIN-G4-DUMP: } |
| 84 | ; DARWIN-G4-DUMP:] |