Skip to content

Commit

Permalink
snapcraft: build and use patchelf 0.18
Browse files Browse the repository at this point in the history
Patching with patchelf 0.14.3 available in 22.04 produces the result
binaries get silently broken and break parsing with python-elfutils.

Inspectign a patched binary with readelf also shows a warning like so:

    snapcraft-snapd-on-amd64-for-amd64-1579591 ../project# readelf -h snapd.orig
    ELF Header:
      Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
      Class:                             ELF64
      Data:                              2's complement, little endian
      Version:                           1 (current)
      OS/ABI:                            UNIX - System V
      ABI Version:                       0
      Type:                              DYN (Position-Independent Executable file)
      Machine:                           Advanced Micro Devices X86-64
      Version:                           0x1
      Entry point address:               0x4800e0
      Start of program headers:          64 (bytes into file)
      Start of section headers:          680 (bytes into file)
      Flags:                             0x0
      Size of this header:               64 (bytes)
      Size of program headers:           56 (bytes)
      Number of program headers:         12
      Size of section headers:           64 (bytes)
      Number of section headers:         37
      Section header string table index: 35
    readelf: Warning: Section 0 has an out of range sh_link value of 72

The upstream patchelf 0.18 is fixed, so do a local build patchelf and
use it instead of a distro package.

Signed-off-by: Maciej Borzecki <[email protected]>
  • Loading branch information
bboozzoo committed Jan 9, 2025
1 parent a24fe7a commit d341191
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion build-aux/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,30 @@ parts:
craftctl default
python3 "${CRAFT_PROJECT_DIR}/build-aux/snap/local/patch-dl.py" "/snap/snapd/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/${DYNAMIC_LINKER}"
patchelf:
plugin: autotools
build-packages:
- autoconf-archive
- bison
- flex
- gettext
- g++
- pkg-config
- wget
source: http://archive.ubuntu.com/ubuntu/pool/universe/p/patchelf/patchelf_0.18.0.orig.tar.gz
source-checksum: sha256/1952b2a782ba576279c211ee942e341748fdb44997f704dd53def46cd055470b
override-prime: |
# nothing to prime
true
snapd:
plugin: nil
source: .
build-snaps:
- go/1.23/stable # the default Go toolchain
after:
- apparmor
- patchelf
build-packages:
- git
- dpkg-dev
Expand Down Expand Up @@ -441,7 +458,10 @@ parts:
- -fips-build-lp
override-prime: |
craftctl default
python3 "${CRAFT_PROJECT_DIR}/build-aux/snap/local/patch-dl.py" "/snap/snapd/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/${DYNAMIC_LINKER}"
# use lpatchelf built in earlier step
PATH="${CRAFT_STAGE}"/usr/local/bin:$PATH \
python3 "${CRAFT_PROJECT_DIR}/build-aux/snap/local/patch-dl.py" \
"/snap/snapd/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/${DYNAMIC_LINKER}"
libcrypto-fips:
plugin: nil
Expand Down

0 comments on commit d341191

Please sign in to comment.