[Bug] Added a possibility to order sections so the address table section can stay last even when user creates sections after it has been created (#293)

This commit is contained in:
kobalicek
2020-08-07 23:44:44 +02:00
parent 10be0c8f1d
commit 0646d0a48f
6 changed files with 110 additions and 20 deletions

View File

@@ -118,7 +118,7 @@ int main() {
// how to do it explicitly.
printf("\nCalculating section offsets:\n");
uint64_t offset = 0;
for (Section* section : code.sections()) {
for (Section* section : code.sectionsByOrder()) {
offset = Support::alignUp(offset, section->alignment());
section->setOffset(offset);
offset += section->realSize();
@@ -157,7 +157,7 @@ int main() {
// Copy the flattened code into `mem.rw`. There are two ways. You can either copy
// everything manually by iterating over all sections or use `copyFlattenedData`.
// This code is similar to what `copyFlattenedData(p, codeSize, 0)` would do:
for (Section* section : code.sections())
for (Section* section : code.sectionsByOrder())
memcpy(static_cast<uint8_t*>(rwPtr) + size_t(section->offset()), section->data(), section->bufferSize());
// Execute the function and test whether it works.