summaryrefslogtreecommitdiff
path: root/usr.bin/ctfconv
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-02-21 13:16:15 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-02-21 13:16:15 +0000
commit628a616686f030b16b8df38c1c85bcc6ec6f0e27 (patch)
tree70b6fd321e8ff777318c72f7dbdf7fdb98583699 /usr.bin/ctfconv
parent1b421910ba04ac9bbfe960c033564da58d37ec86 (diff)
Make sure dw_at2name() never returns NULL. This call is used in various
printf calls that clang decided to optimise into puts calls that crash with a NULL argument. Also add DW_AT_noreturn which caused this when running ./ctfconv -d ./ctfconv OK mpi@
Diffstat (limited to 'usr.bin/ctfconv')
-rw-r--r--usr.bin/ctfconv/dw.c7
-rw-r--r--usr.bin/ctfconv/dwarf.h4
2 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/ctfconv/dw.c b/usr.bin/ctfconv/dw.c
index e1ee7bf11f0..9ebe9d95004 100644
--- a/usr.bin/ctfconv/dw.c
+++ b/usr.bin/ctfconv/dw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dw.c,v 1.5 2021/10/25 19:54:29 kn Exp $ */
+/* $OpenBSD: dw.c,v 1.6 2024/02/21 13:16:14 claudio Exp $ */
/*
* Copyright (c) 2016 Martin Pieuchot
@@ -21,6 +21,7 @@
#include <errno.h>
#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -184,6 +185,7 @@ const char *
dw_at2name(uint64_t at)
{
static const char *dw_attrs[] = { DW_AT_NAMES };
+ static char buf[64];
if (at <= nitems(dw_attrs))
return dw_attrs[at - 1];
@@ -193,7 +195,8 @@ dw_at2name(uint64_t at)
if (at == DW_AT_hi_user)
return "DW_AT_hi_user";
- return NULL;
+ snprintf(buf, sizeof(buf), "#%llu", at);
+ return buf;
}
const char *
diff --git a/usr.bin/ctfconv/dwarf.h b/usr.bin/ctfconv/dwarf.h
index 7da94aaebfa..ecb78873161 100644
--- a/usr.bin/ctfconv/dwarf.h
+++ b/usr.bin/ctfconv/dwarf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dwarf.h,v 1.2 2017/08/11 14:58:56 jasper Exp $ */
+/* $OpenBSD: dwarf.h,v 1.3 2024/02/21 13:16:14 claudio Exp $ */
/*
* Copyright (c) 2016 Martin Pieuchot <mpi@openbsd.org>
@@ -273,6 +273,7 @@
#define DW_AT_const_expr 0x6c
#define DW_AT_enum_class 0x6d
#define DW_AT_linkage_name 0x6e
+#define DW_AT_noreturn 0x87
#define DW_AT_lo_user 0x2000
#define DW_AT_hi_user 0x3fff
@@ -413,6 +414,7 @@
"DW_AT_const_expr", \
"DW_AT_enum_class", \
"DW_AT_linkage_name", \
+ [0x87 - 1] = "DW_AT_noreturn", \
#define DW_FORM_addr 0x01
#define DW_FORM_block2 0x03