Skip to content
Open
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 patchelf.1
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ Use sparingly and with caution.
.IP "--output FILE"
Set the output file name. If not specified, the input will be modified in place.

.IP --force
Force write-out of the ELF binary even when no changes were made.
This is useful for fixing ELF binaries that have issues like
"Program headers not in the first page".

.IP --debug
Prints details of the changes made to the input file.

Expand Down
4 changes: 4 additions & 0 deletions src/patchelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,7 @@ static void showHelp(const std::string & progName)
[--rename-dynamic-symbols NAME_MAP_FILE]\tRenames dynamic symbols. The map file should contain two symbols (old_name new_name) per line\n\
[--no-clobber-old-sections]\t\tDo not clobber old section values - only use when the binary expects to find section info at the old location.\n\
[--output FILE]\n\
[--force]\t\tForce write-out even if no changes were made\n\
[--debug]\n\
[--version]\n\
FILENAME...\n", progName.c_str());
Expand Down Expand Up @@ -2685,6 +2686,9 @@ static int mainWrapped(int argc, char * * argv)
outputFileName = resolveArgument(argv[i]);
alwaysWrite = true;
}
else if (arg == "--force") {
alwaysWrite = true;
}
else if (arg == "--debug") {
debugMode = true;
}
Expand Down
1 change: 1 addition & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ src_TESTS = \
set-rpath-library.sh soname.sh shrink-rpath-with-allowed-prefixes.sh \
set-rpath-rel-map.sh \
force-rpath.sh \
force.sh \
plain-needed.sh \
output-flag.sh \
too-many-strtab.sh \
Expand Down
33 changes: 33 additions & 0 deletions tests/force.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /bin/sh -e
SCRATCH=scratch/$(basename "$0" .sh)

rm -rf "${SCRATCH}"
mkdir -p "${SCRATCH}"

cp simple "${SCRATCH}/"

../src/patchelf --force "${SCRATCH}/simple"

exitCode=0
"${SCRATCH}/simple" || exitCode=$?

if test "$exitCode" != 0; then
echo "bad exit code after --force!"
exit 1
fi

cp simple "${SCRATCH}/simple2"
../src/patchelf --force --output "${SCRATCH}/simple2-out" "${SCRATCH}/simple2"

if ! test -f "${SCRATCH}/simple2-out"; then
echo "--force with --output did not create output file!"
exit 1
fi

exitCode=0
"${SCRATCH}/simple2-out" || exitCode=$?

if test "$exitCode" != 0; then
echo "bad exit code after --force --output!"
exit 1
fi