[PATCH] D62838: [Object] add isExecutableObject member function

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 10:47:25 PDT 2019


abrachet marked an inline comment as done.
abrachet added a comment.

Would it make sense to add something like this? It might catch a case I haven't thought of yet on obscure systems (assuming we end up changing this to do more than just checking e_type and e_entry, otherwise this won't catch much), assuming build bots are running tests on such systems.

  if (!sys::fs::exists("/usr/bin/true") {
      // Try other paths?
      // If it doesn't exist then just return.
  }
  
  // Ensure it isn't a symlink, I think we don't deal with these currently?
  
  auto ObjFile = createObjectFile(Path);
  ASSERT_TRUE(ObjFile->isExecutableObject());

Also, for more reference this <https://github.com/torvalds/linux/blob/master/fs/binfmt_elf.c#L693> is how elf executables are loaded by execve in Linux I believe. Obviously there is more to check than just e_type, e_entry or program headers but how much is reasonable? Is it worth commenting in ObjectFile::isExecutableObject() that a false return may not necessarily mean the OS can't load the object as an executable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62838





More information about the llvm-commits mailing list