[PATCH v4] ld: Issue an error if group nested too deeply

Maciej W. Rozycki macro@orcam.me.uk
Thu Aug 21 12:57:17 GMT 2025


On Fri, 15 Aug 2025, H.J. Lu wrote:

> If a linker script has a group nested too deeply by mistake, issue an
> error instead of hanging forever without outputting any error message.

 Is this so as to break a cycle?

> diff --git a/ld/ldlang.c b/ld/ldlang.c
> index fc7a7d2ced6..2e6d0108f98 100644
> --- a/ld/ldlang.c
> +++ b/ld/ldlang.c
> @@ -58,6 +58,9 @@
>  #define TO_ADDR(X) ((X) >> opb_shift)
>  #define TO_SIZE(X) ((X) << opb_shift)
>  
> +/* The maximum nested group depth.  */
> +#define MAX_NESTED_GROUP_DEPTH 100
> +

 If so, then can't we get away without introducing an arbitrary limit, 
which is against the GNU coding standards we're supposed to follow; cf. 
<https://www.gnu.org/prep/standards/standards.html#Semantics>?

  Maciej


More information about the Binutils mailing list