[PATCH] D97976: [MC] Change ELFOSABI_NONE to ELFOSABI_GNU for SHF_GNU_RETAIN

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 5 09:51:58 PST 2021


MaskRay added a comment.

In D97976#2606678 <https://reviews.llvm.org/D97976#2606678>, @peter.smith wrote:

> No objections.
>
> Just thinking how to avoid lifting markGnuAbi into the generic MCObjectWriter. The only immediate thing I can think of is casting the result of Asm.getWriter in
>
>   if (SectionELF->getFlags() & ELF::SHF_GNU_RETAIN)
>       Asm.getWriter().markGnuAbi();
>
> To MCELFObjectTargetWriter. I think this should be possible as I think it is the only choice from within MCELFStreamer, and I guess we could check with a dyn_cast before doing so if we were paranoid. That would allow either markGnuAbi to be put there, or with some more modifications something like setOsABI().

https://github.com/llvm/llvm-project/blob/main/llvm/lib/MC/ELFObjectWriter.cpp#L219 MCELFObjectTargetWriter is only accessible from the anonymous namespace ELFObjectWriter. We probably don't want to expose ELFObjectWriter in a header.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97976



More information about the llvm-commits mailing list