[PATCH] D43799: Error instead of allocating a header bellow address 0

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 01:09:23 PST 2018


grimar added inline comments.


================
Comment at: ELF/LinkerScript.cpp:898
+    // Error if we were explicitly asked to allocate headers.
+    error("Could not allocate headers");
   }
----------------
Doesn't seem you need `else if` here, it could be:

```
if (Script->AllocateHeaders)
  error("Could not allocate headers");

Out::ElfHeader->PtLoad = nullptr;
Out::ProgramHeaders->PtLoad = nullptr;
...
```


================
Comment at: ELF/LinkerScript.h:277
   bool ErrorOnMissingSection = false;
+  bool AllocateHeaders = false;
 
----------------
I think you can avoid introducing this flag and
just iterate over `Script->PhdrsCommands` to find 
`Cmd.HasPhdrs || Cmd.HasFilehdr` instead ?


https://reviews.llvm.org/D43799





More information about the llvm-commits mailing list