Skip to content

Commit 5aba914

Browse files
committed
Add physical page grouping granularity control.
Makes for smaller output binaries. Also add an -Os option for E9Tool that optimizes for space.
1 parent f0ef8a9 commit 5aba914

7 files changed

Lines changed: 235 additions & 88 deletions

File tree

src/e9patch/e9api.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,23 @@ static void parseEmit(Binary *B, const Message &msg)
424424
// Create and optimize the mappings:
425425
MappingSet mappings;
426426
buildMappings(B->allocator, option_mem_mapping_size, mappings);
427-
optimizeMappings(mappings);
428-
putchar('\n');
427+
switch (option_mem_granularity)
428+
{
429+
case 64:
430+
optimizeMappings<Key64>(B->allocator, option_mem_mapping_size,
431+
mappings);
432+
break;
433+
case 128:
434+
optimizeMappings<Key128>(B->allocator, option_mem_mapping_size,
435+
mappings);
436+
break;
437+
case 4096:
438+
optimizeMappings<Key4096>(B->allocator, option_mem_mapping_size,
439+
mappings);
440+
break;
441+
default:
442+
error("unimplemented granularity (%zu)", option_mem_granularity);
443+
}
429444

430445
// Create the patched binary:
431446
B->patched.size = emitElf(B, mappings, option_mem_mapping_size);

src/e9patch/e9elf.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,9 @@ size_t emitElf(const Binary *B, const MappingSet &mappings,
649649
{
650650
uint8_t *base = data + size;
651651
mapping->offset = (off_t)size;
652-
printf("[\33[33m%.16lX\33[0m]", mapping->key);
653652
flattenMapping(base, mapping, /*int3=*/0xcc);
654653
size += mapping->size;
655654
}
656-
putchar('\n');
657655

658656
// Step (4): Modify the entry address.
659657
intptr_t old_entry = 0;

0 commit comments

Comments
 (0)