Created
March 31, 2017 20:05
-
-
Save rui314/19a059a461dd787ebd4694aebb3b7658 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp | |
index cda8a2b3f42..a77ae6acf73 100644 | |
--- a/lld/ELF/OutputSections.cpp | |
+++ b/lld/ELF/OutputSections.cpp | |
@@ -238,8 +238,21 @@ template <class ELFT> void OutputSection::writeTo(uint8_t *Buf) { | |
if (uint32_t Filler = Script->getFiller(this->Name)) | |
fill(Buf, this->Size, Filler); | |
- parallelForEach(Sections.begin(), Sections.end(), | |
- [=](InputSection *IS) { IS->writeTo<ELFT>(Buf); }); | |
+ parallelFor(0, Sections.size(), [=](size_t I) { | |
+ InputSection *Sec = Sections[I]; | |
+ Sec->writeTo<ELFT>(Buf); | |
+ | |
+ // Fill gaps between executable sections with INT3 or equivalent. | |
+ if (Sec->Flags & SHF_EXECINSTR) { | |
+ uint8_t *Start = Buf + Sec->OutSecOff + Sec->getSize(); | |
+ uint8_t *End; | |
+ if (I + 1 == Sections.size()) | |
+ End = Buf + this->Size; | |
+ else | |
+ End = Buf + Sections[I + 1]->OutSecOff; | |
+ fill(Start, End - Start, 0xcccccccc); | |
+ } | |
+ }); | |
// Linker scripts may have BYTE()-family commands with which you | |
// can write arbitrary bytes to the output. Process them if any. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment