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-lookup.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-lookup.c')
-rw-r--r-- | elf/dl-lookup.c | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index 3d2369dbf2..645dc3ebb4 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -47,23 +47,6 @@ struct sym_val }; -#define make_string(string, rest...) \ - ({ \ - const char *all[] = { string, ## rest }; \ - size_t len, cnt; \ - char *result, *cp; \ - \ - len = 1; \ - for (cnt = 0; cnt < sizeof (all) / sizeof (all[0]); ++cnt) \ - len += strlen (all[cnt]); \ - \ - cp = result = alloca (len); \ - for (cnt = 0; cnt < sizeof (all) / sizeof (all[0]); ++cnt) \ - cp = __stpcpy (cp, all[cnt]); \ - \ - result; \ - }) - /* Statistics function. */ #ifdef SHARED # define bump_num_relocations() ++GL(dl_num_relocations) @@ -843,17 +826,16 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, for unversioned lookups. */ assert (version != NULL); const char *reference_name = undef_map ? undef_map->l_name : ""; - + struct dl_exception exception; /* XXX We cannot translate the message. */ - _dl_signal_cerror (0, DSO_FILENAME (reference_name), - N_("relocation error"), - make_string ("symbol ", undef_name, ", version ", - version->name, - " not defined in file ", - version->filename, - " with link time reference", - res == -2 - ? " (no version symbols)" : "")); + _dl_exception_create_format + (&exception, DSO_FILENAME (reference_name), + "symbol %s version %s not defined in file %s" + " with link time reference%s", + undef_name, version->name, version->filename, + res == -2 ? " (no version symbols)" : ""); + _dl_signal_cexception (0, &exception, N_("relocation error")); + _dl_exception_free (&exception); *ref = NULL; return 0; } @@ -869,12 +851,14 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map, const char *versionstr = version ? ", version " : ""; const char *versionname = (version && version->name ? version->name : ""); - + struct dl_exception exception; /* XXX We cannot translate the message. */ - _dl_signal_cerror (0, DSO_FILENAME (reference_name), - N_("symbol lookup error"), - make_string ("undefined symbol: ", undef_name, - versionstr, versionname)); + _dl_exception_create_format + (&exception, DSO_FILENAME (reference_name), + "undefined symbol: %s%s%s", + undef_name, versionstr, versionname); + _dl_signal_cexception (0, &exception, N_("symbol lookup error")); + _dl_exception_free (&exception); } *ref = NULL; return 0; |