<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 1, 2018 at 4:25 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Testing the patch I have hit a case where the sorted program crashes.<br>
<br>
I have uploaded the test to<br>
<br>
 <a href="https://s3-us-west-2.amazonaws.com/linker-tests/t2.tar.xz" rel="noreferrer" target="_blank">https://s3-us-west-2.amazonaw<wbr>s.com/linker-tests/t2.tar.xz</a></blockquote><div><br></div><div>The call graph file reduces down to a single line.</div><div><br></div><div><div>__libc_csu_init _init 1</div></div><div><br></div><div>You told the linker it could reorder _init, so it did. This happens to move _init to the end of .init. Obviously reordering _init is bad, and I'm pretty sure --symbol-ordering-file has the same problem (although it prefers to move to the front, so it would happen to work for _init). This is part of the reason why I originally restricted this to .text, as it's a known safe to reorder section.</div><div><br></div><div>There are many ways to solve this, but for now I would prefer to white list the sections that are safe to reorder, and ignore any edges that include sections not in that list or edges between output sections.</div><div><br></div><div>- Michael Spencer</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<span class="m_-9157986085025703590gmail-"><br>
<br>
Michael Spencer via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> writes:<br>
<br>
<br>
</span>> Index: test/ELF/cgprofile-txt.s<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- /dev/null<br>
> +++ test/ELF/cgprofile-txt.s<br>
> @@ -0,0 +1,69 @@<br>
<span class="m_-9157986085025703590gmail-">> +# REQUIRES: x86<br>
> +<br>
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t<br>
</span>> +# RUN: ld.lld -e A %t -o %t2<br>
<span class="m_-9157986085025703590gmail-">> +# RUN: llvm-readobj -symbols %t2 | FileCheck %s --check-prefix=NOSORT<br>
> +<br>
</span>> +# RUN: echo "A B 100" > %t.call_graph<br>
> +# RUN: echo "A C 40" >> %t.call_graph<br>
> +# RUN: echo "B C 30" >> %t.call_graph<br>
> +# RUN: echo "C D 90" >> %t.call_graph<br>
> +# RUN: echo "PP TS 100" >> %t.call_graph<br>
> +# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2<br>
<span class="m_-9157986085025703590gmail-">> +# RUN: llvm-readobj -symbols %t2 | FileCheck %s<br>
> +<br>
</span>> +    .section    .text.D,"ax",@progbits<br>
> +D:<br>
> +    retq<br>
> +<br>
> +    .section    .text.C,"ax",@progbits<br>
> +    .globl  C<br>
> +C:<br>
> +    retq<br>
> +<br>
> +    .section    .text.B,"ax",@progbits<br>
> +    .globl  B<br>
> +B:<br>
> +    retq<br>
> +<br>
> +    .section    .text.A,"ax",@progbits<br>
> +    .globl  A<br>
> +A:<br>
> +    retq<br>
> +<br>
trailing white space.<br>
<br>
> +    .section    .ponies,"ax",@progbits,unique,<wbr>1<br>
> +    .globl TS<br>
> +TS:<br>
> +    retq<br>
> +<br>
<br>
trailing white space.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div></div>