1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
4 # T2 SDE: package/.../binutils/ld-glob.patch
5 # Copyright (C) 2004 - 2020 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 This adds /etc/ld.so.conf globbing to the GNU linker. We need this, since we
18 also patch the glibc's dynamic linker and the linker needs to be able to
19 scan the directories, too.
21 Signed-of-by: René Rebe <rene@exactcode.de>
23 --- binutils-2.35/ld/ldelf.c.vanilla 2020-10-06 19:30:24.354063941 +0200
24 +++ binutils-2.35/ld/ldelf.c 2020-10-06 19:29:55.114064099 +0200
30 + else /* normal dir (e.g. no include) */
33 while (*p && *p != '=' && *p != ' ' && *p != '\t' && *p != '\f'
36 while (p != dir && p[-1] == '/')
38 - if (info->path == NULL)
40 + /* cut trailing comments and such */
43 + /* assume path is a pattern - compare with quite equal glibc patch -ReneR */
44 + const unsigned ld_syslen = ld_sysroot ? strlen(ld_sysroot) : 0;
45 + char tmpdir[ld_syslen ? ld_syslen + strlen(dir) + 1 : 0];
46 + if (ld_syslen) snprintf(tmpdir, sizeof(tmpdir), "%s%s", ld_sysroot, dir);
49 + if (glob(ld_syslen ? tmpdir : dir, GLOB_ONLYDIR, NULL, &result) == 0) {
51 + for (j = 0; j < result.gl_pathc; j++)
53 + char* x = result.gl_pathv[j] + ld_syslen;
54 + if (info->path == NULL) {
55 + info->alloc = strlen(x) + 256;
56 + info->path = xmalloc (info->alloc);
60 + if (info->len + 1 + strlen(x) + 1 >= info->alloc) {
61 + info->alloc += strlen(x) + 1 + 256;
62 + info->path = xrealloc (info->path, info->alloc);
64 + info->path[info->len++] = ':';
66 + strcpy (info->path + info->len, x);
67 + info->len += strlen(x);
71 + /* error orig. code from binutils - in theory we do not need it? */
72 + if (info->path == NULL) {
73 info->alloc = p - dir + 1 + 256;
74 info->path = xmalloc (info->alloc);
80 if (info->len + 1 + (p - dir) >= info->alloc)
82 info->alloc += p - dir + 256;
85 info->path[info->len++] = config.rpath_separator;
87 - memcpy (info->path + info->len, dir, p - dir);
88 - info->len += p - dir;
89 - info->path[info->len] = '\0';
90 + memcpy (info->path + info->len, dir, p - dir);
91 + info->len += p - dir;
92 + info->path[info->len] = '\0';