aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/tools
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2018-06-09 15:10:49 +0000
committerMark Johnston <markj@FreeBSD.org>2018-06-09 15:10:49 +0000
commitc5fda9bac0325eb8c5b447717862d279006f318f (patch)
tree7eb63e1e9bb21fdd76bcefabb933103677897380 /cddl/contrib/opensolaris/tools
parent593e2c6ecec705b9fe0f6dcc366b5c1def7a1a7a (diff)
downloadsrc-c5fda9bac0325eb8c5b447717862d279006f318f.tar.gz
src-c5fda9bac0325eb8c5b447717862d279006f318f.zip
Don't process DWARF generated from non-C/C++ code.
ctfconvert(1) is not designed to handle DWARF generated from such code, and will generally fail in non-obvious ways. Use an explicit check to help catch such potential failures. Reported by: Johannes Lundberg <johalun0@gmail.com> MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=334883
Diffstat (limited to 'cddl/contrib/opensolaris/tools')
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
index d97d00e68c29..16000eddaaa9 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
@@ -1901,7 +1901,7 @@ should_have_dwarf(Elf *elf)
int
dw_read(tdata_t *td, Elf *elf, char *filename __unused)
{
- Dwarf_Unsigned abboff, hdrlen, nxthdr;
+ Dwarf_Unsigned abboff, hdrlen, lang, nxthdr;
Dwarf_Half vers, addrsz, offsz;
Dwarf_Die cu = 0;
Dwarf_Die child = 0;
@@ -1941,8 +1941,8 @@ dw_read(tdata_t *td, Elf *elf, char *filename __unused)
}
if ((rc = dwarf_next_cu_header_b(dw.dw_dw, &hdrlen, &vers, &abboff,
- &addrsz, &offsz, NULL, &nxthdr, &dw.dw_err)) != DW_DLV_OK) {
- if (dw.dw_err.err_error == DW_DLE_NO_ENTRY)
+ &addrsz, &offsz, NULL, &nxthdr, &dw.dw_err)) != DW_DLV_OK) {
+ if (dw.dw_err.err_error == DW_DLE_NO_ENTRY)
exit(0);
else
terminate("rc = %d %s\n", rc, dwarf_errmsg(dw.dw_err));
@@ -1972,6 +1972,25 @@ dw_read(tdata_t *td, Elf *elf, char *filename __unused)
free(prod);
}
+ if (dwarf_attrval_unsigned(cu, DW_AT_language, &lang, &dw.dw_err) == 0)
+ switch (lang) {
+ case DW_LANG_C:
+ case DW_LANG_C89:
+ case DW_LANG_C99:
+ case DW_LANG_C11:
+ case DW_LANG_C_plus_plus:
+ case DW_LANG_C_plus_plus_03:
+ case DW_LANG_C_plus_plus_11:
+ case DW_LANG_C_plus_plus_14:
+ break;
+ default:
+ terminate("file contains DWARF for unsupported "
+ "language %d", lang);
+ }
+ else
+ warning("die %llu: failed to get language attribute: %s\n",
+ die_off(&dw, cu), dwarf_errmsg(dw.dw_err));
+
if ((dw.dw_cuname = die_name(&dw, cu)) != NULL) {
char *base = xstrdup(basename(dw.dw_cuname));
free(dw.dw_cuname);