Hi Heinrich,

On 10/30/26 13:35, Heinrich Schuchardt wrote:
> We use  unsigned long virt_size. So wrapping around may not occur in the
> original code on 64bit systems. I think the comment should be tweaked a bit.

It does wrap on 64bit too: VirtualAddress and section_size() are both
u32, so the sum is computed in 32 bits before max_t() converts it to
unsigned long. But the comment should say so. In v2 it reads:

        /*
         * VirtualAddress and section_size() are both u32, so their sum
         * wraps around at 4 GiB, on 64bit systems too. A wrapped end
         * would make virt_size too small for the memset() and memcpy()
         * below.
         */

> The comment above says "Calculate upper virtual address boundary".
> The parameter name virt_size only makes sense for a variable holding
> (max(end[]) - BaseOfCode). We should probably fix that misnomer in a
> future patch.

Agreed. I left the name alone here to keep this patch to the fix.

Thanks,
Ana

Reply via email to