summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils/binutils/0029-CVE-2022-48065-2.patch
blob: 8aa21f271659fc6e18a2b6e74c2e07b032a119ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
From: Alan Modra <amodra@gmail.com>
Date: Wed, 21 Sep 2022 05:15:44 +0000 (+0930)
Subject: dwarf2.c: mangle_style
X-Git-Tag: gdb-13-branchpoint~1165
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=4609af80c29db6015ce01b67c48f237c210da9b4

dwarf2.c: mangle_style

non_mangled incorrectly returned "true" for Ada.  Correct that, and
add a few more non-mangled entries.  Return a value suitable for
passing to cplus_demangle to control demangling.

	* dwarf2.c: Include demangle.h.
	(mangle_style): Rename from non_mangled.  Return DMGL_* value
	to suit lang.  Adjust all callers.
Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=4609af80c29db6015ce01b67c48f237c210da9b4]

CVE: CVE-2022-48065

Signed-off-by: Sanjana Venkatesh <Sanjana.Venkatesh@windriver.com>

---

diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index e7c12c3e9de..138cdbb00bb 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -32,6 +32,7 @@
 #include "sysdep.h"
 #include "bfd.h"
 #include "libiberty.h"
+#include "demangle.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "dwarf2.h"
@@ -1711,31 +1712,52 @@ read_attribute (struct attribute *    attr,
   return info_ptr;
 }
 
-/* Return whether DW_AT_name will return the same as DW_AT_linkage_name
-   for a function.  */
+/* Return mangling style given LANG.  */
 
-static bool
-non_mangled (int lang)
+static int
+mangle_style (int lang)
 {
   switch (lang)
     {
+    case DW_LANG_Ada83:
+    case DW_LANG_Ada95:
+      return DMGL_GNAT;
+
+    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:
+      return DMGL_GNU_V3;
+
+    case DW_LANG_Java:
+      return DMGL_JAVA;
+
+    case DW_LANG_D:
+      return DMGL_DLANG;
+
+    case DW_LANG_Rust:
+    case DW_LANG_Rust_old:
+      return DMGL_RUST;
+
     default:
-      return false;
+      return DMGL_AUTO;
 
     case DW_LANG_C89:
     case DW_LANG_C:
-    case DW_LANG_Ada83:
     case DW_LANG_Cobol74:
     case DW_LANG_Cobol85:
     case DW_LANG_Fortran77:
     case DW_LANG_Pascal83:
-    case DW_LANG_C99:
-    case DW_LANG_Ada95:
     case DW_LANG_PLI:
+    case DW_LANG_C99:
     case DW_LANG_UPC:
     case DW_LANG_C11:
     case DW_LANG_Mips_Assembler:
-      return true;
+    case DW_LANG_Upc:
+    case DW_LANG_HP_Basic91:
+    case DW_LANG_HP_IMacro:
+    case DW_LANG_HP_Assembler:
+      return 0;
     }
 }
 
@@ -3599,7 +3621,7 @@ find_abstract_instance (struct comp_unit *unit,
 		  if (name == NULL && is_str_form (&attr))
 		    {
 		      name = attr.u.str;
-		      if (non_mangled (unit->lang))
+		      if (mangle_style (unit->lang) == 0)
 			*is_linkage = true;
 		    }
 		  break;
@@ -4095,7 +4117,7 @@ scan_unit_for_symbols (struct comp_unit *unit)
 		  if (func->name == NULL && is_str_form (&attr))
 		    {
 		      func->name = attr.u.str;
-		      if (non_mangled (unit->lang))
+		      if (mangle_style (unit->lang) == 0)
 			func->is_linkage = true;
 		    }
 		  break;