[PATCH] ld: Avoid moving desired relro end below relro section
Alan Modra
amodra@gmail.com
Sun Feb 16 04:38:06 GMT 2025
On Sun, Feb 16, 2025 at 06:19:07AM +0800, H.J. Lu wrote:
> --- a/ld/ldlang.c
> +++ b/ld/ldlang.c
> @@ -6605,10 +6605,16 @@ lang_size_relro_segment_1 (void)
> end = start = sec->vma;
> if (!IS_TBSS (sec))
> end += TO_ADDR (sec->size);
> - bump = desired_end - end;
> - /* We'd like to increase START by BUMP, but we must heed
> - alignment so the increase might be less than optimum. */
> - start += bump;
> + if (desired_end > end)
> + {
> + /* Avoid moving START backwards. */
> + bump = desired_end - end;
> + /* We'd like to increase START by BUMP, but we must heed
> + alignment so the increase might be less than optimum. */
> + start += bump;
> + }
> + else
> + start = end;
> start &= ~(((bfd_vma) 1 << sec->alignment_power) - 1);
> /* This is now the desired end for the previous section. */
> desired_end = start;
This doesn't make any sense at all. You're putting sections on top of
each other!
The assert failure can't be fixed by totally breaking this function.
Look instead at why sections now don't fit. Have they changed in size
since the time seg->relro_end and seg->base were set?
--
Alan Modra
More information about the Binutils
mailing list