git: f22d65998fe1 - main - libdwarf: standard DWARF 5 form names, DW_LANG_C17 and C23

From: Xin LI <delphij_at_FreeBSD.org>
Date: Sun, 08 Nov 2026 19:29:13 UTC
The branch main has been updated by delphij:

URL: https://cgit.FreeBSD.org/src/commit/?id=f22d65998fe15b6bed9c8c3a2eede25c706837e1

commit f22d65998fe15b6bed9c8c3a2eede25c706837e1
Author:     Xin LI <delphij@FreeBSD.org>
AuthorDate: 2026-11-02 01:41:07 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2026-11-08 19:28:45 +0000

    libdwarf: standard DWARF 5 form names, DW_LANG_C17 and C23
    
    7bb441c86678 added the fixed-size string and address index forms
    0x25 to 0x2c as DW_FORM_ref_strx1..4 and DW_FORM_ref_addrx1..4; the
    standard (DWARF 5, table 7.6) names them DW_FORM_strx1..4 and
    DW_FORM_addrx1..4, with no "ref".  Rename them, keep the old spellings
    as aliases since the header is installed, and update dwarf_dump.c's
    form names accordingly.  Add DW_LANG_C17 (0x2c) and DW_LANG_C23 (0x3e),
    which clang emits for -std=c17 and -std=c23 units.  ctfconv(1) needs
    all of these; it carried them in a private header until now.
    
    Reviewed by:    markj, emaste
    MFC after:      1 week
    Differential Revision: https://reviews.freebsd.org/D61154
---
 contrib/elftoolchain/libdwarf/dwarf.h      | 27 +++++++++++++++++--------
 contrib/elftoolchain/libdwarf/dwarf_dump.c | 32 +++++++++++++++---------------
 2 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/contrib/elftoolchain/libdwarf/dwarf.h b/contrib/elftoolchain/libdwarf/dwarf.h
index 99e934078e7d..b4ce942a6477 100644
--- a/contrib/elftoolchain/libdwarf/dwarf.h
+++ b/contrib/elftoolchain/libdwarf/dwarf.h
@@ -340,14 +340,23 @@
 #define DW_FORM_loclistx		0x22
 #define DW_FORM_rnglistx		0x23
 #define DW_FORM_ref_sup8		0x24
-#define DW_FORM_ref_strx1		0x25
-#define DW_FORM_ref_strx2		0x26
-#define DW_FORM_ref_strx3		0x27
-#define DW_FORM_ref_strx4		0x28
-#define DW_FORM_ref_addrx1		0x29
-#define DW_FORM_ref_addrx2		0x2a
-#define DW_FORM_ref_addrx3		0x2b
-#define DW_FORM_ref_addrx4		0x2c
+#define DW_FORM_strx1		0x25
+#define DW_FORM_strx2		0x26
+#define DW_FORM_strx3		0x27
+#define DW_FORM_strx4		0x28
+#define DW_FORM_addrx1		0x29
+#define DW_FORM_addrx2		0x2a
+#define DW_FORM_addrx3		0x2b
+#define DW_FORM_addrx4		0x2c
+/* Misspellings of the eight above, kept for source compatibility. */
+#define DW_FORM_ref_strx1		DW_FORM_strx1
+#define DW_FORM_ref_strx2		DW_FORM_strx2
+#define DW_FORM_ref_strx3		DW_FORM_strx3
+#define DW_FORM_ref_strx4		DW_FORM_strx4
+#define DW_FORM_ref_addrx1		DW_FORM_addrx1
+#define DW_FORM_ref_addrx2		DW_FORM_addrx2
+#define DW_FORM_ref_addrx3		DW_FORM_addrx3
+#define DW_FORM_ref_addrx4		DW_FORM_addrx4
 #define	DW_FORM_GNU_ref_alt		0x1f20
 #define	DW_FORM_GNU_strp_alt		0x1f21
 
@@ -609,6 +618,8 @@
 #define DW_LANG_Fortran08		0x0023
 #define DW_LANG_RenderScript		0x0024
 #define DW_LANG_BLISS			0x0025
+#define DW_LANG_C17			0x002c
+#define DW_LANG_C23			0x003e
 #define DW_LANG_lo_user		 	0x8000
 #define DW_LANG_Mips_Assembler		0x8001
 #define DW_LANG_hi_user		 	0xffff
diff --git a/contrib/elftoolchain/libdwarf/dwarf_dump.c b/contrib/elftoolchain/libdwarf/dwarf_dump.c
index e847d8e443f2..381c373e05c0 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_dump.c
+++ b/contrib/elftoolchain/libdwarf/dwarf_dump.c
@@ -670,22 +670,22 @@ dwarf_get_FORM_name(unsigned form, const char **s)
 		*s = "DW_FORM_rnglistx"; break;
 	case DW_FORM_ref_sup8:
 		*s = "DW_FORM_ref_sup8"; break;
-	case DW_FORM_ref_strx1:
-		*s = "DW_FORM_ref_strx1"; break;
-	case DW_FORM_ref_strx2:
-		*s = "DW_FORM_ref_strx2"; break;
-	case DW_FORM_ref_strx3:
-		*s = "DW_FORM_ref_strx3"; break;
-	case DW_FORM_ref_strx4:
-		*s = "DW_FORM_ref_strx4"; break;
-	case DW_FORM_ref_addrx1:
-		*s = "DW_FORM_ref_addrx1"; break;
-	case DW_FORM_ref_addrx2:
-		*s = "DW_FORM_ref_addrx2"; break;
-	case DW_FORM_ref_addrx3:
-		*s = "DW_FORM_ref_addrx3"; break;
-	case DW_FORM_ref_addrx4:
-		*s = "DW_FORM_ref_addrx4"; break;
+	case DW_FORM_strx1:
+		*s = "DW_FORM_strx1"; break;
+	case DW_FORM_strx2:
+		*s = "DW_FORM_strx2"; break;
+	case DW_FORM_strx3:
+		*s = "DW_FORM_strx3"; break;
+	case DW_FORM_strx4:
+		*s = "DW_FORM_strx4"; break;
+	case DW_FORM_addrx1:
+		*s = "DW_FORM_addrx1"; break;
+	case DW_FORM_addrx2:
+		*s = "DW_FORM_addrx2"; break;
+	case DW_FORM_addrx3:
+		*s = "DW_FORM_addrx3"; break;
+	case DW_FORM_addrx4:
+		*s = "DW_FORM_addrx4"; break;
 	default:
 		return (DW_DLV_NO_ENTRY);
 	}