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
Ubuntu Server Dev import team 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?

Unmerged commits

179c6fc... by Dimitri John Ledkov

Properly fixup copying libgcc_s library into the initrd. LP: #1880853 Implemented differently from "[f2ac13e] hook-functions: copy_exec: Copy libgcc_s.so.1 along with libpthread.so.* (Closes: #950254)". To avoid circular shared library dependencies between compiler and libc, libpthreads chooses to dlopen libgcc_s, instead of linking against it. However, we have no way to parse/know what it needs. And even when we hardcode to include libgcc_s1, we don't have a way to know which libgcc_s1 is needed on a given system and from which path to include it. But there is a hook-function to copy a binary and all of its shared library dependencies. Thus create a stub empty executable, with shared linking against pthreads and gcc_s1 and always include it in the initrd. This way at initrd creation time, ldd is used to correctly resolve these shared library dependencies and correctly copy them into the initrd. This removes hardcoding paths as to where these libraries must be copied from on the host.

598dcc8... by Dimitri John Ledkov

0.137ubuntu9 (patches unapplied)

Imported using git-ubuntu import.

b9c21a2... by Dimitri John Ledkov

0.137ubuntu8 (patches unapplied)

Imported using git-ubuntu import.

a9299e3... by Dimitri John Ledkov

0.137ubuntu7 (patches unapplied)

Imported using git-ubuntu import.

76f57d4... by Gianfranco Costamagna

0.137ubuntu6 (patches unapplied)

Imported using git-ubuntu import.

359f422... by Dimitri John Ledkov

0.137ubuntu5 (patches unapplied)

Imported using git-ubuntu import.

bac1590... by Gianfranco Costamagna

0.137ubuntu4 (patches unapplied)

Imported using git-ubuntu import.

ebec39e... by Gianfranco Costamagna

0.137ubuntu3 (patches unapplied)

Imported using git-ubuntu import.

7f599b3... by Ben Hutchings

Import patches-unapplied version 0.137 to debian/sid

Imported using git-ubuntu import.

Changelog parent: 57216af3f25f1f18f09f915d1c3e5799772d1a63

New changelog entries:
  [ Ben Hutchings ]
  * [1b28d25] Document copy_exec as usable for shared libraries
  * [f2ac13e] hook-functions: copy_exec: Copy libgcc_s.so.1 along with
    libpthread.so.* (Closes: #950254)
  * [d96228a] hook-functions: copy_exec: Correct verbose log message for
    symlinks
  * [dd5fb36] hook-functions: Factor out device class walking into a function
  * [14a00af] hook-functions: Don't add backlight modules if we have generic
    fb device (Closes: #955347)
  * [f6133e1] Fix new shellcheck warnings around unquoted parameter expansion
    (Closes: #958851)
  [ AP ]
  * [857042c] hook-functions: Search for firmware under /lib/firmware/updates
    (Closes: #956663)

57216af... by Ben Hutchings

Import patches-unapplied version 0.136 to debian/sid

Imported using git-ubuntu import.

Changelog parent: 42dd22db1f2197e9dee4ef8c3e4131cc696951db

New changelog entries:
  [ Mathieu Malaterre ]
  * [90bd459] Update to new name for kernel module therm_pm72
  [ Alper Nebi Yasak ]
  * [ded7214] hook-functions: Handle dw_mmc-rockchip hidden dependency on
    rockchip-io-domain
  * [da85190] hook-functions: Include modules for Chromebook Plus display
  [ Ben Hutchings ]
  * [afd2668] debian/tests/control: Mark shellcheck test as superficial
  * [9d8b690] mkinitramfs: Remove workaround for old udev versions
  * [2b55aca] mkinitramfs: Remove special case for Arm OABI ports
  * [a9e5169] mkinitramfs: Remove armhf dynamic linker hack
  * [b19b6f3] debian/rules: Suppress execution of dh_installinitramfs
  * [8330bcd] mkinitramfs: Use cp -p option for ld.so.conf* instead of -aZ
  * [15fd713] initramfs-tools(7): Change example to use copy_exec instead of cp
  * [c2d589e] Revert "mkinitramfs: check if initramfs has a shell"
  * [835d584] mkinitramfs: Copy modules.builtin.bin into initramfs
    (Closes: #948257)
  * [0012977] init: Remove special case for kernel parameter resume=UUID=...
  * [897ab77] update-initramfs: Make "-c -k all" options useful again
    (Closes: #926401)
  * [d6c6eec] init: Mount /dev with "exec" option if v86d is present
    (Closes: #940171)
  * [a9e73b5] hook-functions: Drop ext4dev from filesystem module list
  * [41d9ceb] mkinitramfs: Enable multihreaded xz compression (Closes: #942144)
  [ Alexander Volkov ]
  * [e34affa] Don't require build dependency on shellcheck when nocheck profile
    is enabled
  [ Johannes 'josch' Schauer ]
  * [e2ad678] hook-functions: preloaded libraries should not end up in the
    initramfs (Closes: #944929)
  [ Debian Janitor ]
  * [a1e17fc] Bump debhelper from old 9 to 12.
  * [4d86d1a] Set debhelper-compat version in Build-Depends.
  [ Romain Perier ]
  * [4df27e2] hook-functions: Add f2fs as base in auto_add_modules
  [ Christian Göttsche ]
  * [0db5752] Do not copy SELinux context in mkinitramfs (Closes: #948365)
  [ Topi Miettinen ]
  * [55afeec] Tighten permissions for /run/initramfs

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