0003-binutils-nativesdk-Search-for-alternative-ld.so.conf.patch 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. From d49016d3faf684319bf3ac37450558920d70be03 Mon Sep 17 00:00:00 2001
  2. From: Richard Purdie <richard.purdie@linuxfoundation.org>
  3. Date: Wed, 19 Feb 2020 09:51:16 -0800
  4. Subject: [PATCH] binutils-nativesdk: Search for alternative ld.so.conf in SDK
  5. installation
  6. We need binutils to look at our ld.so.conf file within the SDK to ensure
  7. we search the SDK's libdirs as well as those from the host system.
  8. We therefore pass in the directory to the code using a define, then add
  9. it to a section we relocate in a similar way to the way we relocate the
  10. gcc internal paths. This ensures that ld works correctly in our buildtools
  11. tarball.
  12. Standard sysroot relocation doesn't work since we're not in a sysroot,
  13. we want to use both the host system and SDK libs.
  14. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
  15. 2020/1/17
  16. Upstream-Status: Inappropriate [OE specific tweak]
  17. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  18. ---
  19. ld/Makefile.am | 3 ++-
  20. ld/Makefile.in | 3 ++-
  21. ld/ldelf.c | 2 +-
  22. ld/ldmain.c | 1 +
  23. ld/ldmain.h | 1 +
  24. 5 files changed, 7 insertions(+), 3 deletions(-)
  25. diff --git a/ld/Makefile.am b/ld/Makefile.am
  26. index f8e99325361..fd196541f59 100644
  27. --- a/ld/Makefile.am
  28. +++ b/ld/Makefile.am
  29. @@ -42,7 +42,8 @@ ZLIBINC = @zlibinc@
  30. ELF_CLFAGS=-DELF_LIST_OPTIONS=@elf_list_options@ \
  31. -DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
  32. - -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
  33. + -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@ \
  34. + -DSYSCONFDIR="\"$(sysconfdir)\""
  35. WARN_CFLAGS = @WARN_CFLAGS@
  36. NO_WERROR = @NO_WERROR@
  37. AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
  38. diff --git a/ld/Makefile.in b/ld/Makefile.in
  39. index ef2e99e08da..cb8f5bfb70e 100644
  40. --- a/ld/Makefile.in
  41. +++ b/ld/Makefile.in
  42. @@ -555,7 +555,8 @@ ZLIB = @zlibdir@ -lz
  43. ZLIBINC = @zlibinc@
  44. ELF_CLFAGS = -DELF_LIST_OPTIONS=@elf_list_options@ \
  45. -DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
  46. - -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
  47. + -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@ \
  48. + -DSYSCONFDIR="\"$(sysconfdir)\""
  49. AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
  50. diff --git a/ld/ldelf.c b/ld/ldelf.c
  51. index 21e655bb55c..d1615003ede 100644
  52. --- a/ld/ldelf.c
  53. +++ b/ld/ldelf.c
  54. @@ -911,7 +911,7 @@ ldelf_check_ld_so_conf (const struct bfd_link_needed_list *l, int force,
  55. info.path = NULL;
  56. info.len = info.alloc = 0;
  57. - tmppath = concat (ld_sysroot, prefix, "/etc/ld.so.conf",
  58. + tmppath = concat (ld_sysconfdir, "/etc/ld.so.conf",
  59. (const char *) NULL);
  60. if (!ldelf_parse_ld_so_conf (&info, tmppath))
  61. {
  62. diff --git a/ld/ldmain.c b/ld/ldmain.c
  63. index 42660eb9a3c..5a4a4d5da3d 100644
  64. --- a/ld/ldmain.c
  65. +++ b/ld/ldmain.c
  66. @@ -70,6 +70,7 @@ char *program_name;
  67. /* The prefix for system library directories. */
  68. const char *ld_sysroot;
  69. +char ld_sysconfdir[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSCONFDIR;
  70. /* The canonical representation of ld_sysroot. */
  71. char *ld_canon_sysroot;
  72. diff --git a/ld/ldmain.h b/ld/ldmain.h
  73. index 39d08a6c378..4c3519e7970 100644
  74. --- a/ld/ldmain.h
  75. +++ b/ld/ldmain.h
  76. @@ -23,6 +23,7 @@
  77. extern char *program_name;
  78. extern const char *ld_sysroot;
  79. +extern char ld_sysconfdir[4096];
  80. extern char *ld_canon_sysroot;
  81. extern int ld_canon_sysroot_len;
  82. extern FILE *saved_script_handle;