This is an archive of the discontinued LLVM Phabricator instance.

Remove __llvm_mipmap section in llvm-strip
AbandonedPublic

Authored by ellis on Jun 11 2021, 5:31 PM.

Details

Summary

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.

Diff Detail

Event Timeline

ellis created this revision.Jun 11 2021, 5:31 PM
ellis requested review of this revision.Jun 11 2021, 5:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2021, 5:31 PM

I'm wondering if you can use llvm-objcopy --remove-section for these purposes instead?

ellis added a comment.Jun 12 2021, 4:46 PM
In D104164#2815489, @alexshap wrote:

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

MaskRay requested changes to this revision.EditedJun 13 2021, 10:58 AM

__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.

This revision now requires changes to proceed.Jun 13 2021, 10:58 AM
ellis added a comment.Jun 13 2021, 7:22 PM

__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!

ellis abandoned this revision.Jun 13 2021, 7:22 PM