[PATCH] D61688: [LLD][ELF] Full support for -n (--nmagic) and -N (--omagic) via -zcommon-page-size

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 19:14:48 PDT 2019


MaskRay added a comment.

So D61688 <https://reviews.llvm.org/D61688> implements -z common-page-size as a by-product :)
I compared it with D61201 <https://reviews.llvm.org/D61201>. It has a bit more set-up code in Driver.cpp but that part is easy to reason about. In return, it simplifies a few places where D61201 <https://reviews.llvm.org/D61201> additionally checks `Config->Paged`, so I am in favor of D61688 <https://reviews.llvm.org/D61688>:

  // Writer<ELFT>::finalizeSections()
  -  if (!Script->HasSectionsCommand && !Config->Relocatable && Config->Paged)
  +  if (!Script->HasSectionsCommand && !Config->Relocatable)
       fixSectionAlignments();
  
  // computeFileOffset
  -    uint64_t PageSize = Config->Paged ? Config->MaxPageSize : 1;
  -    uint64_t Alignment = std::max<uint64_t>(OS->Alignment, PageSize);
  +    uint64_t Alignment = std::max<uint64_t>(OS->Alignment, Config->MaxPageSize);
  
  // Writer<ELFT>::assignFileOffsets()
  -    if (LastRX && LastRX->LastSec == Sec && Config->Paged)
  -      Off = alignTo(Off, Target->PageSize);
  +    if (LastRX && LastRX->LastSec == Sec)
  +      Off = alignTo(Off, Config->CommonPageSize);
  
  // Writer<ELFT>::writeTrapInstr()
  -  if (Script->HasSectionsCommand || !Config->Paged)
  +  if (Script->HasSectionsCommand)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61688/new/

https://reviews.llvm.org/D61688





More information about the llvm-commits mailing list