mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1499915 - Support undoing elfhack when the elfhacked sections are in separate segments r=froydnj
This is some sort of followup to bug 1423813, providing a minimalistic way to undo elfhack when the elfhack sections are in separate segments, which has been the case since bug 1385783 but didn't cause problems on Android builds until bug 1423822. Depends on D9622 Differential Revision: https://phabricator.services.mozilla.com/D9623 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
66921ba849
commit
0cf2b93ff2
@ -1206,15 +1206,19 @@ void undo_file(const char *name, bool backup = false)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When both elfhack sections are in the same segment, try to merge
|
||||||
|
// the segment that contains them both and the following segment.
|
||||||
|
// When the elfhack sections are in separate segments, try to merge
|
||||||
|
// those segments.
|
||||||
ElfSegment *first = data->getSegmentByType(PT_LOAD);
|
ElfSegment *first = data->getSegmentByType(PT_LOAD);
|
||||||
ElfSegment *second = text->getSegmentByType(PT_LOAD);
|
ElfSegment *second = text->getSegmentByType(PT_LOAD);
|
||||||
if (first != second) {
|
if (first == second) {
|
||||||
fprintf(stderr, elfhack_data " and " elfhack_text " not in the same segment. Skipping\n");
|
second = elf.getSegmentByType(PT_LOAD, first);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
second = elf.getSegmentByType(PT_LOAD, first);
|
|
||||||
|
// Only merge the segments when their flags match.
|
||||||
if (second->getFlags() != first->getFlags()) {
|
if (second->getFlags() != first->getFlags()) {
|
||||||
fprintf(stderr, "Couldn't identify elfhacked PT_LOAD segments. Skipping\n");
|
fprintf(stderr, "Couldn't merge PT_LOAD segments. Skipping\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Move sections from the second PT_LOAD to the first, and remove the
|
// Move sections from the second PT_LOAD to the first, and remove the
|
||||||
@ -1224,6 +1228,7 @@ void undo_file(const char *name, bool backup = false)
|
|||||||
first->addSection(*section);
|
first->addSection(*section);
|
||||||
|
|
||||||
elf.removeSegment(second);
|
elf.removeSegment(second);
|
||||||
|
elf.normalize();
|
||||||
|
|
||||||
if (backup && backup_file(name) != 0) {
|
if (backup && backup_file(name) != 0) {
|
||||||
fprintf(stderr, "Couln't create backup file\n");
|
fprintf(stderr, "Couln't create backup file\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user