From 2b3c9602e710a92f5ab2c6f0a6143fc382aca724 Mon Sep 17 00:00:00 2001 From: Felipe Sateler Date: Thu, 14 Jan 2016 22:21:08 -0300 Subject: Remove stale sysconf configure check --- configure.ac | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure.ac b/configure.ac index bfd3b6e..44783c4 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,5 @@ AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2 foreign color-tests parallel-tests]) AM_PROG_CC_C_O AC_PROG_CXX -AC_CHECK_FUNCS([sysconf]) - AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile patchelf.spec]) AC_OUTPUT -- cgit v0.12 From 5c5026e572e36358b170d15a9451e6a471d710b6 Mon Sep 17 00:00:00 2001 From: Felipe Sateler Date: Thu, 14 Jan 2016 22:47:00 -0300 Subject: Allow specifying page size at configure time --- configure.ac | 18 ++++++++++++++++++ src/patchelf.cc | 8 +------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 44783c4..29445b1 100644 --- a/configure.ac +++ b/configure.ac @@ -6,5 +6,23 @@ AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2 foreign color-tests parallel-tests]) AM_PROG_CC_C_O AC_PROG_CXX +PAGESIZE=auto +AC_ARG_WITH([page-size], + AS_HELP_STRING([--with-page-size=SIZE], [Specify default pagesize (default auto)]), + PAGESIZE=$withval + ) + +AS_IF([test "x$PAGESIZE" = xauto], + AS_IF([which getconf &>/dev/null], [ + PAGESIZE=`getconf PAGESIZE &>/dev/null || getconf PAGE_SIZE &>/dev/null` + ]) + AS_IF([test "x$PAGESIZE" = x], [ + PAGESIZE=4096 + ]) +) + +AC_DEFINE_UNQUOTED(PAGESIZE, ${PAGESIZE}) +AC_MSG_RESULT([Setting page size to ${PAGESIZE}]) + AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile patchelf.spec]) AC_OUTPUT diff --git a/src/patchelf.cc b/src/patchelf.cc index ddde0c1..e4bb084 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -40,13 +40,7 @@ unsigned char * contents = 0; static unsigned int getPageSize(){ -#ifdef MIPSEL - /* The lemote fuloong 2f kernel defconfig sets a page size of - 16KB. */ - return 4096 * 4; -#else - return 4096; -#endif + return PAGESIZE; } -- cgit v0.12 From 20ccc36b9cdb4119fe326724bfee70d1619e31ee Mon Sep 17 00:00:00 2001 From: Felipe Sateler Date: Thu, 14 Jan 2016 22:56:04 -0300 Subject: Allow overriding pagesize at runtime via a command-line argument --- patchelf.1 | 3 +++ src/patchelf.cc | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/patchelf.1 b/patchelf.1 index 92e1729..8067dff 100644 --- a/patchelf.1 +++ b/patchelf.1 @@ -22,6 +22,9 @@ of executables and change the RPATH of executables and libraries. The single option given operates on a given FILE, editing in place. +.IP "--page-size SIZE" +Uses the given page size instead of the default. + .IP "--set-interpreter INTERPRETER" Change the dynamic loader ("ELF interpreter") of executable given to INTERPRETER. diff --git a/src/patchelf.cc b/src/patchelf.cc index e4bb084..0831f62 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -29,7 +29,7 @@ static bool debugMode = false; static bool forceRPath = false; static string fileName; - +static int pageSize = PAGESIZE; off_t fileSize, maxSize; unsigned char * contents = 0; @@ -40,7 +40,7 @@ unsigned char * contents = 0; static unsigned int getPageSize(){ - return PAGESIZE; + return pageSize; } @@ -1472,6 +1472,7 @@ void showHelp(const string & progName) { fprintf(stderr, "syntax: %s\n\ [--set-interpreter FILENAME]\n\ + [--page-size SIZE]\n\ [--print-interpreter]\n\ [--print-soname]\t\tPrints 'DT_SONAME' entry of .dynamic section. Raises an error if DT_SONAME doesn't exist\n\ [--set-soname SONAME]\t\tSets 'DT_SONAME' entry to SONAME.\n\ @@ -1507,6 +1508,11 @@ int main(int argc, char * * argv) if (++i == argc) error("missing argument"); newInterpreter = argv[i]; } + else if (arg == "--page-size") { + if (++i == argc) error("missing argument"); + pageSize = atoi(argv[i]); + if (pageSize <= 0) error("invalid argument to --page-size"); + } else if (arg == "--print-interpreter") { printInterpreter = true; } -- cgit v0.12