ldd: make try_trace more robust and portable