[lld] r288808 - Don't print empty PT_LOAD. (Rafael Espindola via llvm-commits)
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 06:31:00 PST 2016
+template <class ELFT> void Writer<ELFT>::removeEmptyPTLoad() {
+ auto I = std::remove_if(Phdrs.begin(), Phdrs.end(), [&](const Phdr &P) {
+ if (P.H.p_type != PT_LOAD)
+ return false;
+ uintX_t Size = P.Last->Addr + P.Last->Size - P.First->Addr;
+ return Size == 0;
+ });
+ Phdrs.erase(I, Phdrs.end());
+}
+
We have relative code in assignAddresses():
if (!FirstPTLoad->First) {
// Sometimes the very first PT_LOAD segment can be empty.
// This happens if (all conditions met):
// - Linker script is used
// - First section in ELF image is not RO
// - Not enough space for program headers.
// The code below removes empty PT_LOAD segment and updates
// program headers size.
Phdrs.erase(FirstPTLoad);
Out<ELFT>::ProgramHeaders->Size =
sizeof(typename ELFT::Phdr) * Phdrs.size();
}
I wonder if you need to update Out<ELFT>::ProgramHeaders->Size and if
we still need the above one piece then.
George.
More information about the llvm-commits
mailing list