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-open.c | |
parent | f87cc2bfba9b844da48a63441c6099342b1551c7 (diff) | |
download | glibc-2449ae7b2da24c9940962304a3e44bc80e389265.tar.gz glibc-2449ae7b2da24c9940962304a3e44bc80e389265.tar.xz glibc-2449ae7b2da24c9940962304a3e44bc80e389265.zip |
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-open.c')
-rw-r--r-- | elf/dl-open.c | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c index cec54db413..91a1d1a4f8 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -643,11 +643,8 @@ no more namespaces available for dlmopen()")); args.argv = argv; args.env = env; - const char *objname; - const char *errstring; - bool malloced; - int errcode = _dl_catch_error (&objname, &errstring, &malloced, - dl_open_worker, &args); + struct dl_exception exception; + int errcode = _dl_catch_exception (&exception, dl_open_worker, &args); #if defined USE_LDCONFIG && !defined MAP_COPY /* We must unmap the cache file. */ @@ -655,7 +652,7 @@ no more namespaces available for dlmopen()")); #endif /* See if an error occurred during loading. */ - if (__glibc_unlikely (errstring != NULL)) + if (__glibc_unlikely (exception.errstring != NULL)) { /* Remove the object from memory. It may be in an inconsistent state if relocation failed, for example. */ @@ -679,28 +676,8 @@ no more namespaces available for dlmopen()")); /* Release the lock. */ __rtld_lock_unlock_recursive (GL(dl_load_lock)); - /* Make a local copy of the error string so that we can release the - memory allocated for it. */ - size_t len_errstring = strlen (errstring) + 1; - char *local_errstring; - if (objname == errstring + len_errstring) - { - size_t total_len = len_errstring + strlen (objname) + 1; - local_errstring = alloca (total_len); - memcpy (local_errstring, errstring, total_len); - objname = local_errstring + len_errstring; - } - else - { - local_errstring = alloca (len_errstring); - memcpy (local_errstring, errstring, len_errstring); - } - - if (malloced) - free ((char *) errstring); - /* Reraise the error. */ - _dl_signal_error (errcode, objname, NULL, local_errstring); + _dl_signal_exception (errcode, &exception, NULL); } assert (_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT); |