TUESDAY, JULY 7, 2026
binutils/objcopy
Fix objcopy crash when updating SHT_GROUP sections
objcopy no longer crashes when attempting to update SHT_GROUP sections.
objcopy previously crashed with a null-pointer dereference when the —update-section option was used on a SHT_GROUP section. This occurred because the output_section was NULL in such cases. This change modifies objcopy to correctly handle this scenario, preventing the crash and improving error reporting.
In Details
The bfd_get_section_by_name function can return a section that does not have a corresponding output section when dealing with SHT_GROUP sections. The objcopy utility's --update-section logic did not account for this, leading to a NULL pointer dereference when accessing pupdate->section->output_section. This commit adds a check for osec == NULL to prevent the crash.
For Context
- objcopy
- A utility that copies and translates object files. It can be used to modify sections, symbols, and other information within an object file.
- SHT_GROUP
- A section type in ELF object files that indicates a group of sections that should be treated as a single unit. This is often used for symbol tables or other metadata.
- BFD
- The Binary File Descriptor library, a low-level library used by GNU Binutils for reading and writing object file formats.
- output_section
- In the BFD library, this refers to the section in the output object file that corresponds to an input section.