-
Notifications
You must be signed in to change notification settings - Fork 2
/
rogue_company_reverts.patch
765 lines (704 loc) · 26.6 KB
/
rogue_company_reverts.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
From 77ff4447ae96752f80d3d2bb73b8bb7891b722b5 Mon Sep 17 00:00:00 2001
From: Thomas Crider <gloriouseggroll@gmail.com>
Date: Fri, 3 Jun 2022 14:45:09 -0600
Subject: [PATCH 1/4] Revert "elf: Clean up GLIBC_PRIVATE exports of internal
libdl symbols"
This reverts commit 7a5db2e82fbb6c3a6e3fdae02b7166c5d0e8c7a8.
---
dlfcn/dlerror.c | 1 +
elf/Makefile | 16 +++--
elf/Versions | 3 +
elf/dl-addr.c | 1 +
elf/dl-libc.c | 4 ++
elf/dl-sym.c | 2 +
elf/tst-libc_dlvsym-dso.c | 25 +++++++
elf/tst-libc_dlvsym-static.c | 32 +++++++++
elf/tst-libc_dlvsym.c | 34 +++++++++
elf/tst-libc_dlvsym.h | 130 +++++++++++++++++++++++++++++++++++
include/dlfcn.h | 30 ++++----
11 files changed, 260 insertions(+), 18 deletions(-)
create mode 100644 elf/tst-libc_dlvsym-dso.c
create mode 100644 elf/tst-libc_dlvsym-static.c
create mode 100644 elf/tst-libc_dlvsym.c
create mode 100644 elf/tst-libc_dlvsym.h
diff --git a/dlfcn/dlerror.c b/dlfcn/dlerror.c
index 5047b14066..d0194a7cef 100644
--- a/dlfcn/dlerror.c
+++ b/dlfcn/dlerror.c
@@ -196,3 +196,4 @@ _dlerror_run (void (*operate) (void *), void *args)
return 1;
}
}
+libc_hidden_def (_dlerror_run)
diff --git a/elf/Makefile b/elf/Makefile
index a50a988e7362cf3b20ea1c05e1f8eb9f6df2b996..6c8a9e80ba5f91f88e21478084e981f8a30e911d 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -286,6 +286,7 @@ tests-static-internal := \
tst-tls1-static \
tst-tls1-static-non-pie \
tst-tunables \
+ tst-libc_dlvsym-static
# tests-static-internal
CRT-tst-tls1-static-non-pie := $(csu-objpfx)crt1.o
@@ -508,6 +509,7 @@ tests-internal += \
tst-dlmopen2 \
tst-ptrguard1 \
tst-stackguard1 \
+ tst-libc_dlvsym \
tst-tls-surplus \
tst-tls3 \
tst-tls6 \
@@ -867,6 +869,7 @@ modules-names += \
tst-ldconfig-soname-lib-with-soname \
tst-ldconfig-soname-lib-without-soname \
tst-main1mod \
+ tst-libc_dlvsym-dso \
tst-nodelete-dlclose-dso \
tst-nodelete-dlclose-plugin \
tst-nodelete-opened-lib \
@@ -994,7 +997,7 @@ modules-names += \
# Most modules build with _ISOMAC defined, but those filtered out
# depend on internal headers.
-modules-names-tests = $(filter-out ifuncmod% tst-tlsmod%,\
+modules-names-tests = $(filter-out ifuncmod% tst-libc_dlvsym-dso tst-tlsmod%,\
$(modules-names))
# For +depfiles in Makerules.
@@ -2472,6 +2475,14 @@ LDLIBS-tst-absolute-zero-lib.so = tst-absolute-zero-lib.lds
$(objpfx)tst-absolute-zero-lib.so: $(LDLIBS-tst-absolute-zero-lib.so)
$(objpfx)tst-absolute-zero: $(objpfx)tst-absolute-zero-lib.so
+# Both the main program and the DSO for tst-libc_dlvsym need to link
+# against libdl.
+$(objpfx)tst-libc_dlvsym-dso.so: $(libsupport)
+$(objpfx)tst-libc_dlvsym.out: $(objpfx)tst-libc_dlvsym-dso.so
+tst-libc_dlvsym-static-ENV = \
+ LD_LIBRARY_PATH=$(ld-library-path):$(common-objpfx)dlfcn
+$(objpfx)tst-libc_dlvsym-static.out: $(objpfx)tst-libc_dlvsym-dso.so
+
$(objpfx)tst-big-note: $(objpfx)tst-big-note-lib.so
# Avoid creating an ABI tag note, which may come before the
# artificial, large note in tst-big-note-lib.o and invalidate the
diff --git a/elf/Versions b/elf/Versions
index 1591031da990eb93e3d190978a0cd2edf064a6a6..eab8832d2fd16185c766857a905e1fdbdfaa1807 100644
--- a/elf/Versions
+++ b/elf/Versions
@@ -30,6 +30,9 @@ libc {
}
GLIBC_PRIVATE {
# functions used in other libraries
+ _dl_addr;
+ _dl_sym; _dl_vsym;
+ __libc_dlclose; __libc_dlopen_mode; __libc_dlsym; __libc_dlvsym;
__libc_early_init;
}
}
diff --git a/elf/dl-addr.c b/elf/dl-addr.c
index 92a9b91b275e2d31236cd6e4a85e9d32348c7696..4acda3b8ec13beb173f370895b0152083097b5ee 100644
--- a/elf/dl-addr.c
+++ b/elf/dl-addr.c
@@ -136,3 +136,4 @@ _dl_addr (const void *address, Dl_info *info,
return result;
}
+libc_hidden_def (_dl_addr)
diff --git a/elf/dl-libc.c b/elf/dl-libc.c
index 3c048cc6c1791a60ae4610269bf0b85d062bea68..ba3e9fb1c78d0407eb4b81b8bfad8925e616b537 100644
--- a/elf/dl-libc.c
+++ b/elf/dl-libc.c
@@ -161,6 +161,7 @@ __libc_dlopen_mode (const char *name, int mode)
#endif
return dlerror_run (do_dlopen, &args) ? NULL : (void *) args.map;
}
+libc_hidden_def (__libc_dlopen_mode)
#ifndef SHARED
void *
@@ -191,6 +192,7 @@ __libc_dlsym (void *map, const char *name)
return (dlerror_run (do_dlsym, &args) ? NULL
: (void *) (DL_SYMBOL_ADDRESS (args.loadbase, args.ref)));
}
+libc_hidden_def (__libc_dlsym)
/* Replacement for dlvsym. MAP must be a real map. This function
returns NULL without setting the dlerror value in case of static
@@ -217,6 +219,7 @@ __libc_dlvsym (void *map, const char *name, const char *version)
: (void *) (DL_SYMBOL_ADDRESS (args.dlsym.loadbase,
args.dlsym.ref)));
}
+libc_hidden_def (__libc_dlvsym)
int
__libc_dlclose (void *map)
@@ -227,6 +230,7 @@ __libc_dlclose (void *map)
#endif
return dlerror_run (do_dlclose, map);
}
+libc_hidden_def (__libc_dlclose)
static bool __libc_freeres_fn_section
diff --git a/elf/dl-sym.c b/elf/dl-sym.c
index de5769f926..fa0cce678f 100644
--- a/elf/dl-sym.c
+++ b/elf/dl-sym.c
@@ -188,9 +188,11 @@ _dl_vsym (void *handle, const char *name, const char *version, void *who)
return do_sym (handle, name, who, &vers, 0);
}
+libc_hidden_def (_dl_vsym)
void *
_dl_sym (void *handle, const char *name, void *who)
{
return do_sym (handle, name, who, NULL, DL_LOOKUP_RETURN_NEWEST);
}
+libc_hidden_def (_dl_sym)
diff --git a/elf/tst-libc_dlvsym-dso.c b/elf/tst-libc_dlvsym-dso.c
new file mode 100644
index 0000000000..19091ddb41
--- /dev/null
+++ b/elf/tst-libc_dlvsym-dso.c
@@ -0,0 +1,25 @@
+/* Compare dlvsym and __libc_dlvsym results. Shared object code.
+ Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include "tst-libc_dlvsym.h"
+
+void
+compare_vsyms_global (void)
+{
+ compare_vsyms ();
+}
diff --git a/elf/tst-libc_dlvsym-static.c b/elf/tst-libc_dlvsym-static.c
new file mode 100644
index 0000000000..19c438c3cd
--- /dev/null
+++ b/elf/tst-libc_dlvsym-static.c
@@ -0,0 +1,32 @@
+/* Compare dlvsym and __libc_dlvsym results. Static version.
+ Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/xdlfcn.h>
+
+static int
+do_test (void)
+{
+ void *handle = xdlopen ("tst-libc_dlvsym-dso.so", RTLD_LAZY);
+ void (*compare) (void) = xdlsym (handle, "compare_vsyms_global");
+ compare ();
+ xdlclose (handle);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/elf/tst-libc_dlvsym.c b/elf/tst-libc_dlvsym.c
new file mode 100644
index 0000000000..823643fb1c
--- /dev/null
+++ b/elf/tst-libc_dlvsym.c
@@ -0,0 +1,34 @@
+/* Compare dlvsym and __libc_dlvsym results. Dynamic version.
+ Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include "tst-libc_dlvsym.h"
+
+static int
+do_test (void)
+{
+ compare_vsyms ();
+
+ void *handle = xdlopen ("tst-libc_dlvsym-dso.so", RTLD_LAZY);
+ void (*compare) (void) = xdlsym (handle, "compare_vsyms_global");
+ compare ();
+ xdlclose (handle);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/elf/tst-libc_dlvsym.h b/elf/tst-libc_dlvsym.h
new file mode 100644
index 0000000000..1a8f2e9271
--- /dev/null
+++ b/elf/tst-libc_dlvsym.h
@@ -0,0 +1,130 @@
+/* Compare dlvsym and __libc_dlvsym results. Common code.
+ Copyright (C) 2017-2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* compare_vsyms is the main entry point for these tests.
+
+ Indirectly, It calls __libc_dlvsym (from libc.so; internal
+ interface) and dlvsym (from libdl.so; public interface) to compare
+ the results for a selected set of symbols in libc.so which
+ typically have more than one symbol version. The two functions are
+ implemented by somewhat different code, and this test checks that
+ their results are the same.
+
+ The versions are generated to range from GLIBC_2.0 to GLIBC_2.Y,
+ with Y being the current __GLIBC_MINOR__ version plus two. In
+ addition, there is a list of special symbol versions of the form
+ GLIBC_2.Y.Z, which were used for some releases.
+
+ Comparing the two dlvsym results at versions which do not actually
+ exist does not test much, but it will not contribute to false test
+ failures, either. */
+
+#include <array_length.h>
+#include <gnu/lib-names.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <support/check.h>
+#include <support/xdlfcn.h>
+
+/* Run consistency check for versioned symbol NAME@VERSION. NB: We
+ may execute in a shared object, so exit on error for proper error
+ reporting. */
+static void
+compare_vsyms_0 (void *libc_handle, const char *name, const char *version,
+ bool *pfound)
+{
+ void *dlvsym_address = dlvsym (libc_handle, name, version);
+ void *libc_dlvsym_address
+ = __libc_dlvsym (libc_handle, name, version);
+ if (dlvsym_address != libc_dlvsym_address)
+ FAIL_EXIT1 ("%s@%s mismatch: %p != %p",
+ name, version, dlvsym_address, libc_dlvsym_address);
+ if (dlvsym_address != NULL)
+ *pfound = true;
+}
+
+
+/* Run consistency check for versioned symbol NAME at multiple symbol
+ version. */
+static void
+compare_vsyms_1 (void *libc_handle, const char *name)
+{
+ bool found = false;
+
+ /* Historic versions which do not follow the usual GLIBC_2.Y
+ pattern, to increase test coverage. Not all architectures have
+ those, but probing additional versions does not hurt. */
+ static const char special_versions[][12] =
+ {
+ "GLIBC_2.1.1",
+ "GLIBC_2.1.2",
+ "GLIBC_2.1.3",
+ "GLIBC_2.1.4",
+ "GLIBC_2.2.1",
+ "GLIBC_2.2.2",
+ "GLIBC_2.2.3",
+ "GLIBC_2.2.4",
+ "GLIBC_2.2.5",
+ "GLIBC_2.2.6",
+ "GLIBC_2.3.2",
+ "GLIBC_2.3.3",
+ "GLIBC_2.3.4",
+ };
+ for (int i = 0; i < array_length (special_versions); ++i)
+ compare_vsyms_0 (libc_handle, name, special_versions[i], &found);
+
+ /* Iterate to an out-of-range version, to cover some unused symbols
+ as well. */
+ for (int minor_version = 0; minor_version <= __GLIBC_MINOR__ + 2;
+ ++minor_version)
+ {
+ char version[30];
+ snprintf (version, sizeof (version), "GLIBC_%d.%d",
+ __GLIBC__, minor_version);
+ compare_vsyms_0 (libc_handle, name, version, &found);
+ }
+
+ if (!found)
+ FAIL_EXIT1 ("symbol %s not found at any version", name);
+}
+
+/* Run consistency checks for various symbols which usually have
+ multiple versions. */
+static void
+compare_vsyms (void)
+{
+ /* The minor version loop in compare_vsyms_1 needs updating in case
+ we ever switch to glibc 3.0. */
+ if (__GLIBC__ != 2)
+ FAIL_EXIT1 ("unexpected glibc major version: %d", __GLIBC__);
+
+ /* __libc_dlvsym does not recognize the special RTLD_* handles, so
+ obtain an explicit handle for libc.so. */
+ void *libc_handle = xdlopen (LIBC_SO, RTLD_LAZY | RTLD_NOLOAD);
+
+
+ /* sys_errlist and sys_siglist were deprecated in glibc 2.32 and they are
+ not available on architectures with base ABI newer than 2.32. */
+#if TEST_COMPAT (libc, GLIBC_2_0, GLIBC_2_32)
+ compare_vsyms_1 (libc_handle, "_sys_errlist");
+ compare_vsyms_1 (libc_handle, "_sys_siglist");
+#endif
+ compare_vsyms_1 (libc_handle, "quick_exit");
+
+ xdlclose (libc_handle);
+}
diff --git a/include/dlfcn.h b/include/dlfcn.h
index a44420fa37439a8565fa60cec9574dbfd05ce082..bdefa6a12d426d39f87c6938c4861c0d6978fd45 100644
--- a/include/dlfcn.h
+++ b/include/dlfcn.h
@@ -49,20 +49,20 @@ extern char **__libc_argv attribute_hidden;
better error handling semantics for the library. */
#define __libc_dlopen(name) \
__libc_dlopen_mode (name, RTLD_NOW | __RTLD_DLOPEN)
-extern void *__libc_dlopen_mode (const char *__name, int __mode)
- attribute_hidden;
-extern void *__libc_dlsym (void *__map, const char *__name)
- attribute_hidden;
-extern void *__libc_dlvsym (void *map, const char *name, const char *version)
- attribute_hidden;
-extern int __libc_dlclose (void *__map)
- attribute_hidden;
+extern void *__libc_dlopen_mode (const char *__name, int __mode);
+extern void *__libc_dlsym (void *__map, const char *__name);
+extern void *__libc_dlvsym (void *map, const char *name, const char *version);
+extern int __libc_dlclose (void *__map);
+libc_hidden_proto (__libc_dlopen_mode)
+libc_hidden_proto (__libc_dlsym)
+libc_hidden_proto (__libc_dlvsym)
+libc_hidden_proto (__libc_dlclose)
/* Locate shared object containing the given address. */
#ifdef ElfW
extern int _dl_addr (const void *address, Dl_info *info,
- struct link_map **mapp, const ElfW(Sym) **symbolp)
- attribute_hidden;
+ struct link_map **mapp, const ElfW(Sym) **symbolp);
+libc_hidden_proto (_dl_addr)
#endif
struct link_map;
@@ -77,21 +77,23 @@ extern void _dl_close_worker (struct link_map *map, bool force)
/* Look up NAME in shared object HANDLE (which may be RTLD_DEFAULT or
RTLD_NEXT). WHO is the calling function, for RTLD_NEXT. Returns
the symbol value, which may be NULL. */
-extern void *_dl_sym (void *handle, const char *name, void *who)
- attribute_hidden;
+extern void *_dl_sym (void *handle, const char *name, void *who);
+libc_hidden_proto (_dl_sym)
/* Look up version VERSION of symbol NAME in shared object HANDLE
(which may be RTLD_DEFAULT or RTLD_NEXT). WHO is the calling
function, for RTLD_NEXT. Returns the symbol value, which may be
NULL. */
extern void *_dl_vsym (void *handle, const char *name, const char *version,
- void *who) attribute_hidden;
+ void *who);
+libc_hidden_proto (_dl_vsym)
/* Helper function for <dlfcn.h> functions. Runs the OPERATE function via
_dl_catch_error. Returns zero for success, nonzero for failure; and
arranges for `dlerror' to return the error details.
ARGS is passed as argument to OPERATE. */
-extern int _dlerror_run (void (*operate) (void *), void *args) attribute_hidden;
+extern int _dlerror_run (void (*operate) (void *), void *args);
+libc_hidden_proto (_dlerror_run)
/* This structure is used to make the outer (statically linked)
implementation of dlopen and related functions to the inner libc
From 605a02a9152e832b56e7458bddcebf6da88e791f Mon Sep 17 00:00:00 2001
From: Thomas Crider <gloriouseggroll@gmail.com>
Date: Thu, 2 Jun 2022 15:46:37 -0600
Subject: [PATCH 1/4] Revert "Install shared objects under their ABI names"
This reverts commit 8208be389bce84be0e1c35a3daa0c3467418f921.
---
Makefile | 6 ++++++
Makerules | 44 ++++++++++++++++++++++++++++++++++++++++----
elf/Makefile | 10 ++++++++--
3 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index b1454882bd..bde07cdf2a 100644
--- a/Makefile
+++ b/Makefile
@@ -109,6 +109,12 @@ elf/ldso_install:
# Ignore the error if we cannot update /etc/ld.so.cache.
ifeq (no,$(cross-compiling))
ifeq (yes,$(build-shared))
+install: install-symbolic-link
+.PHONY: install-symbolic-link
+install-symbolic-link: subdir_install
+ $(symbolic-link-prog) $(symbolic-link-list)
+ rm -f $(symbolic-link-list)
+
install:
-test ! -x $(elf-objpfx)ldconfig || LC_ALL=C \
$(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \
diff --git a/Makerules b/Makerules
index 00365bc58be119bb0fec9cf2cfa51780c27fae8c..2c22c69e2199d86264c3a3c4d0492d9b5845682b 100644
--- a/Makerules
+++ b/Makerules
@@ -939,12 +939,14 @@ versioned := $(strip $(foreach so,$(install-lib.so),\
install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
-# For libraries whose soname have version numbers, we install two files:
+# For libraries whose soname have version numbers, we install three files:
# $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
-# $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME
+# $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
+# $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
$(foreach L,$(install-lib.so-versioned),\
$(inst_libdir)/$L \
+ $(inst_slibdir)/$(L:.so=)-$(version).so \
$(inst_slibdir)/$L$($L-version))
# Install all the unversioned shared libraries.
@@ -977,8 +979,34 @@ ln -f $(objpfx)/$(@F) $@
endef
endif
+ifeq (yes,$(build-shared))
+ifeq (no,$(cross-compiling))
+symbolic-link-prog := $(elf-objpfx)sln
+symbolic-link-list := $(elf-objpfx)symlink.list
+define make-shlib-link
+echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(symbolic-link-list)
+endef
+else # cross-compiling
+# We need a definition that can be used by elf/Makefile's install rules.
+symbolic-link-prog = $(LN_S)
+endif
+endif
+ifndef make-shlib-link
+define make-shlib-link
+rm -f $@
+$(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
+endef
+endif
+
ifdef libc.so-version
-$(inst_slibdir)/libc.so$(libc.so-version): $(common-objpfx)libc.so $(+force)
+# For a library specified to be version N, install three files:
+# libc.so -> libc.so.N (e.g. libc.so.6)
+# libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so)
+
+$(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
+ $(+force)
+ $(make-shlib-link)
+$(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
$(do-install-program)
install: $(inst_slibdir)/libc.so$(libc.so-version)
@@ -1048,7 +1076,15 @@ include $(o-iterator)
generated += $(foreach o,$(versioned),$o$($o-version))
define o-iterator-doit
-$(inst_slibdir)/$o$($o-version): $(objpfx)$o $(+force);
+$(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
+ $(+force);
+ $$(make-shlib-link)
+endef
+object-suffixes-left := $(versioned)
+include $(o-iterator)
+
+define o-iterator-doit
+$(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
$$(do-install-program)
endef
object-suffixes-left := $(versioned)
diff --git a/elf/Makefile b/elf/Makefile
index 6c8a9e80ba5f91f88e21478084e981f8a30e911d..61384c9b3f932b8ee7105e83158fd8f847818288 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -1375,10 +1375,16 @@ $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
CPPFLAGS-dl-load.c += -I$(objpfx). -I$(csu-objpfx).
ifeq (yes,$(build-shared))
-$(inst_rtlddir)/$(rtld-installed-name): $(objpfx)ld.so $(+force)
+$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
$(make-target-directory)
$(do-install-program)
+$(inst_rtlddir)/$(rtld-installed-name): \
+ $(inst_slibdir)/$(rtld-version-installed-name) \
+ $(inst_slibdir)/libc-$(version).so
+ $(make-target-directory)
+ $(make-shlib-link)
+
# Creates the relative /usr/bin/ld.so symbolic link.
$(inst_bindir)/ld.so: $(inst_rtlddir)/$(rtld-installed-name)
$(make-target-directory)
@@ -1387,7 +1393,7 @@ $(inst_bindir)/ld.so: $(inst_rtlddir)/$(rtld-installed-name)
# Special target called by parent to install just the dynamic linker.
.PHONY: ldso_install
ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
-endif # $(build-shared)
+endif
# Workarounds for ${exec_prefix} expansion in configure variables.
From 270af4eb5410092fbcbe7acd369c7e5a9d27f844 Mon Sep 17 00:00:00 2001
From: Thomas Crider <gloriouseggroll@gmail.com>
Date: Thu, 2 Jun 2022 15:49:48 -0600
Subject: [PATCH 2/4] Revert "elf: Generalize name-based DSO recognition in
ldconfig"
This reverts commit 6bf789d69e6be48419094ca98f064e00297a27d5.
---
elf/Makefile | 1 -
elf/dl-is_dso.h | 33 ---------------------------------
elf/ldconfig.c | 5 +++--
elf/tst-dl-is_dso.c | 35 -----------------------------------
4 files changed, 3 insertions(+), 71 deletions(-)
delete mode 100644 elf/dl-is_dso.h
delete mode 100644 elf/tst-dl-is_dso.c
diff --git a/elf/Makefile b/elf/Makefile
index 61384c9b3f932b8ee7105e83158fd8f847818288..31d0f611162bc047f9aa18f38a79ddbdefc52eed 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -404,7 +404,6 @@ tests += \
tst-big-note \
tst-debug1 \
tst-deep1 \
- tst-dl-is_dso \
tst-dlclose-lazy \
tst-dlmodcount \
tst-dlmopen-dlerror \
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index b64c54b53e1aa5bfb2806eb50d13757e8cb24396..3eab865bf3a0be792cea5d63ff771802d4e3e488 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -42,7 +42,6 @@
#include <ldconfig.h>
#include <dl-cache.h>
#include <dl-hwcaps.h>
-#include <dl-is_dso.h>
#include <dl-procinfo.h>
@@ -742,7 +741,9 @@ search_dir (const struct dir_entry *entry)
continue;
/* Does this file look like a shared library? The dynamic linker
is also considered as shared library. */
- if (!_dl_is_dso (direntry->d_name)
+ if (((strncmp (direntry->d_name, "lib", 3) != 0
+ && strncmp (direntry->d_name, "ld-", 3) != 0)
+ || strstr (direntry->d_name, ".so") == NULL)
&& (direntry->d_type == DT_REG || entry->hwcaps == NULL))
continue;
From 020733a3dcbfbb7340c31c99653a6a95d26b5fe7 Mon Sep 17 00:00:00 2001
From: Thomas Crider <gloriouseggroll@gmail.com>
Date: Thu, 2 Jun 2022 15:53:05 -0600
Subject: [PATCH 3/4] Revert "Makerules: Remove lib-version, $(subdir-version)"
This reverts commit b89d5de2508215ef3131db7bed76ac50b3f4c205.
---
Makerules | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/Makerules b/Makerules
index 2c22c69e2199d86264c3a3c4d0492d9b5845682b..2b56e133f562376cd54a7cab6cf26d6a061787b3 100644
--- a/Makerules
+++ b/Makerules
@@ -932,21 +932,22 @@ install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
install-lib := $(filter-out %.so %_pic.a,$(install-lib))
ifeq (yes,$(build-shared))
-# Find which .so's have a version number in their soname.
+# Find which .so's have versions.
versioned := $(strip $(foreach so,$(install-lib.so),\
$(patsubst %,$(so),$($(so)-version))))
install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
-# For libraries whose soname have version numbers, we install three files:
+# For versioned libraries, we install three files:
# $(inst_libdir)/libfoo.so -- for linking, symlink or ld script
# $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink
# $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
+lib-version := $(firstword $($(subdir)-version) $(version))
install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
$(foreach L,$(install-lib.so-versioned),\
$(inst_libdir)/$L \
- $(inst_slibdir)/$(L:.so=)-$(version).so \
+ $(inst_slibdir)/$(L:.so=)-$(lib-version).so \
$(inst_slibdir)/$L$($L-version))
# Install all the unversioned shared libraries.
@@ -1075,6 +1076,7 @@ include $(o-iterator)
generated += $(foreach o,$(versioned),$o$($o-version))
+ifeq (,$($(subdir)-version))
define o-iterator-doit
$(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
$(+force);
@@ -1089,7 +1091,23 @@ $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
endef
object-suffixes-left := $(versioned)
include $(o-iterator)
-endif # ifneq (,$(versioned))
+else
+define o-iterator-doit
+$(inst_slibdir)/$o$($o-version): \
+ $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
+ $$(make-shlib-link)
+endef
+object-suffixes-left := $(versioned)
+include $(o-iterator)
+
+define o-iterator-doit
+$(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
+ $$(do-install-program)
+endef
+object-suffixes-left := $(versioned)
+include $(o-iterator)
+endif
+endif
define do-install-so
$(do-install-program)
From 0a5e5014b621fed7fe077fdcbdd7727dd12c8d9f Mon Sep 17 00:00:00 2001
From: Thomas Crider <gloriouseggroll@gmail.com>
Date: Thu, 2 Jun 2022 15:54:58 -0600
Subject: [PATCH 4/4] Revert "nptl_db: Install libthread_db under a regular
implementation name"
This reverts commit 86f0179bc003ffc34ffaa8d528a7a90153ac06c6.
---
nptl_db/Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/nptl_db/Makefile b/nptl_db/Makefile
index ed923a41e5..3422959884 100644
--- a/nptl_db/Makefile
+++ b/nptl_db/Makefile
@@ -21,6 +21,8 @@ subdir := nptl_db
include ../Makeconfig
+nptl_db-version = 1.0
+
extra-libs = libthread_db
extra-libs-others := $(extra-libs)
--
2.36.1