Pick up the language codes published after DWARF5 was published.
The are listed at https://dwarfstd.org/languages.html
Also adjust C language dectection in dwarf_getfuncs and update the
dwarf_default_lower_bound function to return the default lower bounds
for the new langauge codes.
There is one small change in dwarf_default_lower_bound. We now return
zero instead of an error when called for DW_LANG_Mips_Assembler. Since
there is now an "official" DW_LANG_Assembly which is explicitly
defined as having a default lower bound of zero. It seems better to do
the same for the vendor code too.
* libdw/dwarf.h: Add new DW_LANG codes.
* libdw/dwarf_default_lower_bound.c (dwarf_default_lower_bound):
Handle new language codes and add a special case for
DW_LANG_Mips_Assembler.
* libdw/dwarf_getfuncs.c (dwarf_getfuncs): Check against
DW_LANG_C17 and DW_LANG_C23.
* tests/dwarf_default_lower_bound.c: Also check for
DW_LANG_Mips_Assembler.
Signed-off-by: Mark Wielaard <[email protected]>
---
libdw/dwarf.h | 36 ++++++++++++++++++++++++++++++-
libdw/dwarf_default_lower_bound.c | 34 +++++++++++++++++++++++++++++
libdw/dwarf_getfuncs.c | 5 ++++-
tests/dwarf_default_lower_bound.c | 13 +----------
4 files changed, 74 insertions(+), 14 deletions(-)
diff --git a/libdw/dwarf.h b/libdw/dwarf.h
index 4be32de5a67d..573ffd6925b2 100644
--- a/libdw/dwarf.h
+++ b/libdw/dwarf.h
@@ -1,5 +1,6 @@
/* This file defines standard DWARF types, structures, and macros.
Copyright (C) 2000-2011, 2014, 2016, 2017, 2018 Red Hat, Inc.
+ Copyright (C) 2024 Mark J. Wielaard <[email protected]>
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -697,7 +698,11 @@ enum
};
-/* DWARF language encodings. */
+/* DWARF language encodings.
+
+ See https://dwarfstd.org/languages.html for language code published
+ after DWARF5 was published (but before DWARF6 has been released,
+ which will introduce a new DW_AT_language_name/version scheme). */
enum
{
DW_LANG_C89 = 0x0001, /* ISO C:1989 */
@@ -738,6 +743,35 @@ enum
DW_LANG_RenderScript = 0x0024, /* RenderScript Kernal Language */
DW_LANG_BLISS = 0x0025, /* BLISS */
+ DW_LANG_Kotlin = 0x0026, /* Kotlin */
+ DW_LANG_Zig = 0x0027, /* Zig */
+ DW_LANG_Crystal = 0x0028, /* Crystal */
+ DW_LANG_C_plus_plus_17 = 0x002a, /* ISO C++:2017 */
+ DW_LANG_C_plus_plus_20 = 0x002b, /* ISO C++:2018 */
+ DW_LANG_C17 = 0x002c, /* ISO C:2017 */
+ DW_LANG_Fortran18 = 0x002d, /* ISO/IEC 1539-1:2018 */
+ DW_LANG_Ada2005 = 0x002e, /* ISO Ada:2005 */
+ DW_LANG_Ada2012 = 0x002f, /* ISO Ada:2005 */
+ DW_LANG_HIP = 0x0030, /* HIP */
+ DW_LANG_Assembly = 0x0031, /* Assembly */
+ DW_LANG_C_sharp = 0x0032, /* C# */
+ DW_LANG_Mojo = 0x0033, /* Mojo */
+ DW_LANG_GLSL = 0x0034, /* OpenGL Shading Language */
+ DW_LANG_GLSL_ES = 0x0035, /* OpenGL ES Shading Language */
+ DW_LANG_HLSL = 0x0036, /* High-Level Shading Language */
+ DW_LANG_OpenCL_CPP = 0x0037, /* OpenCL C++ */
+ DW_LANG_CPP_for_OpenCL = 0x0038, /* C++ for OpenCL */
+ DW_LANG_SYCL = 0x0039, /* SYCL */
+ DW_LANG_C_plus_plus_23 = 0x003a, /* ISO C++:2023 */
+ DW_LANG_Odin = 0x003b, /* Odin */
+ DW_LANG_P4 = 0x003c, /* P4 */
+ DW_LANG_Metal = 0x003d, /* Metal */
+ DW_LANG_C23 = 0x003e, /* ISO C:2023 */
+ DW_LANG_Fortran23 = 0x003f, /* ISO/IEC 1539-1:2023 */
+ DW_LANG_Ruby = 0x0040, /* Ruby */
+ DW_LANG_Move = 0x0041, /* Move */
+ DW_LANG_Hylo = 0x0042, /* Hylo */
+
DW_LANG_lo_user = 0x8000,
DW_LANG_Mips_Assembler = 0x8001, /* Assembler */
DW_LANG_hi_user = 0xffff
diff --git a/libdw/dwarf_default_lower_bound.c
b/libdw/dwarf_default_lower_bound.c
index a33a34335b1b..50639e32428e 100644
--- a/libdw/dwarf_default_lower_bound.c
+++ b/libdw/dwarf_default_lower_bound.c
@@ -1,5 +1,6 @@
/* Get the default subrange lower bound for a given language.
Copyright (C) 2016 Red Hat, Inc.
+ Copyright (C) 2024 Mark J. Wielaard <[email protected]>
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -63,6 +64,30 @@ dwarf_default_lower_bound (int lang, Dwarf_Sword *result)
case DW_LANG_Dylan:
case DW_LANG_RenderScript:
case DW_LANG_BLISS:
+ case DW_LANG_Kotlin:
+ case DW_LANG_Zig:
+ case DW_LANG_Crystal:
+ case DW_LANG_C_plus_plus_17:
+ case DW_LANG_C_plus_plus_20:
+ case DW_LANG_C17:
+ case DW_LANG_HIP:
+ case DW_LANG_Assembly:
+ case DW_LANG_C_sharp:
+ case DW_LANG_Mojo:
+ case DW_LANG_GLSL:
+ case DW_LANG_GLSL_ES:
+ case DW_LANG_HLSL:
+ case DW_LANG_OpenCL_CPP:
+ case DW_LANG_CPP_for_OpenCL:
+ case DW_LANG_SYCL:
+ case DW_LANG_C_plus_plus_23:
+ case DW_LANG_Odin:
+ case DW_LANG_P4:
+ case DW_LANG_Metal:
+ case DW_LANG_C23:
+ case DW_LANG_Ruby:
+ case DW_LANG_Move:
+ case DW_LANG_Hylo:
*result = 0;
return 0;
@@ -80,9 +105,18 @@ dwarf_default_lower_bound (int lang, Dwarf_Sword *result)
case DW_LANG_Modula3:
case DW_LANG_PLI:
case DW_LANG_Julia:
+ case DW_LANG_Fortran18:
+ case DW_LANG_Ada2005:
+ case DW_LANG_Ada2012:
+ case DW_LANG_Fortran23:
*result = 1;
return 0;
+ /* Special case vendor Assembly variant. */
+ case DW_LANG_Mips_Assembler:
+ *result = 0;
+ return 0;
+
default:
__libdw_seterrno (DWARF_E_UNKNOWN_LANGUAGE);
return -1;
diff --git a/libdw/dwarf_getfuncs.c b/libdw/dwarf_getfuncs.c
index b95f06f403d1..f6968f0081d4 100644
--- a/libdw/dwarf_getfuncs.c
+++ b/libdw/dwarf_getfuncs.c
@@ -1,5 +1,6 @@
/* Get function information.
Copyright (C) 2005, 2013, 2015 Red Hat, Inc.
+ Copyright (C) 2024 Mark J. Wielaard <[email protected]>
This file is part of elfutils.
Written by Ulrich Drepper <[email protected]>, 2005.
@@ -104,7 +105,9 @@ dwarf_getfuncs (Dwarf_Die *cudie, int (*callback)
(Dwarf_Die *, void *),
bool c_cu = (lang == DW_LANG_C89
|| lang == DW_LANG_C
|| lang == DW_LANG_C99
- || lang == DW_LANG_C11);
+ || lang == DW_LANG_C11
+ || lang == DW_LANG_C17
+ || lang == DW_LANG_C23);
struct visitor_info v = { callback, arg, (void *) offset, NULL, c_cu };
struct Dwarf_Die_Chain chain = { .die = CUDIE (cudie->cu),
diff --git a/tests/dwarf_default_lower_bound.c
b/tests/dwarf_default_lower_bound.c
index d57424fc77fe..46e26f885a6b 100644
--- a/tests/dwarf_default_lower_bound.c
+++ b/tests/dwarf_default_lower_bound.c
@@ -1,6 +1,7 @@
/* Test all DW_LANG constants are handled by dwarf_default_lower_bound.
Copyright (C) 2016 Red Hat, Inc.
+ Copyright (C) 2024 Mark J. Wielaard <[email protected]>
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -34,18 +35,6 @@ test_lang (const char *name, int lang)
Dwarf_Sword low;
int res = dwarf_default_lower_bound (lang, &low);
- /* Assembler is special, it doesn't really have arrays. */
- if (lang == DW_LANG_Mips_Assembler)
- {
- if (res == 0)
- {
- printf ("%s shouldn't have a known lower bound\n", name);
- exit (-1);
- }
- printf ("%s: <unknown>\n", name);
- return;
- }
-
if (res != 0)
{
printf ("dwarf_default_lower_bound failed (%d) for %s\n", res, name);
--
2.47.0