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

Vyacheslav Zakharin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 08:47:08 PDT 2021


vzakhari added a comment.

In D103546#2802020 <https://reviews.llvm.org/D103546#2802020>, @jhenderson wrote:

> 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?

Exactly!  I could add the same helper in the plugin code, but I'd rather keep it close to the `file_magic` enum definition.  Do you suggest adding it in the plugin code?


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

https://reviews.llvm.org/D103546



More information about the llvm-commits mailing list