The __llvm_mipmap section should be considered a debug section because it provides no use at runtime. The llvm-strip tool should remove that section.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I'm wondering if you can use llvm-objcopy --remove-section for these purposes instead?
Yes, we can use llvm-objcopy --remove-section=__llvm_mipmap a.out. I like this patch because it allows you to use llvm-strip easily, but it technically isn't required.
my 0.02$ - (the diff lacks tests, isDebugSection has a more specific meaning in this context - but these are minor concerns), the main concern - I'm not sure that putting this logic into llvm-objcopy is a good idea, there are many tools which create extra sections and making llvm-objcopy aware of them doesn't feel right. Btw - llvm-strip has --remove-section as well, so e.g. you can simply add it to the same invocation of the tool, no need to run it as a separate build step. But I'd like to hear what others think, cc @jhenderson, @MaskRay
__llvm_mipmap is not a debug section, so not suitable in isDebugSection.
--strip-debug/--strip-nonalloc/--strip-all-gnu cannot remove SHF_ALLOC sections. The proposed __llvm_mipmap has the SHF_ALLOC flag so not suitable.
Every SHF_ALLOC section is part of the program image. A tool like llvm-strip needs to be conservative and assumes removal of every such section can affect runtime behaviors and probably correctness.
(A self-introspection program can dump its own non-SHF_ALLOC section; this sentence does not discuss such programs.)
Sometimes there are indeed special SHF_ALLOC sections which are strippable, users can remove them with --remove-section. It is not strip's business to understand every such section.
I have no problem using --remove-section so I'll update this stack to use that. Thanks for the feedback!