ld-segfault-linux-modules.xtensa 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. From e7d17e71cdc10a2e81e454ce3b9637f1b2a587f2 Mon Sep 17 00:00:00 2001
  2. From: Max Filippov <jcmvbkbc@gmail.com>
  3. Date: Thu, 10 Jul 2014 01:47:33 +0400
  4. Subject: [PATCH] Fix xtensa ld segfault when linking linux modules
  5. is_inconsistent_linkonce_section makes an assumption that section name
  6. that starts with ".gnu.linkonce.prop." has one more dot in its suffix.
  7. However gas generates such section name by insertion of "prop." right
  8. after ".gnu.linkonce." part of the name of the original section. So, for
  9. section named ".gnu.linkonce.this_module" corresponding property section
  10. name does not satisfy the assumption. Such section names are common in
  11. linux modules. This bug was exposed by the patch "a35d5e8 Fix alignment
  12. for the first section frag on xtensa", that makes gas produce property
  13. section for each section that has ".align" directive in it.
  14. Use suffix that immediately follows ".gnu.linkonce.prop." when there are
  15. no more dots following it.
  16. 2014-07-10 Max Filippov <jcmvbkbc@gmail.com>
  17. ld/
  18. * emultempl/xtensaelf.em (is_inconsistent_linkonce_section):
  19. correctly handle missing dot in section name after
  20. ".gnu.linkonce.prop.".
  21. ---
  22. Backported from: e7d17e71cdc10a2e81e454ce3b9637f1b2a587f2
  23. Changes to ld/ChangeLog file are dropped.
  24. ld/emultempl/xtensaelf.em | 2 +-
  25. 1 file changed, 1 insertion(+), 1 deletion(-)
  26. diff --git a/ld/emultempl/xtensaelf.em b/ld/emultempl/xtensaelf.em
  27. index 151eea4..948d18d 100644
  28. --- a/ld/emultempl/xtensaelf.em
  29. +++ b/ld/emultempl/xtensaelf.em
  30. @@ -1310,7 +1310,7 @@ is_inconsistent_linkonce_section (asection *sec)
  31. for Tensilica's XCC compiler. */
  32. name = sec_name + linkonce_len;
  33. if (CONST_STRNEQ (name, "prop."))
  34. - name = strchr (name + 5, '.') + 1;
  35. + name = strchr (name + 5, '.') ? strchr (name + 5, '.') + 1 : name + 5;
  36. else if (name[1] == '.'
  37. && (name[0] == 'p' || name[0] == 'e' || name[0] == 'h'))
  38. name += 2;
  39. --
  40. 1.8.1.4