diff options
author | nate <nate@FreeBSD.org> | 1995-09-27 23:13:33 +0000 |
---|---|---|
committer | nate <nate@FreeBSD.org> | 1995-09-27 23:13:33 +0000 |
commit | f12729acb8ecbd618c3c778035349a964e1586a6 (patch) | |
tree | 51c70b260239d4721e155b1bb40242faff292053 /lib/csu | |
parent | da12a17f8e9410107abb07fa8e8dc55cdfddc6da (diff) | |
download | FreeBSD-src-f12729acb8ecbd618c3c778035349a964e1586a6.zip FreeBSD-src-f12729acb8ecbd618c3c778035349a964e1586a6.tar.gz |
Fixup the "ld.so failed" message for the case when ld.so finds undefined
symbols.
An easy example to see this is to develop an X program which links
against Xt, but doesn't add -lX11 to the link line. It will link fine,
but cause run-time errors by ld.so because of missing symbols used by Xt
defined in X11. This patch makes the errors more readable.
Submitted by: jdp@polstra.com (John Polstra)
Diffstat (limited to 'lib/csu')
-rw-r--r-- | lib/csu/i386/crt0.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/csu/i386/crt0.c b/lib/csu/i386/crt0.c index 7959e66..e42e21f 100644 --- a/lib/csu/i386/crt0.c +++ b/lib/csu/i386/crt0.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: crt0.c,v 1.16 1995/02/24 07:51:13 phk Exp $ + * $Id: crt0.c,v 1.17 1995/06/27 09:53:27 dfr Exp $ */ @@ -117,9 +117,9 @@ char *__progname = empty; __syscall(SYS_mmap, (caddr_t)(addr), (size_t)(len), (int)(prot), (int)(flags), (int)(fd), (long)0L, (off_t)(off)) #endif -#define _FATAL(str) \ - write(2, str, sizeof(str) - 1), \ - _exit(1); +#define _PUTNMSG(str, len) write(2, (str), (len)) +#define _PUTMSG(str) _PUTNMSG((str), sizeof (str) - 1) +#define _FATAL(str) ( _PUTMSG(str), _exit(1) ) start() @@ -262,7 +262,18 @@ __do_dynamic_link () entry = (int (*)())(crt.crt_ba + sizeof hdr); ret = (*entry)(CRT_VERSION_BSD_3, &crt); if (ret == -1) { - _FATAL("ld.so failed\n"); + _PUTMSG("ld.so failed"); + if(_DYNAMIC.d_entry != NULL) { + char *msg = (_DYNAMIC.d_entry->dlerror)(); + if(msg != NULL) { + char *endp; + _PUTMSG(": "); + for(endp = msg; *endp != '\0'; ++endp) + ; /* Find the end */ + _PUTNMSG(msg, endp - msg); + } + } + _FATAL("\n"); } ld_entry = _DYNAMIC.d_entry; |