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

Bug#489347: libc6: dladdr() should use better source than argv[0] for functions in main binary



Package: libc6
Version: 2.7-12
Severity: wishlist

The source above will display argv[0], while one could expect the full
path for the executable to be shown. It is particularly annoying when
the program is run from $PATH, since argv[0] doesn't contain any path,
then.

I guess the information is available somewhere, at least, since
/proc/self/maps shows the full executable path.

/proc/self/exe also points to the executable, but iirc, there are cases
where it is not reliable.

Mike

#include <stdio.h>
#define _GNU_SOURCE
#include <dlfcn.h>

int main(int argc, char *argv[]) {
	Dl_info dli;
	dladdr(main, &dli)
	printf("%s\n", dli.dli_fname);
	return 0;
}


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.25-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libc6 depends on:
ii  libgcc1                       1:4.3.1-3  GCC support library

libc6 recommends no packages.

-- debconf information excluded



Reply to: