diff options
author | emaste <emaste@FreeBSD.org> | 2016-05-20 17:24:34 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2016-05-20 17:24:34 +0000 |
commit | e1afa8a66332bcb42ea042ec5dfb59de5b33ee08 (patch) | |
tree | 53f16cf467b740bb55f778ee1a5c3b117e43c2e0 /contrib/elftoolchain/cxxfilt | |
parent | 1860a225caf7329b3bc2038750624b9d0b47139a (diff) | |
parent | db27a04d331bc804aa12a4a70e9e0d939f3773c0 (diff) | |
download | FreeBSD-src-e1afa8a66332bcb42ea042ec5dfb59de5b33ee08.zip FreeBSD-src-e1afa8a66332bcb42ea042ec5dfb59de5b33ee08.tar.gz |
Update to ELF Tool Chain r3475
Improvements include:
* Add support for reporting and handling a number of new constants in
various tools, including:
* CloudABI OSABI
* DT_TLSDESC_*
* i386, MIPS, SPARC and amd64 relocations
* C++ demangler bug fixes
* Man page updates
* Improved input validation in several tools
This update also reduces diffs against upstream as a number of fixes
included in upstream were previously cherry-picked into FreeBSD.
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'contrib/elftoolchain/cxxfilt')
-rw-r--r-- | contrib/elftoolchain/cxxfilt/cxxfilt.c | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/contrib/elftoolchain/cxxfilt/cxxfilt.c b/contrib/elftoolchain/cxxfilt/cxxfilt.c index 9318c64..c6d737a 100644 --- a/contrib/elftoolchain/cxxfilt/cxxfilt.c +++ b/contrib/elftoolchain/cxxfilt/cxxfilt.c @@ -35,7 +35,7 @@ #include "_elftc.h" -ELFTC_VCSID("$Id: cxxfilt.c 3356 2016-01-22 22:31:38Z jkoshy $"); +ELFTC_VCSID("$Id: cxxfilt.c 3454 2016-05-07 17:11:05Z kaiwang27 $"); #define STRBUFSZ 8192 @@ -112,35 +112,18 @@ find_format(const char *fstr) } static char * -demangle(char *name, int strict, size_t *pos) +demangle(char *name) { static char dem[STRBUFSZ]; - char nb[STRBUFSZ]; - size_t p, t; - if (stripus && *name == '_') { - strncpy(nb, name + 1, sizeof(nb) - 1); - t = 1; - } else { - strncpy(nb, name, sizeof(nb) - 1); - t = 0; - } - nb[sizeof(nb) - 1] = '\0'; - - p = strlen(nb); - if (p == 0) - return NULL; - - while (elftc_demangle(nb, dem, sizeof(dem), (unsigned) format) < 0) { - if (!strict && p > 1) { - nb[--p] = '\0'; - continue; - } else - return (NULL); - } + if (stripus && *name == '_') + name++; + + if (strlen(name) == 0) + return (NULL); - if (pos != NULL) - *pos = t ? p + 1 : p; + if (elftc_demangle(name, dem, sizeof(dem), (unsigned) format) < 0) + return (NULL); return (dem); } @@ -149,7 +132,7 @@ int main(int argc, char **argv) { char *dem, buf[STRBUFSZ]; - size_t i, p, s; + size_t p; int c, n, opt; while ((opt = getopt_long(argc, argv, "_nps:V", longopts, NULL)) != @@ -184,8 +167,8 @@ main(int argc, char **argv) if (*argv != NULL) { for (n = 0; n < argc; n++) { - if ((dem = demangle(argv[n], 1, NULL)) == NULL) - fprintf(stderr, "Failed: %s\n", argv[n]); + if ((dem = demangle(argv[n])) == NULL) + printf("%s\n", argv[n]); else printf("%s\n", dem); } @@ -193,23 +176,18 @@ main(int argc, char **argv) p = 0; for (;;) { c = fgetc(stdin); - if (c == EOF || !isprint(c) || strchr(" \t\n", c)) { + if (c == EOF || !(isalnum(c) || strchr(".$_", c))) { if (p > 0) { buf[p] = '\0'; - if ((dem = demangle(buf, 0, &s)) == - NULL) + if ((dem = demangle(buf)) == NULL) printf("%s", buf); - else { + else printf("%s", dem); - for (i = s; i < p; i++) - putchar(buf[i]); - } p = 0; } if (c == EOF) break; - if (isprint(c) || strchr(" \t\n", c)) - putchar(c); + putchar(c); } else { if ((size_t) p >= sizeof(buf) - 1) warnx("buffer overflowed"); |