pcrelopt.s 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. .text
  2. .globl _start
  3. _start:
  4. # original PCREL_OPT definition, with second insn immediately after first
  5. pld 9,sym@got@pcrel
  6. .reloc .-8,R_PPC64_PCREL_OPT,0
  7. lbz 3,0(9)
  8. # but we now allow an offset to the second insn
  9. pld 22,sym@got@pcrel
  10. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  11. nop
  12. 0: lhz 4,0(22)
  13. # in fact, it can even be before the "first" insn
  14. 0: lha 3,0(9)
  15. pld 9,sym@got@pcrel
  16. .reloc .-8,R_PPC64_PCREL_OPT,0b-(.-8)
  17. bne 0b
  18. # and of course, other local labels work
  19. pld 9,sym@got@pcrel
  20. .reloc .-8,R_PPC64_PCREL_OPT,.L1-(.-8)
  21. .L1: lwz 3,0(9)
  22. pld 9,sym@got@pcrel
  23. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  24. 0: lwa 3,0(9)
  25. pld 9,sym@got@pcrel
  26. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  27. 0: ld 3,0(9)
  28. pld 9,sym@got@pcrel
  29. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  30. 0: lq 14,0(9)
  31. pld 9,sym@got@pcrel
  32. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  33. 0: lfs 1,0(9)
  34. pld 9,sym@got@pcrel
  35. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  36. 0: lfd 1,0(9)
  37. pld 9,sym@got@pcrel
  38. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  39. 0: lxsd 30,0(9)
  40. pld 9,sym@got@pcrel
  41. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  42. 0: lxssp 31,0(9)
  43. pld 9,sym@got@pcrel
  44. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  45. 0: lxv 63,0(9)
  46. pld 9,sym@got@pcrel
  47. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  48. 0: lxv 0,0(9)
  49. pld 9,sym@got@pcrel
  50. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  51. 0: stb 3,0(9)
  52. pld 9,sym@got@pcrel
  53. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  54. 0: sth 3,0(9)
  55. pld 9,sym@got@pcrel
  56. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  57. 0: stw 3,0(9)
  58. pld 9,sym@got@pcrel
  59. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  60. 0: std 3,0(9)
  61. pld 9,sym@got@pcrel
  62. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  63. 0: stq 14,0(9)
  64. pld 9,sym@got@pcrel
  65. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  66. 0: stfd 1,0(9)
  67. pld 9,sym@got@pcrel
  68. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  69. 0: stfs 2,0(9)
  70. pld 9,sym@got@pcrel
  71. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  72. 0: stxsd 30,0(9)
  73. pld 9,sym@got@pcrel
  74. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  75. 0: stxssp 31,0(9)
  76. pld 9,sym@got@pcrel
  77. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  78. 0: stxv 63,0(9)
  79. pld 9,sym@got@pcrel
  80. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  81. 0: stxv 0,0(9)
  82. #offsets are allowed too
  83. pld 9,sym@got@pcrel
  84. 0:
  85. lbz 3,0x1234(9)
  86. .reloc 0b-8,R_PPC64_PCREL_OPT,(.-4)-(0b-8)
  87. #and prefix insns as the second insn
  88. pld 9,sym@got@pcrel
  89. 0:
  90. plq 4,0x12345678(9)
  91. .reloc 0b-8,R_PPC64_PCREL_OPT,(.-8)-(0b-8)
  92. # This should not optimize
  93. .extern i
  94. .type i,@object
  95. pld 9,i@got@pcrel
  96. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  97. 0: ld 0,0(9)
  98. # and this should edit from GOT indirect to GOT relative
  99. # ie. change the pld to paddi, leaving the lbz as is.
  100. pld 7,sym@got@pcrel
  101. lbz 6,0(7)
  102. pld 9,sym@got@pcrel
  103. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  104. 0: lxvp 62,0(9)
  105. pld 9,sym@got@pcrel
  106. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  107. 0: lxvp 0,0(9)
  108. pld 9,sym@got@pcrel
  109. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  110. 0: stxvp 62,0(9)
  111. pld 9,sym@got@pcrel
  112. .reloc .-8,R_PPC64_PCREL_OPT,0f-(.-8)
  113. 0: stxvp 0,0(9)
  114. .data
  115. sym: .space 32