usr/src/cmd/sgs links against libraries outside the proto area
It's unfortunate but when building in usr/src/lib the build runs make in usr/src/cmd/sgs/librtld_db which also causes a "demo" program to be built. This demo program depends on librtld_db but gets built before it, causing it to link against the host version instead. It also depends on libl (lex) and liby (yacc) which don't get built until much later causing those to link against the host versions too. libdwarf is also missing a dependency on libelf which can cause it to link against the host version.