1 From bbb86582536ba9e4ab0fb4656d4697542172ab78 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
7 We need binutils to look at our ld.so.conf file within the SDK to ensure
8 we search the SDK's libdirs as well as those from the host system.
10 We therefore pass in the directory to the code using a define, then add
11 it to a section we relocate in a similar way to the way we relocate the
12 gcc internal paths. This ensures that ld works correctly in our buildtools
15 Standard sysroot relocation doesn't work since we're not in a sysroot,
16 we want to use both the host system and SDK libs.
18 Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
20 Upstream-Status: Inappropriate [OE specific tweak]
22 Signed-off-by: Khem Raj <raj.khem@gmail.com>
24 ld/Makefile.am | 3 ++-
25 ld/Makefile.in | 3 ++-
29 5 files changed, 7 insertions(+), 3 deletions(-)
31 diff --git a/ld/Makefile.am b/ld/Makefile.am
32 index 6a9833e5775..b2776d2a1f3 100644
35 @@ -42,7 +42,8 @@ ZLIBINC = @zlibinc@
37 ELF_CFLAGS=-DELF_LIST_OPTIONS=@elf_list_options@ \
38 -DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
39 - -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
40 + -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@ \
41 + -DSYSCONFDIR="\"$(sysconfdir)\""
42 WARN_CFLAGS = @WARN_CFLAGS@
43 NO_WERROR = @NO_WERROR@
44 AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CFLAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
45 diff --git a/ld/Makefile.in b/ld/Makefile.in
46 index 8639e782cdf..19c19088724 100644
49 @@ -576,7 +576,8 @@ ZLIB = @zlibdir@ -lz
51 ELF_CFLAGS = -DELF_LIST_OPTIONS=@elf_list_options@ \
52 -DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
53 - -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
54 + -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@ \
55 + -DSYSCONFDIR="\"$(sysconfdir)\""
57 AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CFLAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
59 diff --git a/ld/ldelf.c b/ld/ldelf.c
60 index 09691609fc0..e49c0217ae2 100644
63 @@ -939,7 +939,7 @@ ldelf_check_ld_so_conf (const struct bfd_link_needed_list *l, int force,
66 info.len = info.alloc = 0;
67 - tmppath = concat (ld_sysroot, prefix, "/etc/ld.so.conf",
68 + tmppath = concat (ld_sysconfdir, "/ld.so.conf",
70 if (!ldelf_parse_ld_so_conf (&info, tmppath))
72 diff --git a/ld/ldmain.c b/ld/ldmain.c
73 index 037099b9d37..2f500d73c58 100644
76 @@ -69,6 +69,7 @@ char *program_name;
78 /* The prefix for system library directories. */
79 const char *ld_sysroot;
80 +char ld_sysconfdir[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSCONFDIR;
82 /* The canonical representation of ld_sysroot. */
83 char *ld_canon_sysroot;
84 diff --git a/ld/ldmain.h b/ld/ldmain.h
85 index 0238aed0ebd..2dd00db13b3 100644
90 extern char *program_name;
91 extern const char *ld_sysroot;
92 +extern char ld_sysconfdir[4096];
93 extern char *ld_canon_sysroot;
94 extern int ld_canon_sysroot_len;
95 extern FILE *saved_script_handle;