ld: Don't ignore bfd_gc_sections failure
Report bfd_gc_sections failures as fatal errors instead of warnings to prevent potential issues in the linker.
This patch modifies the linker (ld) to treat failures in bfd_gc_sections as fatal errors. Previously, these failures were sometimes treated as warnings. The change ensures that the fatal function is called with correct arguments to prevent the failure from being misinterpreted. This addresses an issue where linker warnings might mask critical errors, potentially leading to incorrect output.
- proposer
Proposes to issue a fatal error when bfd_gc_sections fails instead of treating it as a warning.
“If bfd_gc_sections fails, issue a fatal error and change fatal to pass false as the is_warning argument to vfinfo so that the fatal isn't treated as a warning by vfinfo.”
- reviewer
Agrees with the change but suggests splitting it into two separate commits for better clarity.
“Okay, albeit I think the two would better have been separate changes.”
Technical Tradeoffs
- Ensures critical errors are not silently ignored.
- Slightly increases verbosity if `bfd_gc_sections` fails, but improves robustness.
In Details
This patch addresses an issue in binutils/ld where a failure in bfd_gc_sections might not be escalated to a fatal error. The change modifies how the fatal function is invoked to ensure such failures are treated with the appropriate severity, preventing them from being masked as warnings.
- bfd_gc_sections
- A function within the Binary File Descriptor (BFD) library used by the linker to garbage collect unused sections in an object file.
- ld
- The GNU linker, responsible for combining object files and libraries into an executable or shared library.
- vfinfo
- A function likely used for verbose informational output within the linker, which differentiates between fatal errors and warnings.