320-mips-elf-reloc-regression.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. diff -ur binutils-2.17.50.0.12/bfd/elfxx-mips.c binutils-2.17.50.0.12-patched/bfd/elfxx-mips.c
  2. --- binutils-2.17.50.0.12/bfd/elfxx-mips.c 2006-11-27 16:21:04.000000000 -0600
  3. +++ binutils-2.17.50.0.12-patched/bfd/elfxx-mips.c 2007-03-20 15:25:42.000000000 -0500
  4. @@ -3615,7 +3615,6 @@
  5. }
  6. /* We didn't find it. */
  7. - bfd_set_error (bfd_error_bad_value);
  8. return NULL;
  9. }
  10. @@ -7849,32 +7848,36 @@
  11. several relocations for the same address. In
  12. that case, the R_MIPS_LO16 relocation may occur
  13. as one of these. We permit a similar extension
  14. - in general, as that is useful for GCC. */
  15. + in general, as that is useful for GCC.
  16. +
  17. + In some cases GCC dead code elimination removes
  18. + the LO16 but keeps the corresponding HI16. */
  19. lo16_relocation = mips_elf_next_relocation (input_bfd,
  20. lo16_type,
  21. rel, relend);
  22. - if (lo16_relocation == NULL)
  23. - return FALSE;
  24. -
  25. - lo16_location = contents + lo16_relocation->r_offset;
  26. + if (lo16_relocation != NULL)
  27. + {
  28. + lo16_location = contents + lo16_relocation->r_offset;
  29. - /* Obtain the addend kept there. */
  30. - lo16_howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd,
  31. - lo16_type, FALSE);
  32. - _bfd_mips16_elf_reloc_unshuffle (input_bfd, lo16_type, FALSE,
  33. - lo16_location);
  34. - l = mips_elf_obtain_contents (lo16_howto, lo16_relocation,
  35. - input_bfd, contents);
  36. - _bfd_mips16_elf_reloc_shuffle (input_bfd, lo16_type, FALSE,
  37. - lo16_location);
  38. - l &= lo16_howto->src_mask;
  39. - l <<= lo16_howto->rightshift;
  40. - l = _bfd_mips_elf_sign_extend (l, 16);
  41. + /* Obtain the addend kept there. */
  42. + lo16_howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd,
  43. + lo16_type, FALSE);
  44. + _bfd_mips16_elf_reloc_unshuffle (input_bfd, lo16_type,
  45. + FALSE, lo16_location);
  46. + l = mips_elf_obtain_contents (lo16_howto,
  47. + lo16_relocation,
  48. + input_bfd, contents);
  49. + _bfd_mips16_elf_reloc_shuffle (input_bfd, lo16_type,
  50. + FALSE, lo16_location);
  51. + l &= lo16_howto->src_mask;
  52. + l <<= lo16_howto->rightshift;
  53. + l = _bfd_mips_elf_sign_extend (l, 16);
  54. - addend <<= 16;
  55. + addend <<= 16;
  56. - /* Compute the combined addend. */
  57. - addend += l;
  58. + /* Compute the combined addend. */
  59. + addend += l;
  60. + }
  61. }
  62. else
  63. addend <<= howto->rightshift;