crt0.S 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (C) Paul Mackerras 1997.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. *
  9. * NOTE: this code runs in 32 bit mode and is packaged as ELF32.
  10. */
  11. #include "ppc_asm.h"
  12. .text
  13. .globl _zimage_start
  14. _zimage_start:
  15. bl reloc_offset
  16. reloc_offset:
  17. mflr r0
  18. lis r9,reloc_offset@ha
  19. addi r9,r9,reloc_offset@l
  20. subf. r0,r9,r0
  21. beq clear_caches
  22. reloc_got2:
  23. lis r9,__got2_start@ha
  24. addi r9,r9,__got2_start@l
  25. lis r8,__got2_end@ha
  26. addi r8,r8,__got2_end@l
  27. subf. r8,r9,r8
  28. beq clear_caches
  29. srwi. r8,r8,2
  30. mtctr r8
  31. add r9,r0,r9
  32. reloc_got2_loop:
  33. lwz r8,0(r9)
  34. add r8,r8,r0
  35. stw r8,0(r9)
  36. addi r9,r9,4
  37. bdnz reloc_got2_loop
  38. clear_caches:
  39. lis r9,_start@h
  40. add r9,r0,r9
  41. lis r8,_etext@ha
  42. addi r8,r8,_etext@l
  43. add r8,r0,r8
  44. 1: dcbf r0,r9
  45. icbi r0,r9
  46. addi r9,r9,0x20
  47. cmplwi 0,r9,8
  48. blt 1b
  49. sync
  50. isync
  51. mr r6,r1
  52. b start