[PATCH v2 3/5] ld: fix segfault on discarded input sections not fitting in memory regions
Jan Beulich
jbeulich@suse.com
Wed Oct 15 13:09:14 GMT 2025
On 14.10.2025 12:46, Matthieu Longo wrote:
> In the case of non-contiguous memory regions, if an input section did not
> fit in any of the designated memory regions, the linker marked it as
> discarded, and warn_non_contiguous_discards() would only issue warning on
> it, relying on later unresolved symbol errors to terminate the process
> before a crash occur. This approach was insufficient, and crashes did occur
> on AArch64.
>
> This patch renames warn_non_contiguous_discards () to a name that does not
> contain "discard" as it created some confusion with the /DISCARD/ output
> section. It also promotes the warnings to errors, and ensures that the
> link process terminates cleanly if any input section is not allocated to
> an output section.
Avoiding the crash is of course an improvement, so the change is okay-ish
by me. I don't like fatal error very much though, so I wonder whether we
couldn't do better. In any event ...
> It also updates an AArch32 test expectations to match the corrected
> behavior. Tests for the crash cases are added in a subsequent patch.
... the change will also want an Arm maintainer's approval.
Jan
More information about the Binutils
mailing list