This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] ELF: Discard a section if any of its linked-to section has been discarded


On Sat, Feb 8, 2020 at 10:14 AM Fangrui Song <i@maskray.me> wrote:
>
> On 2020-02-06, H.J. Lu wrote:
> >Add ldelf_before_place_orphans to call before lang_place_orphans to
> >discard a section if any of its linked-to sections has been discarded.
> >
> >       PR ld/25022
> >       * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add
> >       before_place_orphans_default.
> >       * emultempl/armcoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
> >       * emultempl/beos.em (ld_${EMULATION_NAME}_emulation): Likewise.
> >       * emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Likewise.
> >       * emultempl/linux.em (ld_${EMULATION_NAME}_emulation): Likewise.
> >       * emultempl/msp430.em (ld_${EMULATION_NAME}_emulation): Likewise.
> >       * emultempl/pe.em (ld_${EMULATION_NAME}_emulation): Likewise.
> >       * emultempl/pep.em (ld_${EMULATION_NAME}_emulation): Likewise.
> >       * emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
> >       * emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise.
> >       * emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Use
> >       ldelf_before_place_orphans.
> >       * ldelf.c (ldelf_before_place_orphans): New.
> >       * ldelf.h (ldelf_before_place_orphans): Likewise.
> >       * ldemul.c (ldemul_before_place_orphans): Likewise.
> >       (before_place_orphans_default): Likewise.
> >       * ldemul.h (ldemul_before_place_orphans): Likewise.
> >       (before_place_orphans_default): Likewise.
> >       (ld_emulation_xfer_struct): Add before_place_orphans.
> >       * ldlang.c (lang_process): Call ldemul_before_place_orphans
> >       before lang_place_orphans.
> >       * testsuite/ld-elf/pr25022.d: New file.
> >       * testsuite/ld-elf/pr25022.s: Likewise.
> >       * testsuite/ld-elf/pr25022.t: Likewise.
>
> Is the second rule listed on
> https://sourceware.org/ml/binutils/2020-02/msg00035.html respected?
>
> > For a non-SHF_ALLOC section, it is a GC root only if all the following
> > conditions are satisfied:
> > ...
> > * it is not in a section group with at least one SHF_ALLOC section.
> >   If it belongs to such a section group, we expect a
> >     SHF_ALLOC section in the section group responsible for making the
> >     whole group alive. This semantic is at least expected by
>
> If A (with SHF_LINK_ORDER) is in a section group with no SHF_ALLOC
> section, we should not garbage collect A.

Testcase please.

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]