diff options
Diffstat (limited to 'meta-microblaze/recipes-devtools/binutils/binutils/0032-Patch-MicroBlaze-Double-free-with-ld-no-keep-memory.patch')
-rw-r--r-- | meta-microblaze/recipes-devtools/binutils/binutils/0032-Patch-MicroBlaze-Double-free-with-ld-no-keep-memory.patch | 199 |
1 files changed, 0 insertions, 199 deletions
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils/0032-Patch-MicroBlaze-Double-free-with-ld-no-keep-memory.patch b/meta-microblaze/recipes-devtools/binutils/binutils/0032-Patch-MicroBlaze-Double-free-with-ld-no-keep-memory.patch deleted file mode 100644 index 58c3d784..00000000 --- a/meta-microblaze/recipes-devtools/binutils/binutils/0032-Patch-MicroBlaze-Double-free-with-ld-no-keep-memory.patch +++ /dev/null | |||
@@ -1,199 +0,0 @@ | |||
1 | From 70268d8d38851d06bd66f9c7cc85865f2f3c0e48 Mon Sep 17 00:00:00 2001 | ||
2 | From: Mahesh Bodapati <mbodapat@xilinx.com> | ||
3 | Date: Mon, 24 Jan 2022 16:59:19 +0530 | ||
4 | Subject: [PATCH 32/34] [Patch,MicroBlaze] : Double free with ld | ||
5 | --no-keep-memory. Proposed patches from the community member | ||
6 | (dednev@rambler.ru) for 2021.1. [CR-1115233] | ||
7 | |||
8 | Conflicts: | ||
9 | bfd/elf32-microblaze.c | ||
10 | bfd/elf64-microblaze.c | ||
11 | Upstream-Status: Pending | ||
12 | |||
13 | Signed-off-by: Mark Hatle <mark.hatle@amd.com> | ||
14 | |||
15 | --- | ||
16 | bfd/elf32-microblaze.c | 40 ++++++++++++++++++++++------------------ | ||
17 | bfd/elf64-microblaze.c | 38 ++++++++++++++++++++------------------ | ||
18 | 2 files changed, 42 insertions(+), 36 deletions(-) | ||
19 | |||
20 | diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c | ||
21 | index 588367ebcbb..28589db662f 100644 | ||
22 | --- a/bfd/elf32-microblaze.c | ||
23 | +++ b/bfd/elf32-microblaze.c | ||
24 | @@ -1800,10 +1800,8 @@ microblaze_elf_relax_section (bfd *abfd, | ||
25 | { | ||
26 | Elf_Internal_Shdr *symtab_hdr; | ||
27 | Elf_Internal_Rela *internal_relocs; | ||
28 | - Elf_Internal_Rela *free_relocs = NULL; | ||
29 | Elf_Internal_Rela *irel, *irelend; | ||
30 | bfd_byte *contents = NULL; | ||
31 | - bfd_byte *free_contents = NULL; | ||
32 | int rel_count; | ||
33 | unsigned int shndx; | ||
34 | size_t i, sym_index; | ||
35 | @@ -1847,8 +1845,6 @@ microblaze_elf_relax_section (bfd *abfd, | ||
36 | internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, link_info->keep_memory); | ||
37 | if (internal_relocs == NULL) | ||
38 | goto error_return; | ||
39 | - if (! link_info->keep_memory) | ||
40 | - free_relocs = internal_relocs; | ||
41 | |||
42 | sdata->relax_count = 0; | ||
43 | sdata->relax = (struct relax_table *) bfd_malloc ((sec->reloc_count + 1) | ||
44 | @@ -1876,7 +1872,6 @@ microblaze_elf_relax_section (bfd *abfd, | ||
45 | contents = (bfd_byte *) bfd_malloc (sec->size); | ||
46 | if (contents == NULL) | ||
47 | goto error_return; | ||
48 | - free_contents = contents; | ||
49 | |||
50 | if (!bfd_get_section_contents (abfd, sec, contents, | ||
51 | (file_ptr) 0, sec->size)) | ||
52 | @@ -2396,25 +2391,26 @@ microblaze_elf_relax_section (bfd *abfd, | ||
53 | } | ||
54 | |||
55 | elf_section_data (sec)->relocs = internal_relocs; | ||
56 | - free_relocs = NULL; | ||
57 | |||
58 | elf_section_data (sec)->this_hdr.contents = contents; | ||
59 | - free_contents = NULL; | ||
60 | |||
61 | symtab_hdr->contents = (bfd_byte *) isymbuf; | ||
62 | } | ||
63 | |||
64 | - free (free_relocs); | ||
65 | - free_relocs = NULL; | ||
66 | + if (internal_relocs != NULL | ||
67 | + && elf_section_data (sec)->relocs != internal_relocs) | ||
68 | + free (internal_relocs); | ||
69 | |||
70 | - if (free_contents != NULL) | ||
71 | - { | ||
72 | - if (!link_info->keep_memory) | ||
73 | - free (free_contents); | ||
74 | + if (contents != NULL | ||
75 | + && elf_section_data (sec)->this_hdr.contents != contents) | ||
76 | + { | ||
77 | + if (! link_info->keep_memory) | ||
78 | + free (contents); | ||
79 | else | ||
80 | - /* Cache the section contents for elf_link_input_bfd. */ | ||
81 | - elf_section_data (sec)->this_hdr.contents = contents; | ||
82 | - free_contents = NULL; | ||
83 | + { | ||
84 | + /* Cache the section contents for elf_link_input_bfd. */ | ||
85 | + elf_section_data (sec)->this_hdr.contents = contents; | ||
86 | + } | ||
87 | } | ||
88 | |||
89 | if (sdata->relax_count == 0) | ||
90 | @@ -2428,8 +2424,16 @@ microblaze_elf_relax_section (bfd *abfd, | ||
91 | return true; | ||
92 | |||
93 | error_return: | ||
94 | - free (free_relocs); | ||
95 | - free (free_contents); | ||
96 | + | ||
97 | + if (isymbuf != NULL | ||
98 | + && symtab_hdr->contents != (unsigned char *) isymbuf) | ||
99 | + free (isymbuf); | ||
100 | + if (internal_relocs != NULL | ||
101 | + && elf_section_data (sec)->relocs != internal_relocs) | ||
102 | + free (internal_relocs); | ||
103 | + if (contents != NULL | ||
104 | + && elf_section_data (sec)->this_hdr.contents != contents) | ||
105 | + free (contents); | ||
106 | free (sdata->relax); | ||
107 | sdata->relax = NULL; | ||
108 | sdata->relax_count = 0; | ||
109 | diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c | ||
110 | index 76aec43ec7a..77872cef1ab 100644 | ||
111 | --- a/bfd/elf64-microblaze.c | ||
112 | +++ b/bfd/elf64-microblaze.c | ||
113 | @@ -1840,10 +1840,8 @@ microblaze_elf_relax_section (bfd *abfd, | ||
114 | { | ||
115 | Elf_Internal_Shdr *symtab_hdr; | ||
116 | Elf_Internal_Rela *internal_relocs; | ||
117 | - Elf_Internal_Rela *free_relocs = NULL; | ||
118 | Elf_Internal_Rela *irel, *irelend; | ||
119 | bfd_byte *contents = NULL; | ||
120 | - bfd_byte *free_contents = NULL; | ||
121 | int rel_count; | ||
122 | unsigned int shndx; | ||
123 | size_t i, sym_index; | ||
124 | @@ -1887,8 +1885,6 @@ microblaze_elf_relax_section (bfd *abfd, | ||
125 | internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, link_info->keep_memory); | ||
126 | if (internal_relocs == NULL) | ||
127 | goto error_return; | ||
128 | - if (! link_info->keep_memory) | ||
129 | - free_relocs = internal_relocs; | ||
130 | |||
131 | sdata->relax_count = 0; | ||
132 | sdata->relax = (struct relax_table *) bfd_malloc ((sec->reloc_count + 1) | ||
133 | @@ -1916,8 +1912,6 @@ microblaze_elf_relax_section (bfd *abfd, | ||
134 | contents = (bfd_byte *) bfd_malloc (sec->size); | ||
135 | if (contents == NULL) | ||
136 | goto error_return; | ||
137 | - free_contents = contents; | ||
138 | - | ||
139 | if (!bfd_get_section_contents (abfd, sec, contents, | ||
140 | (file_ptr) 0, sec->size)) | ||
141 | goto error_return; | ||
142 | @@ -2449,25 +2443,26 @@ microblaze_elf_relax_section (bfd *abfd, | ||
143 | } | ||
144 | |||
145 | elf_section_data (sec)->relocs = internal_relocs; | ||
146 | - free_relocs = NULL; | ||
147 | |||
148 | elf_section_data (sec)->this_hdr.contents = contents; | ||
149 | - free_contents = NULL; | ||
150 | |||
151 | symtab_hdr->contents = (bfd_byte *) isymbuf; | ||
152 | } | ||
153 | |||
154 | - free (free_relocs); | ||
155 | - free_relocs = NULL; | ||
156 | + if (internal_relocs != NULL | ||
157 | + && elf_section_data (sec)->relocs != internal_relocs) | ||
158 | + free (internal_relocs); | ||
159 | |||
160 | - if (free_contents != NULL) | ||
161 | + if (contents != NULL | ||
162 | + && elf_section_data (sec)->this_hdr.contents != contents) | ||
163 | { | ||
164 | - if (!link_info->keep_memory) | ||
165 | - free (free_contents); | ||
166 | + if (! link_info->keep_memory) | ||
167 | + free (contents); | ||
168 | else | ||
169 | - /* Cache the section contents for elf_link_input_bfd. */ | ||
170 | - elf_section_data (sec)->this_hdr.contents = contents; | ||
171 | - free_contents = NULL; | ||
172 | + { | ||
173 | + /* Cache the section contents for elf_link_input_bfd. */ | ||
174 | + elf_section_data (sec)->this_hdr.contents = contents; | ||
175 | + } | ||
176 | } | ||
177 | |||
178 | if (sdata->relax_count == 0) | ||
179 | @@ -2481,8 +2476,15 @@ microblaze_elf_relax_section (bfd *abfd, | ||
180 | return true; | ||
181 | |||
182 | error_return: | ||
183 | - free (free_relocs); | ||
184 | - free (free_contents); | ||
185 | + if (isymbuf != NULL | ||
186 | + && symtab_hdr->contents != (unsigned char *) isymbuf) | ||
187 | + free (isymbuf); | ||
188 | + if (internal_relocs != NULL | ||
189 | + && elf_section_data (sec)->relocs != internal_relocs) | ||
190 | + free (internal_relocs); | ||
191 | + if (contents != NULL | ||
192 | + && elf_section_data (sec)->this_hdr.contents != contents) | ||
193 | + free (contents); | ||
194 | free (sdata->relax); | ||
195 | sdata->relax = NULL; | ||
196 | sdata->relax_count = 0; | ||
197 | -- | ||
198 | 2.37.1 (Apple Git-137.1) | ||
199 | |||