[PATCH] objcopy: check input flavor before setting PE/COFF section alignment

Jan Beulich jbeulich@suse.com
Mon Apr 22 07:15:28 GMT 2024


On 19.04.2024 12:37, Nick Clifton wrote:
>> coff_section_data() and elf_section_data() use the same underlying
>> field. The pointer being non-NULL therefore isn't sufficient to know
>> that pei_section_data() can validly be used on the incoming object.
>> Apparently in 64-bit-host builds the resulting memory corruption is
>> benign, whereas in 32-bit-host builds a segmentation fault occurs upon
>> de-referencing pei_section_data()'s return value.
>> ---
>> Of course the value (first) being set on the input bfd is suspicious
>> in the first place: When copying e.g. ELF to PE/COFF, the option ought
>> to be similarly respected, yet clearly it can't be set like this then on
>> the incoming object. The change here is merely to address the testsuite
>> failures observed for Arm64 and RISC-V ("Check if efi app format is
>> recognized") as well as the (latent) memory corruption.
> 
> Thanks for fixing my oversight!

Well, before putting it in - any thoughts on the post-commit-message remark
above? Is it really meant to stay the way of the input bfd's data is being
altered, rather than keeping that intact and fiddling only with the output?
And thus - afaict - rendering the command line option (silently) useless
when copying ELF to PE?

Jan


More information about the Binutils mailing list