<div dir="ltr">Looks like the GNU driver doesn't support --gc-sections, and the gc-sections feature is turned off by default. So no section is removed as long as you are using the GNU driver.<div><br></div><div>I think we first have to add that command line option to the driver to turn on the flag in the linking context. Whether turning on the flag is enough or not is that I don't know. We should just try.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 5, 2015 at 2:53 PM, Rafael Espíndola <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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think this is testing for a gnu ld bug/limitation:<br>
<br>
With the attached testcase, gnu ld keeps zed and bar. Gold keeps only bar.<br>
<br>
lld keeps _start, bad, zed and produces wrong bindings :-(<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On 1 February 2015 at 00:47, Shankar Easwaran <<a href="mailto:shankare@codeaurora.org">shankare@codeaurora.org</a>> wrote:<br>
> Author: shankare<br>
> Date: Sat Jan 31 23:47:02 2015<br>
> New Revision: 227711<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227711&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=227711&view=rev</a><br>
> Log:<br>
> [test] Add test for section groups and deadstrip<br>
><br>
> This adds a test that deadstrip should preserve the section group even if there<br>
> is only one reference to a function in the group.<br>
><br>
> Added:<br>
>     lld/trunk/test/core/sectiongroup-deadstrip.objtxt<br>
><br>
> Added: lld/trunk/test/core/sectiongroup-deadstrip.objtxt<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/sectiongroup-deadstrip.objtxt?rev=227711&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/core/sectiongroup-deadstrip.objtxt?rev=227711&view=auto</a><br>
> ==============================================================================<br>
> --- lld/trunk/test/core/sectiongroup-deadstrip.objtxt (added)<br>
> +++ lld/trunk/test/core/sectiongroup-deadstrip.objtxt Sat Jan 31 23:47:02 2015<br>
> @@ -0,0 +1,92 @@<br>
> +# Test for section group members be preserved even if there is a<br>
> +# reference to only one functions in the group.<br>
> +# RUN: lld -core --dead-strip %s | FileCheck %s<br>
> +<br>
> +#<br>
> +# Test that section groups are parsed properly when there is a reference to a<br>
> +# group atom from outside a group.<br>
> +#<br>
> +<br>
> +---<br>
> +defined-atoms:<br>
> +  - name:         entry<br>
> +    dead-strip:   never<br>
> +    references:<br>
> +    - offset:          1<br>
> +      kind:            pcrel32<br>
> +      target:          d1<br>
> +  - name:            f1<br>
> +    scope:           global<br>
> +    type:            code<br>
> +  - name:            f2<br>
> +    scope:           global<br>
> +    type:            code<br>
> +  - name:            g1<br>
> +    scope:           global<br>
> +    type:            code<br>
> +  - name:            d1<br>
> +    scope:           global<br>
> +    type:            data<br>
> +  - name:            g1<br>
> +    scope:           global<br>
> +    type:            group-comdat<br>
> +    references:<br>
> +      - kind:            group-child<br>
> +        target:          f1<br>
> +      - kind:            group-child<br>
> +        target:          f2<br>
> +      - kind:            group-child<br>
> +        target:          d1<br>
> +      - kind:            group-child<br>
> +        target:          g1<br>
> +  - name:            anotherfunction<br>
> +    scope:           global<br>
> +    type:            data<br>
> +    references:<br>
> +      - kind:            layout-before<br>
> +        target:          f1<br>
> +---<br>
> +undefined-atoms:<br>
> +    - name:              f1<br>
> +      can-be-null:       never<br>
> +...<br>
> +<br>
> +#CHECK: defined-atoms:<br>
> +#CHECK:   - name:            g1<br>
> +#CHECK:     ref-name:        [[PARENT:[a-zA-Z\.0-9_]+]]<br>
> +#CHECK:     scope:           global<br>
> +#CHECK:     type:            group-comdat<br>
> +#CHECK:     references:<br>
> +#CHECK:       - kind:            group-child<br>
> +#CHECK:         offset:          0<br>
> +#CHECK:         target:          [[GCHILDONE:[a-zA-Z\.0-9_]+]]<br>
> +#CHECK:       - kind:            group-child<br>
> +#CHECK:         offset:          0<br>
> +#CHECK:         target:          [[GCHILDTWO:[a-zA-Z\.0-9_]+]]<br>
> +#CHECK:       - kind:            group-child<br>
> +#CHECK:         offset:          0<br>
> +#CHECK:         target:          [[GCHILDTHREE:[a-zA-Z\.0-9_]+]]<br>
> +#CHECK:       - kind:            group-child<br>
> +#CHECK:         offset:          0<br>
> +#CHECK:         target:          [[GCHILDFOUR:[a-zA-Z\.0-9_]+]]<br>
> +#CHECK:   - name:            f1<br>
> +#CHECK:     ref-name:        [[GCHILDONE]]<br>
> +#CHECK:     scope:           global<br>
> +#CHECK:   - name:            f2<br>
> +#CHECK:     ref-name:        [[GCHILDTWO]]<br>
> +#CHECK:     scope:           global<br>
> +#CHECK:   - name:            d1<br>
> +#CHECK:     ref-name:        [[GCHILDTHREE]]<br>
> +#CHECK:     scope:           global<br>
> +#CHECK:     type:            data<br>
> +#CHECK:   - name:            g1<br>
> +#CHECK:     ref-name:        [[GCHILDFOUR]]<br>
> +#CHECK:     scope:           global<br>
> +#CHECK:   - name:            anotherfunction<br>
> +#CHECK:     scope:           global<br>
> +#CHECK:     type:            data<br>
> +#CHECK:     references:<br>
> +#CHECK:       - kind:            layout-before<br>
> +#CHECK:         offset:          0<br>
> +#CHECK:         target:          [[GCHILDONE]]<br>
> +#CHECK: ...<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>