diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-08-10 13:40:22 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-08-10 16:54:57 +0200 |
commit | 2449ae7b2da24c9940962304a3e44bc80e389265 (patch) | |
tree | c2cfdcfc3a90731d2da26dda79984eda95e9079e /elf/dl-deps.c | |
parent | f87cc2bfba9b844da48a63441c6099342b1551c7 (diff) | |
download | glibc-2449ae7b2da24c9940962304a3e44bc80e389265.zip glibc-2449ae7b2da24c9940962304a3e44bc80e389265.tar.gz glibc-2449ae7b2da24c9940962304a3e44bc80e389265.tar.bz2 |
ld.so: Introduce struct dl_exception
This commit separates allocating and raising exceptions. This
simplifies catching and re-raising them because it is no longer
necessary to make a temporary, on-stack copy of the exception message.
Diffstat (limited to 'elf/dl-deps.c')
-rw-r--r-- | elf/dl-deps.c | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/elf/dl-deps.c b/elf/dl-deps.c index 1b8bac6..7c82d42 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -165,8 +165,7 @@ _dl_map_object_deps (struct link_map *map, const char *name; int errno_saved; int errno_reason; - const char *errstring; - const char *objname; + struct dl_exception exception; /* No loaded object so far. */ nlist = 0; @@ -200,7 +199,6 @@ _dl_map_object_deps (struct link_map *map, alloca means we cannot use recursive function calls. */ errno_saved = errno; errno_reason = 0; - errstring = NULL; errno = 0; name = NULL; for (runp = known; runp; ) @@ -250,17 +248,9 @@ _dl_map_object_deps (struct link_map *map, /* Store the tag in the argument structure. */ args.name = name; - bool malloced; - int err = _dl_catch_error (&objname, &errstring, &malloced, - openaux, &args); - if (__glibc_unlikely (errstring != NULL)) + int err = _dl_catch_exception (&exception, openaux, &args); + if (__glibc_unlikely (exception.errstring != NULL)) { - char *new_errstring = strdupa (errstring); - objname = strdupa (objname); - if (malloced) - free ((char *) errstring); - errstring = new_errstring; - if (err) errno_reason = err; else @@ -313,31 +303,18 @@ _dl_map_object_deps (struct link_map *map, /* We must be prepared that the addressed shared object is not available. For filter objects the dependency must be available. */ - bool malloced; - int err = _dl_catch_error (&objname, &errstring, &malloced, - openaux, &args); - - if (__glibc_unlikely (errstring != NULL)) + int err = _dl_catch_exception (&exception, openaux, &args); + if (__glibc_unlikely (exception.errstring != NULL)) { if (d->d_tag == DT_AUXILIARY) { /* We are not interested in the error message. */ - assert (errstring != NULL); - if (malloced) - free ((char *) errstring); - + _dl_exception_free (&exception); /* Simply ignore this error and continue the work. */ continue; } else { - - char *new_errstring = strdupa (errstring); - objname = strdupa (objname); - if (malloced) - free ((char *) errstring); - errstring = new_errstring; - if (err) errno_reason = err; else @@ -683,6 +660,6 @@ Filters not supported with LD_TRACE_PRELINKING")); _dl_scope_free (old_l_initfini); if (errno_reason) - _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname, - NULL, errstring); + _dl_signal_exception (errno_reason == -1 ? 0 : errno_reason, + &exception, NULL); } |