How to check not assigned input sections?

First of all, the linker warning -Wl,--orphan-handling=warn must be set.

To check for unassigned input sections, the following ASSERT statement can be put at the end of a linker script to test the size of sections.

Example code snippet

illegal_section :
	{
		*(*)
	}
	_. = ASSERT (SIZEOF(illegal_section) == 0 , "there are unallocated input sections");

The linker will generate an error message if this ASSERT condition fails, leaving you to analyze the reported sections in the generated map file.