[lld][WinLink] Fix use-after-return and add unit tests.