[PATCH] D103546: Added ELFObjectFileBase::checkMagic() for checking ELF magic word.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 02:24:50 PDT 2021


jhenderson added a comment.

In D103546#2799634 <https://reviews.llvm.org/D103546#2799634>, @vzakhari wrote:

> In D103546#2799569 <https://reviews.llvm.org/D103546#2799569>, @MaskRay wrote:
>
>> We have `lib/BinaryFormat/Magic.cpp`. Do we need the ELF specific API?
>
> Thanks!  I was not aware of this code.  How about adding something like `static inline is_any_elf(file_magic)` method in `Magic.h`?  If you agree, then I will abandon this change-set and add the new method in D103545 <https://reviews.llvm.org/D103545>.

I'm assuming this would be to avoid having to write something like `if (objectType == elf || objectType == elf_relocatable || /*all the other elf_* types*/ ...)` (or an equivalent switch statement)? Is this something you'd use in more than one place within your code?


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

https://reviews.llvm.org/D103546



More information about the llvm-commits mailing list