bfd: fix AIX after-allocation crashes on foreign and retargeted inputs
Fixes crashes in AIX linker emulations related to foreign inputs and retargeted outputs by adding necessary checks.
This series of patches addresses crashes occurring in AIX linker emulations when processing foreign inputs or when the output format is retargeted via a linker script. Previously, the bfd_xcoff_build_dynamic_sections function would crash due to dereferencing NULL magic sections (for foreign inputs) or accessing a generic hash table as if it were an XCOFF hash table (for retargeted outputs). The patches add checks for NULL magic sections and verify the output format before proceeding, ensuring stable linking and a new regression test validates these fixes.
- proposer
Submits a series of patches to fix AIX after-allocation crashes triggered by foreign inputs and retargeted outputs, including code changes and a new regression test.
“A linker script can retarget the output to a generic ELF format with a plain bfd_link_hash_table. Both paths previously crashed before the link could terminate.”
In Details
This cover letter introduces a set of fixes for the AIX linker's after-allocation phase, specifically targeting crashes that occur under two conditions: linking foreign (non-XCOFF) object files and retargeting the output format to a generic ELF via a linker script. For foreign inputs, the XCOFF-specific magic sections (linkage, TOC, descriptor) are not created, leading to NULL pointer dereferences. For retargeted ELF outputs, a generic bfd_link_hash_table is used instead of the expected xcoff_link_hash_table, causing out-of-bounds reads. The patches introduce guards for both scenarios, en…
- AIX
- Advanced Interactive eXecutive, a Unix operating system developed by IBM.
- linker emulation
- Specific configurations and logic within the linker tailored for a particular target architecture or operating system.
- foreign input
- An input object file that does not match the expected format or architecture of the target system.
- retargeted output
- An output file format that has been changed from the default or expected format, often specified by a linker script.
- XCOFF
- Extended Common Object File Format, a file format used on IBM AIX systems.
- magic sections
- Special sections within an object file format (like XCOFF) that hold metadata or control information required by the linker.
- link hash table
- A data structure used by the linker to store and quickly access symbol information.