ld: Issue an error if group nested too deeply

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

	PR ld/33265
	* ldlang.c (MAX_NESTED_GROUP_DEPTH): New.
	(open_input_bfds): Add a pointer argument for the nested group
	count.  Increment the count before the while loop and decrement
	it after the loop.  Issue an error if the nested group count >=
	MAX_NESTED_GROUP_DEPTH when processing input statement.
	(lang_process): Update open_input_bfds calls.
	(cmdline_emit_object_only_section): Likewise.
	* testsuite/ld-scripts/libpr33265-1.a: New file.
	* testsuite/ld-scripts/libpr33265-2.a: Likewise.
	* testsuite/ld-scripts/libpr33265-3a.a: Likewise.
	* testsuite/ld-scripts/libpr33265-3b.a: Likewise.
	* testsuite/ld-scripts/libpr33265-3c.a: Likewise.
	* testsuite/ld-scripts/pr33265-1.d: Likewise.
	* testsuite/ld-scripts/pr33265-2.d: Likewise.
	* testsuite/ld-scripts/pr33265-3.d: Likewise.
	* testsuite/ld-scripts/script.exp: Run PR ld/33265 tests.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
10 files changed