blob: 8e5e2be81dd02b1b85653708a18cc49c1981438e [file] [log] [blame]
Andrew Geisslerc5535c92023-01-27 16:10:19 -06001From 90d1bb804033a74b54f64cd5d3127c004c266af8 Mon Sep 17 00:00:00 2001
Andrew Geissler82c905d2020-04-13 13:39:40 -05002From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Wed, 19 Feb 2020 09:51:16 -0800
Andrew Geisslerd1e89492021-02-12 15:35:20 -06004Subject: [PATCH] binutils-nativesdk: Search for alternative ld.so.conf in SDK
5 installation
Andrew Geissler82c905d2020-04-13 13:39:40 -05006
7We need binutils to look at our ld.so.conf file within the SDK to ensure
8we search the SDK's libdirs as well as those from the host system.
9
10We therefore pass in the directory to the code using a define, then add
11it to a section we relocate in a similar way to the way we relocate the
12gcc internal paths. This ensures that ld works correctly in our buildtools
13tarball.
14
15Standard sysroot relocation doesn't work since we're not in a sysroot,
16we want to use both the host system and SDK libs.
17
18Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
192020/1/17
20Upstream-Status: Inappropriate [OE specific tweak]
21
22Signed-off-by: Khem Raj <raj.khem@gmail.com>
23---
24 ld/Makefile.am | 3 ++-
25 ld/Makefile.in | 3 ++-
26 ld/ldelf.c | 2 +-
27 ld/ldmain.c | 1 +
28 ld/ldmain.h | 1 +
29 5 files changed, 7 insertions(+), 3 deletions(-)
30
31diff --git a/ld/Makefile.am b/ld/Makefile.am
Andrew Geisslerc5535c92023-01-27 16:10:19 -060032index 12b2c3c453f..0590b7055d0 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050033--- a/ld/Makefile.am
34+++ b/ld/Makefile.am
35@@ -42,7 +42,8 @@ ZLIBINC = @zlibinc@
36
37 ELF_CLFAGS=-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@
Andrew Geisslerc5535c92023-01-27 16:10:19 -060044 AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
Andrew Geissler82c905d2020-04-13 13:39:40 -050045diff --git a/ld/Makefile.in b/ld/Makefile.in
Andrew Geisslerc5535c92023-01-27 16:10:19 -060046index 3d5685d6bae..70643b1ce46 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050047--- a/ld/Makefile.in
48+++ b/ld/Makefile.in
Andrew Geisslerc5535c92023-01-27 16:10:19 -060049@@ -566,7 +566,8 @@ ZLIB = @zlibdir@ -lz
Andrew Geissler82c905d2020-04-13 13:39:40 -050050 ZLIBINC = @zlibinc@
51 ELF_CLFAGS = -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)\""
56
Andrew Geisslerc5535c92023-01-27 16:10:19 -060057 AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
Andrew Geissler635e0e42020-08-21 15:58:33 -050058
Andrew Geissler82c905d2020-04-13 13:39:40 -050059diff --git a/ld/ldelf.c b/ld/ldelf.c
Andrew Geisslerc5535c92023-01-27 16:10:19 -060060index eff6693e052..95787012b89 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050061--- a/ld/ldelf.c
62+++ b/ld/ldelf.c
Patrick Williams92b42cb2022-09-03 06:53:57 -050063@@ -936,7 +936,7 @@ ldelf_check_ld_so_conf (const struct bfd_link_needed_list *l, int force,
Andrew Geissler82c905d2020-04-13 13:39:40 -050064
65 info.path = NULL;
66 info.len = info.alloc = 0;
67- tmppath = concat (ld_sysroot, prefix, "/etc/ld.so.conf",
Andrew Geissler635e0e42020-08-21 15:58:33 -050068+ tmppath = concat (ld_sysconfdir, "/etc/ld.so.conf",
Andrew Geissler82c905d2020-04-13 13:39:40 -050069 (const char *) NULL);
70 if (!ldelf_parse_ld_so_conf (&info, tmppath))
71 {
72diff --git a/ld/ldmain.c b/ld/ldmain.c
Andrew Geisslerc5535c92023-01-27 16:10:19 -060073index 9290a189b0d..ceaca2d85d0 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050074--- a/ld/ldmain.c
75+++ b/ld/ldmain.c
Andrew Geissler635e0e42020-08-21 15:58:33 -050076@@ -70,6 +70,7 @@ char *program_name;
Andrew Geissler82c905d2020-04-13 13:39:40 -050077
78 /* The prefix for system library directories. */
79 const char *ld_sysroot;
80+char ld_sysconfdir[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSCONFDIR;
81
82 /* The canonical representation of ld_sysroot. */
83 char *ld_canon_sysroot;
84diff --git a/ld/ldmain.h b/ld/ldmain.h
Andrew Geisslerc5535c92023-01-27 16:10:19 -060085index dda124b96e8..ba06a7d7be2 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050086--- a/ld/ldmain.h
87+++ b/ld/ldmain.h
88@@ -23,6 +23,7 @@
89
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;