<br><br>пятница, 16 сентября 2016 г. пользователь Rui Ueyama  написал:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Sep 15, 2016 at 1:02 PM, Eugene Leviant <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','evgeny.leviant@gmail.com');" target="_blank">evgeny.leviant@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">First of all, I need to identify this section, because, like I said, it's being added only once to a single object file. When some group is seen next time, all member sections are discarded. This means that relocations in some object file may point to discarded sections. When you see this discarded section in GC, you should (IMHO) find it counterpart and mark it live.</div></blockquote><div><br></div><div>No, I don't think relocations could point to sections that were removed because of comdat group deduplication.</div><div></div></div></div></div></blockquote><div><br></div><div>I'm sorry but this does happen. I can't share the real world example, but you can try the test case which is a part of this patch (comdat-gc.s). You'll get a crash in forEachSuccessor.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>All relocations to sections in comdat groups should be through undefined symbols. So, when the control reaches this part of code, all symbols should have already been resolved, or it will end up with a link error. You shouldn't have to "resolve" comdat groups by name again here. </div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>What I'm doing now is:<div><br></div><div>a) Get group signature, given object file and some input section index. This is done using SectionGroupSig hash map.</div><div>b) Store all group signatures in hash set</div><div>c) Iterate object files and fetch all input sections, which are members of comdat groups with signatures in this hash set.</div><div><br></div><div>Now I'm trying to understand your suggestion. You suggest to keep list of member sections in each member of the group, correct?</div><div>You cannot do so in discarded section, so you still need to find real section, having some object file and section number in it, right?</div><div><br></div></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2016-09-15 22:45 GMT+03:00 Rui Ueyama <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','ruiu@google.com');" target="_blank">ruiu@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Imagine any section that is in some comdat group have a GroupMembers vector, so that starting from any comdat group member section, you can reach all siblings in the same group. With that, all you have to do for a section S to make all its siblings live is to do `for (InputSectionData *Succ : S->GroupMember) Enque({Succ, 0});`. Doesn't it work?</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 15, 2016 at 12:32 PM, Eugene Leviant <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','evgeny.leviant@gmail.com');" target="_blank">evgeny.leviant@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">evgeny777 added a comment.<br>
<br>
Let's elaborate the idea. The main problem is that symbol 'D' inside resolveReloc() may point to InputSectionBase<ELFT>::Discar<wbr>ded. This happens because comdat group is added to only one object file and causes crash in GC, because forEachSuccessor implicitly casts Discarded to InputSection<ELFT> and tries to fetch relocs from it. How this 'GroupMembers' vector would help?<br>
<div><div><br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D24616" rel="noreferrer" target="_blank">https://reviews.llvm.org/D2461<wbr>6</a><br>
<br>
<br>
<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>
</blockquote>