NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/58865: static and dynamic dl_iterate_phdr disagree on main object name



The following reply was made to PR lib/58865; it has been noted by GNATS.

From: Christos Zoulas <christos%zoulas.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: lib-bug-people%netbsd.org@localhost,
 gnats-admin%netbsd.org@localhost,
 netbsd-bugs%netbsd.org@localhost
Subject: Re: lib/58865: static and dynamic dl_iterate_phdr disagree on main
 object name
Date: Sat, 30 Nov 2024 13:32:17 -0500

 --Apple-Mail=_AFD46184-104A-4358-AB84-5875042323C1
 Content-Type: multipart/mixed;
 	boundary="Apple-Mail=_7E2AA65F-A7B7-4570-9B65-7FB4110A2775"
 
 
 --Apple-Mail=_7E2AA65F-A7B7-4570-9B65-7FB4110A2775
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=us-ascii
 
 FreeBSD does not process AT_SUN_EXECNAME at all. But I think you are =
 right, might as well use the full path for the name. The Dl_info will be =
 different as returned from dladdr(3), the linkmap entry as returned by =
 dlinfo(3), and the error messages from the linker itself. It will look =
 non-familiar to the user (why I typed ./foo and the error message is =
 /path/foo?), but I think it is better (since it provides an absolute =
 path) and should not break anything.
 
 christos
 
 
 
 --Apple-Mail=_7E2AA65F-A7B7-4570-9B65-7FB4110A2775
 Content-Disposition: attachment;
 	filename=objmain_name.diff
 Content-Type: application/octet-stream;
 	name=objmain_name.diff;
 	x-unix-mode=0664
 Content-Transfer-Encoding: 7bit
 
 ? align.cc
 ? elf_hash.c
 ? o
 ? symbol.c.debug
 Index: rtld.c
 ===================================================================
 RCS file: /cvsroot/src/libexec/ld.elf_so/rtld.c,v
 retrieving revision 1.217
 diff -u -p -u -r1.217 rtld.c
 --- rtld.c	19 Jan 2024 19:21:34 -0000	1.217
 +++ rtld.c	30 Nov 2024 18:23:08 -0000
 @@ -467,7 +467,7 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
  	bool            bind_now = 0;
  	const char     *ld_bind_now, *ld_preload, *ld_library_path;
  	const char    **argv;
 -	const char     *execname;
 +	const char     *execname, objmain_name;
  	long		argc;
  	const char **real___progname;
  	const Obj_Entry **real___mainprog_obj;
 @@ -656,11 +656,12 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
           * Load the main program, or process its program header if it is
           * already loaded.
           */
 +	objmain_name = execname ? execname :
 +	    (argv[0] ? argv[0] : "main program");
  	if (pAUX_execfd != NULL) {	/* Load the main program. */
  		int             fd = pAUX_execfd->a_v;
 -		const char *obj_name = argv[0] ? argv[0] : "main program";
  		dbg(("loading main program"));
 -		_rtld_objmain = _rtld_map_object(obj_name, fd, NULL);
 +		_rtld_objmain = _rtld_map_object(objmain_name, fd, NULL);
  		close(fd);
  		if (_rtld_objmain == NULL)
  			_rtld_die();
 @@ -679,8 +680,7 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
  		assert(pAUX_entry != NULL);
  		entry = (caddr_t) pAUX_entry->a_v;
  		_rtld_objmain = _rtld_digest_phdr(phdr, phnum, entry);
 -		_rtld_objmain->path = xstrdup(argv[0] ? argv[0] :
 -		    "main program");
 +		_rtld_objmain->path = xstrdup(objmain_name);
  		_rtld_objmain->pathlen = strlen(_rtld_objmain->path);
  	}
  
 
 --Apple-Mail=_7E2AA65F-A7B7-4570-9B65-7FB4110A2775
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii
 
 
 
 
 
 --Apple-Mail=_7E2AA65F-A7B7-4570-9B65-7FB4110A2775--
 
 --Apple-Mail=_AFD46184-104A-4358-AB84-5875042323C1
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP
 
 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - http://gpgtools.org
 
 iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCZ0taMQAKCRBxESqxbLM7
 OqFvAJ9LWss/4WJivSQsMjOdEHjonE1bKgCdGpMUkZFtN6YE9AuyvCHMqTFUxQ0=
 =cpgu
 -----END PGP SIGNATURE-----
 
 --Apple-Mail=_AFD46184-104A-4358-AB84-5875042323C1--
 


Home | Main Index | Thread Index | Old Index