File tree Expand file tree Collapse file tree 3 files changed +28
-9
lines changed Expand file tree Collapse file tree 3 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,23 @@ AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2 foreign color-tests parallel-tests])
66AM_PROG_CC_C_O
77AC_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
1127AC_CONFIG_FILES ( [ Makefile src/Makefile tests/Makefile patchelf.spec] )
1228AC_OUTPUT
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ of executables and change the RPATH of executables and libraries.
2222
2323The 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"
2629Change the dynamic loader ("ELF interpreter") of executable given to
2730INTERPRETER.
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ static bool debugMode = false;
4747static bool forceRPath = false ;
4848
4949static string fileName;
50-
50+ static int pageSize = PAGESIZE;
5151
5252off_t fileSize, maxSize;
5353unsigned char * contents = 0 ;
@@ -58,13 +58,7 @@ unsigned char * contents = 0;
5858
5959
6060static 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\t Prints 'DT_SONAME' entry of .dynamic section. Raises an error if DT_SONAME doesn't exist\n \
15011496 [--set-soname SONAME]\t\t Sets '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 }
You can’t perform that action at this time.
0 commit comments