This is similar to r322317, but for visibility. It is not as neat because we have to special case extern_weak.
The idea is the same as the previous change, make the transition to explicit dso_local easier for the frontends. With this they only have to add dso_local to symbols where we need some external information to decide if it is dso_local (like it being part of an ELF executable.