Currently, when reporting unresolved symbols in shared libraries, if an undefined symbol is firstly seen in a regular object file that shadows the reference for the same symbol in a shared object. As a result, the error for the unresolved symbol in the shared library is not reported. If referencing sections in regular object files are discarded because of --gc-sections, no reports about such symbols are generated, and the linker finishes successfully, generating an output image that fails on the run.
The patch fixes the issue by keeping symbols, which should be checked, for each shared library separately.
Perhaps simply this to --no-allow-shlib-undefined