Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 authored Jan 7, 2025
2 parents 65e1479 + 43b75fb commit 01e9cc8
Show file tree
Hide file tree
Showing 15 changed files with 286 additions and 124 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: shellcheck tests/*.sh
nix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v25
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- run: nix-build -A hydraJobs.release
ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: get toolchain version
run: |
c++ --version
Expand Down
49 changes: 30 additions & 19 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,44 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: cachix/install-nix-action@v25
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- name: Build tarballs
run: |
nix build -L .#hydraJobs.tarball
install -D ./result/tarballs/*.tar.bz2 ./dist/patchelf-$(cat version).tar.bz2
install -D ./result/tarballs/*.tar.gz ./dist/patchelf-$(cat version).tar.gz
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: patchelf
name: patchelf-tarball
path: dist/*

build_windows:
name: Build windows executable
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: cachix/install-nix-action@v25
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- name: Build windows executable
run: |
nix build -L .#patchelf-win32 .#patchelf-win64
install -D ./result/bin/patchelf.exe ./dist/patchelf-win32-$(cat version).exe
install -D ./result-1/bin/patchelf.exe ./dist/patchelf-win64-$(cat version).exe
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: patchelf
name: patchelf-windows
path: dist/*

test_windows:
name: Test windows binaries
needs: [build_windows]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: patchelf
name: patchelf-windows
path: dist
- name: Show binaries
run: dir .\\dist
Expand All @@ -73,9 +73,19 @@ jobs:
if: matrix.platform != 'amd64'
uses: docker/setup-qemu-action@v3

- uses: actions/download-artifact@v3
- name: Set docker arch
run: |
platform=${{ matrix.platform }}
if [[ $platform == arm64v8 ]]; then
platform=arm64
elif [[ $platform == arm32v7 ]]; then
platform=arm
fi
echo "DOCKER_PLATFORM=$platform" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
name: patchelf
name: patchelf-tarball
path: dist
- name: Build binaries
env:
Expand All @@ -100,7 +110,7 @@ jobs:
else
ENTRYPOINT=
fi
docker run -e CXXFLAGS -v $(pwd):/gha ${{ matrix.platform }}/alpine:edge ${ENTRYPOINT} sh -ec "cd /gha && sh ./build.sh"
docker run --platform "$DOCKER_PLATFORM" -e CXXFLAGS -v $(pwd):/gha ${{ matrix.platform }}/alpine:edge ${ENTRYPOINT} sh -ec "cd /gha && sh ./build.sh"
- name: Check binaries
run: |
cat <<EOF > check.sh
Expand All @@ -109,10 +119,10 @@ jobs:
tar -xf ./dist/patchelf-*-*.tar.gz
./bin/patchelf --version
EOF
docker run -v $(pwd):/gha ${{ matrix.platform }}/debian:unstable-slim sh -ec "cd /gha && sh ./check.sh"
- uses: actions/upload-artifact@v3
docker run --platform "$DOCKER_PLATFORM" -v $(pwd):/gha ${{ matrix.platform }}/debian:unstable-slim sh -ec "cd /gha && sh ./check.sh"
- uses: actions/upload-artifact@v4
with:
name: patchelf
name: patchelf-${{ matrix.platform }}
path: dist/*

publish:
Expand All @@ -121,9 +131,10 @@ jobs:
if: github.event_name == 'push' && github.repository == 'NixOS/patchelf' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: patchelf
pattern: patchelf-*
merge-multiple: true
path: dist
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
Expand Down
6 changes: 0 additions & 6 deletions BUGS

This file was deleted.

39 changes: 31 additions & 8 deletions completions/zsh/_patchelf
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
#compdef patchelf

_get_dep() {
# preparm have fewer checks, as they can't be the so to replace
if [[ -f $words[2] ]] { # check if arg #1 is a elf file and not a so
local deps=($(patchelf --print-needed $words[2] 2>/dev/null)) # discard error
if [[ $? -ne 0 ]] || [[ $#deps -eq 0 ]] { # if no dependency or not a elf
_files # fallback to _files
} else {
_values "LIBS" $deps # else use dependencies of the file as candidates
}
# postparm need to check
} elif [[ -f $words[-1] ]] && [[ -z ${words[-1]:e} ]] { # check arg #-1, as most people do like this
local deps=($(patchelf --print-needed $words[-1] 2>/dev/null))
if [[ $? -ne 0 ]] || [[ $#deps -eq 0 ]] {
_files
} else {
_values "LIBS" $deps
}
} else {
_files
}
}

local options=(
'--page-size[Uses the given page size]:SIZE'
'--set-interpreter[Change the dynamic loader of executable]:INTERPRETER:dynamic loader:_files'
'--page-size[Uses the given page size]:SIZE:'
'--set-interpreter[Change the dynamic loader of executable]:INTERPRETER:_files'
'(- : *)--print-interpreter[Prints the ELF interpreter of the executable]'
'(- : *)--print-os-abi[Prints the OS ABI of the executable]'
'--set-os-abi[Changes the OS ABI of the executable]:ABI:(none sysv hpux netbsd gnu linux solaris aix irix freebsd tru64 modesto openbsd arm_aeabi arm standalone)'
'(- : *)--print-soname[Prints DT_SONAME entry of .dynamic section]'
'--set-soname[Sets DT_SONAME entry of a library to SONAME]:SONAME'
'--set-soname[Sets DT_SONAME entry of a library to SONAME]:SONAME:'
'--set-rpath[Change the DT_RUNPATH of the executable or library to RUNPATH]:RUNPATH:_dirs'
'--add-rpath[Add RUNPATH to the existing DT_RUNPATH of the executable or library.]:RUNPATH:_dirs'
'--remove-rpath[Removes the DT_RPATH or DT_RUNPATH entry of the executable or library]'
'--shrink-rpath[Remove from the DT_RUNPATH or DT_RPATH all directories that do not contain a library referenced by DT_NEEDED fields of the executable or library]'
'--allowed-rpath-prefixes[Combined with the "--shrink-rpath" option, this can be used for further rpath tuning]:PREFIXES'
'--allowed-rpath-prefixes[Combined with the "--shrink-rpath" option, this can be used for further rpath tuning]:PREFIXES:'
'(- : *)--print-rpath[Prints the DT_RUNPATH or DT_RPATH for an executable or library]'
'--force-rpath[Forces the use of the obsolete DT_RPATH in the file instead of DT_RUNPATH]'
'--add-needed[Adds a declared dependency on a dynamic library]:LIBRARY'
'*--replace-needed[Replaces a declared dependency on a dynamic library with another one]:a declared dependency:LIB_ORIG:another declared dependency:LIB_NEW'
'--remove-needed[Removes a declared dependency on LIBRARY]:LIBRARY'
'--add-needed[Adds a declared dependency on a dynamic library]:LIBRARY:_files'
'*--replace-needed[Replaces a declared dependency on a dynamic library with another one]:LIB_ORIG:_get_dep:LIB_NEW:_files'
'--remove-needed[Removes a declared dependency on LIBRARY]:LIBRARY:_get_dep'
'(- : *)--print-needed[Prints all DT_NEEDED entries of the executable]'
'--no-default-lib[Marks the object so that the search for dependencies of this object will ignore any default library search paths]'
'--no-sort[Do not sort program headers or section headers]'
'--add-debug-tag[Adds DT_DEBUG tag to the .dynamic section if not yet present in an ELF object]'
'(- : *)--print-execstack[Prints the state of the executable flag of the GNU_STACK program header, if present]'
'--clear-execstack[Clears the executable flag of the GNU_STACK program header, or adds a new header]'
'--set-execstack[Sets the executable flag of the GNU_STACK program header, or adds a new header]'
'--rename-dynamic-symbols[Renames dynamic symbols]:NAME_MAP_FILE'
'--rename-dynamic-symbols[Renames dynamic symbols]:NAME_MAP_FILE:_files'
'--output[Set the output file name]:FILE:_files'
'--debug[Prints details of the changes made to the input file]'
'--version[Shows the version of patchelf]'
Expand Down
11 changes: 6 additions & 5 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
description = "A tool for modifying ELF executables and libraries";

inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

outputs = { self, nixpkgs }:

let
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" "riscv64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

version = nixpkgs.lib.removeSuffix "\n" (builtins.readFile ./version);
Expand Down Expand Up @@ -36,6 +36,11 @@
versionSuffix = ""; # obsolete
src = self;
preAutoconf = "echo ${version} > version";

# portable configure shouldn't have a shebang pointing to the nix store
postConfigure = ''
sed -i '1s|^.*$|#!/bin/sh|' ./configure
'';
postDist = ''
cp README.md $out/
echo "doc readme $out/README.md" >> $out/nix-support/hydra-build-products
Expand Down Expand Up @@ -76,10 +81,12 @@
[ self.hydraJobs.tarball
self.hydraJobs.build.x86_64-linux
self.hydraJobs.build.i686-linux
# FIXME: add aarch64 emulation to our github action...
# FIXME: add aarch64/riscv64 emulation to our github action...
#self.hydraJobs.build.aarch64-linux
#self.hydraJobs.build.riscv64-linux
self.hydraJobs.build-sanitized.x86_64-linux
#self.hydraJobs.build-sanitized.aarch64-linux
#self.hydraJobs.build-sanitized.riscv64-linux
self.hydraJobs.build-sanitized.i686-linux
self.hydraJobs.build-sanitized-clang.x86_64-linux
];
Expand Down
5 changes: 4 additions & 1 deletion src/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4002,8 +4002,11 @@ enum
#define R_RISCV_SET32 56
#define R_RISCV_32_PCREL 57
#define R_RISCV_IRELATIVE 58
#define R_RISCV_PLT32 59
#define R_RISCV_SET_ULEB128 60
#define R_RISCV_SUB_ULEB128 61

#define R_RISCV_NUM 59
#define R_RISCV_NUM 62

/* RISC-V specific values for the st_other field. */
#define STO_RISCV_VARIANT_CC 0x80 /* Function uses variant calling
Expand Down
Loading

0 comments on commit 01e9cc8

Please sign in to comment.