[PATCH] ld: Don't define section symbols for excluded sections
H.J. Lu
hjl.tools@gmail.com
Thu Jul 30 10:54:46 GMT 2026
On Thu, Jul 30, 2026 at 6:34 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Thu, Jul 30, 2026 at 03:17:45PM +0800, H.J. Lu wrote:
> > When the SEC_EXCLUDE bit is set on a section, the contents of the section
> > are excluded by the linker for non-relocatable output. Define __start,
> > __stop, .startof. and .sizeof. symbols for relocatable link or if the
> > SEC_EXCLUDE bit on the section is cleared.
>
> Looks good to me. You might like to mention the ELF SHF_EXCLUDE flag
> in the description too, since it was that flag being set that
> triggered the segfault in bug_4.o from the pr. bug_4.o didn't even
> need --gc-sections to fail.
I am checking it in with the updated commit message:
When the SEC_EXCLUDE bit is set on a section, for example, sections with
the SHF_EXCLUDE flag bit set in ELF input, the contents of the section
are excluded by the linker for non-relocatable output. Define __start,
__stop, .startof. and .sizeof. symbols for relocatable link or if the
SEC_EXCLUDE bit on the section is cleared.
> > PR ld/34448
> > * ldlang.c (lang_init_start_stop): Call lang_define_start_stop
> > for relocatable link or if the SEC_EXCLUDE bit on the section
> > is cleared.
> >
>
--
H.J.
More information about the Binutils
mailing list