Skip to content

Commit 20ccc36

Browse files
committed
Allow overriding pagesize at runtime via a command-line argument
1 parent 5c5026e commit 20ccc36

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static bool debugMode = false;
2929
static bool forceRPath = false;
3030

3131
static string fileName;
32-
32+
static int pageSize = PAGESIZE;
3333

3434
off_t fileSize, maxSize;
3535
unsigned char * contents = 0;
@@ -40,7 +40,7 @@ unsigned char * contents = 0;
4040

4141

4242
static unsigned int getPageSize(){
43-
return PAGESIZE;
43+
return pageSize;
4444
}
4545

4646

@@ -1472,6 +1472,7 @@ void showHelp(const string & progName)
14721472
{
14731473
fprintf(stderr, "syntax: %s\n\
14741474
[--set-interpreter FILENAME]\n\
1475+
[--page-size SIZE]\n\
14751476
[--print-interpreter]\n\
14761477
[--print-soname]\t\tPrints 'DT_SONAME' entry of .dynamic section. Raises an error if DT_SONAME doesn't exist\n\
14771478
[--set-soname SONAME]\t\tSets 'DT_SONAME' entry to SONAME.\n\
@@ -1507,6 +1508,11 @@ int main(int argc, char * * argv)
15071508
if (++i == argc) error("missing argument");
15081509
newInterpreter = argv[i];
15091510
}
1511+
else if (arg == "--page-size") {
1512+
if (++i == argc) error("missing argument");
1513+
pageSize = atoi(argv[i]);
1514+
if (pageSize <= 0) error("invalid argument to --page-size");
1515+
}
15101516
else if (arg == "--print-interpreter") {
15111517
printInterpreter = true;
15121518
}

0 commit comments

Comments
 (0)