[PATCH] D61201: [LLD][ELF] Full support for -n (--nmagic) and -N (--omagic)

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 26 19:04:51 PDT 2019


MaskRay added inline comments.


================
Comment at: ELF/Driver.cpp:826
       Args.hasFlag(OPT_merge_exidx_entries, OPT_no_merge_exidx_entries, true);
+  Config->Nmagic = Args.hasFlag(OPT_nmagic, OPT_no_nmagic, false);
   Config->NoinhibitExec = Args.hasArg(OPT_noinhibit_exec);
----------------
Since `--omagic` implies `--nmagic`, we can probably use:

`Config->Nmagic = Config->OMagic || Args.hasFlag(OPT_nmagic, OPT_no_nmagic, false);`

and delete `Config::Paged`.

or

`Config->Paged = !(Config->OMagic || Args.hasFlag(OPT_nmagic, OPT_no_nmagic, false));`


================
Comment at: ELF/Driver.cpp:959
   // make sense to create PT_GNU_RELRO for such executables.
-  if (Config->Omagic)
+  if (Config->Omagic || Config->Nmagic)
     Config->ZRelro = false;
----------------
Then, this will become `if (Config->Nmagic)` or `if (!Config->Paged)`


================
Comment at: ELF/Writer.cpp:2083
   if (OS == First) {
-    uint64_t Alignment = std::max<uint64_t>(OS->Alignment, Config->MaxPageSize);
+    uint64_t PageSize = Config->Paged ? Config->MaxPageSize : 1;
+    uint64_t Alignment = std::max<uint64_t>(OS->Alignment, PageSize);
----------------
Do other occurrences of `Config->MaxPageSize` need similar changes?

i.e, what will happen if we do `if (Config->Nmagic) Config->MaxPageSize = 1;`


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

https://reviews.llvm.org/D61201





More information about the llvm-commits mailing list