home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / config / rs6000 / eabi.asm < prev    next >
Assembly Source File  |  1995-07-25  |  10KB  |  380 lines

  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.
  3.  
  4.     .file    "eabi.asm"
  5.     .section ".text"
  6.     .globl     __eabi
  7.  
  8.      .section ".got2","aw"
  9. .LCTOC1 = . # +32768
  10.  
  11. # Table of addresses
  12. .Ltable = .-.LCTOC1
  13.     .long    .LCTOC1                # address we are really at
  14.  
  15. .Lgot = .-.LCTOC1
  16.     .long    _GLOBAL_OFFSET_TABLE_        # normal GOT address
  17.  
  18. .Lgots = .-.LCTOC1
  19.     .long    _GOT_START_            # start of .got section
  20.  
  21. .Lgote = .-.LCTOC1
  22.     .long    _GOT_END_            # end of .got section
  23.  
  24. .Lgot2s = .-.LCTOC1
  25.     .long    _GOT2_START_            # -mrelocatable GOT pointers start
  26.  
  27. .Lgot2e = .-.LCTOC1
  28.     .long    _GOT2_END_            # -mrelocatable GOT pointers end
  29.  
  30. .Lfixups = .-.LCTOC1
  31.     .long    _FIXUP_START_            # start of .fixup section
  32.  
  33. .Lfixupe = .-.LCTOC1
  34.     .long    _FIXUP_END_            # end of .fixup section
  35.  
  36.     .text
  37. .Lptr:
  38.     .long    .LCTOC1-.Laddr            # PC relative pointer to .got2
  39.     .long    0x4000                # traceback table
  40.  
  41. __eabi:    mflr    0
  42.     bl    .Laddr                # get current address
  43. .Laddr:
  44.     mflr    12                # real address of .Laddr
  45.     lwz    11,(.Lptr-.Laddr)(12)        # linker generated address of .LCTOC1
  46.     add    11,11,12            # correct to real pointer
  47.     lwz    12,.Ltable(11)            # get linker's idea of where .Laddr is
  48.     subf.    12,12,11            # calculate difference
  49.     mtlr    0                # restore link register
  50.     bc    4,2,.Lreloc            # skip if we need to relocate
  51.  
  52. # Only load up register 2 if there is a .got section
  53.  
  54.     lwz    3,.Lgots(11)            # start of .got section
  55.     lwz    4,.Lgote(11)            # end of .got section
  56.     cmpw    1,3,4                # .got section non-empty?
  57.     bc    12,6,.Ldone
  58.  
  59. # Normal program, load up register 2
  60.  
  61.     lwz    2,.Lgot(11)            # normal GOT address (obsolete in register 2)
  62.     mr    13,2                # also same as _SDA_BASE_ (V.4 small data ptr)
  63.     b    __do_global_ctors        # do any C++ global constructors (which returns to caller)
  64.  
  65. # We need to relocate the .got2 pointers.  Don't load register 2
  66.  
  67. .Lreloc:
  68.     lwz    3,.Lgot2s(11)            # GOT pointers start
  69.     lwz    4,.Lgot2e(11)            # GOT pointers end
  70.     add    3,12,3                # adjust pointers
  71.     add    4,12,4
  72.  
  73.     cmpw    1,3,4                # any pointers to adjust
  74.     bc    12,6,.Lfix
  75.  
  76. .Lloop:
  77.     lwz    5,0(3)                # next pointer
  78.     add    5,5,12                # adjust
  79.     stw    5,0(3)
  80.     addi    3,3,4                # bump to next word
  81.     cmpw    1,3,4                # more pointers to adjust?
  82.     bc    4,6,.Lloop
  83.  
  84. # Fixup any user initialized pointers now (the compiler drops pointers to
  85. # each of the relocs that it does in the .fixup section).  Note, the pointers
  86. # themselves have already been fixed up by the previous loop.
  87.  
  88. .Lfix:
  89.     lwz    3,.Lfixups(11)            # fixup pointers start
  90.     lwz    4,.Lfixupe(11)            # fixup pointers end
  91.  
  92.     cmpw    1,3,4                # any user pointers to adjust
  93.     bc    12,6,.Ldone
  94.  
  95. .Lfloop:
  96.     lwz    5,0(3)                # next pointer
  97.     lwz    6,0(5)                # get the pointer it points to
  98.     add    6,6,12                # adjust
  99.     stw    6,0(5)
  100.     addi    3,3,4                # bump to next word
  101.     cmpw    1,3,4                # more pointers to adjust?
  102.     bc    4,6,.Lfloop
  103.  
  104. # Done adjusting pointers, return
  105.  
  106. .Ldone:
  107.     b    __do_global_ctors        # do any C++ global constructors (which returns to caller)
  108.  
  109. # Routines for saving floating point registers, called by the compiler.
  110. # Called with r11 pointing to the stack header word of the caller of the
  111. # function, just beyond the end of the floating point save area.
  112.  
  113.     .globl    _savefpr_14
  114.     .globl    _savefpr_15
  115.     .globl    _savefpr_16
  116.     .globl    _savefpr_17
  117.     .globl    _savefpr_18
  118.     .globl    _savefpr_19
  119.     .globl    _savefpr_20
  120.     .globl    _savefpr_21
  121.     .globl    _savefpr_22
  122.     .globl    _savefpr_23
  123.     .globl    _savefpr_24
  124.     .globl    _savefpr_25
  125.     .globl    _savefpr_26
  126.     .globl    _savefpr_27
  127.     .globl    _savefpr_28
  128.     .globl    _savefpr_29
  129.     .globl    _savefpr_30
  130.     .globl    _savefpr_31
  131.  
  132.         .long    0x00400000    # traceback tag
  133. _savefpr_14:    stfd    14,-144(11)    # save fp registers
  134. _savefpr_15:    stfd    15,-136(11)
  135. _savefpr_16:    stfd    16,-128(11)
  136. _savefpr_17:    stfd    17,-120(11)
  137. _savefpr_18:    stfd    18,-112(11)
  138. _savefpr_19:    stfd    19,-104(11)
  139. _savefpr_20:    stfd    20,-96(11)
  140. _savefpr_21:    stfd    21,-88(11)
  141. _savefpr_22:    stfd    22,-80(11)
  142. _savefpr_23:    stfd    23,-72(11)
  143. _savefpr_24:    stfd    24,-64(11)
  144. _savefpr_25:    stfd    25,-56(11)
  145. _savefpr_26:    stfd    26,-48(11)
  146. _savefpr_27:    stfd    27,-40(11)
  147. _savefpr_28:    stfd    28,-32(11)
  148. _savefpr_29:    stfd    29,-24(11)
  149. _savefpr_30:    stfd    30,-16(11)
  150. _savefpr_31:    stfd    31,-8(11)
  151.         blr
  152.  
  153. # Routines for saving integer registers, called by the compiler.
  154. # Called with r11 pointing to the stack header word of the caller of the
  155. # function, just beyond the end of the integer save area.
  156.  
  157.     .globl    _savegpr_14
  158.     .globl    _savegpr_15
  159.     .globl    _savegpr_16
  160.     .globl    _savegpr_17
  161.     .globl    _savegpr_18
  162.     .globl    _savegpr_19
  163.     .globl    _savegpr_20
  164.     .globl    _savegpr_21
  165.     .globl    _savegpr_22
  166.     .globl    _savegpr_23
  167.     .globl    _savegpr_24
  168.     .globl    _savegpr_25
  169.     .globl    _savegpr_26
  170.     .globl    _savegpr_27
  171.     .globl    _savegpr_28
  172.     .globl    _savegpr_29
  173.     .globl    _savegpr_30
  174.     .globl    _savegpr_31
  175.  
  176.         .long    0x00400000    # traceback tag
  177. _savegpr_14:    stw    14,-72(11)    # save gp registers
  178. _savegpr_15:    stw    15,-68(11)
  179. _savegpr_16:    stw    16,-64(11)
  180. _savegpr_17:    stw    17,-60(11)
  181. _savegpr_18:    stw    18,-56(11)
  182. _savegpr_19:    stw    19,-52(11)
  183. _savegpr_20:    stw    20,-48(11)
  184. _savegpr_21:    stw    21,-44(11)
  185. _savegpr_22:    stw    22,-40(11)
  186. _savegpr_23:    stw    23,-36(11)
  187. _savegpr_24:    stw    24,-32(11)
  188. _savegpr_25:    stw    25,-28(11)
  189. _savegpr_26:    stw    26,-24(11)
  190. _savegpr_27:    stw    27,-20(11)
  191. _savegpr_28:    stw    28,-16(11)
  192. _savegpr_29:    stw    29,-12(11)
  193. _savegpr_30:    stw    30,-8(11)
  194. _savegpr_31:    stw    31,-4(11)
  195.         blr
  196.  
  197. # Routines for restoring floating point registers, called by the compiler.
  198. # Called with r11 pointing to the stack header word of the caller of the
  199. # function, just beyond the end of the floating point save area.
  200.  
  201.     .globl    _restfpr_14
  202.     .globl    _restfpr_15
  203.     .globl    _restfpr_16
  204.     .globl    _restfpr_17
  205.     .globl    _restfpr_18
  206.     .globl    _restfpr_19
  207.     .globl    _restfpr_20
  208.     .globl    _restfpr_21
  209.     .globl    _restfpr_22
  210.     .globl    _restfpr_23
  211.     .globl    _restfpr_24
  212.     .globl    _restfpr_25
  213.     .globl    _restfpr_26
  214.     .globl    _restfpr_27
  215.     .globl    _restfpr_28
  216.     .globl    _restfpr_29
  217.     .globl    _restfpr_30
  218.     .globl    _restfpr_31
  219.  
  220.         .long    0x00600000    # traceback tag
  221. _restfpr_14:    lfd    14,-144(11)    # restore fp registers
  222. _restfpr_15:    lfd    15,-136(11)
  223. _restfpr_16:    lfd    16,-128(11)
  224. _restfpr_17:    lfd    17,-120(11)
  225. _restfpr_18:    lfd    18,-112(11)
  226. _restfpr_19:    lfd    19,-104(11)
  227. _restfpr_20:    lfd    20,-96(11)
  228. _restfpr_21:    lfd    21,-88(11)
  229. _restfpr_22:    lfd    22,-80(11)
  230. _restfpr_23:    lfd    23,-72(11)
  231. _restfpr_24:    lfd    24,-64(11)
  232. _restfpr_25:    lfd    25,-56(11)
  233. _restfpr_26:    lfd    26,-48(11)
  234. _restfpr_27:    lfd    27,-40(11)
  235. _restfpr_28:    lfd    28,-32(11)
  236. _restfpr_29:    lfd    29,-24(11)
  237. _restfpr_30:    lfd    30,-16(11)
  238. _restfpr_31:    lfd    31,-8(11)
  239.         blr
  240.  
  241. # Routines for restoring integer registers, called by the compiler.
  242. # Called with r11 pointing to the stack header word of the caller of the
  243. # function, just beyond the end of the integer restore area.
  244.  
  245.     .globl    _restgpr_14
  246.     .globl    _restgpr_15
  247.     .globl    _restgpr_16
  248.     .globl    _restgpr_17
  249.     .globl    _restgpr_18
  250.     .globl    _restgpr_19
  251.     .globl    _restgpr_20
  252.     .globl    _restgpr_21
  253.     .globl    _restgpr_22
  254.     .globl    _restgpr_23
  255.     .globl    _restgpr_24
  256.     .globl    _restgpr_25
  257.     .globl    _restgpr_26
  258.     .globl    _restgpr_27
  259.     .globl    _restgpr_28
  260.     .globl    _restgpr_29
  261.     .globl    _restgpr_30
  262.     .globl    _restgpr_31
  263.  
  264.         .long    0x00600000    # traceback tag
  265. _restgpr_14:    lwz    14,-72(11)    # rest gp registers
  266. _restgpr_15:    lwz    15,-68(11)
  267. _restgpr_16:    lwz    16,-64(11)
  268. _restgpr_17:    lwz    17,-60(11)
  269. _restgpr_18:    lwz    18,-56(11)
  270. _restgpr_19:    lwz    19,-52(11)
  271. _restgpr_20:    lwz    20,-48(11)
  272. _restgpr_21:    lwz    21,-44(11)
  273. _restgpr_22:    lwz    22,-40(11)
  274. _restgpr_23:    lwz    23,-36(11)
  275. _restgpr_24:    lwz    24,-32(11)
  276. _restgpr_25:    lwz    25,-28(11)
  277. _restgpr_26:    lwz    26,-24(11)
  278. _restgpr_27:    lwz    27,-20(11)
  279. _restgpr_28:    lwz    28,-16(11)
  280. _restgpr_29:    lwz    29,-12(11)
  281. _restgpr_30:    lwz    30,-8(11)
  282. _restgpr_31:    lwz    31,-4(11)
  283.         blr
  284.  
  285. # Routines for restoring floating point registers, called by the compiler.
  286. # Called with r11 pointing to the stack header word of the caller of the
  287. # function, just beyond the end of the floating point save area.
  288. # In addition to restoring the fp registers, it will return to the caller's
  289. # caller
  290.  
  291.     .globl    _restfpr_14_x
  292.     .globl    _restfpr_15_x
  293.     .globl    _restfpr_16_x
  294.     .globl    _restfpr_17_x
  295.     .globl    _restfpr_18_x
  296.     .globl    _restfpr_19_x
  297.     .globl    _restfpr_20_x
  298.     .globl    _restfpr_21_x
  299.     .globl    _restfpr_22_x
  300.     .globl    _restfpr_23_x
  301.     .globl    _restfpr_24_x
  302.     .globl    _restfpr_25_x
  303.     .globl    _restfpr_26_x
  304.     .globl    _restfpr_27_x
  305.     .globl    _restfpr_28_x
  306.     .globl    _restfpr_29_x
  307.     .globl    _restfpr_30_x
  308.     .globl    _restfpr_31_x
  309.  
  310.         .long    0x00600000    # traceback tag
  311. _restfpr_14_x:    lfd    14,-144(11)    # restore fp registers
  312. _restfpr_15_x:    lfd    15,-136(11)
  313. _restfpr_16_x:    lfd    16,-128(11)
  314. _restfpr_17_x:    lfd    17,-120(11)
  315. _restfpr_18_x:    lfd    18,-112(11)
  316. _restfpr_19_x:    lfd    19,-104(11)
  317. _restfpr_20_x:    lfd    20,-96(11)
  318. _restfpr_21_x:    lfd    21,-88(11)
  319. _restfpr_22_x:    lfd    22,-80(11)
  320. _restfpr_23_x:    lfd    23,-72(11)
  321. _restfpr_24_x:    lfd    24,-64(11)
  322. _restfpr_25_x:    lfd    25,-56(11)
  323. _restfpr_26_x:    lfd    26,-48(11)
  324. _restfpr_27_x:    lfd    27,-40(11)
  325. _restfpr_28_x:    lfd    28,-32(11)
  326. _restfpr_29_x:    lfd    29,-24(11)
  327. _restfpr_30_x:    lfd    30,-16(11)
  328. _restfpr_31_x:    lwz    0,4(11)
  329.         lfd    31,-8(11)
  330.         mtlr    0
  331.         mr    1,11
  332.         blr
  333.  
  334. # Routines for restoring integer registers, called by the compiler.
  335. # Called with r11 pointing to the stack header word of the caller of the
  336. # function, just beyond the end of the integer restore area.
  337.  
  338.     .globl    _restgpr_14_x
  339.     .globl    _restgpr_15_x
  340.     .globl    _restgpr_16_x
  341.     .globl    _restgpr_17_x
  342.     .globl    _restgpr_18_x
  343.     .globl    _restgpr_19_x
  344.     .globl    _restgpr_20_x
  345.     .globl    _restgpr_21_x
  346.     .globl    _restgpr_22_x
  347.     .globl    _restgpr_23_x
  348.     .globl    _restgpr_24_x
  349.     .globl    _restgpr_25_x
  350.     .globl    _restgpr_26_x
  351.     .globl    _restgpr_27_x
  352.     .globl    _restgpr_28_x
  353.     .globl    _restgpr_29_x
  354.     .globl    _restgpr_30_x
  355.     .globl    _restgpr_31_x
  356.  
  357.         .long    0x00600000    # traceback tag
  358. _restgpr_14_x:    lwz    14,-72(11)    # rest gp registers
  359. _restgpr_15_x:    lwz    15,-68(11)
  360. _restgpr_16_x:    lwz    16,-64(11)
  361. _restgpr_17_x:    lwz    17,-60(11)
  362. _restgpr_18_x:    lwz    18,-56(11)
  363. _restgpr_19_x:    lwz    19,-52(11)
  364. _restgpr_20_x:    lwz    20,-48(11)
  365. _restgpr_21_x:    lwz    21,-44(11)
  366. _restgpr_22_x:    lwz    22,-40(11)
  367. _restgpr_23_x:    lwz    23,-36(11)
  368. _restgpr_24_x:    lwz    24,-32(11)
  369. _restgpr_25_x:    lwz    25,-28(11)
  370. _restgpr_26_x:    lwz    26,-24(11)
  371. _restgpr_27_x:    lwz    27,-20(11)
  372. _restgpr_28_x:    lwz    28,-16(11)
  373. _restgpr_29_x:    lwz    29,-12(11)
  374. _restgpr_30_x:    lwz    30,-8(11)
  375. _restgpr_31_x:    lwz    0,4(11)
  376.         lwz    31,-4(11)
  377.         mtlr    0
  378.         mr    1,11
  379.         blr
  380.