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.
8 .long 0x4000 # traceback table
10 bl .Laddr # get current address
14 .long .Ltable # address we are really at
15 .long _GLOBAL_OFFSET_TABLE_ # normal GOT address
16 .long _GOT2_START_ # -mrelocatable GOT pointers start
17 .long _GOT2_END_ # -mrelocatable GOT pointers end
19 .Laddr: mflr 11 # real address of .Ltable
20 lwz 12,0(11) # linker generated address of .Ltable
21 subf. 12,12,11 # calculate difference
22 bc 4,2,.Lreloc # skip if we need to relocate
24 # Normal program, load up register 2
26 mtlr 0 # restore link register
27 lwz 2,4(11) # normal GOT address
30 # We need to relocate the .got2 pointers. Don't load register 2
35 lwz 30,8(11) # GOT pointers start
36 lwz 31,12(11) # GOT pointers end
37 add 30,12,30 # adjust pointers
40 cmpw 1,30,31 # any pointers to adjust
43 .Lloop: lwz 11,0(30) # next pointer
46 addi 30,30,4 # bump to next word
47 cmpw 1,30,31 # more pointers to adjust?
50 # Done adjusting pointers, return
53 mtlr 0 # restore link register
55 lwz 30,4(1) # restore regs
56 addic 1,1,8 # pop stack