From owner-freebsd-bugs Wed Dec 9 10:50:02 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA13151 for freebsd-bugs-outgoing; Wed, 9 Dec 1998 10:50:02 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA13098 for ; Wed, 9 Dec 1998 10:49:59 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from Unknown UID 563@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id KAA11014; Wed, 9 Dec 1998 10:50:00 -0800 (PST) Received: from boco.fee.vutbr.cz (boco.fee.vutbr.cz [147.229.9.11]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA12949 for ; Wed, 9 Dec 1998 10:48:24 -0800 (PST) (envelope-from cejkar@dcse.fee.vutbr.cz) Received: from kazi.dcse.fee.vutbr.cz (kazi.dcse.fee.vutbr.cz [147.229.8.12]) by boco.fee.vutbr.cz (8.9.1/8.9.1) with ESMTP id TAA80834 for ; Wed, 9 Dec 1998 19:48:11 +0100 (CET) Received: (from cejkar@localhost) by kazi.dcse.fee.vutbr.cz (8.8.8/8.8.8) id TAA18006; Wed, 9 Dec 1998 19:48:06 +0100 (CET) Message-Id: <199812091848.TAA18006@kazi.dcse.fee.vutbr.cz> Date: Wed, 9 Dec 1998 19:48:06 +0100 (CET) From: cejkar@dcse.fee.vutbr.cz Reply-To: cejkar@dcse.fee.vutbr.cz To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/9035: Bad __progname content in ELF programs Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 9035 >Category: bin >Synopsis: Bad __progname content in ELF programs >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Dec 9 10:50:00 PST 1998 >Last-Modified: >Originator: Rudolf Cejka >Organization: FEE TU Brno, Czech Republic >Release: FreeBSD 3.0-CURRENT i386 >Environment: ELFoized current -current :-) [YY-MM-DD: 98-12-09] >Description: For aout programs, __progname variable contains only program name. For ELF programs, __progname variable contains program name with full path (i386 & alpha). ( There must be something wrong. If this difference is right you must fix at least manpage for err*()/warn*() or err*()/warn*() itself: ... In all cases, the last component of the program name, a colon character, and a space are output ... ... Which for ELF programs at this time doen't apply. ) >How-To-Repeat: Simple program test.c: #include extern char *__progname; int main(void) { printf("%s\n", __progname); return 0; } gives there results: # gcc -aout -o test test.c # ./././test test # gcc -elf -o test test.c # ./././test ./././test >Fix: Patch is taken from /usr/src/lib/csu/i386/crt0.c. It isn't tested so you must review my patch! patch /usr/src/lib/csu/i386-elf/crt1.c: (You need similar patch for /usr/src/lib/csu/alpha/crt1.c!) --- crt1.c Wed Sep 9 10:11:21 1998 +++ /tmp/crt1.c.new Wed Dec 9 19:43:17 1998 @@ -72,8 +72,13 @@ argc = * (int *) (argv - 1); env = argv + argc + 1; environ = env; - if(argc > 0) + if(argc > 0 && argv[0]) { + register char *s; __progname = argv[0]; + for (s = __progname; *s != '\0'; s++) + if (*s == '/') + __progname = s + 1; + } if(&_DYNAMIC != 0) atexit(rtld_cleanup); --=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-- Rudolf Cejka (cejkar@dcse.fee.vutbr.cz; http://www.fee.vutbr.cz/~cejkar) Technical University of Brno, Faculty of El. Engineering and Comp. Science Bozetechova 2, 612 66 Brno, Czech Republic >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message