0004-add-sysroot-fix-from-bug-3049.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 378bda0e19d279535b3f4a0e448a658a534a5d67 Mon Sep 17 00:00:00 2001
  2. From: Romain Naour <romain.naour@gmail.com>
  3. Date: Fri, 25 Dec 2015 11:42:48 +0100
  4. Subject: [PATCH] add sysroot fix from bug #3049
  5. Always try to prepend the sysroot prefix to absolute filenames first.
  6. http://bugs.gentoo.org/275666
  7. http://sourceware.org/bugzilla/show_bug.cgi?id=10340
  8. Signed-off-by: Sven Rebhan <odinshorse@googlemail.com>
  9. [Romain: rebase on top of 2.26]
  10. Signed-off-by: Romain Naour <romain.naour@gmail.com>
  11. ---
  12. ld/ldfile.c | 10 ++++++++--
  13. 1 file changed, 8 insertions(+), 2 deletions(-)
  14. diff --git a/ld/ldfile.c b/ld/ldfile.c
  15. index 3b37a0a..f7e5473 100644
  16. --- a/ld/ldfile.c
  17. +++ b/ld/ldfile.c
  18. @@ -338,18 +338,24 @@ ldfile_open_file_search (const char *arch,
  19. directory first. */
  20. if (!entry->flags.maybe_archive)
  21. {
  22. - if (entry->flags.sysrooted && IS_ABSOLUTE_PATH (entry->filename))
  23. + /* For absolute pathnames, try to always open the file in the
  24. + sysroot first. If this fails, try to open the file at the
  25. + given location. */
  26. + entry->flags.sysrooted = is_sysrooted_pathname (entry->filename);
  27. + if (!entry->flags.sysrooted && IS_ABSOLUTE_PATH (entry->filename)
  28. + && ld_sysroot)
  29. {
  30. char *name = concat (ld_sysroot, entry->filename,
  31. (const char *) NULL);
  32. if (ldfile_try_open_bfd (name, entry))
  33. {
  34. entry->filename = name;
  35. + entry->flags.sysrooted = TRUE;
  36. return TRUE;
  37. }
  38. free (name);
  39. }
  40. - else if (ldfile_try_open_bfd (entry->filename, entry))
  41. + if (ldfile_try_open_bfd (entry->filename, entry))
  42. return TRUE;
  43. if (IS_ABSOLUTE_PATH (entry->filename))
  44. --
  45. 2.9.4