1 # File to either setup register 2 to point to the GOT, or to adjust the
2 # pointers in the .got2 section to point to their new addresses.
13 .long .Laddr # address we are really at
14 .long _GLOBAL_OFFSET_TABLE_ # normal GOT address
15 .long _GOT2_START_ # -mrelocatable GOT pointers start
16 .long _GOT2_END_ # -mrelocatable GOT pointers end
19 .Lptr: .long .LCTOC1-.Laddr # PC relative pointer to .got2
20 .long 0x4000 # traceback table
23 bl .Laddr # get current address
24 .Laddr: mflr 11 # real address of .Ltable
25 lwz 12,(.Lptr-.Laddr)(11) # linker generated address of .Ltable
26 add 12,12,11 # correct to real pointer
27 subf. 12,12,11 # calculate difference
28 bc 4,2,.Lreloc # skip if we need to relocate
30 # Normal program, load up register 2
32 mtlr 0 # restore link register
33 lwz 2,4(11) # normal GOT address
36 # We need to relocate the .got2 pointers. Don't load register 2
41 lwz 30,8(11) # GOT pointers start
42 lwz 31,12(11) # GOT pointers end
43 add 30,12,30 # adjust pointers
46 cmpw 1,30,31 # any pointers to adjust
49 .Lloop: lwz 11,0(30) # next pointer
52 addi 30,30,4 # bump to next word
53 cmpw 1,30,31 # more pointers to adjust?
56 # Done adjusting pointers, return
59 mtlr 0 # restore link register
61 lwz 30,4(1) # restore regs
62 addic 1,1,8 # pop stack