removal of the LD_TRACE_PRELINKING, and LD_USE_LOAD_BIAS, environment
variables and their functionality in the dynamic loader.
+* The LD_TRACE_PRELINKING environment variable has been removed. Similar
+ functionality to obtain the program mapping address can be achieved by
+ using LD_TRACE_LOADED_OBJECTS to value of 2.
+
Changes to build and runtime requirements:
* The audit module interface version LAV_CURRENT is increased to enable
enum rtld_mode mode;
+ /* True if program should be also printed for rtld_mode_trace. */
+ bool mode_trace_program;
+
/* True if any of the debugging options is enabled. */
bool any_debug;
_dl_printf ("\tstatically linked\n");
else
{
- for (l = main_map->l_next; l; l = l->l_next)
+ for (l = state.mode_trace_program ? main_map : main_map->l_next;
+ l; l = l->l_next) {
if (l->l_faked)
/* The library was not found. */
- _dl_printf ("\t%s => not found\n", l->l_libname->name);
- else if (strcmp (l->l_libname->name, l->l_name) == 0)
- _dl_printf ("\t%s (0x%0*Zx)\n", l->l_libname->name,
- (int) sizeof l->l_map_start * 2,
- (size_t) l->l_map_start);
+ _dl_printf ("\t%s => not found\n", l->l_libname->name);
else
- _dl_printf ("\t%s => %s (0x%0*Zx)\n", l->l_libname->name,
- l->l_name, (int) sizeof l->l_map_start * 2,
+ _dl_printf ("\t%s => %s (0x%0*Zx)\n",
+ DSO_FILENAME (l->l_libname->name),
+ DSO_FILENAME (l->l_name),
+ (int) sizeof l->l_map_start * 2,
(size_t) l->l_map_start);
+ }
}
if (__glibc_unlikely (state.mode != rtld_mode_trace))
case 20:
/* The mode of the dynamic linker can be set. */
if (memcmp (envline, "TRACE_LOADED_OBJECTS", 20) == 0)
- state->mode = rtld_mode_trace;
+ {
+ state->mode = rtld_mode_trace;
+ state->mode_trace_program
+ = _dl_strtoul (&envline[21], NULL) > 1;
+ }
break;
/* We might have some extra environment variable to handle. This
} else {
$prog = "./$binary";
}
- # Set the environment variable LD_TRACE_PRELINKING to an empty string so
- # that we trigger tracing but do not match with the executable or any of
- # its dependencies.
- if (open (LOCS, "env LD_TRACE_PRELINKING= $prog |")) {
- while (<LOCS>) {
+ # Set the environment variable LD_TRACE_LOADED_OBJECTS to 2 so the
+ # executable is also printed.
+ if (open (locs, "env LD_TRACE_LOADED_OBJECTS=2 $prog |")) {
+ while (<locs>) {
chop;
- if (/^.*=> (.*) \((0x[0123456789abcdef]*), (0x[0123456789abcdef]*).*/) {
+ if (/^.*=> (.*) .(0x[0123456789abcdef]*).$/) {
$locs{$1} = $2;
- $rel{$1} = hex($2) - hex($3);
+ $rel{$1} = hex($2);
}
}
close (LOCS);
die "Wrong number of arguments, run $progname --help for help.";
}
+sub addr2line {
+ my $addr = pop(@_);
+ my $prog = pop(@_);
+ if (open (ADDR, "addr2line -e $prog $addr|")) {
+ my $line = <ADDR>;
+ chomp $line;
+ close (ADDR);
+ if ($line ne '??:0') {
+ return $line
+ }
+ }
+}
sub location {
my $str = pop(@_);
return $str if ($str eq "");
my $addr = $1;
my $fct = $2;
return $cache{$addr} if (exists $cache{$addr});
- if ($binary ne "" && open (ADDR, "addr2line -e $binary $addr|")) {
- my $line = <ADDR>;
- chomp $line;
- close (ADDR);
- if ($line ne '??:0') {
+ if ($binary ne "") {
+ my $line = &addr2line($binary, $addr);
+ if ($line) {
$cache{$addr} = $line;
return $cache{$addr};
}
my $searchaddr;
return $cache{$addr} if (exists $cache{$addr});
$searchaddr = sprintf "%#x", hex($addr) + $rel{$prog};
- if ($binary ne "" && open (ADDR, "addr2line -e $prog $searchaddr|")) {
- my $line = <ADDR>;
- chomp $line;
- close (ADDR);
- if ($line ne '??:0') {
- $cache{$addr} = $line;
- return $cache{$addr};
+ if ($binary ne "") {
+ for my $address ($searchaddr, $addr) {
+ my $line = &addr2line($prog, $address);
+ if ($line) {
+ $cache{$addr} = $line;
+ return $cache{$addr};
+ }
}
}
$cache{$addr} = $str = $addr;
} elsif ($str =~ /^.*[[](0x[^]]*)]$/) {
my $addr = $1;
return $cache{$addr} if (exists $cache{$addr});
- if ($binary ne "" && open (ADDR, "addr2line -e $binary $addr|")) {
- my $line = <ADDR>;
- chomp $line;
- close (ADDR);
- if ($line ne '??:0') {
+ if ($binary ne "") {
+ my $line = &addr2line($binary, $addr);
+ if ($line) {
$cache{$addr} = $line;
return $cache{$addr};
}