[PATCH] D37736: [ELF] - Do not spread specific flags when emiting output sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 02:51:18 PDT 2017


grimar added a comment.

In https://reviews.llvm.org/D37736#868269, @ruiu wrote:

> This is a very obscure way of setting flags to sections. I shouldn't be buried deep inside code like this.
>
> Instead of doing something like this, drop the flag you don't want to propagate to the output when you parse input sections. I believe you can still recall we did something like this for SHF_COMPRESSED until I changed the way of handling it in some patch I submitted a few months ago.


I sure remember that patch, but this is very different situation I believe. Let me try to explain the issue again:
We have 2 output sections: `.ARM.exidx` and `foo`. First one has SHF_LINK_ORDER flag and has 1 input section.
This flag should not be dropped from output. It just like SHF_TLS for example, which also should be preserved.
Issue is that after we adjusted section `.ARM.exidx`, we want to proccess `foo`. But `foo` does not have any input sections,
so we have to set flags for it basing on something.

In this method (`adjustSectionsBeforeSorting`), flag is calculated for `foo` basing on previous output section flag. 
It does not seem to me that it is correct to spread special flags for empty sections, so we should exclude some flags
that are valid for another sections but does not valid for this one. That is what my patch do.

This method is a single isolated place in whole LLD that handles empty output sections like `foo`.
I can't call this logic "buried inside code", because this logic is exactly for special case and it is isolated, what is good I think.


https://reviews.llvm.org/D37736





More information about the llvm-commits mailing list