The currenr ELF visibility handling is wrong on several things: 1. Ld doesn't report an error for undefined symbols with non-default visibility when there is a definition from a shared library. 2. Weak undefined symbols with non-default visibility results in undetermined run-time behavior depending on if there is a definition at run-time. 3. Ld gives no warnings when a shared library refeneces a hidden symbol. 4. ld merges visibility with symbols from shared libraries. This patch fixes those problems with testcases. As for weak undefined symbols with non-default visibility, I only fixed x86 and ia64. H.J.