Skip to content

Commit 5010097

Browse files
committed
Merge branch 'pagesize' of https://github.com/fsateler/patchelf
2 parents 0fa104d + 20ccc36 commit 5010097

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

configure.ac

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,23 @@ AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2 foreign color-tests parallel-tests])
66
AM_PROG_CC_C_O
77
AC_PROG_CXX
88

9-
AC_CHECK_FUNCS([sysconf])
9+
PAGESIZE=auto
10+
AC_ARG_WITH([page-size],
11+
AS_HELP_STRING([--with-page-size=SIZE], [Specify default pagesize (default auto)]),
12+
PAGESIZE=$withval
13+
)
14+
15+
AS_IF([test "x$PAGESIZE" = xauto],
16+
AS_IF([which getconf &>/dev/null], [
17+
PAGESIZE=`getconf PAGESIZE &>/dev/null || getconf PAGE_SIZE &>/dev/null`
18+
])
19+
AS_IF([test "x$PAGESIZE" = x], [
20+
PAGESIZE=4096
21+
])
22+
)
23+
24+
AC_DEFINE_UNQUOTED(PAGESIZE, ${PAGESIZE})
25+
AC_MSG_RESULT([Setting page size to ${PAGESIZE}])
1026

1127
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile patchelf.spec])
1228
AC_OUTPUT

patchelf.1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ of executables and change the RPATH of executables and libraries.
2222

2323
The single option given operates on a given FILE, editing in place.
2424

25+
.IP "--page-size SIZE"
26+
Uses the given page size instead of the default.
27+
2528
.IP "--set-interpreter INTERPRETER"
2629
Change the dynamic loader ("ELF interpreter") of executable given to
2730
INTERPRETER.

src/patchelf.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static bool debugMode = false;
4747
static bool forceRPath = false;
4848

4949
static string fileName;
50-
50+
static int pageSize = PAGESIZE;
5151

5252
off_t fileSize, maxSize;
5353
unsigned char * contents = 0;
@@ -58,13 +58,7 @@ unsigned char * contents = 0;
5858

5959

6060
static unsigned int getPageSize(){
61-
#ifdef MIPSEL
62-
/* The lemote fuloong 2f kernel defconfig sets a page size of
63-
16KB. */
64-
return 4096 * 4;
65-
#else
66-
return 4096;
67-
#endif
61+
return pageSize;
6862
}
6963

7064

@@ -1496,6 +1490,7 @@ void showHelp(const string & progName)
14961490
{
14971491
fprintf(stderr, "syntax: %s\n\
14981492
[--set-interpreter FILENAME]\n\
1493+
[--page-size SIZE]\n\
14991494
[--print-interpreter]\n\
15001495
[--print-soname]\t\tPrints 'DT_SONAME' entry of .dynamic section. Raises an error if DT_SONAME doesn't exist\n\
15011496
[--set-soname SONAME]\t\tSets 'DT_SONAME' entry to SONAME.\n\
@@ -1531,6 +1526,11 @@ int main(int argc, char * * argv)
15311526
if (++i == argc) error("missing argument");
15321527
newInterpreter = argv[i];
15331528
}
1529+
else if (arg == "--page-size") {
1530+
if (++i == argc) error("missing argument");
1531+
pageSize = atoi(argv[i]);
1532+
if (pageSize <= 0) error("invalid argument to --page-size");
1533+
}
15341534
else if (arg == "--print-interpreter") {
15351535
printInterpreter = true;
15361536
}

0 commit comments

Comments
 (0)