Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
patchelf (0.10-1) experimental; urgency=low

* Packaging for 0.10

-- Illia Pshonkin <illia.pshonkin@percona.com> Mon, 25 May 2020 10:57:32 +0300
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
21 changes: 21 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Source: patchelf
Section: utils
Priority: optional
Maintainer: Felipe Sateler <fsateler@debian.org>
Build-Depends: debhelper (>= 9.0.0)
Standards-Version: 3.9.7
Homepage: https://nixos.org/patchelf.html
Vcs-Git: https://salsa.debian.org/debian/patchelf.git
Vcs-Browser: https://salsa.debian.org/debian/patchelf

Package: patchelf
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: modify properties of ELF executables
PatchELF is a simple utility for modifying existing ELF executables and
libraries. In particular, it can do the following:
.
* Change the dynamic loader ("ELF interpreter") of executables
* Change the RPATH of executables and libraries
* Remove declared dependencies on dynamic libraries
(DT_NEEDED entries)
50 changes: 50 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: patchelf
Source: http://nixos.org/patchelf.html

Files: *
Copyright: 2004-2014 Eelco Dolstra <eelco.dolstra@logicblox.com>
License: GPL-3.0+

Files: debian/*
Copyright: 2014 Felipe Sateler <fsateler@debian.org>
License: GPL-3.0+

Files: src/elf.h
Copyright: 1995-2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
License: LGPL-2.1+

License: GPL-3.0+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This package 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 General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".

License: LGPL-2.1+
This package 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.
.
This package 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 General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU Lesser General
Public License can be found in "/usr/share/common-licenses/LGPL-2.1".

1 change: 1 addition & 0 deletions debian/docs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README
2 changes: 2 additions & 0 deletions debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
usr/local/bin/patchelf /usr/bin
usr/local/share/* /usr/share
35 changes: 35 additions & 0 deletions debian/patches/adjust_startPage_issue127_commit1cc234fea.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From: Ed Bartosh <ed.bartosh@linux.intel.com>
Date: Fri, 21 Jul 2017 12:33:53 +0300
Subject: [PATCH] fix adjusting startPage

startPage is adjusted unconditionally for all executables.
This results in incorrect addresses assigned to INTERP and LOAD
program headers, which breaks patched executable.

Adjusting startPage variable only when startOffset > startPage
should fix this.

This change is related to the issue NixOS#10

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
src/patchelf.cc | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/patchelf.cc b/src/patchelf.cc
index 0b4965a..12d6bf1 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -742,10 +742,8 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
since DYN executables tend to start at virtual address 0, so
rewriteSectionsExecutable() won't work because it doesn't have
any virtual address space to grow downwards into. */
- if (isExecutable) {
- if (startOffset >= startPage) {
- debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage);
- }
+ if (isExecutable && startOffset > startPage) {
+ debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage);
startPage = startOffset;
}

1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
adjust_startPage_issue127_commit1cc234fea.patch
53 changes: 53 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
dh $@
TMP=$(CURDIR)/debian/tmp/
TMPD=$(CURDIR)/debian/tmp-debug/
prefix=/usr
ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
ARCH_OS = $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
NCPU = $(shell grep -c processor /proc/cpuinfo)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

DEB_SOURCE_PACKAGE ?= $(strip $(shell egrep '^Source: ' debian/control | cut -f 2 -d ':'))
DEB_VERSION ?= $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
DEB_NOEPOCH_VERSION ?= $(shell echo $(DEB_VERSION) | cut -d: -f2-)
DEB_UPSTREAM_VERSION ?= $(shell echo $(DEB_NOEPOCH_VERSION) | sed 's/-[^-]*$$//')
DEB_UPSTREAM_VERSION_MAJOR_MINOR := $(shell echo $(DEB_UPSTREAM_VERSION) | sed -r -n 's/^([0-9]+\.[0-9]+).*/\1/p')
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

DISTRIBUTION = $(shell lsb_release -i -s)
DISTRELEASE = $(shell lsb_release -c -s)

patchelfdir = patchelf-$(VERSION)

override_dh_auto_configure:
@echo "RULES.$@"
./bootstrap.sh
./configure
make
touch $@

override_dh_auto_build:
@echo "RULES.$@"
./bootstrap.sh
./configure
make
touch $@

override_dh_auto_install:
@echo "RULES.$@"
make DESTDIR="$(TMP)" install

override_dh_auto_clean:
[ ! -f Makefile ] || $(MAKE) maintainer-clean
rm -rf build-aux
find . -name Makefile.in -delete
rm -f configure
rm -f aclocal.m4
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
5 changes: 5 additions & 0 deletions debian/source/options
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extend-diff-ignore=bootstrap.sh
extend-diff-ignore=release.nix
extend-diff-ignore=version
extend-diff-ignore=BUGS

6 changes: 6 additions & 0 deletions debian/watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

version=4
opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%patchelf-$1.tar.gz%" \
https://github.com/NixOS/patchelf/tags \
(?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate

48 changes: 48 additions & 0 deletions patchelf.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Summary: A utility for patching ELF binaries

Name: patchelf
Version: @PACKAGE_VERSION@
Release: 1
License: GPL
Group: Development/Tools
URL: http://nixos.org/patchelf.html
Source0: %{name}-%{version}.tar.gz
Patch0: adjust_startPage_issue127_commit1cc234fea.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
Prefix: /usr

%description

PatchELF is a simple utility for modifing existing ELF executables and
libraries. It can change the dynamic loader ("ELF interpreter") of
executables and change the RPATH of executables and libraries.

%prep
%setup -q
%patch0 -p1

%build
%if 0%{?rhel} == 6
sed -i "s: serial-tests::g" configure.ac
%endif
./bootstrap.sh
./configure --prefix=%{_prefix}
make
make check

%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
# rpmbuild automatically strips... strip $RPM_BUILD_ROOT/%%{_bindir}/* || true

%clean
rm -rf $RPM_BUILD_ROOT

%files
%{_bindir}/patchelf
%doc %{_docdir}/patchelf/README
%{_mandir}/man1/patchelf.1.gz

%changelog
* Wed May 27 2020 Illia Pshonkin <illia.pshonkin@percona.com>
- Packaging for 0.10
Loading