[PATCH] objcopy: Disallow interleave width > size of section

Jan Beulich jbeulich@suse.com
Mon Jun 23 07:04:59 GMT 2025


On 21.06.2025 00:55, H.J. Lu wrote:
> PR binutils/33049
> * objcopy.c (copy_section): Disallow interleave width > size of
> section.

I can't help the impression that this covers only a special case, and
then in a way going against the intentions.

Taking

	  size = (size + interleave - 1 - copy_byte) / interleave * copy_width;

and assuming the "worst" case copy_byte == 0, for interleave == copy_width
size is going to increase as long as interleave > 1. Aiui any increase of
size would trigger the observed ASAN behavior. So perhaps size simply needs
capping at its original value?

As to "against the intentions", the

		if (&from[i] >= end)
		  break;

in the copying loop appears to suggest that corner cases of going beyond
the original section contents are intended to be dealt with.

Jan


More information about the Binutils mailing list