blob: 1e3fb8fb0e71a9ab39080a6037988dd2fe1d3591 [file] [log] [blame]
David Fangb88cdf62013-08-08 20:14:40 +00001; This tests for the basic implementation of PPCMachObjectWriter.cpp,
2; which is responsible for writing mach-o relocation entries for (PIC)
3; PowerPC objects.
David Fangb88cdf62013-08-08 20:14:40 +00004
5; 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
6
Iain Sandoee0b4cb62013-12-14 13:34:02 +00007 .machine ppc7400
David Fangb88cdf62013-08-08 20:14:40 +00008 .section __TEXT,__textcoal_nt,coalesced,pure_instructions
9 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
10 .section __TEXT,__text,regular,pure_instructions
11 .globl _main
12 .align 4
13_main: ; @main
14; BB#0: ; %entry
Iain Sandoee0b4cb62013-12-14 13:34:02 +000015 mflr r0
16 stw r31, -4(r1)
17 stw r0, 8(r1)
18 stwu r1, -80(r1)
David Fangb88cdf62013-08-08 20:14:40 +000019 bl L0$pb
20L0$pb:
Iain Sandoee0b4cb62013-12-14 13:34:02 +000021 mr r31, r1
22 li r5, 0
David Fangb88cdf62013-08-08 20:14:40 +000023 mflr 2
Iain Sandoee0b4cb62013-12-14 13:34:02 +000024 stw r3, 68(r31)
25 stw r5, 72(r31)
26 stw r4, 64(r31)
27 addis r2, r2, ha16(L_.str-L0$pb)
28 la r3, lo16(L_.str-L0$pb)(r2)
David Fangb88cdf62013-08-08 20:14:40 +000029 bl L_puts$stub
Iain Sandoee0b4cb62013-12-14 13:34:02 +000030 li r3, 0
31 addi r1, r1, 80
32 lwz r0, 8(r1)
33 lwz r31, -4(r1)
34 mtlr r0
David Fangb88cdf62013-08-08 20:14:40 +000035 blr
36
37 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
38 .align 4
39L_puts$stub:
40 .indirect_symbol _puts
Iain Sandoee0b4cb62013-12-14 13:34:02 +000041 mflr r0
David Fangb88cdf62013-08-08 20:14:40 +000042 bcl 20, 31, L_puts$stub$tmp
43L_puts$stub$tmp:
Iain Sandoee0b4cb62013-12-14 13:34:02 +000044 mflr r11
45 addis r11, r11, ha16(L_puts$lazy_ptr-L_puts$stub$tmp)
46 mtlr r0
47 lwzu r12, lo16(L_puts$lazy_ptr-L_puts$stub$tmp)(r11)
48 mtctr r12
David Fangb88cdf62013-08-08 20:14:40 +000049 bctr
50 .section __DATA,__la_symbol_ptr,lazy_symbol_pointers
51L_puts$lazy_ptr:
52 .indirect_symbol _puts
53 .long dyld_stub_binding_helper
54
55.subsections_via_symbols
56 .section __TEXT,__cstring,cstring_literals
57L_.str: ; @.str
58 .asciz "Hello, world!"
59
60; DARWIN-G4-DUMP:Format: Mach-O 32-bit ppc
61; DARWIN-G4-DUMP:Arch: powerpc
62; DARWIN-G4-DUMP:AddressSize: 32bit
63; DARWIN-G4-DUMP:Relocations [
64; DARWIN-G4-DUMP: Section __text {
65; DARWIN-G4-DUMP: 0x34 1 2 0 PPC_RELOC_BR24 0 -
66; DARWIN-G4-DUMP: 0x30 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 _main
67; DARWIN-G4-DUMP: 0x0 0 2 n/a PPC_RELOC_PAIR 1 _main
68; DARWIN-G4-DUMP: 0x2C 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 _main
69; DARWIN-G4-DUMP: 0x60 0 2 n/a PPC_RELOC_PAIR 1 _main
70; DARWIN-G4-DUMP: }
71; DARWIN-G4-DUMP: Section __picsymbolstub1 {
72; DARWIN-G4-DUMP: 0x14 0 2 n/a PPC_RELOC_LO16_SECTDIFF 1 _main
73; DARWIN-G4-DUMP: 0x0 0 2 n/a PPC_RELOC_PAIR 1 _main
74; DARWIN-G4-DUMP: 0xC 0 2 n/a PPC_RELOC_HA16_SECTDIFF 1 _main
75; DARWIN-G4-DUMP: 0x18 0 2 n/a PPC_RELOC_PAIR 1 _main
76; DARWIN-G4-DUMP: }
77; DARWIN-G4-DUMP: Section __la_symbol_ptr {
78; DARWIN-G4-DUMP: 0x0 0 2 1 PPC_RELOC_VANILLA 0 dyld_stub_binding_helper
79; DARWIN-G4-DUMP: }
80; DARWIN-G4-DUMP:]