diff options
author | Ulrich Drepper <drepper@redhat.com> | 2005-06-12 16:29:51 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2005-06-12 16:29:51 +0000 |
commit | 74780cf659d1e5cd91e82b6e5314dcfc7bba033b (patch) | |
tree | d71a5f1c94a7b7ac1a117760f2f3bd45ab1eea1d /elf/rtld.c | |
parent | 6dffebd8b4ef0e3310ac97cade0d5dc33c49dadc (diff) | |
download | glibc-74780cf659d1e5cd91e82b6e5314dcfc7bba033b.tar.gz glibc-74780cf659d1e5cd91e82b6e5314dcfc7bba033b.tar.xz glibc-74780cf659d1e5cd91e82b6e5314dcfc7bba033b.zip |
* elf/dl-error.c (_dl_signal_error): Store information about use of
real malloc in the catch object. (_dl_catch_error): Forward information about malloc use to caller in new parameter. (_dl_out_of_memory): Make static. * elf/dl-deps.c: Adjust callers of _dl_catch_error. * elf/dl-libc.c: Likewise. * elf/dl-open.c: Likewise. * elf/rtld.c: Likewise. Add new --audit option. * sysdeps/generic/ldsodefs.h: Remove _dl_out_of_memory declaration. (rtld_global_ro._dl_signal_error): Add new parameter. * include/dlfcn.h (_dl_catch_error): Add new parameter. * dlfcn/dlfcn.c (_dlerror_run): Pass additional parameter to _dl_catch_error. Only free if the returned newly value says so.
Diffstat (limited to 'elf/rtld.c')
-rw-r--r-- | elf/rtld.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/elf/rtld.c b/elf/rtld.c index 615eb91fca..03096a38d8 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -61,6 +61,9 @@ static void print_missing_version (int errcode, const char *objname, /* Print the various times we collected. */ static void print_statistics (hp_timing_t *total_timep); +/* Add audit objects. */ +static void process_dl_audit (char *str); + /* This is a list of all the modes the dynamic loader can be in. */ enum mode { normal, list, verify, trace }; @@ -771,6 +774,7 @@ do_preload (char *fname, struct link_map *main_map, const char *where) const char *objname; const char *err_str = NULL; struct map_args args; + bool malloced; args.str = fname; args.loader = main_map; @@ -779,7 +783,7 @@ do_preload (char *fname, struct link_map *main_map, const char *where) unsigned int old_nloaded = GL(dl_ns)[LM_ID_BASE]._ns_nloaded; - (void) _dl_catch_error (&objname, &err_str, map_doit, &args); + (void) _dl_catch_error (&objname, &err_str, &malloced, map_doit, &args); if (__builtin_expect (err_str != NULL, 0)) { _dl_error_printf ("\ @@ -927,6 +931,14 @@ dl_main (const ElfW(Phdr) *phdr, _dl_argc -= 2; INTUSE(_dl_argv) += 2; } + else if (! strcmp (INTUSE(_dl_argv)[1], "--audit") && _dl_argc > 2) + { + process_dl_audit (INTUSE(_dl_argv)[2]); + + _dl_skip_args += 2; + _dl_argc -= 2; + INTUSE(_dl_argv) += 2; + } else break; @@ -983,12 +995,14 @@ of this helper program; chances are you did not intend to run this program.\n\ const char *objname; const char *err_str = NULL; struct map_args args; + bool malloced; args.str = rtld_progname; args.loader = NULL; args.is_preloaded = 0; args.mode = __RTLD_OPENEXEC; - (void) _dl_catch_error (&objname, &err_str, map_doit, &args); + (void) _dl_catch_error (&objname, &err_str, &malloced, map_doit, + &args); if (__builtin_expect (err_str != NULL, 0)) /* We don't free the returned string, the programs stops anyway. */ @@ -1398,14 +1412,17 @@ ld.so does not support TLS, but program uses it!\n"); const char *objname; const char *err_str = NULL; - (void) _dl_catch_error (&objname, &err_str, dlmopen_doit, &dlmargs); + bool malloced; + (void) _dl_catch_error (&objname, &err_str, &malloced, dlmopen_doit, + &dlmargs); if (__builtin_expect (err_str != NULL, 0)) { not_loaded: _dl_error_printf ("\ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", al->name, err_str); - free ((char *) err_str); + if (malloced) + free ((char *) err_str); } else { @@ -1414,7 +1431,8 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", largs.map = dlmargs.map; /* Check whether the interface version matches. */ - (void) _dl_catch_error (&objname, &err_str, lookup_doit, &largs); + (void) _dl_catch_error (&objname, &err_str, &malloced, + lookup_doit, &largs); unsigned int (*laversion) (unsigned int); unsigned int lav; @@ -1455,8 +1473,8 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", do { largs.name = cp; - (void) _dl_catch_error (&objname, &err_str, lookup_doit, - &largs); + (void) _dl_catch_error (&objname, &err_str, &malloced, + lookup_doit, &largs); /* Store the pointer. */ if (err_str == NULL && largs.result != NULL) |