Merge ~xnox/ubuntu/+source/initramfs-tools:libgcc_s into ubuntu/+source/initramfs-tools:ubuntu/devel

Proposed by Dimitri John Ledkov
Status: Needs review
Proposed branch: ~xnox/ubuntu/+source/initramfs-tools:libgcc_s
Merge into: ubuntu/+source/initramfs-tools:ubuntu/devel
Diff against target: 92 lines (+29/-9)
5 files modified
debian/changelog (+20/-0)
debian/initramfs-tools-bin.install (+1/-0)
hook-functions (+0/-7)
mkinitramfs (+3/-0)
src/Makefile (+5/-2)
Reviewer Review Type Date Requested Status
Canonical Foundations Team Pending
git-ubuntu developers Pending
Review via email: mp+385243@code.launchpad.net

Commit message

Reliable libgcc_s inclusion

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

Can you get agreement on this upstream in Debian first?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index cfc177f..56c17a6 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,23 @@
6+initramfs-tools (0.137ubuntu10) groovy; urgency=medium
7+
8+ * Properly fixup copying libgcc_s library into the initrd. LP: #1880853
9+ Implemented differently from "[f2ac13e] hook-functions: copy_exec:
10+ Copy libgcc_s.so.1 along with libpthread.so.* (Closes: #950254)". To
11+ avoid circular shared library dependencies between compiler and libc,
12+ libpthreads chooses to dlopen libgcc_s, instead of linking against
13+ it. However, we have no way to parse/know what it needs. And even when
14+ we hardcode to include libgcc_s1, we don't have a way to know which
15+ libgcc_s1 is needed on a given system and from which path to include
16+ it. But there is a hook-function to copy a binary and all of its
17+ shared library dependencies. Thus create a stub empty executable, with
18+ shared linking against pthreads and gcc_s1 and always include it in
19+ the initrd. This way at initrd creation time, ldd is used to correctly
20+ resolve these shared library dependencies and correctly copy them into
21+ the initrd. This removes hardcoding paths as to where these libraries
22+ must be copied from on the host.
23+
24+ -- Dimitri John Ledkov <xnox@ubuntu.com> Fri, 05 Jun 2020 13:38:11 +0100
25+
26 initramfs-tools (0.137ubuntu9) groovy; urgency=medium
27
28 * Document add_mountroot_fail_hook correctly.
29diff --git a/debian/initramfs-tools-bin.install b/debian/initramfs-tools-bin.install
30index 9d63a93..bdc60f7 100644
31--- a/debian/initramfs-tools-bin.install
32+++ b/debian/initramfs-tools-bin.install
33@@ -1,2 +1,3 @@
34 src/wait-for-root usr/lib/initramfs-tools/bin
35 src/rzscontrol usr/lib/initramfs-tools/bin
36+src/gcc_s1-stub usr/lib/initramfs-tools/bin
37diff --git a/hook-functions b/hook-functions
38index d80fe32..0517140 100644
39--- a/hook-functions
40+++ b/hook-functions
41@@ -213,13 +213,6 @@ copy_exec() {
42 x="${nonoptlib}"
43 fi
44
45- # Handle common dlopen() dependency (Debian bug #950254)
46- case "${x}" in
47- */libpthread.so.*)
48- copy_exec "${x%/*}/libgcc_s.so.1" || copy_exec "${x%/*}/../libgcc_s.so.1" || return
49- ;;
50- esac
51-
52 copy_file binary "${x}" || {
53 ret=$?
54 [ ${ret} = 1 ] || return $((ret - 1))
55diff --git a/mkinitramfs b/mkinitramfs
56index 637f1d6..2883a27 100644
57--- a/mkinitramfs
58+++ b/mkinitramfs
59@@ -360,6 +360,9 @@ fi
60 touch "${DESTDIR}/etc/fstab"
61 ln -s /proc/mounts "${DESTDIR}/etc/mtab"
62
63+# Install libc6, pthreads, and dlopened gcc_s.so.1 (Debian bug #950254)
64+copy_exec /usr/lib/initrmafs-tools/bin/gcc_s1-stub /usr/lib/initrmafs-tools/bin/gcc_s1-stub
65+
66 # install wait-for-root binary.
67 copy_exec /usr/lib/initramfs-tools/bin/wait-for-root /sbin
68
69diff --git a/src/Makefile b/src/Makefile
70index c7ac39e..6210775 100644
71--- a/src/Makefile
72+++ b/src/Makefile
73@@ -8,7 +8,7 @@ LDFLAGS =
74
75
76 .PHONY: all
77-all: wait-for-root rzscontrol
78+all: wait-for-root rzscontrol gcc_s1-stub
79
80 wait-for-root: wait-for-root.o
81 $(CC) $(LDFLAGS) -o $@ $< $(UDEV_LIBS)
82@@ -16,6 +16,9 @@ wait-for-root: wait-for-root.o
83 rzscontrol: rzscontrol.o
84 $(CC) $(LDFLAGS) -o $@ $<
85
86+gcc_s1-stub:
87+ gcc -Wl,--no-as-needed -shared -pthread -l:libgcc_s.so.1 -o $@
88+
89 .PHONY: clean
90 clean:
91- rm -f wait-for-root.o wait-for-root rzscontrol.o rzscontrol core *~
92+ rm -f wait-for-root.o wait-for-root rzscontrol.o rzscontrol gcc_s1-stub core *~

Subscribers

People subscribed via source and target branches