This fixes two related related issue. Firstly we were never generting
imports for weak functions (even with the import-functions policy
for undefined symbols). Adding a direct call to foo in the
weak-undefined-pic.s exposed a crash in the linker which this
change fixes.
Secondly we were failing to call handleWeakUndefines for the -pie
case which is PIC but doesn't set the undefined symbol policy to
import-functions. With this change -pie binaries will by default
call handleWeakUndefines which generates the undefined stub handlers
for any weakly undefined symbols.
Fixes: https://github.com/emscripten-core/emscripten/issues/13337