diff options
author | Yash Shinde <yashinde145@gmail.com> | 2023-04-10 17:05:43 +0530 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-04-19 04:44:59 -1000 |
commit | dea0c1e1f5e0d256ee7dce61fb3edb6bfcfa70f8 (patch) | |
tree | ff0e7109c875862978f6ad2945f716de84c53634 /meta | |
parent | 09def309f91929f47c6cce386016ccb777bd2cfc (diff) | |
download | poky-dea0c1e1f5e0d256ee7dce61fb3edb6bfcfa70f8.tar.gz |
binutils : Fix CVE-2023-1579
Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3e307d538c351aa9327cbad672c884059ecc20dd]
(From OE-Core rev: d478e7ea0bb897e13d86c476966924ef9927f11a)
Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
5 files changed, 2783 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils-2.38.inc b/meta/recipes-devtools/binutils/binutils-2.38.inc index 30a34d7ba4..bf44e6c762 100644 --- a/meta/recipes-devtools/binutils/binutils-2.38.inc +++ b/meta/recipes-devtools/binutils/binutils-2.38.inc | |||
@@ -46,5 +46,9 @@ SRC_URI = "\ | |||
46 | file://0020-CVE-2023-22608-1.patch \ | 46 | file://0020-CVE-2023-22608-1.patch \ |
47 | file://0020-CVE-2023-22608-2.patch \ | 47 | file://0020-CVE-2023-22608-2.patch \ |
48 | file://0020-CVE-2023-22608-3.patch \ | 48 | file://0020-CVE-2023-22608-3.patch \ |
49 | file://0021-CVE-2023-1579-1.patch \ | ||
50 | file://0021-CVE-2023-1579-2.patch \ | ||
51 | file://0021-CVE-2023-1579-3.patch \ | ||
52 | file://0021-CVE-2023-1579-4.patch \ | ||
49 | " | 53 | " |
50 | S = "${WORKDIR}/git" | 54 | S = "${WORKDIR}/git" |
diff --git a/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-1.patch b/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-1.patch new file mode 100644 index 0000000000..1e9c03e70e --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-1.patch | |||
@@ -0,0 +1,459 @@ | |||
1 | From f67741e172bf342291fe3abd2b395899ce6433a0 Mon Sep 17 00:00:00 2001 | ||
2 | From: "Potharla, Rupesh" <Rupesh.Potharla@amd.com> | ||
3 | Date: Tue, 24 May 2022 00:01:49 +0000 | ||
4 | Subject: [PATCH] bfd: Add Support for DW_FORM_strx* and DW_FORM_addrx* | ||
5 | |||
6 | Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=f67741e172bf342291fe3abd2b395899ce6433a0] | ||
7 | |||
8 | CVE: CVE-2023-1579 | ||
9 | |||
10 | Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com> | ||
11 | |||
12 | --- | ||
13 | bfd/dwarf2.c | 282 ++++++++++++++++++++++++++++++++++++++++++++++++--- | ||
14 | 1 file changed, 268 insertions(+), 14 deletions(-) | ||
15 | |||
16 | diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c | ||
17 | index f6b0183720b..45e286754e4 100644 | ||
18 | --- a/bfd/dwarf2.c | ||
19 | +++ b/bfd/dwarf2.c | ||
20 | @@ -189,6 +189,18 @@ struct dwarf2_debug_file | ||
21 | /* Length of the loaded .debug_str section. */ | ||
22 | bfd_size_type dwarf_str_size; | ||
23 | |||
24 | + /* Pointer to the .debug_str_offsets section loaded into memory. */ | ||
25 | + bfd_byte *dwarf_str_offsets_buffer; | ||
26 | + | ||
27 | + /* Length of the loaded .debug_str_offsets section. */ | ||
28 | + bfd_size_type dwarf_str_offsets_size; | ||
29 | + | ||
30 | + /* Pointer to the .debug_addr section loaded into memory. */ | ||
31 | + bfd_byte *dwarf_addr_buffer; | ||
32 | + | ||
33 | + /* Length of the loaded .debug_addr section. */ | ||
34 | + bfd_size_type dwarf_addr_size; | ||
35 | + | ||
36 | /* Pointer to the .debug_line_str section loaded into memory. */ | ||
37 | bfd_byte *dwarf_line_str_buffer; | ||
38 | |||
39 | @@ -382,6 +394,12 @@ struct comp_unit | ||
40 | /* Used when iterating over trie leaves to know which units we have | ||
41 | already seen in this iteration. */ | ||
42 | bool mark; | ||
43 | + | ||
44 | + /* Base address of debug_addr section. */ | ||
45 | + size_t dwarf_addr_offset; | ||
46 | + | ||
47 | + /* Base address of string offset table. */ | ||
48 | + size_t dwarf_str_offset; | ||
49 | }; | ||
50 | |||
51 | /* This data structure holds the information of an abbrev. */ | ||
52 | @@ -424,6 +442,8 @@ const struct dwarf_debug_section dwarf_debug_sections[] = | ||
53 | { ".debug_static_vars", ".zdebug_static_vars" }, | ||
54 | { ".debug_str", ".zdebug_str", }, | ||
55 | { ".debug_str", ".zdebug_str", }, | ||
56 | + { ".debug_str_offsets", ".zdebug_str_offsets", }, | ||
57 | + { ".debug_addr", ".zdebug_addr", }, | ||
58 | { ".debug_line_str", ".zdebug_line_str", }, | ||
59 | { ".debug_types", ".zdebug_types" }, | ||
60 | /* GNU DWARF 1 extensions */ | ||
61 | @@ -458,6 +478,8 @@ enum dwarf_debug_section_enum | ||
62 | debug_static_vars, | ||
63 | debug_str, | ||
64 | debug_str_alt, | ||
65 | + debug_str_offsets, | ||
66 | + debug_addr, | ||
67 | debug_line_str, | ||
68 | debug_types, | ||
69 | debug_sfnames, | ||
70 | @@ -1307,12 +1329,92 @@ is_int_form (const struct attribute *attr) | ||
71 | } | ||
72 | } | ||
73 | |||
74 | +/* Returns true if the form is strx[1-4]. */ | ||
75 | + | ||
76 | +static inline bool | ||
77 | +is_strx_form (enum dwarf_form form) | ||
78 | +{ | ||
79 | + return (form == DW_FORM_strx | ||
80 | + || form == DW_FORM_strx1 | ||
81 | + || form == DW_FORM_strx2 | ||
82 | + || form == DW_FORM_strx3 | ||
83 | + || form == DW_FORM_strx4); | ||
84 | +} | ||
85 | + | ||
86 | +/* Return true if the form is addrx[1-4]. */ | ||
87 | + | ||
88 | +static inline bool | ||
89 | +is_addrx_form (enum dwarf_form form) | ||
90 | +{ | ||
91 | + return (form == DW_FORM_addrx | ||
92 | + || form == DW_FORM_addrx1 | ||
93 | + || form == DW_FORM_addrx2 | ||
94 | + || form == DW_FORM_addrx3 | ||
95 | + || form == DW_FORM_addrx4); | ||
96 | +} | ||
97 | + | ||
98 | +/* Returns the address in .debug_addr section using DW_AT_addr_base. | ||
99 | + Used to implement DW_FORM_addrx*. */ | ||
100 | +static bfd_vma | ||
101 | +read_indexed_address (bfd_uint64_t idx, | ||
102 | + struct comp_unit *unit) | ||
103 | +{ | ||
104 | + struct dwarf2_debug *stash = unit->stash; | ||
105 | + struct dwarf2_debug_file *file = unit->file; | ||
106 | + size_t addr_base = unit->dwarf_addr_offset; | ||
107 | + bfd_byte *info_ptr; | ||
108 | + | ||
109 | + if (stash == NULL) | ||
110 | + return 0; | ||
111 | + | ||
112 | + if (!read_section (unit->abfd, &stash->debug_sections[debug_addr], | ||
113 | + file->syms, 0, | ||
114 | + &file->dwarf_addr_buffer, &file->dwarf_addr_size)) | ||
115 | + return 0; | ||
116 | + | ||
117 | + info_ptr = file->dwarf_addr_buffer + addr_base + idx * unit->offset_size; | ||
118 | + | ||
119 | + if (unit->offset_size == 4) | ||
120 | + return bfd_get_32 (unit->abfd, info_ptr); | ||
121 | + else | ||
122 | + return bfd_get_64 (unit->abfd, info_ptr); | ||
123 | +} | ||
124 | + | ||
125 | +/* Returns the string using DW_AT_str_offsets_base. | ||
126 | + Used to implement DW_FORM_strx*. */ | ||
127 | static const char * | ||
128 | -read_indexed_string (bfd_uint64_t idx ATTRIBUTE_UNUSED, | ||
129 | - struct comp_unit * unit ATTRIBUTE_UNUSED) | ||
130 | +read_indexed_string (bfd_uint64_t idx, | ||
131 | + struct comp_unit *unit) | ||
132 | { | ||
133 | - /* FIXME: Add support for indexed strings. */ | ||
134 | - return "<indexed strings not yet supported>"; | ||
135 | + struct dwarf2_debug *stash = unit->stash; | ||
136 | + struct dwarf2_debug_file *file = unit->file; | ||
137 | + bfd_byte *info_ptr; | ||
138 | + unsigned long str_offset; | ||
139 | + | ||
140 | + if (stash == NULL) | ||
141 | + return NULL; | ||
142 | + | ||
143 | + if (!read_section (unit->abfd, &stash->debug_sections[debug_str], | ||
144 | + file->syms, 0, | ||
145 | + &file->dwarf_str_buffer, &file->dwarf_str_size)) | ||
146 | + return NULL; | ||
147 | + | ||
148 | + if (!read_section (unit->abfd, &stash->debug_sections[debug_str_offsets], | ||
149 | + file->syms, 0, | ||
150 | + &file->dwarf_str_offsets_buffer, | ||
151 | + &file->dwarf_str_offsets_size)) | ||
152 | + return NULL; | ||
153 | + | ||
154 | + info_ptr = (file->dwarf_str_offsets_buffer | ||
155 | + + unit->dwarf_str_offset | ||
156 | + + idx * unit->offset_size); | ||
157 | + | ||
158 | + if (unit->offset_size == 4) | ||
159 | + str_offset = bfd_get_32 (unit->abfd, info_ptr); | ||
160 | + else | ||
161 | + str_offset = bfd_get_64 (unit->abfd, info_ptr); | ||
162 | + | ||
163 | + return (const char *) file->dwarf_str_buffer + str_offset; | ||
164 | } | ||
165 | |||
166 | /* Read and fill in the value of attribute ATTR as described by FORM. | ||
167 | @@ -1381,21 +1483,37 @@ read_attribute_value (struct attribute * attr, | ||
168 | case DW_FORM_ref1: | ||
169 | case DW_FORM_flag: | ||
170 | case DW_FORM_data1: | ||
171 | + attr->u.val = read_1_byte (abfd, &info_ptr, info_ptr_end); | ||
172 | + break; | ||
173 | case DW_FORM_addrx1: | ||
174 | attr->u.val = read_1_byte (abfd, &info_ptr, info_ptr_end); | ||
175 | + /* dwarf_addr_offset value 0 indicates the attribute DW_AT_addr_base | ||
176 | + is not yet read. */ | ||
177 | + if (unit->dwarf_addr_offset != 0) | ||
178 | + attr->u.val = read_indexed_address (attr->u.val, unit); | ||
179 | break; | ||
180 | case DW_FORM_data2: | ||
181 | - case DW_FORM_addrx2: | ||
182 | case DW_FORM_ref2: | ||
183 | attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); | ||
184 | break; | ||
185 | + case DW_FORM_addrx2: | ||
186 | + attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); | ||
187 | + if (unit->dwarf_addr_offset != 0) | ||
188 | + attr->u.val = read_indexed_address (attr->u.val, unit); | ||
189 | + break; | ||
190 | case DW_FORM_addrx3: | ||
191 | attr->u.val = read_3_bytes (abfd, &info_ptr, info_ptr_end); | ||
192 | + if (unit->dwarf_addr_offset != 0) | ||
193 | + attr->u.val = read_indexed_address(attr->u.val, unit); | ||
194 | break; | ||
195 | case DW_FORM_ref4: | ||
196 | case DW_FORM_data4: | ||
197 | + attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); | ||
198 | + break; | ||
199 | case DW_FORM_addrx4: | ||
200 | attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); | ||
201 | + if (unit->dwarf_addr_offset != 0) | ||
202 | + attr->u.val = read_indexed_address (attr->u.val, unit); | ||
203 | break; | ||
204 | case DW_FORM_data8: | ||
205 | case DW_FORM_ref8: | ||
206 | @@ -1416,24 +1534,31 @@ read_attribute_value (struct attribute * attr, | ||
207 | break; | ||
208 | case DW_FORM_strx1: | ||
209 | attr->u.val = read_1_byte (abfd, &info_ptr, info_ptr_end); | ||
210 | - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
211 | + /* dwarf_str_offset value 0 indicates the attribute DW_AT_str_offsets_base | ||
212 | + is not yet read. */ | ||
213 | + if (unit->dwarf_str_offset != 0) | ||
214 | + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
215 | break; | ||
216 | case DW_FORM_strx2: | ||
217 | attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); | ||
218 | - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
219 | + if (unit->dwarf_str_offset != 0) | ||
220 | + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
221 | break; | ||
222 | case DW_FORM_strx3: | ||
223 | attr->u.val = read_3_bytes (abfd, &info_ptr, info_ptr_end); | ||
224 | - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
225 | + if (unit->dwarf_str_offset != 0) | ||
226 | + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
227 | break; | ||
228 | case DW_FORM_strx4: | ||
229 | attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); | ||
230 | - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
231 | + if (unit->dwarf_str_offset != 0) | ||
232 | + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
233 | break; | ||
234 | case DW_FORM_strx: | ||
235 | attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, | ||
236 | false, info_ptr_end); | ||
237 | - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
238 | + if (unit->dwarf_str_offset != 0) | ||
239 | + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
240 | break; | ||
241 | case DW_FORM_exprloc: | ||
242 | case DW_FORM_block: | ||
243 | @@ -1455,9 +1580,14 @@ read_attribute_value (struct attribute * attr, | ||
244 | break; | ||
245 | case DW_FORM_ref_udata: | ||
246 | case DW_FORM_udata: | ||
247 | + attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, | ||
248 | + false, info_ptr_end); | ||
249 | + break; | ||
250 | case DW_FORM_addrx: | ||
251 | attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, | ||
252 | false, info_ptr_end); | ||
253 | + if (unit->dwarf_addr_offset != 0) | ||
254 | + attr->u.val = read_indexed_address (attr->u.val, unit); | ||
255 | break; | ||
256 | case DW_FORM_indirect: | ||
257 | form = _bfd_safe_read_leb128 (abfd, &info_ptr, | ||
258 | @@ -2396,6 +2526,11 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp, | ||
259 | { | ||
260 | case DW_FORM_string: | ||
261 | case DW_FORM_line_strp: | ||
262 | + case DW_FORM_strx: | ||
263 | + case DW_FORM_strx1: | ||
264 | + case DW_FORM_strx2: | ||
265 | + case DW_FORM_strx3: | ||
266 | + case DW_FORM_strx4: | ||
267 | *stringp = attr.u.str; | ||
268 | break; | ||
269 | |||
270 | @@ -4031,6 +4166,80 @@ scan_unit_for_symbols (struct comp_unit *unit) | ||
271 | return false; | ||
272 | } | ||
273 | |||
274 | +/* Read the attributes of the form strx and addrx. */ | ||
275 | + | ||
276 | +static void | ||
277 | +reread_attribute (struct comp_unit *unit, | ||
278 | + struct attribute *attr, | ||
279 | + bfd_vma *low_pc, | ||
280 | + bfd_vma *high_pc, | ||
281 | + bool *high_pc_relative, | ||
282 | + bool compunit) | ||
283 | +{ | ||
284 | + if (is_strx_form (attr->form)) | ||
285 | + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
286 | + if (is_addrx_form (attr->form)) | ||
287 | + attr->u.val = read_indexed_address (attr->u.val, unit); | ||
288 | + | ||
289 | + switch (attr->name) | ||
290 | + { | ||
291 | + case DW_AT_stmt_list: | ||
292 | + unit->stmtlist = 1; | ||
293 | + unit->line_offset = attr->u.val; | ||
294 | + break; | ||
295 | + | ||
296 | + case DW_AT_name: | ||
297 | + if (is_str_form (attr)) | ||
298 | + unit->name = attr->u.str; | ||
299 | + break; | ||
300 | + | ||
301 | + case DW_AT_low_pc: | ||
302 | + *low_pc = attr->u.val; | ||
303 | + if (compunit) | ||
304 | + unit->base_address = *low_pc; | ||
305 | + break; | ||
306 | + | ||
307 | + case DW_AT_high_pc: | ||
308 | + *high_pc = attr->u.val; | ||
309 | + *high_pc_relative = attr->form != DW_FORM_addr; | ||
310 | + break; | ||
311 | + | ||
312 | + case DW_AT_ranges: | ||
313 | + if (!read_rangelist (unit, &unit->arange, | ||
314 | + &unit->file->trie_root, attr->u.val)) | ||
315 | + return; | ||
316 | + break; | ||
317 | + | ||
318 | + case DW_AT_comp_dir: | ||
319 | + { | ||
320 | + char *comp_dir = attr->u.str; | ||
321 | + | ||
322 | + if (!is_str_form (attr)) | ||
323 | + { | ||
324 | + _bfd_error_handler | ||
325 | + (_("DWARF error: DW_AT_comp_dir attribute encountered " | ||
326 | + "with a non-string form")); | ||
327 | + comp_dir = NULL; | ||
328 | + } | ||
329 | + | ||
330 | + if (comp_dir) | ||
331 | + { | ||
332 | + char *cp = strchr (comp_dir, ':'); | ||
333 | + | ||
334 | + if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/') | ||
335 | + comp_dir = cp + 1; | ||
336 | + } | ||
337 | + unit->comp_dir = comp_dir; | ||
338 | + break; | ||
339 | + } | ||
340 | + | ||
341 | + case DW_AT_language: | ||
342 | + unit->lang = attr->u.val; | ||
343 | + default: | ||
344 | + break; | ||
345 | + } | ||
346 | +} | ||
347 | + | ||
348 | /* Parse a DWARF2 compilation unit starting at INFO_PTR. UNIT_LENGTH | ||
349 | includes the compilation unit header that proceeds the DIE's, but | ||
350 | does not include the length field that precedes each compilation | ||
351 | @@ -4064,6 +4273,10 @@ parse_comp_unit (struct dwarf2_debug *stash, | ||
352 | bfd *abfd = file->bfd_ptr; | ||
353 | bool high_pc_relative = false; | ||
354 | enum dwarf_unit_type unit_type; | ||
355 | + struct attribute *str_addrp = NULL; | ||
356 | + size_t str_count = 0; | ||
357 | + size_t str_alloc = 0; | ||
358 | + bool compunit_flag = false; | ||
359 | |||
360 | version = read_2_bytes (abfd, &info_ptr, end_ptr); | ||
361 | if (version < 2 || version > 5) | ||
362 | @@ -4168,11 +4381,33 @@ parse_comp_unit (struct dwarf2_debug *stash, | ||
363 | unit->file = file; | ||
364 | unit->info_ptr_unit = info_ptr_unit; | ||
365 | |||
366 | + if (abbrev->tag == DW_TAG_compile_unit) | ||
367 | + compunit_flag = true; | ||
368 | + | ||
369 | for (i = 0; i < abbrev->num_attrs; ++i) | ||
370 | { | ||
371 | info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr, end_ptr); | ||
372 | if (info_ptr == NULL) | ||
373 | - return NULL; | ||
374 | + goto err_exit; | ||
375 | + | ||
376 | + /* Identify attributes of the form strx* and addrx* which come before | ||
377 | + DW_AT_str_offsets_base and DW_AT_addr_base respectively in the CU. | ||
378 | + Store the attributes in an array and process them later. */ | ||
379 | + if ((unit->dwarf_str_offset == 0 && is_strx_form (attr.form)) | ||
380 | + || (unit->dwarf_addr_offset == 0 && is_addrx_form (attr.form))) | ||
381 | + { | ||
382 | + if (str_count <= str_alloc) | ||
383 | + { | ||
384 | + str_alloc = 2 * str_alloc + 200; | ||
385 | + str_addrp = bfd_realloc (str_addrp, | ||
386 | + str_alloc * sizeof (*str_addrp)); | ||
387 | + if (str_addrp == NULL) | ||
388 | + goto err_exit; | ||
389 | + } | ||
390 | + str_addrp[str_count] = attr; | ||
391 | + str_count++; | ||
392 | + continue; | ||
393 | + } | ||
394 | |||
395 | /* Store the data if it is of an attribute we want to keep in a | ||
396 | partial symbol table. */ | ||
397 | @@ -4198,7 +4433,7 @@ parse_comp_unit (struct dwarf2_debug *stash, | ||
398 | /* If the compilation unit DIE has a DW_AT_low_pc attribute, | ||
399 | this is the base address to use when reading location | ||
400 | lists or range lists. */ | ||
401 | - if (abbrev->tag == DW_TAG_compile_unit) | ||
402 | + if (compunit_flag) | ||
403 | unit->base_address = low_pc; | ||
404 | } | ||
405 | break; | ||
406 | @@ -4215,7 +4450,7 @@ parse_comp_unit (struct dwarf2_debug *stash, | ||
407 | if (is_int_form (&attr) | ||
408 | && !read_rangelist (unit, &unit->arange, | ||
409 | &unit->file->trie_root, attr.u.val)) | ||
410 | - return NULL; | ||
411 | + goto err_exit; | ||
412 | break; | ||
413 | |||
414 | case DW_AT_comp_dir: | ||
415 | @@ -4248,21 +4483,40 @@ parse_comp_unit (struct dwarf2_debug *stash, | ||
416 | unit->lang = attr.u.val; | ||
417 | break; | ||
418 | |||
419 | + case DW_AT_addr_base: | ||
420 | + unit->dwarf_addr_offset = attr.u.val; | ||
421 | + break; | ||
422 | + | ||
423 | + case DW_AT_str_offsets_base: | ||
424 | + unit->dwarf_str_offset = attr.u.val; | ||
425 | + break; | ||
426 | + | ||
427 | default: | ||
428 | break; | ||
429 | } | ||
430 | } | ||
431 | + | ||
432 | + for (i = 0; i < str_count; ++i) | ||
433 | + reread_attribute (unit, &str_addrp[i], &low_pc, &high_pc, | ||
434 | + &high_pc_relative, compunit_flag); | ||
435 | + | ||
436 | if (high_pc_relative) | ||
437 | high_pc += low_pc; | ||
438 | if (high_pc != 0) | ||
439 | { | ||
440 | if (!arange_add (unit, &unit->arange, &unit->file->trie_root, | ||
441 | low_pc, high_pc)) | ||
442 | - return NULL; | ||
443 | + goto err_exit; | ||
444 | } | ||
445 | |||
446 | unit->first_child_die_ptr = info_ptr; | ||
447 | + | ||
448 | + free (str_addrp); | ||
449 | return unit; | ||
450 | + | ||
451 | + err_exit: | ||
452 | + free (str_addrp); | ||
453 | + return NULL; | ||
454 | } | ||
455 | |||
456 | /* Return TRUE if UNIT may contain the address given by ADDR. When | ||
457 | -- | ||
458 | 2.31.1 | ||
459 | |||
diff --git a/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-2.patch b/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-2.patch new file mode 100644 index 0000000000..be698ef5c1 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-2.patch | |||
@@ -0,0 +1,2127 @@ | |||
1 | From 0e3c1eebb22e0ade28b619fb41f42d66ed6fb145 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alan Modra <amodra@gmail.com> | ||
3 | Date: Fri, 27 May 2022 12:37:21 +0930 | ||
4 | Subject: [PATCH] Remove use of bfd_uint64_t and similar | ||
5 | |||
6 | Requiring C99 means that uses of bfd_uint64_t can be replaced with | ||
7 | uint64_t, and similarly for bfd_int64_t, BFD_HOST_U_64_BIT, and | ||
8 | BFD_HOST_64_BIT. This patch does that, removes #ifdef BFD_HOST_* | ||
9 | and tidies a few places that print 64-bit values. | ||
10 | |||
11 | Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=0e3c1eebb22e0ade28b619fb41f42d66ed6fb145] | ||
12 | |||
13 | CVE: CVE-2023-1579 | ||
14 | |||
15 | Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com> | ||
16 | |||
17 | --- | ||
18 | bfd/aix386-core.c | 6 +-- | ||
19 | bfd/bfd-in.h | 24 ++++++------ | ||
20 | bfd/bfd-in2.h | 36 +++++++++--------- | ||
21 | bfd/coff-rs6000.c | 10 +---- | ||
22 | bfd/coff-x86_64.c | 2 +- | ||
23 | bfd/cpu-ia64-opc.c | 22 +++++------ | ||
24 | bfd/dwarf2.c | 83 ++++++++++++++++++++--------------------- | ||
25 | bfd/elf32-score.c | 16 ++++---- | ||
26 | bfd/elf64-ia64-vms.c | 8 ++-- | ||
27 | bfd/elflink.c | 16 +------- | ||
28 | bfd/elfxx-ia64.c | 6 +-- | ||
29 | bfd/hppabsd-core.c | 6 +-- | ||
30 | bfd/hpux-core.c | 6 +-- | ||
31 | bfd/irix-core.c | 6 +-- | ||
32 | bfd/libbfd.c | 65 +++++++++----------------------- | ||
33 | bfd/mach-o.c | 2 +- | ||
34 | bfd/mach-o.h | 8 ++-- | ||
35 | bfd/netbsd-core.c | 6 +-- | ||
36 | bfd/osf-core.c | 6 +-- | ||
37 | bfd/ptrace-core.c | 6 +-- | ||
38 | bfd/sco5-core.c | 6 +-- | ||
39 | bfd/targets.c | 12 +++--- | ||
40 | bfd/trad-core.c | 6 +-- | ||
41 | bfd/vms-alpha.c | 2 +- | ||
42 | binutils/nm.c | 49 +++--------------------- | ||
43 | binutils/od-macho.c | 50 ++++++++----------------- | ||
44 | binutils/prdbg.c | 39 +++---------------- | ||
45 | binutils/readelf.c | 21 +++++------ | ||
46 | gas/config/tc-arm.c | 28 ++++---------- | ||
47 | gas/config/tc-csky.c | 10 ++--- | ||
48 | gas/config/tc-sparc.c | 35 +++++++++-------- | ||
49 | gas/config/tc-tilegx.c | 20 +++++----- | ||
50 | gas/config/tc-tilepro.c | 20 +++++----- | ||
51 | gas/config/tc-z80.c | 8 ++-- | ||
52 | gas/config/te-vms.c | 2 +- | ||
53 | gas/config/te-vms.h | 2 +- | ||
54 | gdb/findcmd.c | 2 +- | ||
55 | gdb/tilegx-tdep.c | 2 +- | ||
56 | gprof/gmon_io.c | 44 ++++++---------------- | ||
57 | include/elf/nfp.h | 2 +- | ||
58 | include/opcode/csky.h | 62 +++++++++++++++--------------- | ||
59 | include/opcode/ia64.h | 2 +- | ||
60 | opcodes/csky-dis.c | 2 +- | ||
61 | opcodes/csky-opc.h | 4 +- | ||
62 | opcodes/ia64-dis.c | 2 +- | ||
63 | 45 files changed, 297 insertions(+), 475 deletions(-) | ||
64 | |||
65 | diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c | ||
66 | index 3443e49ed46..977a6bd1fb4 100644 | ||
67 | --- a/bfd/aix386-core.c | ||
68 | +++ b/bfd/aix386-core.c | ||
69 | @@ -220,9 +220,9 @@ swap_abort (void) | ||
70 | #define NO_GET ((bfd_vma (*) (const void *)) swap_abort) | ||
71 | #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) | ||
72 | #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) | ||
73 | -#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) | ||
74 | -#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) | ||
75 | -#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) | ||
76 | +#define NO_GET64 ((uint64_t (*) (const void *)) swap_abort) | ||
77 | +#define NO_PUT64 ((void (*) (uint64_t, void *)) swap_abort) | ||
78 | +#define NO_GETS64 ((int64_t (*) (const void *)) swap_abort) | ||
79 | |||
80 | const bfd_target core_aix386_vec = | ||
81 | { | ||
82 | diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h | ||
83 | index a1c4bf139fc..09c5728e944 100644 | ||
84 | --- a/bfd/bfd-in.h | ||
85 | +++ b/bfd/bfd-in.h | ||
86 | @@ -116,10 +116,10 @@ typedef struct bfd bfd; | ||
87 | #error No 64 bit integer type available | ||
88 | #endif /* ! defined (BFD_HOST_64_BIT) */ | ||
89 | |||
90 | -typedef BFD_HOST_U_64_BIT bfd_vma; | ||
91 | -typedef BFD_HOST_64_BIT bfd_signed_vma; | ||
92 | -typedef BFD_HOST_U_64_BIT bfd_size_type; | ||
93 | -typedef BFD_HOST_U_64_BIT symvalue; | ||
94 | +typedef uint64_t bfd_vma; | ||
95 | +typedef int64_t bfd_signed_vma; | ||
96 | +typedef uint64_t bfd_size_type; | ||
97 | +typedef uint64_t symvalue; | ||
98 | |||
99 | #if BFD_HOST_64BIT_LONG | ||
100 | #define BFD_VMA_FMT "l" | ||
101 | @@ -447,10 +447,10 @@ extern bool bfd_record_phdr | ||
102 | |||
103 | /* Byte swapping routines. */ | ||
104 | |||
105 | -bfd_uint64_t bfd_getb64 (const void *); | ||
106 | -bfd_uint64_t bfd_getl64 (const void *); | ||
107 | -bfd_int64_t bfd_getb_signed_64 (const void *); | ||
108 | -bfd_int64_t bfd_getl_signed_64 (const void *); | ||
109 | +uint64_t bfd_getb64 (const void *); | ||
110 | +uint64_t bfd_getl64 (const void *); | ||
111 | +int64_t bfd_getb_signed_64 (const void *); | ||
112 | +int64_t bfd_getl_signed_64 (const void *); | ||
113 | bfd_vma bfd_getb32 (const void *); | ||
114 | bfd_vma bfd_getl32 (const void *); | ||
115 | bfd_signed_vma bfd_getb_signed_32 (const void *); | ||
116 | @@ -459,8 +459,8 @@ bfd_vma bfd_getb16 (const void *); | ||
117 | bfd_vma bfd_getl16 (const void *); | ||
118 | bfd_signed_vma bfd_getb_signed_16 (const void *); | ||
119 | bfd_signed_vma bfd_getl_signed_16 (const void *); | ||
120 | -void bfd_putb64 (bfd_uint64_t, void *); | ||
121 | -void bfd_putl64 (bfd_uint64_t, void *); | ||
122 | +void bfd_putb64 (uint64_t, void *); | ||
123 | +void bfd_putl64 (uint64_t, void *); | ||
124 | void bfd_putb32 (bfd_vma, void *); | ||
125 | void bfd_putl32 (bfd_vma, void *); | ||
126 | void bfd_putb24 (bfd_vma, void *); | ||
127 | @@ -470,8 +470,8 @@ void bfd_putl16 (bfd_vma, void *); | ||
128 | |||
129 | /* Byte swapping routines which take size and endiannes as arguments. */ | ||
130 | |||
131 | -bfd_uint64_t bfd_get_bits (const void *, int, bool); | ||
132 | -void bfd_put_bits (bfd_uint64_t, void *, int, bool); | ||
133 | +uint64_t bfd_get_bits (const void *, int, bool); | ||
134 | +void bfd_put_bits (uint64_t, void *, int, bool); | ||
135 | |||
136 | |||
137 | /* mmap hacks */ | ||
138 | diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h | ||
139 | index 50e26fc691d..d50885e76cf 100644 | ||
140 | --- a/bfd/bfd-in2.h | ||
141 | +++ b/bfd/bfd-in2.h | ||
142 | @@ -123,10 +123,10 @@ typedef struct bfd bfd; | ||
143 | #error No 64 bit integer type available | ||
144 | #endif /* ! defined (BFD_HOST_64_BIT) */ | ||
145 | |||
146 | -typedef BFD_HOST_U_64_BIT bfd_vma; | ||
147 | -typedef BFD_HOST_64_BIT bfd_signed_vma; | ||
148 | -typedef BFD_HOST_U_64_BIT bfd_size_type; | ||
149 | -typedef BFD_HOST_U_64_BIT symvalue; | ||
150 | +typedef uint64_t bfd_vma; | ||
151 | +typedef int64_t bfd_signed_vma; | ||
152 | +typedef uint64_t bfd_size_type; | ||
153 | +typedef uint64_t symvalue; | ||
154 | |||
155 | #if BFD_HOST_64BIT_LONG | ||
156 | #define BFD_VMA_FMT "l" | ||
157 | @@ -454,10 +454,10 @@ extern bool bfd_record_phdr | ||
158 | |||
159 | /* Byte swapping routines. */ | ||
160 | |||
161 | -bfd_uint64_t bfd_getb64 (const void *); | ||
162 | -bfd_uint64_t bfd_getl64 (const void *); | ||
163 | -bfd_int64_t bfd_getb_signed_64 (const void *); | ||
164 | -bfd_int64_t bfd_getl_signed_64 (const void *); | ||
165 | +uint64_t bfd_getb64 (const void *); | ||
166 | +uint64_t bfd_getl64 (const void *); | ||
167 | +int64_t bfd_getb_signed_64 (const void *); | ||
168 | +int64_t bfd_getl_signed_64 (const void *); | ||
169 | bfd_vma bfd_getb32 (const void *); | ||
170 | bfd_vma bfd_getl32 (const void *); | ||
171 | bfd_signed_vma bfd_getb_signed_32 (const void *); | ||
172 | @@ -466,8 +466,8 @@ bfd_vma bfd_getb16 (const void *); | ||
173 | bfd_vma bfd_getl16 (const void *); | ||
174 | bfd_signed_vma bfd_getb_signed_16 (const void *); | ||
175 | bfd_signed_vma bfd_getl_signed_16 (const void *); | ||
176 | -void bfd_putb64 (bfd_uint64_t, void *); | ||
177 | -void bfd_putl64 (bfd_uint64_t, void *); | ||
178 | +void bfd_putb64 (uint64_t, void *); | ||
179 | +void bfd_putl64 (uint64_t, void *); | ||
180 | void bfd_putb32 (bfd_vma, void *); | ||
181 | void bfd_putl32 (bfd_vma, void *); | ||
182 | void bfd_putb24 (bfd_vma, void *); | ||
183 | @@ -477,8 +477,8 @@ void bfd_putl16 (bfd_vma, void *); | ||
184 | |||
185 | /* Byte swapping routines which take size and endiannes as arguments. */ | ||
186 | |||
187 | -bfd_uint64_t bfd_get_bits (const void *, int, bool); | ||
188 | -void bfd_put_bits (bfd_uint64_t, void *, int, bool); | ||
189 | +uint64_t bfd_get_bits (const void *, int, bool); | ||
190 | +void bfd_put_bits (uint64_t, void *, int, bool); | ||
191 | |||
192 | |||
193 | /* mmap hacks */ | ||
194 | @@ -7416,9 +7416,9 @@ typedef struct bfd_target | ||
195 | /* Entries for byte swapping for data. These are different from the | ||
196 | other entry points, since they don't take a BFD as the first argument. | ||
197 | Certain other handlers could do the same. */ | ||
198 | - bfd_uint64_t (*bfd_getx64) (const void *); | ||
199 | - bfd_int64_t (*bfd_getx_signed_64) (const void *); | ||
200 | - void (*bfd_putx64) (bfd_uint64_t, void *); | ||
201 | + uint64_t (*bfd_getx64) (const void *); | ||
202 | + int64_t (*bfd_getx_signed_64) (const void *); | ||
203 | + void (*bfd_putx64) (uint64_t, void *); | ||
204 | bfd_vma (*bfd_getx32) (const void *); | ||
205 | bfd_signed_vma (*bfd_getx_signed_32) (const void *); | ||
206 | void (*bfd_putx32) (bfd_vma, void *); | ||
207 | @@ -7427,9 +7427,9 @@ typedef struct bfd_target | ||
208 | void (*bfd_putx16) (bfd_vma, void *); | ||
209 | |||
210 | /* Byte swapping for the headers. */ | ||
211 | - bfd_uint64_t (*bfd_h_getx64) (const void *); | ||
212 | - bfd_int64_t (*bfd_h_getx_signed_64) (const void *); | ||
213 | - void (*bfd_h_putx64) (bfd_uint64_t, void *); | ||
214 | + uint64_t (*bfd_h_getx64) (const void *); | ||
215 | + int64_t (*bfd_h_getx_signed_64) (const void *); | ||
216 | + void (*bfd_h_putx64) (uint64_t, void *); | ||
217 | bfd_vma (*bfd_h_getx32) (const void *); | ||
218 | bfd_signed_vma (*bfd_h_getx_signed_32) (const void *); | ||
219 | void (*bfd_h_putx32) (bfd_vma, void *); | ||
220 | diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c | ||
221 | index 8819187ab42..48ce5c0516b 100644 | ||
222 | --- a/bfd/coff-rs6000.c | ||
223 | +++ b/bfd/coff-rs6000.c | ||
224 | @@ -1890,18 +1890,12 @@ xcoff_write_armap_old (bfd *abfd, unsigned int elength ATTRIBUTE_UNUSED, | ||
225 | } | ||
226 | |||
227 | static char buff20[XCOFFARMAGBIG_ELEMENT_SIZE + 1]; | ||
228 | -#if BFD_HOST_64BIT_LONG | ||
229 | -#define FMT20 "%-20ld" | ||
230 | -#elif defined (__MSVCRT__) | ||
231 | -#define FMT20 "%-20I64d" | ||
232 | -#else | ||
233 | -#define FMT20 "%-20lld" | ||
234 | -#endif | ||
235 | +#define FMT20 "%-20" PRId64 | ||
236 | #define FMT12 "%-12d" | ||
237 | #define FMT12_OCTAL "%-12o" | ||
238 | #define FMT4 "%-4d" | ||
239 | #define PRINT20(d, v) \ | ||
240 | - sprintf (buff20, FMT20, (bfd_uint64_t)(v)), \ | ||
241 | + sprintf (buff20, FMT20, (uint64_t) (v)), \ | ||
242 | memcpy ((void *) (d), buff20, 20) | ||
243 | |||
244 | #define PRINT12(d, v) \ | ||
245 | diff --git a/bfd/coff-x86_64.c b/bfd/coff-x86_64.c | ||
246 | index e8e16d3ce4b..cf339c93215 100644 | ||
247 | --- a/bfd/coff-x86_64.c | ||
248 | +++ b/bfd/coff-x86_64.c | ||
249 | @@ -201,7 +201,7 @@ coff_amd64_reloc (bfd *abfd, | ||
250 | |||
251 | case 4: | ||
252 | { | ||
253 | - bfd_uint64_t x = bfd_get_64 (abfd, addr); | ||
254 | + uint64_t x = bfd_get_64 (abfd, addr); | ||
255 | DOIT (x); | ||
256 | bfd_put_64 (abfd, x, addr); | ||
257 | } | ||
258 | diff --git a/bfd/cpu-ia64-opc.c b/bfd/cpu-ia64-opc.c | ||
259 | index e2b5c2694b6..01e3c3f476a 100644 | ||
260 | --- a/bfd/cpu-ia64-opc.c | ||
261 | +++ b/bfd/cpu-ia64-opc.c | ||
262 | @@ -99,14 +99,14 @@ ins_immu (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) | ||
263 | static const char* | ||
264 | ext_immu (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) | ||
265 | { | ||
266 | - BFD_HOST_U_64_BIT value = 0; | ||
267 | + uint64_t value = 0; | ||
268 | int i, bits = 0, total = 0; | ||
269 | |||
270 | for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i) | ||
271 | { | ||
272 | bits = self->field[i].bits; | ||
273 | value |= ((code >> self->field[i].shift) | ||
274 | - & ((((BFD_HOST_U_64_BIT) 1) << bits) - 1)) << total; | ||
275 | + & (((uint64_t) 1 << bits) - 1)) << total; | ||
276 | total += bits; | ||
277 | } | ||
278 | *valuep = value; | ||
279 | @@ -161,7 +161,7 @@ static const char* | ||
280 | ins_imms_scaled (const struct ia64_operand *self, ia64_insn value, | ||
281 | ia64_insn *code, int scale) | ||
282 | { | ||
283 | - BFD_HOST_64_BIT svalue = value, sign_bit = 0; | ||
284 | + int64_t svalue = value, sign_bit = 0; | ||
285 | ia64_insn new_insn = 0; | ||
286 | int i; | ||
287 | |||
288 | @@ -186,17 +186,17 @@ ext_imms_scaled (const struct ia64_operand *self, ia64_insn code, | ||
289 | ia64_insn *valuep, int scale) | ||
290 | { | ||
291 | int i, bits = 0, total = 0; | ||
292 | - BFD_HOST_U_64_BIT val = 0, sign; | ||
293 | + uint64_t val = 0, sign; | ||
294 | |||
295 | for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i) | ||
296 | { | ||
297 | bits = self->field[i].bits; | ||
298 | val |= ((code >> self->field[i].shift) | ||
299 | - & ((((BFD_HOST_U_64_BIT) 1) << bits) - 1)) << total; | ||
300 | + & (((uint64_t) 1 << bits) - 1)) << total; | ||
301 | total += bits; | ||
302 | } | ||
303 | /* sign extend: */ | ||
304 | - sign = (BFD_HOST_U_64_BIT) 1 << (total - 1); | ||
305 | + sign = (uint64_t) 1 << (total - 1); | ||
306 | val = (val ^ sign) - sign; | ||
307 | |||
308 | *valuep = val << scale; | ||
309 | @@ -312,7 +312,7 @@ static const char* | ||
310 | ins_cnt (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) | ||
311 | { | ||
312 | --value; | ||
313 | - if (value >= ((BFD_HOST_U_64_BIT) 1) << self->field[0].bits) | ||
314 | + if (value >= (uint64_t) 1 << self->field[0].bits) | ||
315 | return "count out of range"; | ||
316 | |||
317 | *code |= value << self->field[0].shift; | ||
318 | @@ -323,7 +323,7 @@ static const char* | ||
319 | ext_cnt (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) | ||
320 | { | ||
321 | *valuep = ((code >> self->field[0].shift) | ||
322 | - & ((((BFD_HOST_U_64_BIT) 1) << self->field[0].bits) - 1)) + 1; | ||
323 | + & (((uint64_t) 1 << self->field[0].bits) - 1)) + 1; | ||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | @@ -421,8 +421,8 @@ ext_strd5b (const struct ia64_operand *self, ia64_insn code, | ||
328 | static const char* | ||
329 | ins_inc3 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) | ||
330 | { | ||
331 | - BFD_HOST_64_BIT val = value; | ||
332 | - BFD_HOST_U_64_BIT sign = 0; | ||
333 | + int64_t val = value; | ||
334 | + uint64_t sign = 0; | ||
335 | |||
336 | if (val < 0) | ||
337 | { | ||
338 | @@ -444,7 +444,7 @@ ins_inc3 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code) | ||
339 | static const char* | ||
340 | ext_inc3 (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep) | ||
341 | { | ||
342 | - BFD_HOST_64_BIT val; | ||
343 | + int64_t val; | ||
344 | int negate; | ||
345 | |||
346 | val = (code >> self->field[0].shift) & 0x7; | ||
347 | diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c | ||
348 | index 45e286754e4..6a728fc38b0 100644 | ||
349 | --- a/bfd/dwarf2.c | ||
350 | +++ b/bfd/dwarf2.c | ||
351 | @@ -63,8 +63,8 @@ struct attribute | ||
352 | { | ||
353 | char *str; | ||
354 | struct dwarf_block *blk; | ||
355 | - bfd_uint64_t val; | ||
356 | - bfd_int64_t sval; | ||
357 | + uint64_t val; | ||
358 | + int64_t sval; | ||
359 | } | ||
360 | u; | ||
361 | }; | ||
362 | @@ -632,12 +632,12 @@ lookup_info_hash_table (struct info_hash_table *hash_table, const char *key) | ||
363 | the located section does not contain at least OFFSET bytes. */ | ||
364 | |||
365 | static bool | ||
366 | -read_section (bfd * abfd, | ||
367 | +read_section (bfd *abfd, | ||
368 | const struct dwarf_debug_section *sec, | ||
369 | - asymbol ** syms, | ||
370 | - bfd_uint64_t offset, | ||
371 | - bfd_byte ** section_buffer, | ||
372 | - bfd_size_type * section_size) | ||
373 | + asymbol **syms, | ||
374 | + uint64_t offset, | ||
375 | + bfd_byte **section_buffer, | ||
376 | + bfd_size_type *section_size) | ||
377 | { | ||
378 | const char *section_name = sec->uncompressed_name; | ||
379 | bfd_byte *contents = *section_buffer; | ||
380 | @@ -848,7 +848,7 @@ read_indirect_string (struct comp_unit *unit, | ||
381 | bfd_byte **ptr, | ||
382 | bfd_byte *buf_end) | ||
383 | { | ||
384 | - bfd_uint64_t offset; | ||
385 | + uint64_t offset; | ||
386 | struct dwarf2_debug *stash = unit->stash; | ||
387 | struct dwarf2_debug_file *file = unit->file; | ||
388 | char *str; | ||
389 | @@ -882,7 +882,7 @@ read_indirect_line_string (struct comp_unit *unit, | ||
390 | bfd_byte **ptr, | ||
391 | bfd_byte *buf_end) | ||
392 | { | ||
393 | - bfd_uint64_t offset; | ||
394 | + uint64_t offset; | ||
395 | struct dwarf2_debug *stash = unit->stash; | ||
396 | struct dwarf2_debug_file *file = unit->file; | ||
397 | char *str; | ||
398 | @@ -919,7 +919,7 @@ read_alt_indirect_string (struct comp_unit *unit, | ||
399 | bfd_byte **ptr, | ||
400 | bfd_byte *buf_end) | ||
401 | { | ||
402 | - bfd_uint64_t offset; | ||
403 | + uint64_t offset; | ||
404 | struct dwarf2_debug *stash = unit->stash; | ||
405 | char *str; | ||
406 | |||
407 | @@ -975,8 +975,7 @@ read_alt_indirect_string (struct comp_unit *unit, | ||
408 | or NULL upon failure. */ | ||
409 | |||
410 | static bfd_byte * | ||
411 | -read_alt_indirect_ref (struct comp_unit * unit, | ||
412 | - bfd_uint64_t offset) | ||
413 | +read_alt_indirect_ref (struct comp_unit *unit, uint64_t offset) | ||
414 | { | ||
415 | struct dwarf2_debug *stash = unit->stash; | ||
416 | |||
417 | @@ -1012,7 +1011,7 @@ read_alt_indirect_ref (struct comp_unit * unit, | ||
418 | return stash->alt.dwarf_info_buffer + offset; | ||
419 | } | ||
420 | |||
421 | -static bfd_uint64_t | ||
422 | +static uint64_t | ||
423 | read_address (struct comp_unit *unit, bfd_byte **ptr, bfd_byte *buf_end) | ||
424 | { | ||
425 | bfd_byte *buf = *ptr; | ||
426 | @@ -1131,7 +1130,7 @@ del_abbrev (void *p) | ||
427 | in a hash table. */ | ||
428 | |||
429 | static struct abbrev_info** | ||
430 | -read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash, | ||
431 | +read_abbrevs (bfd *abfd, uint64_t offset, struct dwarf2_debug *stash, | ||
432 | struct dwarf2_debug_file *file) | ||
433 | { | ||
434 | struct abbrev_info **abbrevs; | ||
435 | @@ -1356,8 +1355,7 @@ is_addrx_form (enum dwarf_form form) | ||
436 | /* Returns the address in .debug_addr section using DW_AT_addr_base. | ||
437 | Used to implement DW_FORM_addrx*. */ | ||
438 | static bfd_vma | ||
439 | -read_indexed_address (bfd_uint64_t idx, | ||
440 | - struct comp_unit *unit) | ||
441 | +read_indexed_address (uint64_t idx, struct comp_unit *unit) | ||
442 | { | ||
443 | struct dwarf2_debug *stash = unit->stash; | ||
444 | struct dwarf2_debug_file *file = unit->file; | ||
445 | @@ -1383,8 +1381,7 @@ read_indexed_address (bfd_uint64_t idx, | ||
446 | /* Returns the string using DW_AT_str_offsets_base. | ||
447 | Used to implement DW_FORM_strx*. */ | ||
448 | static const char * | ||
449 | -read_indexed_string (bfd_uint64_t idx, | ||
450 | - struct comp_unit *unit) | ||
451 | +read_indexed_string (uint64_t idx, struct comp_unit *unit) | ||
452 | { | ||
453 | struct dwarf2_debug *stash = unit->stash; | ||
454 | struct dwarf2_debug_file *file = unit->file; | ||
455 | @@ -1717,39 +1714,39 @@ struct line_info_table | ||
456 | struct funcinfo | ||
457 | { | ||
458 | /* Pointer to previous function in list of all functions. */ | ||
459 | - struct funcinfo * prev_func; | ||
460 | + struct funcinfo *prev_func; | ||
461 | /* Pointer to function one scope higher. */ | ||
462 | - struct funcinfo * caller_func; | ||
463 | + struct funcinfo *caller_func; | ||
464 | /* Source location file name where caller_func inlines this func. */ | ||
465 | - char * caller_file; | ||
466 | + char *caller_file; | ||
467 | /* Source location file name. */ | ||
468 | - char * file; | ||
469 | + char *file; | ||
470 | /* Source location line number where caller_func inlines this func. */ | ||
471 | - int caller_line; | ||
472 | + int caller_line; | ||
473 | /* Source location line number. */ | ||
474 | - int line; | ||
475 | - int tag; | ||
476 | - bool is_linkage; | ||
477 | - const char * name; | ||
478 | - struct arange arange; | ||
479 | + int line; | ||
480 | + int tag; | ||
481 | + bool is_linkage; | ||
482 | + const char *name; | ||
483 | + struct arange arange; | ||
484 | /* Where the symbol is defined. */ | ||
485 | - asection * sec; | ||
486 | + asection *sec; | ||
487 | /* The offset of the funcinfo from the start of the unit. */ | ||
488 | - bfd_uint64_t unit_offset; | ||
489 | + uint64_t unit_offset; | ||
490 | }; | ||
491 | |||
492 | struct lookup_funcinfo | ||
493 | { | ||
494 | /* Function information corresponding to this lookup table entry. */ | ||
495 | - struct funcinfo * funcinfo; | ||
496 | + struct funcinfo *funcinfo; | ||
497 | |||
498 | /* The lowest address for this specific function. */ | ||
499 | - bfd_vma low_addr; | ||
500 | + bfd_vma low_addr; | ||
501 | |||
502 | /* The highest address of this function before the lookup table is sorted. | ||
503 | The highest address of all prior functions after the lookup table is | ||
504 | sorted, which is used for binary search. */ | ||
505 | - bfd_vma high_addr; | ||
506 | + bfd_vma high_addr; | ||
507 | /* Index of this function, used to ensure qsort is stable. */ | ||
508 | unsigned int idx; | ||
509 | }; | ||
510 | @@ -1759,7 +1756,7 @@ struct varinfo | ||
511 | /* Pointer to previous variable in list of all variables. */ | ||
512 | struct varinfo *prev_var; | ||
513 | /* The offset of the varinfo from the start of the unit. */ | ||
514 | - bfd_uint64_t unit_offset; | ||
515 | + uint64_t unit_offset; | ||
516 | /* Source location file name. */ | ||
517 | char *file; | ||
518 | /* Source location line number. */ | ||
519 | @@ -3335,7 +3332,7 @@ find_abstract_instance (struct comp_unit *unit, | ||
520 | bfd_byte *info_ptr_end; | ||
521 | unsigned int abbrev_number, i; | ||
522 | struct abbrev_info *abbrev; | ||
523 | - bfd_uint64_t die_ref = attr_ptr->u.val; | ||
524 | + uint64_t die_ref = attr_ptr->u.val; | ||
525 | struct attribute attr; | ||
526 | const char *name = NULL; | ||
527 | |||
528 | @@ -3549,7 +3546,7 @@ find_abstract_instance (struct comp_unit *unit, | ||
529 | |||
530 | static bool | ||
531 | read_ranges (struct comp_unit *unit, struct arange *arange, | ||
532 | - struct trie_node **trie_root, bfd_uint64_t offset) | ||
533 | + struct trie_node **trie_root, uint64_t offset) | ||
534 | { | ||
535 | bfd_byte *ranges_ptr; | ||
536 | bfd_byte *ranges_end; | ||
537 | @@ -3594,7 +3591,7 @@ read_ranges (struct comp_unit *unit, struct arange *arange, | ||
538 | |||
539 | static bool | ||
540 | read_rnglists (struct comp_unit *unit, struct arange *arange, | ||
541 | - struct trie_node **trie_root, bfd_uint64_t offset) | ||
542 | + struct trie_node **trie_root, uint64_t offset) | ||
543 | { | ||
544 | bfd_byte *rngs_ptr; | ||
545 | bfd_byte *rngs_end; | ||
546 | @@ -3675,7 +3672,7 @@ read_rnglists (struct comp_unit *unit, struct arange *arange, | ||
547 | |||
548 | static bool | ||
549 | read_rangelist (struct comp_unit *unit, struct arange *arange, | ||
550 | - struct trie_node **trie_root, bfd_uint64_t offset) | ||
551 | + struct trie_node **trie_root, uint64_t offset) | ||
552 | { | ||
553 | if (unit->version <= 4) | ||
554 | return read_ranges (unit, arange, trie_root, offset); | ||
555 | @@ -3684,7 +3681,7 @@ read_rangelist (struct comp_unit *unit, struct arange *arange, | ||
556 | } | ||
557 | |||
558 | static struct funcinfo * | ||
559 | -lookup_func_by_offset (bfd_uint64_t offset, struct funcinfo * table) | ||
560 | +lookup_func_by_offset (uint64_t offset, struct funcinfo * table) | ||
561 | { | ||
562 | for (; table != NULL; table = table->prev_func) | ||
563 | if (table->unit_offset == offset) | ||
564 | @@ -3693,7 +3690,7 @@ lookup_func_by_offset (bfd_uint64_t offset, struct funcinfo * table) | ||
565 | } | ||
566 | |||
567 | static struct varinfo * | ||
568 | -lookup_var_by_offset (bfd_uint64_t offset, struct varinfo * table) | ||
569 | +lookup_var_by_offset (uint64_t offset, struct varinfo * table) | ||
570 | { | ||
571 | while (table) | ||
572 | { | ||
573 | @@ -3775,7 +3772,7 @@ scan_unit_for_symbols (struct comp_unit *unit) | ||
574 | struct abbrev_info *abbrev; | ||
575 | struct funcinfo *func; | ||
576 | struct varinfo *var; | ||
577 | - bfd_uint64_t current_offset; | ||
578 | + uint64_t current_offset; | ||
579 | |||
580 | /* PR 17512: file: 9f405d9d. */ | ||
581 | if (info_ptr >= info_ptr_end) | ||
582 | @@ -3909,7 +3906,7 @@ scan_unit_for_symbols (struct comp_unit *unit) | ||
583 | bfd_vma low_pc = 0; | ||
584 | bfd_vma high_pc = 0; | ||
585 | bool high_pc_relative = false; | ||
586 | - bfd_uint64_t current_offset; | ||
587 | + uint64_t current_offset; | ||
588 | |||
589 | /* PR 17512: file: 9f405d9d. */ | ||
590 | if (info_ptr >= info_ptr_end) | ||
591 | @@ -4259,7 +4256,7 @@ parse_comp_unit (struct dwarf2_debug *stash, | ||
592 | { | ||
593 | struct comp_unit* unit; | ||
594 | unsigned int version; | ||
595 | - bfd_uint64_t abbrev_offset = 0; | ||
596 | + uint64_t abbrev_offset = 0; | ||
597 | /* Initialize it just to avoid a GCC false warning. */ | ||
598 | unsigned int addr_size = -1; | ||
599 | struct abbrev_info** abbrevs; | ||
600 | diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c | ||
601 | index c868707347c..5bc78d523ea 100644 | ||
602 | --- a/bfd/elf32-score.c | ||
603 | +++ b/bfd/elf32-score.c | ||
604 | @@ -230,14 +230,14 @@ static bfd_vma | ||
605 | score3_bfd_getl48 (const void *p) | ||
606 | { | ||
607 | const bfd_byte *addr = p; | ||
608 | - bfd_uint64_t v; | ||
609 | - | ||
610 | - v = (bfd_uint64_t) addr[4]; | ||
611 | - v |= (bfd_uint64_t) addr[5] << 8; | ||
612 | - v |= (bfd_uint64_t) addr[2] << 16; | ||
613 | - v |= (bfd_uint64_t) addr[3] << 24; | ||
614 | - v |= (bfd_uint64_t) addr[0] << 32; | ||
615 | - v |= (bfd_uint64_t) addr[1] << 40; | ||
616 | + uint64_t v; | ||
617 | + | ||
618 | + v = (uint64_t) addr[4]; | ||
619 | + v |= (uint64_t) addr[5] << 8; | ||
620 | + v |= (uint64_t) addr[2] << 16; | ||
621 | + v |= (uint64_t) addr[3] << 24; | ||
622 | + v |= (uint64_t) addr[0] << 32; | ||
623 | + v |= (uint64_t) addr[1] << 40; | ||
624 | return v; | ||
625 | } | ||
626 | |||
627 | diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c | ||
628 | index 59cc6b6fe85..4d8f98550a3 100644 | ||
629 | --- a/bfd/elf64-ia64-vms.c | ||
630 | +++ b/bfd/elf64-ia64-vms.c | ||
631 | @@ -179,7 +179,7 @@ struct elf64_ia64_vms_obj_tdata | ||
632 | struct elf_obj_tdata root; | ||
633 | |||
634 | /* Ident for shared library. */ | ||
635 | - bfd_uint64_t ident; | ||
636 | + uint64_t ident; | ||
637 | |||
638 | /* Used only during link: offset in the .fixups section for this bfd. */ | ||
639 | bfd_vma fixups_off; | ||
640 | @@ -2791,7 +2791,7 @@ elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, | ||
641 | if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_IDENT, 0)) | ||
642 | return false; | ||
643 | if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_LINKTIME, | ||
644 | - (((bfd_uint64_t)time_hi) << 32) | ||
645 | + ((uint64_t) time_hi << 32) | ||
646 | + time_lo)) | ||
647 | return false; | ||
648 | |||
649 | @@ -4720,7 +4720,7 @@ elf64_vms_close_and_cleanup (bfd *abfd) | ||
650 | if ((isize & 7) != 0) | ||
651 | { | ||
652 | int ishort = 8 - (isize & 7); | ||
653 | - bfd_uint64_t pad = 0; | ||
654 | + uint64_t pad = 0; | ||
655 | |||
656 | bfd_seek (abfd, isize, SEEK_SET); | ||
657 | bfd_bwrite (&pad, ishort, abfd); | ||
658 | @@ -4853,7 +4853,7 @@ elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) | ||
659 | bed->s->swap_dyn_in (abfd, extdyn, &dyn); | ||
660 | if (dyn.d_tag == DT_IA_64_VMS_IDENT) | ||
661 | { | ||
662 | - bfd_uint64_t tagv = dyn.d_un.d_val; | ||
663 | + uint64_t tagv = dyn.d_un.d_val; | ||
664 | elf_ia64_vms_ident (abfd) = tagv; | ||
665 | break; | ||
666 | } | ||
667 | diff --git a/bfd/elflink.c b/bfd/elflink.c | ||
668 | index 96eb36aa5bf..fc3a335c72d 100644 | ||
669 | --- a/bfd/elflink.c | ||
670 | +++ b/bfd/elflink.c | ||
671 | @@ -6354,15 +6354,11 @@ compute_bucket_count (struct bfd_link_info *info ATTRIBUTE_UNUSED, | ||
672 | size_t best_size = 0; | ||
673 | unsigned long int i; | ||
674 | |||
675 | - /* We have a problem here. The following code to optimize the table | ||
676 | - size requires an integer type with more the 32 bits. If | ||
677 | - BFD_HOST_U_64_BIT is set we know about such a type. */ | ||
678 | -#ifdef BFD_HOST_U_64_BIT | ||
679 | if (info->optimize) | ||
680 | { | ||
681 | size_t minsize; | ||
682 | size_t maxsize; | ||
683 | - BFD_HOST_U_64_BIT best_chlen = ~((BFD_HOST_U_64_BIT) 0); | ||
684 | + uint64_t best_chlen = ~((uint64_t) 0); | ||
685 | bfd *dynobj = elf_hash_table (info)->dynobj; | ||
686 | size_t dynsymcount = elf_hash_table (info)->dynsymcount; | ||
687 | const struct elf_backend_data *bed = get_elf_backend_data (dynobj); | ||
688 | @@ -6399,7 +6395,7 @@ compute_bucket_count (struct bfd_link_info *info ATTRIBUTE_UNUSED, | ||
689 | for (i = minsize; i < maxsize; ++i) | ||
690 | { | ||
691 | /* Walk through the array of hashcodes and count the collisions. */ | ||
692 | - BFD_HOST_U_64_BIT max; | ||
693 | + uint64_t max; | ||
694 | unsigned long int j; | ||
695 | unsigned long int fact; | ||
696 | |||
697 | @@ -6464,11 +6460,7 @@ compute_bucket_count (struct bfd_link_info *info ATTRIBUTE_UNUSED, | ||
698 | free (counts); | ||
699 | } | ||
700 | else | ||
701 | -#endif /* defined (BFD_HOST_U_64_BIT) */ | ||
702 | { | ||
703 | - /* This is the fallback solution if no 64bit type is available or if we | ||
704 | - are not supposed to spend much time on optimizations. We select the | ||
705 | - bucket count using a fixed set of numbers. */ | ||
706 | for (i = 0; elf_buckets[i] != 0; i++) | ||
707 | { | ||
708 | best_size = elf_buckets[i]; | ||
709 | @@ -9354,7 +9346,6 @@ ext32b_r_offset (const void *p) | ||
710 | return aval; | ||
711 | } | ||
712 | |||
713 | -#ifdef BFD_HOST_64_BIT | ||
714 | static bfd_vma | ||
715 | ext64l_r_offset (const void *p) | ||
716 | { | ||
717 | @@ -9398,7 +9389,6 @@ ext64b_r_offset (const void *p) | ||
718 | | (uint64_t) a->c[7]); | ||
719 | return aval; | ||
720 | } | ||
721 | -#endif | ||
722 | |||
723 | /* When performing a relocatable link, the input relocations are | ||
724 | preserved. But, if they reference global symbols, the indices | ||
725 | @@ -9502,13 +9492,11 @@ elf_link_adjust_relocs (bfd *abfd, | ||
726 | } | ||
727 | else | ||
728 | { | ||
729 | -#ifdef BFD_HOST_64_BIT | ||
730 | if (abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE) | ||
731 | ext_r_off = ext64l_r_offset; | ||
732 | else if (abfd->xvec->header_byteorder == BFD_ENDIAN_BIG) | ||
733 | ext_r_off = ext64b_r_offset; | ||
734 | else | ||
735 | -#endif | ||
736 | abort (); | ||
737 | } | ||
738 | |||
739 | diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c | ||
740 | index c126adf6890..a108324ca39 100644 | ||
741 | --- a/bfd/elfxx-ia64.c | ||
742 | +++ b/bfd/elfxx-ia64.c | ||
743 | @@ -555,11 +555,7 @@ ia64_elf_install_value (bfd_byte *hit_addr, bfd_vma v, unsigned int r_type) | ||
744 | enum ia64_opnd opnd; | ||
745 | const char *err; | ||
746 | size_t size = 8; | ||
747 | -#ifdef BFD_HOST_U_64_BIT | ||
748 | - BFD_HOST_U_64_BIT val = (BFD_HOST_U_64_BIT) v; | ||
749 | -#else | ||
750 | - bfd_vma val = v; | ||
751 | -#endif | ||
752 | + uint64_t val = v; | ||
753 | |||
754 | opnd = IA64_OPND_NIL; | ||
755 | switch (r_type) | ||
756 | diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c | ||
757 | index acfa5f69a95..d87af955838 100644 | ||
758 | --- a/bfd/hppabsd-core.c | ||
759 | +++ b/bfd/hppabsd-core.c | ||
760 | @@ -213,9 +213,9 @@ swap_abort (void) | ||
761 | #define NO_GET ((bfd_vma (*) (const void *)) swap_abort) | ||
762 | #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) | ||
763 | #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) | ||
764 | -#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) | ||
765 | -#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) | ||
766 | -#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) | ||
767 | +#define NO_GET64 ((uint64_t (*) (const void *)) swap_abort) | ||
768 | +#define NO_PUT64 ((void (*) (uint64_t, void *)) swap_abort) | ||
769 | +#define NO_GETS64 ((int64_t (*) (const void *)) swap_abort) | ||
770 | |||
771 | const bfd_target core_hppabsd_vec = | ||
772 | { | ||
773 | diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c | ||
774 | index 4f03b84909a..654532c6bb9 100644 | ||
775 | --- a/bfd/hpux-core.c | ||
776 | +++ b/bfd/hpux-core.c | ||
777 | @@ -362,9 +362,9 @@ swap_abort (void) | ||
778 | #define NO_GET ((bfd_vma (*) (const void *)) swap_abort) | ||
779 | #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) | ||
780 | #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) | ||
781 | -#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) | ||
782 | -#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) | ||
783 | -#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) | ||
784 | +#define NO_GET64 ((uint64_t (*) (const void *)) swap_abort) | ||
785 | +#define NO_PUT64 ((void (*) (uint64_t, void *)) swap_abort) | ||
786 | +#define NO_GETS64 ((int64_t (*) (const void *)) swap_abort) | ||
787 | |||
788 | const bfd_target core_hpux_vec = | ||
789 | { | ||
790 | diff --git a/bfd/irix-core.c b/bfd/irix-core.c | ||
791 | index 694fe2e2e07..b12aef9ce8b 100644 | ||
792 | --- a/bfd/irix-core.c | ||
793 | +++ b/bfd/irix-core.c | ||
794 | @@ -275,9 +275,9 @@ swap_abort(void) | ||
795 | #define NO_GET ((bfd_vma (*) (const void *)) swap_abort) | ||
796 | #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) | ||
797 | #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) | ||
798 | -#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) | ||
799 | -#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) | ||
800 | -#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) | ||
801 | +#define NO_GET64 ((uint64_t (*) (const void *)) swap_abort) | ||
802 | +#define NO_PUT64 ((void (*) (uint64_t, void *)) swap_abort) | ||
803 | +#define NO_GETS64 ((int64_t (*) (const void *)) swap_abort) | ||
804 | |||
805 | const bfd_target core_irix_vec = | ||
806 | { | ||
807 | diff --git a/bfd/libbfd.c b/bfd/libbfd.c | ||
808 | index 2781671ddba..d33f3416206 100644 | ||
809 | --- a/bfd/libbfd.c | ||
810 | +++ b/bfd/libbfd.c | ||
811 | @@ -617,7 +617,7 @@ DESCRIPTION | ||
812 | #define COERCE16(x) (((bfd_vma) (x) ^ 0x8000) - 0x8000) | ||
813 | #define COERCE32(x) (((bfd_vma) (x) ^ 0x80000000) - 0x80000000) | ||
814 | #define COERCE64(x) \ | ||
815 | - (((bfd_uint64_t) (x) ^ ((bfd_uint64_t) 1 << 63)) - ((bfd_uint64_t) 1 << 63)) | ||
816 | + (((uint64_t) (x) ^ ((uint64_t) 1 << 63)) - ((uint64_t) 1 << 63)) | ||
817 | |||
818 | bfd_vma | ||
819 | bfd_getb16 (const void *p) | ||
820 | @@ -757,12 +757,11 @@ bfd_getl_signed_32 (const void *p) | ||
821 | return COERCE32 (v); | ||
822 | } | ||
823 | |||
824 | -bfd_uint64_t | ||
825 | -bfd_getb64 (const void *p ATTRIBUTE_UNUSED) | ||
826 | +uint64_t | ||
827 | +bfd_getb64 (const void *p) | ||
828 | { | ||
829 | -#ifdef BFD_HOST_64_BIT | ||
830 | const bfd_byte *addr = (const bfd_byte *) p; | ||
831 | - bfd_uint64_t v; | ||
832 | + uint64_t v; | ||
833 | |||
834 | v = addr[0]; v <<= 8; | ||
835 | v |= addr[1]; v <<= 8; | ||
836 | @@ -774,18 +773,13 @@ bfd_getb64 (const void *p ATTRIBUTE_UNUSED) | ||
837 | v |= addr[7]; | ||
838 | |||
839 | return v; | ||
840 | -#else | ||
841 | - BFD_FAIL(); | ||
842 | - return 0; | ||
843 | -#endif | ||
844 | } | ||
845 | |||
846 | -bfd_uint64_t | ||
847 | -bfd_getl64 (const void *p ATTRIBUTE_UNUSED) | ||
848 | +uint64_t | ||
849 | +bfd_getl64 (const void *p) | ||
850 | { | ||
851 | -#ifdef BFD_HOST_64_BIT | ||
852 | const bfd_byte *addr = (const bfd_byte *) p; | ||
853 | - bfd_uint64_t v; | ||
854 | + uint64_t v; | ||
855 | |||
856 | v = addr[7]; v <<= 8; | ||
857 | v |= addr[6]; v <<= 8; | ||
858 | @@ -797,19 +791,13 @@ bfd_getl64 (const void *p ATTRIBUTE_UNUSED) | ||
859 | v |= addr[0]; | ||
860 | |||
861 | return v; | ||
862 | -#else | ||
863 | - BFD_FAIL(); | ||
864 | - return 0; | ||
865 | -#endif | ||
866 | - | ||
867 | } | ||
868 | |||
869 | -bfd_int64_t | ||
870 | -bfd_getb_signed_64 (const void *p ATTRIBUTE_UNUSED) | ||
871 | +int64_t | ||
872 | +bfd_getb_signed_64 (const void *p) | ||
873 | { | ||
874 | -#ifdef BFD_HOST_64_BIT | ||
875 | const bfd_byte *addr = (const bfd_byte *) p; | ||
876 | - bfd_uint64_t v; | ||
877 | + uint64_t v; | ||
878 | |||
879 | v = addr[0]; v <<= 8; | ||
880 | v |= addr[1]; v <<= 8; | ||
881 | @@ -821,18 +809,13 @@ bfd_getb_signed_64 (const void *p ATTRIBUTE_UNUSED) | ||
882 | v |= addr[7]; | ||
883 | |||
884 | return COERCE64 (v); | ||
885 | -#else | ||
886 | - BFD_FAIL(); | ||
887 | - return 0; | ||
888 | -#endif | ||
889 | } | ||
890 | |||
891 | -bfd_int64_t | ||
892 | -bfd_getl_signed_64 (const void *p ATTRIBUTE_UNUSED) | ||
893 | +int64_t | ||
894 | +bfd_getl_signed_64 (const void *p) | ||
895 | { | ||
896 | -#ifdef BFD_HOST_64_BIT | ||
897 | const bfd_byte *addr = (const bfd_byte *) p; | ||
898 | - bfd_uint64_t v; | ||
899 | + uint64_t v; | ||
900 | |||
901 | v = addr[7]; v <<= 8; | ||
902 | v |= addr[6]; v <<= 8; | ||
903 | @@ -844,10 +827,6 @@ bfd_getl_signed_64 (const void *p ATTRIBUTE_UNUSED) | ||
904 | v |= addr[0]; | ||
905 | |||
906 | return COERCE64 (v); | ||
907 | -#else | ||
908 | - BFD_FAIL(); | ||
909 | - return 0; | ||
910 | -#endif | ||
911 | } | ||
912 | |||
913 | void | ||
914 | @@ -871,9 +850,8 @@ bfd_putl32 (bfd_vma data, void *p) | ||
915 | } | ||
916 | |||
917 | void | ||
918 | -bfd_putb64 (bfd_uint64_t data ATTRIBUTE_UNUSED, void *p ATTRIBUTE_UNUSED) | ||
919 | +bfd_putb64 (uint64_t data, void *p) | ||
920 | { | ||
921 | -#ifdef BFD_HOST_64_BIT | ||
922 | bfd_byte *addr = (bfd_byte *) p; | ||
923 | addr[0] = (data >> (7*8)) & 0xff; | ||
924 | addr[1] = (data >> (6*8)) & 0xff; | ||
925 | @@ -883,15 +861,11 @@ bfd_putb64 (bfd_uint64_t data ATTRIBUTE_UNUSED, void *p ATTRIBUTE_UNUSED) | ||
926 | addr[5] = (data >> (2*8)) & 0xff; | ||
927 | addr[6] = (data >> (1*8)) & 0xff; | ||
928 | addr[7] = (data >> (0*8)) & 0xff; | ||
929 | -#else | ||
930 | - BFD_FAIL(); | ||
931 | -#endif | ||
932 | } | ||
933 | |||
934 | void | ||
935 | -bfd_putl64 (bfd_uint64_t data ATTRIBUTE_UNUSED, void *p ATTRIBUTE_UNUSED) | ||
936 | +bfd_putl64 (uint64_t data, void *p) | ||
937 | { | ||
938 | -#ifdef BFD_HOST_64_BIT | ||
939 | bfd_byte *addr = (bfd_byte *) p; | ||
940 | addr[7] = (data >> (7*8)) & 0xff; | ||
941 | addr[6] = (data >> (6*8)) & 0xff; | ||
942 | @@ -901,13 +875,10 @@ bfd_putl64 (bfd_uint64_t data ATTRIBUTE_UNUSED, void *p ATTRIBUTE_UNUSED) | ||
943 | addr[2] = (data >> (2*8)) & 0xff; | ||
944 | addr[1] = (data >> (1*8)) & 0xff; | ||
945 | addr[0] = (data >> (0*8)) & 0xff; | ||
946 | -#else | ||
947 | - BFD_FAIL(); | ||
948 | -#endif | ||
949 | } | ||
950 | |||
951 | void | ||
952 | -bfd_put_bits (bfd_uint64_t data, void *p, int bits, bool big_p) | ||
953 | +bfd_put_bits (uint64_t data, void *p, int bits, bool big_p) | ||
954 | { | ||
955 | bfd_byte *addr = (bfd_byte *) p; | ||
956 | int i; | ||
957 | @@ -926,11 +897,11 @@ bfd_put_bits (bfd_uint64_t data, void *p, int bits, bool big_p) | ||
958 | } | ||
959 | } | ||
960 | |||
961 | -bfd_uint64_t | ||
962 | +uint64_t | ||
963 | bfd_get_bits (const void *p, int bits, bool big_p) | ||
964 | { | ||
965 | const bfd_byte *addr = (const bfd_byte *) p; | ||
966 | - bfd_uint64_t data; | ||
967 | + uint64_t data; | ||
968 | int i; | ||
969 | int bytes; | ||
970 | |||
971 | diff --git a/bfd/mach-o.c b/bfd/mach-o.c | ||
972 | index e32b7873cef..9f3f1f13e4e 100644 | ||
973 | --- a/bfd/mach-o.c | ||
974 | +++ b/bfd/mach-o.c | ||
975 | @@ -4773,7 +4773,7 @@ bfd_mach_o_read_source_version (bfd *abfd, bfd_mach_o_load_command *command) | ||
976 | { | ||
977 | bfd_mach_o_source_version_command *cmd = &command->command.source_version; | ||
978 | struct mach_o_source_version_command_external raw; | ||
979 | - bfd_uint64_t ver; | ||
980 | + uint64_t ver; | ||
981 | |||
982 | if (command->len < sizeof (raw) + 8) | ||
983 | return false; | ||
984 | diff --git a/bfd/mach-o.h b/bfd/mach-o.h | ||
985 | index 5a068d8d970..f7418ad8d40 100644 | ||
986 | --- a/bfd/mach-o.h | ||
987 | +++ b/bfd/mach-o.h | ||
988 | @@ -545,8 +545,8 @@ bfd_mach_o_encryption_info_command; | ||
989 | |||
990 | typedef struct bfd_mach_o_main_command | ||
991 | { | ||
992 | - bfd_uint64_t entryoff; | ||
993 | - bfd_uint64_t stacksize; | ||
994 | + uint64_t entryoff; | ||
995 | + uint64_t stacksize; | ||
996 | } | ||
997 | bfd_mach_o_main_command; | ||
998 | |||
999 | @@ -563,8 +563,8 @@ bfd_mach_o_source_version_command; | ||
1000 | typedef struct bfd_mach_o_note_command | ||
1001 | { | ||
1002 | char data_owner[16]; | ||
1003 | - bfd_uint64_t offset; | ||
1004 | - bfd_uint64_t size; | ||
1005 | + uint64_t offset; | ||
1006 | + uint64_t size; | ||
1007 | } | ||
1008 | bfd_mach_o_note_command; | ||
1009 | |||
1010 | diff --git a/bfd/netbsd-core.c b/bfd/netbsd-core.c | ||
1011 | index cb215937da6..ffc8e50842c 100644 | ||
1012 | --- a/bfd/netbsd-core.c | ||
1013 | +++ b/bfd/netbsd-core.c | ||
1014 | @@ -257,9 +257,9 @@ swap_abort (void) | ||
1015 | #define NO_GET ((bfd_vma (*) (const void *)) swap_abort) | ||
1016 | #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) | ||
1017 | #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) | ||
1018 | -#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) | ||
1019 | -#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) | ||
1020 | -#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) | ||
1021 | +#define NO_GET64 ((uint64_t (*) (const void *)) swap_abort) | ||
1022 | +#define NO_PUT64 ((void (*) (uint64_t, void *)) swap_abort) | ||
1023 | +#define NO_GETS64 ((int64_t (*) (const void *)) swap_abort) | ||
1024 | |||
1025 | const bfd_target core_netbsd_vec = | ||
1026 | { | ||
1027 | diff --git a/bfd/osf-core.c b/bfd/osf-core.c | ||
1028 | index 09a04a07624..04434b2045c 100644 | ||
1029 | --- a/bfd/osf-core.c | ||
1030 | +++ b/bfd/osf-core.c | ||
1031 | @@ -169,9 +169,9 @@ swap_abort (void) | ||
1032 | #define NO_GET ((bfd_vma (*) (const void *)) swap_abort) | ||
1033 | #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) | ||
1034 | #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) | ||
1035 | -#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) | ||
1036 | -#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) | ||
1037 | -#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) | ||
1038 | +#define NO_GET64 ((uint64_t (*) (const void *)) swap_abort) | ||
1039 | +#define NO_PUT64 ((void (*) (uint64_t, void *)) swap_abort) | ||
1040 | +#define NO_GETS64 ((int64_t (*) (const void *)) swap_abort) | ||
1041 | |||
1042 | const bfd_target core_osf_vec = | ||
1043 | { | ||
1044 | diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c | ||
1045 | index 3d077d21200..c4afffbfb95 100644 | ||
1046 | --- a/bfd/ptrace-core.c | ||
1047 | +++ b/bfd/ptrace-core.c | ||
1048 | @@ -160,9 +160,9 @@ swap_abort (void) | ||
1049 | #define NO_GET ((bfd_vma (*) (const void *)) swap_abort) | ||
1050 | #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) | ||
1051 | #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) | ||
1052 | -#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) | ||
1053 | -#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) | ||
1054 | -#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) | ||
1055 | +#define NO_GET64 ((uint64_t (*) (const void *)) swap_abort) | ||
1056 | +#define NO_PUT64 ((void (*) (uint64_t, void *)) swap_abort) | ||
1057 | +#define NO_GETS64 ((int64_t (*) (const void *)) swap_abort) | ||
1058 | |||
1059 | const bfd_target core_ptrace_vec = | ||
1060 | { | ||
1061 | diff --git a/bfd/sco5-core.c b/bfd/sco5-core.c | ||
1062 | index d1f80c9079f..7807ac86a65 100644 | ||
1063 | --- a/bfd/sco5-core.c | ||
1064 | +++ b/bfd/sco5-core.c | ||
1065 | @@ -340,9 +340,9 @@ swap_abort (void) | ||
1066 | #define NO_GET ((bfd_vma (*) (const void *)) swap_abort) | ||
1067 | #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) | ||
1068 | #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) | ||
1069 | -#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) | ||
1070 | -#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) | ||
1071 | -#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) | ||
1072 | +#define NO_GET64 ((uint64_t (*) (const void *)) swap_abort) | ||
1073 | +#define NO_PUT64 ((void (*) (uint64_t, void *)) swap_abort) | ||
1074 | +#define NO_GETS64 ((int64_t (*) (const void *)) swap_abort) | ||
1075 | |||
1076 | const bfd_target core_sco5_vec = | ||
1077 | { | ||
1078 | diff --git a/bfd/targets.c b/bfd/targets.c | ||
1079 | index 05dd8236d91..f44b5c67724 100644 | ||
1080 | --- a/bfd/targets.c | ||
1081 | +++ b/bfd/targets.c | ||
1082 | @@ -226,9 +226,9 @@ DESCRIPTION | ||
1083 | . {* Entries for byte swapping for data. These are different from the | ||
1084 | . other entry points, since they don't take a BFD as the first argument. | ||
1085 | . Certain other handlers could do the same. *} | ||
1086 | -. bfd_uint64_t (*bfd_getx64) (const void *); | ||
1087 | -. bfd_int64_t (*bfd_getx_signed_64) (const void *); | ||
1088 | -. void (*bfd_putx64) (bfd_uint64_t, void *); | ||
1089 | +. uint64_t (*bfd_getx64) (const void *); | ||
1090 | +. int64_t (*bfd_getx_signed_64) (const void *); | ||
1091 | +. void (*bfd_putx64) (uint64_t, void *); | ||
1092 | . bfd_vma (*bfd_getx32) (const void *); | ||
1093 | . bfd_signed_vma (*bfd_getx_signed_32) (const void *); | ||
1094 | . void (*bfd_putx32) (bfd_vma, void *); | ||
1095 | @@ -237,9 +237,9 @@ DESCRIPTION | ||
1096 | . void (*bfd_putx16) (bfd_vma, void *); | ||
1097 | . | ||
1098 | . {* Byte swapping for the headers. *} | ||
1099 | -. bfd_uint64_t (*bfd_h_getx64) (const void *); | ||
1100 | -. bfd_int64_t (*bfd_h_getx_signed_64) (const void *); | ||
1101 | -. void (*bfd_h_putx64) (bfd_uint64_t, void *); | ||
1102 | +. uint64_t (*bfd_h_getx64) (const void *); | ||
1103 | +. int64_t (*bfd_h_getx_signed_64) (const void *); | ||
1104 | +. void (*bfd_h_putx64) (uint64_t, void *); | ||
1105 | . bfd_vma (*bfd_h_getx32) (const void *); | ||
1106 | . bfd_signed_vma (*bfd_h_getx_signed_32) (const void *); | ||
1107 | . void (*bfd_h_putx32) (bfd_vma, void *); | ||
1108 | diff --git a/bfd/trad-core.c b/bfd/trad-core.c | ||
1109 | index 92a279b6a72..8e9ee0d6667 100644 | ||
1110 | --- a/bfd/trad-core.c | ||
1111 | +++ b/bfd/trad-core.c | ||
1112 | @@ -249,9 +249,9 @@ swap_abort (void) | ||
1113 | #define NO_GET ((bfd_vma (*) (const void *)) swap_abort) | ||
1114 | #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort) | ||
1115 | #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort) | ||
1116 | -#define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort) | ||
1117 | -#define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort) | ||
1118 | -#define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort) | ||
1119 | +#define NO_GET64 ((uint64_t (*) (const void *)) swap_abort) | ||
1120 | +#define NO_PUT64 ((void (*) (uint64_t, void *)) swap_abort) | ||
1121 | +#define NO_GETS64 ((int64_t (*) (const void *)) swap_abort) | ||
1122 | |||
1123 | const bfd_target core_trad_vec = | ||
1124 | { | ||
1125 | diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c | ||
1126 | index 1129c98f0e2..fd0762811df 100644 | ||
1127 | --- a/bfd/vms-alpha.c | ||
1128 | +++ b/bfd/vms-alpha.c | ||
1129 | @@ -522,7 +522,7 @@ _bfd_vms_slurp_eisd (bfd *abfd, unsigned int offset) | ||
1130 | struct vms_eisd *eisd; | ||
1131 | unsigned int rec_size; | ||
1132 | unsigned int size; | ||
1133 | - bfd_uint64_t vaddr; | ||
1134 | + uint64_t vaddr; | ||
1135 | unsigned int flags; | ||
1136 | unsigned int vbn; | ||
1137 | char *name = NULL; | ||
1138 | diff --git a/binutils/nm.c b/binutils/nm.c | ||
1139 | index 60e4d850885..539c5688425 100644 | ||
1140 | --- a/binutils/nm.c | ||
1141 | +++ b/binutils/nm.c | ||
1142 | @@ -1557,29 +1557,15 @@ get_print_format (void) | ||
1143 | padding = "016"; | ||
1144 | } | ||
1145 | |||
1146 | - const char * length = "l"; | ||
1147 | - if (print_width == 64) | ||
1148 | - { | ||
1149 | -#if BFD_HOST_64BIT_LONG | ||
1150 | - ; | ||
1151 | -#elif BFD_HOST_64BIT_LONG_LONG | ||
1152 | -#ifndef __MSVCRT__ | ||
1153 | - length = "ll"; | ||
1154 | -#else | ||
1155 | - length = "I64"; | ||
1156 | -#endif | ||
1157 | -#endif | ||
1158 | - } | ||
1159 | - | ||
1160 | const char * radix = NULL; | ||
1161 | switch (print_radix) | ||
1162 | { | ||
1163 | - case 8: radix = "o"; break; | ||
1164 | - case 10: radix = "d"; break; | ||
1165 | - case 16: radix = "x"; break; | ||
1166 | + case 8: radix = PRIo64; break; | ||
1167 | + case 10: radix = PRId64; break; | ||
1168 | + case 16: radix = PRIx64; break; | ||
1169 | } | ||
1170 | |||
1171 | - return concat ("%", padding, length, radix, NULL); | ||
1172 | + return concat ("%", padding, radix, NULL); | ||
1173 | } | ||
1174 | |||
1175 | static void | ||
1176 | @@ -1874,33 +1860,8 @@ print_value (bfd *abfd ATTRIBUTE_UNUSED, bfd_vma val) | ||
1177 | switch (print_width) | ||
1178 | { | ||
1179 | case 32: | ||
1180 | - printf (print_format_string, (unsigned long) val); | ||
1181 | - break; | ||
1182 | - | ||
1183 | case 64: | ||
1184 | -#if BFD_HOST_64BIT_LONG || BFD_HOST_64BIT_LONG_LONG | ||
1185 | - printf (print_format_string, val); | ||
1186 | -#else | ||
1187 | - /* We have a 64 bit value to print, but the host is only 32 bit. */ | ||
1188 | - if (print_radix == 16) | ||
1189 | - bfd_fprintf_vma (abfd, stdout, val); | ||
1190 | - else | ||
1191 | - { | ||
1192 | - char buf[30]; | ||
1193 | - char *s; | ||
1194 | - | ||
1195 | - s = buf + sizeof buf; | ||
1196 | - *--s = '\0'; | ||
1197 | - while (val > 0) | ||
1198 | - { | ||
1199 | - *--s = (val % print_radix) + '0'; | ||
1200 | - val /= print_radix; | ||
1201 | - } | ||
1202 | - while ((buf + sizeof buf - 1) - s < 16) | ||
1203 | - *--s = '0'; | ||
1204 | - printf ("%s", s); | ||
1205 | - } | ||
1206 | -#endif | ||
1207 | + printf (print_format_string, (uint64_t) val); | ||
1208 | break; | ||
1209 | |||
1210 | default: | ||
1211 | diff --git a/binutils/od-macho.c b/binutils/od-macho.c | ||
1212 | index 56d448ac3bd..e91c87d2acf 100644 | ||
1213 | --- a/binutils/od-macho.c | ||
1214 | +++ b/binutils/od-macho.c | ||
1215 | @@ -283,15 +283,6 @@ bfd_mach_o_print_flags (const bfd_mach_o_xlat_name *table, | ||
1216 | printf ("-"); | ||
1217 | } | ||
1218 | |||
1219 | -/* Print a bfd_uint64_t, using a platform independent style. */ | ||
1220 | - | ||
1221 | -static void | ||
1222 | -printf_uint64 (bfd_uint64_t v) | ||
1223 | -{ | ||
1224 | - printf ("0x%08lx%08lx", | ||
1225 | - (unsigned long)((v >> 16) >> 16), (unsigned long)(v & 0xffffffffUL)); | ||
1226 | -} | ||
1227 | - | ||
1228 | static const char * | ||
1229 | bfd_mach_o_get_name_or_null (const bfd_mach_o_xlat_name *table, | ||
1230 | unsigned long val) | ||
1231 | @@ -1729,26 +1720,20 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd, | ||
1232 | } | ||
1233 | case BFD_MACH_O_LC_MAIN: | ||
1234 | { | ||
1235 | - bfd_mach_o_main_command *entry = &cmd->command.main; | ||
1236 | - printf (" entry offset: "); | ||
1237 | - printf_uint64 (entry->entryoff); | ||
1238 | - printf ("\n" | ||
1239 | - " stack size: "); | ||
1240 | - printf_uint64 (entry->stacksize); | ||
1241 | - printf ("\n"); | ||
1242 | - break; | ||
1243 | + bfd_mach_o_main_command *entry = &cmd->command.main; | ||
1244 | + printf (" entry offset: %#016" PRIx64 "\n" | ||
1245 | + " stack size: %#016" PRIx64 "\n", | ||
1246 | + entry->entryoff, entry->stacksize); | ||
1247 | + break; | ||
1248 | } | ||
1249 | case BFD_MACH_O_LC_NOTE: | ||
1250 | { | ||
1251 | - bfd_mach_o_note_command *note = &cmd->command.note; | ||
1252 | - printf (" data owner: %.16s\n", note->data_owner); | ||
1253 | - printf (" offset: "); | ||
1254 | - printf_uint64 (note->offset); | ||
1255 | - printf ("\n" | ||
1256 | - " size: "); | ||
1257 | - printf_uint64 (note->size); | ||
1258 | - printf ("\n"); | ||
1259 | - break; | ||
1260 | + bfd_mach_o_note_command *note = &cmd->command.note; | ||
1261 | + printf (" data owner: %.16s\n" | ||
1262 | + " offset: %#016" PRIx64 "\n" | ||
1263 | + " size: %#016" PRIx64 "\n", | ||
1264 | + note->data_owner, note->offset, note->size); | ||
1265 | + break; | ||
1266 | } | ||
1267 | case BFD_MACH_O_LC_BUILD_VERSION: | ||
1268 | dump_build_version (abfd, cmd); | ||
1269 | @@ -2013,14 +1998,11 @@ dump_obj_compact_unwind (bfd *abfd, | ||
1270 | { | ||
1271 | e = (struct mach_o_compact_unwind_64 *) p; | ||
1272 | |||
1273 | - putchar (' '); | ||
1274 | - printf_uint64 (bfd_get_64 (abfd, e->start)); | ||
1275 | - printf (" %08lx", (unsigned long)bfd_get_32 (abfd, e->length)); | ||
1276 | - putchar (' '); | ||
1277 | - printf_uint64 (bfd_get_64 (abfd, e->personality)); | ||
1278 | - putchar (' '); | ||
1279 | - printf_uint64 (bfd_get_64 (abfd, e->lsda)); | ||
1280 | - putchar ('\n'); | ||
1281 | + printf (" %#016" PRIx64 " %#08x %#016" PRIx64 " %#016" PRIx64 "\n", | ||
1282 | + (uint64_t) bfd_get_64 (abfd, e->start), | ||
1283 | + (unsigned int) bfd_get_32 (abfd, e->length), | ||
1284 | + (uint64_t) bfd_get_64 (abfd, e->personality), | ||
1285 | + (uint64_t) bfd_get_64 (abfd, e->lsda)); | ||
1286 | |||
1287 | printf (" encoding: "); | ||
1288 | dump_unwind_encoding (mdata, bfd_get_32 (abfd, e->encoding)); | ||
1289 | diff --git a/binutils/prdbg.c b/binutils/prdbg.c | ||
1290 | index d6cbab8578b..c1e41628d26 100644 | ||
1291 | --- a/binutils/prdbg.c | ||
1292 | +++ b/binutils/prdbg.c | ||
1293 | @@ -485,41 +485,12 @@ pop_type (struct pr_handle *info) | ||
1294 | static void | ||
1295 | print_vma (bfd_vma vma, char *buf, bool unsignedp, bool hexp) | ||
1296 | { | ||
1297 | - if (sizeof (vma) <= sizeof (unsigned long)) | ||
1298 | - { | ||
1299 | - if (hexp) | ||
1300 | - sprintf (buf, "0x%lx", (unsigned long) vma); | ||
1301 | - else if (unsignedp) | ||
1302 | - sprintf (buf, "%lu", (unsigned long) vma); | ||
1303 | - else | ||
1304 | - sprintf (buf, "%ld", (long) vma); | ||
1305 | - } | ||
1306 | -#if BFD_HOST_64BIT_LONG_LONG | ||
1307 | - else if (sizeof (vma) <= sizeof (unsigned long long)) | ||
1308 | - { | ||
1309 | -#ifndef __MSVCRT__ | ||
1310 | - if (hexp) | ||
1311 | - sprintf (buf, "0x%llx", (unsigned long long) vma); | ||
1312 | - else if (unsignedp) | ||
1313 | - sprintf (buf, "%llu", (unsigned long long) vma); | ||
1314 | - else | ||
1315 | - sprintf (buf, "%lld", (long long) vma); | ||
1316 | -#else | ||
1317 | - if (hexp) | ||
1318 | - sprintf (buf, "0x%I64x", (unsigned long long) vma); | ||
1319 | - else if (unsignedp) | ||
1320 | - sprintf (buf, "%I64u", (unsigned long long) vma); | ||
1321 | - else | ||
1322 | - sprintf (buf, "%I64d", (long long) vma); | ||
1323 | -#endif | ||
1324 | - } | ||
1325 | -#endif | ||
1326 | + if (hexp) | ||
1327 | + sprintf (buf, "%#" PRIx64, (uint64_t) vma); | ||
1328 | + else if (unsignedp) | ||
1329 | + sprintf (buf, "%" PRIu64, (uint64_t) vma); | ||
1330 | else | ||
1331 | - { | ||
1332 | - buf[0] = '0'; | ||
1333 | - buf[1] = 'x'; | ||
1334 | - sprintf_vma (buf + 2, vma); | ||
1335 | - } | ||
1336 | + sprintf (buf, "%" PRId64, (int64_t) vma); | ||
1337 | } | ||
1338 | |||
1339 | /* Start a new compilation unit. */ | ||
1340 | diff --git a/binutils/readelf.c b/binutils/readelf.c | ||
1341 | index c35bfc12366..4c0a2a34767 100644 | ||
1342 | --- a/binutils/readelf.c | ||
1343 | +++ b/binutils/readelf.c | ||
1344 | @@ -10729,7 +10729,7 @@ dynamic_section_parisc_val (Elf_Internal_Dyn * entry) | ||
1345 | /* Display a VMS time in a human readable format. */ | ||
1346 | |||
1347 | static void | ||
1348 | -print_vms_time (bfd_int64_t vmstime) | ||
1349 | +print_vms_time (int64_t vmstime) | ||
1350 | { | ||
1351 | struct tm *tm = NULL; | ||
1352 | time_t unxtime; | ||
1353 | @@ -20764,7 +20764,7 @@ print_ia64_vms_note (Elf_Internal_Note * pnote) | ||
1354 | /* FIXME: Generate an error if descsz > 8 ? */ | ||
1355 | |||
1356 | printf ("0x%016" BFD_VMA_FMT "x\n", | ||
1357 | - (bfd_vma) byte_get ((unsigned char *)pnote->descdata, 8)); | ||
1358 | + (bfd_vma) byte_get ((unsigned char *) pnote->descdata, 8)); | ||
1359 | break; | ||
1360 | |||
1361 | case NT_VMS_LINKTIME: | ||
1362 | @@ -20773,8 +20773,7 @@ print_ia64_vms_note (Elf_Internal_Note * pnote) | ||
1363 | goto desc_size_fail; | ||
1364 | /* FIXME: Generate an error if descsz > 8 ? */ | ||
1365 | |||
1366 | - print_vms_time | ||
1367 | - ((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata, 8)); | ||
1368 | + print_vms_time (byte_get ((unsigned char *) pnote->descdata, 8)); | ||
1369 | printf ("\n"); | ||
1370 | break; | ||
1371 | |||
1372 | @@ -20784,8 +20783,7 @@ print_ia64_vms_note (Elf_Internal_Note * pnote) | ||
1373 | goto desc_size_fail; | ||
1374 | /* FIXME: Generate an error if descsz > 8 ? */ | ||
1375 | |||
1376 | - print_vms_time | ||
1377 | - ((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata, 8)); | ||
1378 | + print_vms_time (byte_get ((unsigned char *) pnote->descdata, 8)); | ||
1379 | printf ("\n"); | ||
1380 | break; | ||
1381 | |||
1382 | @@ -20794,16 +20792,15 @@ print_ia64_vms_note (Elf_Internal_Note * pnote) | ||
1383 | goto desc_size_fail; | ||
1384 | |||
1385 | printf (_(" Major id: %u, minor id: %u\n"), | ||
1386 | - (unsigned) byte_get ((unsigned char *)pnote->descdata, 4), | ||
1387 | - (unsigned) byte_get ((unsigned char *)pnote->descdata + 4, 4)); | ||
1388 | + (unsigned) byte_get ((unsigned char *) pnote->descdata, 4), | ||
1389 | + (unsigned) byte_get ((unsigned char *) pnote->descdata + 4, 4)); | ||
1390 | printf (_(" Last modified : ")); | ||
1391 | - print_vms_time | ||
1392 | - ((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata + 8, 8)); | ||
1393 | + print_vms_time (byte_get ((unsigned char *) pnote->descdata + 8, 8)); | ||
1394 | printf (_("\n Link flags : ")); | ||
1395 | printf ("0x%016" BFD_VMA_FMT "x\n", | ||
1396 | - (bfd_vma) byte_get ((unsigned char *)pnote->descdata + 16, 8)); | ||
1397 | + (bfd_vma) byte_get ((unsigned char *) pnote->descdata + 16, 8)); | ||
1398 | printf (_(" Header flags: 0x%08x\n"), | ||
1399 | - (unsigned) byte_get ((unsigned char *)pnote->descdata + 24, 4)); | ||
1400 | + (unsigned) byte_get ((unsigned char *) pnote->descdata + 24, 4)); | ||
1401 | printf (_(" Image id : %.*s\n"), maxlen - 32, pnote->descdata + 32); | ||
1402 | break; | ||
1403 | #endif | ||
1404 | diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c | ||
1405 | index 1721097cfca..2e6d175482e 100644 | ||
1406 | --- a/gas/config/tc-arm.c | ||
1407 | +++ b/gas/config/tc-arm.c | ||
1408 | @@ -3565,7 +3565,7 @@ add_to_lit_pool (unsigned int nbytes) | ||
1409 | imm1 = inst.operands[1].imm; | ||
1410 | imm2 = (inst.operands[1].regisimm ? inst.operands[1].reg | ||
1411 | : inst.relocs[0].exp.X_unsigned ? 0 | ||
1412 | - : ((bfd_int64_t) inst.operands[1].imm) >> 32); | ||
1413 | + : (int64_t) inst.operands[1].imm >> 32); | ||
1414 | if (target_big_endian) | ||
1415 | { | ||
1416 | imm1 = imm2; | ||
1417 | @@ -8819,15 +8819,14 @@ neon_cmode_for_move_imm (unsigned immlo, unsigned immhi, int float_p, | ||
1418 | return FAIL; | ||
1419 | } | ||
1420 | |||
1421 | -#if defined BFD_HOST_64_BIT | ||
1422 | /* Returns TRUE if double precision value V may be cast | ||
1423 | to single precision without loss of accuracy. */ | ||
1424 | |||
1425 | static bool | ||
1426 | -is_double_a_single (bfd_uint64_t v) | ||
1427 | +is_double_a_single (uint64_t v) | ||
1428 | { | ||
1429 | int exp = (v >> 52) & 0x7FF; | ||
1430 | - bfd_uint64_t mantissa = v & 0xFFFFFFFFFFFFFULL; | ||
1431 | + uint64_t mantissa = v & 0xFFFFFFFFFFFFFULL; | ||
1432 | |||
1433 | return ((exp == 0 || exp == 0x7FF | ||
1434 | || (exp >= 1023 - 126 && exp <= 1023 + 127)) | ||
1435 | @@ -8838,11 +8837,11 @@ is_double_a_single (bfd_uint64_t v) | ||
1436 | (ignoring the least significant bits in exponent and mantissa). */ | ||
1437 | |||
1438 | static int | ||
1439 | -double_to_single (bfd_uint64_t v) | ||
1440 | +double_to_single (uint64_t v) | ||
1441 | { | ||
1442 | unsigned int sign = (v >> 63) & 1; | ||
1443 | int exp = (v >> 52) & 0x7FF; | ||
1444 | - bfd_uint64_t mantissa = v & 0xFFFFFFFFFFFFFULL; | ||
1445 | + uint64_t mantissa = v & 0xFFFFFFFFFFFFFULL; | ||
1446 | |||
1447 | if (exp == 0x7FF) | ||
1448 | exp = 0xFF; | ||
1449 | @@ -8865,7 +8864,6 @@ double_to_single (bfd_uint64_t v) | ||
1450 | mantissa >>= 29; | ||
1451 | return (sign << 31) | (exp << 23) | mantissa; | ||
1452 | } | ||
1453 | -#endif /* BFD_HOST_64_BIT */ | ||
1454 | |||
1455 | enum lit_type | ||
1456 | { | ||
1457 | @@ -8914,11 +8912,7 @@ move_or_literal_pool (int i, enum lit_type t, bool mode_3) | ||
1458 | if (inst.relocs[0].exp.X_op == O_constant | ||
1459 | || inst.relocs[0].exp.X_op == O_big) | ||
1460 | { | ||
1461 | -#if defined BFD_HOST_64_BIT | ||
1462 | - bfd_uint64_t v; | ||
1463 | -#else | ||
1464 | - valueT v; | ||
1465 | -#endif | ||
1466 | + uint64_t v; | ||
1467 | if (inst.relocs[0].exp.X_op == O_big) | ||
1468 | { | ||
1469 | LITTLENUM_TYPE w[X_PRECISION]; | ||
1470 | @@ -8933,7 +8927,6 @@ move_or_literal_pool (int i, enum lit_type t, bool mode_3) | ||
1471 | else | ||
1472 | l = generic_bignum; | ||
1473 | |||
1474 | -#if defined BFD_HOST_64_BIT | ||
1475 | v = l[3] & LITTLENUM_MASK; | ||
1476 | v <<= LITTLENUM_NUMBER_OF_BITS; | ||
1477 | v |= l[2] & LITTLENUM_MASK; | ||
1478 | @@ -8941,11 +8934,6 @@ move_or_literal_pool (int i, enum lit_type t, bool mode_3) | ||
1479 | v |= l[1] & LITTLENUM_MASK; | ||
1480 | v <<= LITTLENUM_NUMBER_OF_BITS; | ||
1481 | v |= l[0] & LITTLENUM_MASK; | ||
1482 | -#else | ||
1483 | - v = l[1] & LITTLENUM_MASK; | ||
1484 | - v <<= LITTLENUM_NUMBER_OF_BITS; | ||
1485 | - v |= l[0] & LITTLENUM_MASK; | ||
1486 | -#endif | ||
1487 | } | ||
1488 | else | ||
1489 | v = inst.relocs[0].exp.X_add_number; | ||
1490 | @@ -9041,7 +9029,7 @@ move_or_literal_pool (int i, enum lit_type t, bool mode_3) | ||
1491 | ? inst.operands[1].reg | ||
1492 | : inst.relocs[0].exp.X_unsigned | ||
1493 | ? 0 | ||
1494 | - : ((bfd_int64_t)((int) immlo)) >> 32; | ||
1495 | + : (int64_t) (int) immlo >> 32; | ||
1496 | int cmode = neon_cmode_for_move_imm (immlo, immhi, false, &immbits, | ||
1497 | &op, 64, NT_invtype); | ||
1498 | |||
1499 | @@ -9090,7 +9078,6 @@ move_or_literal_pool (int i, enum lit_type t, bool mode_3) | ||
1500 | discrepancy between the output produced by an assembler built for | ||
1501 | a 32-bit-only host and the output produced from a 64-bit host, but | ||
1502 | this cannot be helped. */ | ||
1503 | -#if defined BFD_HOST_64_BIT | ||
1504 | else if (!inst.operands[1].issingle | ||
1505 | && ARM_CPU_HAS_FEATURE (cpu_variant, fpu_vfp_ext_v3)) | ||
1506 | { | ||
1507 | @@ -9103,7 +9090,6 @@ move_or_literal_pool (int i, enum lit_type t, bool mode_3) | ||
1508 | return true; | ||
1509 | } | ||
1510 | } | ||
1511 | -#endif | ||
1512 | } | ||
1513 | } | ||
1514 | |||
1515 | diff --git a/gas/config/tc-csky.c b/gas/config/tc-csky.c | ||
1516 | index 2371eeb747e..5b824d89af0 100644 | ||
1517 | --- a/gas/config/tc-csky.c | ||
1518 | +++ b/gas/config/tc-csky.c | ||
1519 | @@ -215,7 +215,7 @@ enum | ||
1520 | unsigned int mach_flag = 0; | ||
1521 | unsigned int arch_flag = 0; | ||
1522 | unsigned int other_flag = 0; | ||
1523 | -BFD_HOST_U_64_BIT isa_flag = 0; | ||
1524 | +uint64_t isa_flag = 0; | ||
1525 | unsigned int dsp_flag = 0; | ||
1526 | |||
1527 | typedef struct stack_size_entry | ||
1528 | @@ -245,7 +245,7 @@ struct csky_macro_info | ||
1529 | const char *name; | ||
1530 | /* How many operands : if operands == 5, all of 1,2,3,4 are ok. */ | ||
1531 | long oprnd_num; | ||
1532 | - BFD_HOST_U_64_BIT isa_flag; | ||
1533 | + uint64_t isa_flag; | ||
1534 | /* Do the work. */ | ||
1535 | void (*handle_func)(void); | ||
1536 | }; | ||
1537 | @@ -591,14 +591,14 @@ struct csky_cpu_feature | ||
1538 | { | ||
1539 | const char unique; | ||
1540 | unsigned int arch_flag; | ||
1541 | - bfd_uint64_t isa_flag; | ||
1542 | + uint64_t isa_flag; | ||
1543 | }; | ||
1544 | |||
1545 | struct csky_cpu_version | ||
1546 | { | ||
1547 | int r; | ||
1548 | int p; | ||
1549 | - bfd_uint64_t isa_flag; | ||
1550 | + uint64_t isa_flag; | ||
1551 | }; | ||
1552 | |||
1553 | #define CSKY_FEATURE_MAX 10 | ||
1554 | @@ -608,7 +608,7 @@ struct csky_cpu_info | ||
1555 | { | ||
1556 | const char *name; | ||
1557 | unsigned int arch_flag; | ||
1558 | - bfd_uint64_t isa_flag; | ||
1559 | + uint64_t isa_flag; | ||
1560 | struct csky_cpu_feature features[CSKY_FEATURE_MAX]; | ||
1561 | struct csky_cpu_version ver[CSKY_CPU_REVERISON_MAX]; | ||
1562 | }; | ||
1563 | diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c | ||
1564 | index 222223f3549..4e443b1d28d 100644 | ||
1565 | --- a/gas/config/tc-sparc.c | ||
1566 | +++ b/gas/config/tc-sparc.c | ||
1567 | @@ -75,10 +75,10 @@ static enum { MM_TSO, MM_PSO, MM_RMO } sparc_memory_model = MM_RMO; | ||
1568 | #ifndef TE_SOLARIS | ||
1569 | /* Bitmask of instruction types seen so far, used to populate the | ||
1570 | GNU attributes section with hwcap information. */ | ||
1571 | -static bfd_uint64_t hwcap_seen; | ||
1572 | +static uint64_t hwcap_seen; | ||
1573 | #endif | ||
1574 | |||
1575 | -static bfd_uint64_t hwcap_allowed; | ||
1576 | +static uint64_t hwcap_allowed; | ||
1577 | |||
1578 | static int architecture_requested; | ||
1579 | static int warn_on_bump; | ||
1580 | @@ -498,15 +498,15 @@ md_parse_option (int c, const char *arg) | ||
1581 | || opcode_arch > max_architecture) | ||
1582 | max_architecture = opcode_arch; | ||
1583 | |||
1584 | - /* The allowed hardware capabilities are the implied by the | ||
1585 | - opcodes arch plus any extra capabilities defined in the GAS | ||
1586 | - arch. */ | ||
1587 | - hwcap_allowed | ||
1588 | - = (hwcap_allowed | ||
1589 | - | (((bfd_uint64_t) sparc_opcode_archs[opcode_arch].hwcaps2) << 32) | ||
1590 | - | (((bfd_uint64_t) sa->hwcap2_allowed) << 32) | ||
1591 | - | sparc_opcode_archs[opcode_arch].hwcaps | ||
1592 | - | sa->hwcap_allowed); | ||
1593 | + /* The allowed hardware capabilities are the implied by the | ||
1594 | + opcodes arch plus any extra capabilities defined in the GAS | ||
1595 | + arch. */ | ||
1596 | + hwcap_allowed | ||
1597 | + = (hwcap_allowed | ||
1598 | + | ((uint64_t) sparc_opcode_archs[opcode_arch].hwcaps2 << 32) | ||
1599 | + | ((uint64_t) sa->hwcap2_allowed << 32) | ||
1600 | + | sparc_opcode_archs[opcode_arch].hwcaps | ||
1601 | + | sa->hwcap_allowed); | ||
1602 | architecture_requested = 1; | ||
1603 | } | ||
1604 | break; | ||
1605 | @@ -1607,7 +1607,7 @@ md_assemble (char *str) | ||
1606 | } | ||
1607 | |||
1608 | static const char * | ||
1609 | -get_hwcap_name (bfd_uint64_t mask) | ||
1610 | +get_hwcap_name (uint64_t mask) | ||
1611 | { | ||
1612 | if (mask & HWCAP_MUL32) | ||
1613 | return "mul32"; | ||
1614 | @@ -3171,8 +3171,7 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn) | ||
1615 | msg_str = sasi->name; | ||
1616 | } | ||
1617 | |||
1618 | - bfd_uint64_t hwcaps | ||
1619 | - = (((bfd_uint64_t) insn->hwcaps2) << 32) | insn->hwcaps; | ||
1620 | + uint64_t hwcaps = ((uint64_t) insn->hwcaps2 << 32) | insn->hwcaps; | ||
1621 | |||
1622 | #ifndef TE_SOLARIS | ||
1623 | if (hwcaps) | ||
1624 | @@ -3211,10 +3210,10 @@ sparc_ip (char *str, const struct sparc_opcode **pinsn) | ||
1625 | } | ||
1626 | current_architecture = needed_architecture; | ||
1627 | hwcap_allowed | ||
1628 | - = (hwcap_allowed | ||
1629 | - | hwcaps | ||
1630 | - | (((bfd_uint64_t) sparc_opcode_archs[current_architecture].hwcaps2) << 32) | ||
1631 | - | sparc_opcode_archs[current_architecture].hwcaps); | ||
1632 | + = (hwcap_allowed | ||
1633 | + | hwcaps | ||
1634 | + | ((uint64_t) sparc_opcode_archs[current_architecture].hwcaps2 << 32) | ||
1635 | + | sparc_opcode_archs[current_architecture].hwcaps); | ||
1636 | } | ||
1637 | /* Conflict. */ | ||
1638 | /* ??? This seems to be a bit fragile. What if the next entry in | ||
1639 | diff --git a/gas/config/tc-tilegx.c b/gas/config/tc-tilegx.c | ||
1640 | index b627b7080e5..4fcc38c9034 100644 | ||
1641 | --- a/gas/config/tc-tilegx.c | ||
1642 | +++ b/gas/config/tc-tilegx.c | ||
1643 | @@ -789,16 +789,16 @@ emit_tilegx_instruction (tilegx_bundle_bits bits, | ||
1644 | static void | ||
1645 | check_illegal_reg_writes (void) | ||
1646 | { | ||
1647 | - BFD_HOST_U_64_BIT all_regs_written = 0; | ||
1648 | + uint64_t all_regs_written = 0; | ||
1649 | int j; | ||
1650 | |||
1651 | for (j = 0; j < current_bundle_index; j++) | ||
1652 | { | ||
1653 | const struct tilegx_instruction *instr = ¤t_bundle[j]; | ||
1654 | int k; | ||
1655 | - BFD_HOST_U_64_BIT regs = | ||
1656 | - ((BFD_HOST_U_64_BIT)1) << instr->opcode->implicitly_written_register; | ||
1657 | - BFD_HOST_U_64_BIT conflict; | ||
1658 | + uint64_t regs = | ||
1659 | + (uint64_t) 1 << instr->opcode->implicitly_written_register; | ||
1660 | + uint64_t conflict; | ||
1661 | |||
1662 | for (k = 0; k < instr->opcode->num_operands; k++) | ||
1663 | { | ||
1664 | @@ -808,12 +808,12 @@ check_illegal_reg_writes (void) | ||
1665 | if (operand->is_dest_reg) | ||
1666 | { | ||
1667 | int regno = instr->operand_values[k].X_add_number; | ||
1668 | - BFD_HOST_U_64_BIT mask = ((BFD_HOST_U_64_BIT)1) << regno; | ||
1669 | + uint64_t mask = (uint64_t) 1 << regno; | ||
1670 | |||
1671 | - if ((mask & ( (((BFD_HOST_U_64_BIT)1) << TREG_IDN1) | ||
1672 | - | (((BFD_HOST_U_64_BIT)1) << TREG_UDN1) | ||
1673 | - | (((BFD_HOST_U_64_BIT)1) << TREG_UDN2) | ||
1674 | - | (((BFD_HOST_U_64_BIT)1) << TREG_UDN3))) != 0 | ||
1675 | + if ((mask & ( ((uint64_t) 1 << TREG_IDN1) | ||
1676 | + | ((uint64_t) 1 << TREG_UDN1) | ||
1677 | + | ((uint64_t) 1 << TREG_UDN2) | ||
1678 | + | ((uint64_t) 1 << TREG_UDN3))) != 0 | ||
1679 | && !allow_suspicious_bundles) | ||
1680 | { | ||
1681 | as_bad (_("Writes to register '%s' are not allowed."), | ||
1682 | @@ -825,7 +825,7 @@ check_illegal_reg_writes (void) | ||
1683 | } | ||
1684 | |||
1685 | /* Writing to the zero register doesn't count. */ | ||
1686 | - regs &= ~(((BFD_HOST_U_64_BIT)1) << TREG_ZERO); | ||
1687 | + regs &= ~((uint64_t) 1 << TREG_ZERO); | ||
1688 | |||
1689 | conflict = all_regs_written & regs; | ||
1690 | if (conflict != 0 && !allow_suspicious_bundles) | ||
1691 | diff --git a/gas/config/tc-tilepro.c b/gas/config/tc-tilepro.c | ||
1692 | index af0be422f98..ca092d77a4b 100644 | ||
1693 | --- a/gas/config/tc-tilepro.c | ||
1694 | +++ b/gas/config/tc-tilepro.c | ||
1695 | @@ -677,16 +677,16 @@ emit_tilepro_instruction (tilepro_bundle_bits bits, | ||
1696 | static void | ||
1697 | check_illegal_reg_writes (void) | ||
1698 | { | ||
1699 | - BFD_HOST_U_64_BIT all_regs_written = 0; | ||
1700 | + uint64_t all_regs_written = 0; | ||
1701 | int j; | ||
1702 | |||
1703 | for (j = 0; j < current_bundle_index; j++) | ||
1704 | { | ||
1705 | const struct tilepro_instruction *instr = ¤t_bundle[j]; | ||
1706 | int k; | ||
1707 | - BFD_HOST_U_64_BIT regs = | ||
1708 | - ((BFD_HOST_U_64_BIT)1) << instr->opcode->implicitly_written_register; | ||
1709 | - BFD_HOST_U_64_BIT conflict; | ||
1710 | + uint64_t regs = | ||
1711 | + (uint64_t) 1 << instr->opcode->implicitly_written_register; | ||
1712 | + uint64_t conflict; | ||
1713 | |||
1714 | for (k = 0; k < instr->opcode->num_operands; k++) | ||
1715 | { | ||
1716 | @@ -696,12 +696,12 @@ check_illegal_reg_writes (void) | ||
1717 | if (operand->is_dest_reg) | ||
1718 | { | ||
1719 | int regno = instr->operand_values[k].X_add_number; | ||
1720 | - BFD_HOST_U_64_BIT mask = ((BFD_HOST_U_64_BIT)1) << regno; | ||
1721 | + uint64_t mask = (uint64_t) 1 << regno; | ||
1722 | |||
1723 | - if ((mask & ( (((BFD_HOST_U_64_BIT)1) << TREG_IDN1) | ||
1724 | - | (((BFD_HOST_U_64_BIT)1) << TREG_UDN1) | ||
1725 | - | (((BFD_HOST_U_64_BIT)1) << TREG_UDN2) | ||
1726 | - | (((BFD_HOST_U_64_BIT)1) << TREG_UDN3))) != 0 | ||
1727 | + if ((mask & ( ((uint64_t) 1 << TREG_IDN1) | ||
1728 | + | ((uint64_t) 1 << TREG_UDN1) | ||
1729 | + | ((uint64_t) 1 << TREG_UDN2) | ||
1730 | + | ((uint64_t) 1 << TREG_UDN3))) != 0 | ||
1731 | && !allow_suspicious_bundles) | ||
1732 | { | ||
1733 | as_bad (_("Writes to register '%s' are not allowed."), | ||
1734 | @@ -713,7 +713,7 @@ check_illegal_reg_writes (void) | ||
1735 | } | ||
1736 | |||
1737 | /* Writing to the zero register doesn't count. */ | ||
1738 | - regs &= ~(((BFD_HOST_U_64_BIT)1) << TREG_ZERO); | ||
1739 | + regs &= ~((uint64_t) 1 << TREG_ZERO); | ||
1740 | |||
1741 | conflict = all_regs_written & regs; | ||
1742 | if (conflict != 0 && !allow_suspicious_bundles) | ||
1743 | diff --git a/gas/config/tc-z80.c b/gas/config/tc-z80.c | ||
1744 | index 81fbfe3b0ae..714e704e24a 100644 | ||
1745 | --- a/gas/config/tc-z80.c | ||
1746 | +++ b/gas/config/tc-z80.c | ||
1747 | @@ -3910,11 +3910,11 @@ z80_tc_label_is_local (const char *name) | ||
1748 | #define EXP_MIN -0x10000 | ||
1749 | #define EXP_MAX 0x10000 | ||
1750 | static int | ||
1751 | -str_to_broken_float (bool *signP, bfd_uint64_t *mantissaP, int *expP) | ||
1752 | +str_to_broken_float (bool *signP, uint64_t *mantissaP, int *expP) | ||
1753 | { | ||
1754 | char *p; | ||
1755 | bool sign; | ||
1756 | - bfd_uint64_t mantissa = 0; | ||
1757 | + uint64_t mantissa = 0; | ||
1758 | int exponent = 0; | ||
1759 | int i; | ||
1760 | |||
1761 | @@ -4029,7 +4029,7 @@ str_to_broken_float (bool *signP, bfd_uint64_t *mantissaP, int *expP) | ||
1762 | static const char * | ||
1763 | str_to_zeda32(char *litP, int *sizeP) | ||
1764 | { | ||
1765 | - bfd_uint64_t mantissa; | ||
1766 | + uint64_t mantissa; | ||
1767 | bool sign; | ||
1768 | int exponent; | ||
1769 | unsigned i; | ||
1770 | @@ -4088,7 +4088,7 @@ str_to_zeda32(char *litP, int *sizeP) | ||
1771 | static const char * | ||
1772 | str_to_float48(char *litP, int *sizeP) | ||
1773 | { | ||
1774 | - bfd_uint64_t mantissa; | ||
1775 | + uint64_t mantissa; | ||
1776 | bool sign; | ||
1777 | int exponent; | ||
1778 | unsigned i; | ||
1779 | diff --git a/gas/config/te-vms.c b/gas/config/te-vms.c | ||
1780 | index 015c95867f0..6661a3b6a72 100644 | ||
1781 | --- a/gas/config/te-vms.c | ||
1782 | +++ b/gas/config/te-vms.c | ||
1783 | @@ -339,7 +339,7 @@ vms_file_stats_name (const char *dirname, | ||
1784 | return 0; | ||
1785 | } | ||
1786 | |||
1787 | -bfd_uint64_t | ||
1788 | +uint64_t | ||
1789 | vms_dwarf2_file_time_name (const char *filename, const char *dirname) | ||
1790 | { | ||
1791 | long long cdt; | ||
1792 | diff --git a/gas/config/te-vms.h b/gas/config/te-vms.h | ||
1793 | index ffe7f5e8f37..08f218502de 100644 | ||
1794 | --- a/gas/config/te-vms.h | ||
1795 | +++ b/gas/config/te-vms.h | ||
1796 | @@ -20,7 +20,7 @@ | ||
1797 | #define TE_VMS | ||
1798 | #include "obj-format.h" | ||
1799 | |||
1800 | -extern bfd_uint64_t vms_dwarf2_file_time_name (const char *, const char *); | ||
1801 | +extern uint64_t vms_dwarf2_file_time_name (const char *, const char *); | ||
1802 | extern long vms_dwarf2_file_size_name (const char *, const char *); | ||
1803 | extern char *vms_dwarf2_file_name (const char *, const char *); | ||
1804 | |||
1805 | diff --git a/gdb/findcmd.c b/gdb/findcmd.c | ||
1806 | index ff13f22e970..ed2cea7b74d 100644 | ||
1807 | --- a/gdb/findcmd.c | ||
1808 | +++ b/gdb/findcmd.c | ||
1809 | @@ -30,7 +30,7 @@ | ||
1810 | /* Copied from bfd_put_bits. */ | ||
1811 | |||
1812 | static void | ||
1813 | -put_bits (bfd_uint64_t data, gdb::byte_vector &buf, int bits, bfd_boolean big_p) | ||
1814 | +put_bits (uint64_t data, gdb::byte_vector &buf, int bits, bfd_boolean big_p) | ||
1815 | { | ||
1816 | int i; | ||
1817 | int bytes; | ||
1818 | diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c | ||
1819 | index 7930db72779..9668aa80b53 100644 | ||
1820 | --- a/gdb/tilegx-tdep.c | ||
1821 | +++ b/gdb/tilegx-tdep.c | ||
1822 | @@ -375,7 +375,7 @@ tilegx_analyze_prologue (struct gdbarch* gdbarch, | ||
1823 | CORE_ADDR instbuf_start; | ||
1824 | unsigned int instbuf_size; | ||
1825 | int status; | ||
1826 | - bfd_uint64_t bundle; | ||
1827 | + uint64_t bundle; | ||
1828 | struct tilegx_decoded_instruction | ||
1829 | decoded[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE]; | ||
1830 | int num_insns; | ||
1831 | diff --git a/gprof/gmon_io.c b/gprof/gmon_io.c | ||
1832 | index c613809d396..2b4dd26375b 100644 | ||
1833 | --- a/gprof/gmon_io.c | ||
1834 | +++ b/gprof/gmon_io.c | ||
1835 | @@ -48,10 +48,8 @@ enum gmon_ptr_signedness { | ||
1836 | static enum gmon_ptr_size gmon_get_ptr_size (void); | ||
1837 | static enum gmon_ptr_signedness gmon_get_ptr_signedness (void); | ||
1838 | |||
1839 | -#ifdef BFD_HOST_U_64_BIT | ||
1840 | -static int gmon_io_read_64 (FILE *, BFD_HOST_U_64_BIT *); | ||
1841 | -static int gmon_io_write_64 (FILE *, BFD_HOST_U_64_BIT); | ||
1842 | -#endif | ||
1843 | +static int gmon_io_read_64 (FILE *, uint64_t *); | ||
1844 | +static int gmon_io_write_64 (FILE *, uint64_t); | ||
1845 | static int gmon_read_raw_arc | ||
1846 | (FILE *, bfd_vma *, bfd_vma *, unsigned long *); | ||
1847 | static int gmon_write_raw_arc | ||
1848 | @@ -109,9 +107,8 @@ gmon_io_read_32 (FILE *ifp, unsigned int *valp) | ||
1849 | return 0; | ||
1850 | } | ||
1851 | |||
1852 | -#ifdef BFD_HOST_U_64_BIT | ||
1853 | static int | ||
1854 | -gmon_io_read_64 (FILE *ifp, BFD_HOST_U_64_BIT *valp) | ||
1855 | +gmon_io_read_64 (FILE *ifp, uint64_t *valp) | ||
1856 | { | ||
1857 | char buf[8]; | ||
1858 | |||
1859 | @@ -120,15 +117,12 @@ gmon_io_read_64 (FILE *ifp, BFD_HOST_U_64_BIT *valp) | ||
1860 | *valp = bfd_get_64 (core_bfd, buf); | ||
1861 | return 0; | ||
1862 | } | ||
1863 | -#endif | ||
1864 | |||
1865 | int | ||
1866 | gmon_io_read_vma (FILE *ifp, bfd_vma *valp) | ||
1867 | { | ||
1868 | unsigned int val32; | ||
1869 | -#ifdef BFD_HOST_U_64_BIT | ||
1870 | - BFD_HOST_U_64_BIT val64; | ||
1871 | -#endif | ||
1872 | + uint64_t val64; | ||
1873 | |||
1874 | switch (gmon_get_ptr_size ()) | ||
1875 | { | ||
1876 | @@ -136,23 +130,19 @@ gmon_io_read_vma (FILE *ifp, bfd_vma *valp) | ||
1877 | if (gmon_io_read_32 (ifp, &val32)) | ||
1878 | return 1; | ||
1879 | if (gmon_get_ptr_signedness () == ptr_signed) | ||
1880 | - *valp = (int) val32; | ||
1881 | + *valp = (int) val32; | ||
1882 | else | ||
1883 | - *valp = val32; | ||
1884 | + *valp = val32; | ||
1885 | break; | ||
1886 | |||
1887 | -#ifdef BFD_HOST_U_64_BIT | ||
1888 | case ptr_64bit: | ||
1889 | if (gmon_io_read_64 (ifp, &val64)) | ||
1890 | return 1; | ||
1891 | -#ifdef BFD_HOST_64_BIT | ||
1892 | if (gmon_get_ptr_signedness () == ptr_signed) | ||
1893 | - *valp = (BFD_HOST_64_BIT) val64; | ||
1894 | + *valp = (int64_t) val64; | ||
1895 | else | ||
1896 | -#endif | ||
1897 | - *valp = val64; | ||
1898 | + *valp = val64; | ||
1899 | break; | ||
1900 | -#endif | ||
1901 | } | ||
1902 | return 0; | ||
1903 | } | ||
1904 | @@ -176,9 +166,8 @@ gmon_io_write_32 (FILE *ofp, unsigned int val) | ||
1905 | return 0; | ||
1906 | } | ||
1907 | |||
1908 | -#ifdef BFD_HOST_U_64_BIT | ||
1909 | static int | ||
1910 | -gmon_io_write_64 (FILE *ofp, BFD_HOST_U_64_BIT val) | ||
1911 | +gmon_io_write_64 (FILE *ofp, uint64_t val) | ||
1912 | { | ||
1913 | char buf[8]; | ||
1914 | |||
1915 | @@ -187,7 +176,6 @@ gmon_io_write_64 (FILE *ofp, BFD_HOST_U_64_BIT val) | ||
1916 | return 1; | ||
1917 | return 0; | ||
1918 | } | ||
1919 | -#endif | ||
1920 | |||
1921 | int | ||
1922 | gmon_io_write_vma (FILE *ofp, bfd_vma val) | ||
1923 | @@ -200,12 +188,10 @@ gmon_io_write_vma (FILE *ofp, bfd_vma val) | ||
1924 | return 1; | ||
1925 | break; | ||
1926 | |||
1927 | -#ifdef BFD_HOST_U_64_BIT | ||
1928 | case ptr_64bit: | ||
1929 | - if (gmon_io_write_64 (ofp, (BFD_HOST_U_64_BIT) val)) | ||
1930 | + if (gmon_io_write_64 (ofp, (uint64_t) val)) | ||
1931 | return 1; | ||
1932 | break; | ||
1933 | -#endif | ||
1934 | } | ||
1935 | return 0; | ||
1936 | } | ||
1937 | @@ -232,9 +218,7 @@ gmon_io_write (FILE *ofp, char *buf, size_t n) | ||
1938 | static int | ||
1939 | gmon_read_raw_arc (FILE *ifp, bfd_vma *fpc, bfd_vma *spc, unsigned long *cnt) | ||
1940 | { | ||
1941 | -#ifdef BFD_HOST_U_64_BIT | ||
1942 | - BFD_HOST_U_64_BIT cnt64; | ||
1943 | -#endif | ||
1944 | + uint64_t cnt64; | ||
1945 | unsigned int cnt32; | ||
1946 | |||
1947 | if (gmon_io_read_vma (ifp, fpc) | ||
1948 | @@ -249,13 +233,11 @@ gmon_read_raw_arc (FILE *ifp, bfd_vma *fpc, bfd_vma *spc, unsigned long *cnt) | ||
1949 | *cnt = cnt32; | ||
1950 | break; | ||
1951 | |||
1952 | -#ifdef BFD_HOST_U_64_BIT | ||
1953 | case ptr_64bit: | ||
1954 | if (gmon_io_read_64 (ifp, &cnt64)) | ||
1955 | return 1; | ||
1956 | *cnt = cnt64; | ||
1957 | break; | ||
1958 | -#endif | ||
1959 | |||
1960 | default: | ||
1961 | return 1; | ||
1962 | @@ -278,12 +260,10 @@ gmon_write_raw_arc (FILE *ofp, bfd_vma fpc, bfd_vma spc, unsigned long cnt) | ||
1963 | return 1; | ||
1964 | break; | ||
1965 | |||
1966 | -#ifdef BFD_HOST_U_64_BIT | ||
1967 | case ptr_64bit: | ||
1968 | - if (gmon_io_write_64 (ofp, (BFD_HOST_U_64_BIT) cnt)) | ||
1969 | + if (gmon_io_write_64 (ofp, (uint64_t) cnt)) | ||
1970 | return 1; | ||
1971 | break; | ||
1972 | -#endif | ||
1973 | } | ||
1974 | return 0; | ||
1975 | } | ||
1976 | diff --git a/include/elf/nfp.h b/include/elf/nfp.h | ||
1977 | index 5a06051196c..c89cefff27b 100644 | ||
1978 | --- a/include/elf/nfp.h | ||
1979 | +++ b/include/elf/nfp.h | ||
1980 | @@ -102,7 +102,7 @@ extern "C" | ||
1981 | #define SHF_NFP_INIT 0x80000000 | ||
1982 | #define SHF_NFP_INIT2 0x40000000 | ||
1983 | #define SHF_NFP_SCS(shf) (((shf) >> 32) & 0xFF) | ||
1984 | -#define SHF_NFP_SET_SCS(v) (((BFD_HOST_U_64_BIT)((v) & 0xFF)) << 32) | ||
1985 | +#define SHF_NFP_SET_SCS(v) ((uint64_t) ((v) & 0xFF) << 32) | ||
1986 | |||
1987 | /* NFP Section Info | ||
1988 | For PROGBITS and NOBITS sections: | ||
1989 | diff --git a/include/opcode/csky.h b/include/opcode/csky.h | ||
1990 | index ed00bfd7cd6..faecba11611 100644 | ||
1991 | --- a/include/opcode/csky.h | ||
1992 | +++ b/include/opcode/csky.h | ||
1993 | @@ -22,46 +22,46 @@ | ||
1994 | #include "dis-asm.h" | ||
1995 | |||
1996 | /* The following bitmasks control instruction set architecture. */ | ||
1997 | -#define CSKYV1_ISA_E1 ((bfd_uint64_t)1 << 0) | ||
1998 | -#define CSKYV2_ISA_E1 ((bfd_uint64_t)1 << 1) | ||
1999 | -#define CSKYV2_ISA_1E2 ((bfd_uint64_t)1 << 2) | ||
2000 | -#define CSKYV2_ISA_2E3 ((bfd_uint64_t)1 << 3) | ||
2001 | -#define CSKYV2_ISA_3E7 ((bfd_uint64_t)1 << 4) | ||
2002 | -#define CSKYV2_ISA_7E10 ((bfd_uint64_t)1 << 5) | ||
2003 | -#define CSKYV2_ISA_3E3R1 ((bfd_uint64_t)1 << 6) | ||
2004 | -#define CSKYV2_ISA_3E3R2 ((bfd_uint64_t)1 << 7) | ||
2005 | -#define CSKYV2_ISA_10E60 ((bfd_uint64_t)1 << 8) | ||
2006 | -#define CSKYV2_ISA_3E3R3 ((bfd_uint64_t)1 << 9) | ||
2007 | - | ||
2008 | -#define CSKY_ISA_TRUST ((bfd_uint64_t)1 << 11) | ||
2009 | -#define CSKY_ISA_CACHE ((bfd_uint64_t)1 << 12) | ||
2010 | -#define CSKY_ISA_NVIC ((bfd_uint64_t)1 << 13) | ||
2011 | -#define CSKY_ISA_CP ((bfd_uint64_t)1 << 14) | ||
2012 | -#define CSKY_ISA_MP ((bfd_uint64_t)1 << 15) | ||
2013 | -#define CSKY_ISA_MP_1E2 ((bfd_uint64_t)1 << 16) | ||
2014 | -#define CSKY_ISA_JAVA ((bfd_uint64_t)1 << 17) | ||
2015 | -#define CSKY_ISA_MAC ((bfd_uint64_t)1 << 18) | ||
2016 | -#define CSKY_ISA_MAC_DSP ((bfd_uint64_t)1 << 19) | ||
2017 | +#define CSKYV1_ISA_E1 ((uint64_t) 1 << 0) | ||
2018 | +#define CSKYV2_ISA_E1 ((uint64_t) 1 << 1) | ||
2019 | +#define CSKYV2_ISA_1E2 ((uint64_t) 1 << 2) | ||
2020 | +#define CSKYV2_ISA_2E3 ((uint64_t) 1 << 3) | ||
2021 | +#define CSKYV2_ISA_3E7 ((uint64_t) 1 << 4) | ||
2022 | +#define CSKYV2_ISA_7E10 ((uint64_t) 1 << 5) | ||
2023 | +#define CSKYV2_ISA_3E3R1 ((uint64_t) 1 << 6) | ||
2024 | +#define CSKYV2_ISA_3E3R2 ((uint64_t) 1 << 7) | ||
2025 | +#define CSKYV2_ISA_10E60 ((uint64_t) 1 << 8) | ||
2026 | +#define CSKYV2_ISA_3E3R3 ((uint64_t) 1 << 9) | ||
2027 | + | ||
2028 | +#define CSKY_ISA_TRUST ((uint64_t) 1 << 11) | ||
2029 | +#define CSKY_ISA_CACHE ((uint64_t) 1 << 12) | ||
2030 | +#define CSKY_ISA_NVIC ((uint64_t) 1 << 13) | ||
2031 | +#define CSKY_ISA_CP ((uint64_t) 1 << 14) | ||
2032 | +#define CSKY_ISA_MP ((uint64_t) 1 << 15) | ||
2033 | +#define CSKY_ISA_MP_1E2 ((uint64_t) 1 << 16) | ||
2034 | +#define CSKY_ISA_JAVA ((uint64_t) 1 << 17) | ||
2035 | +#define CSKY_ISA_MAC ((uint64_t) 1 << 18) | ||
2036 | +#define CSKY_ISA_MAC_DSP ((uint64_t) 1 << 19) | ||
2037 | |||
2038 | /* Base ISA for csky v1 and v2. */ | ||
2039 | -#define CSKY_ISA_DSP ((bfd_uint64_t)1 << 20) | ||
2040 | -#define CSKY_ISA_DSP_1E2 ((bfd_uint64_t)1 << 21) | ||
2041 | -#define CSKY_ISA_DSP_ENHANCE ((bfd_uint64_t)1 << 22) | ||
2042 | -#define CSKY_ISA_DSPE60 ((bfd_uint64_t)1 << 23) | ||
2043 | +#define CSKY_ISA_DSP ((uint64_t) 1 << 20) | ||
2044 | +#define CSKY_ISA_DSP_1E2 ((uint64_t) 1 << 21) | ||
2045 | +#define CSKY_ISA_DSP_ENHANCE ((uint64_t) 1 << 22) | ||
2046 | +#define CSKY_ISA_DSPE60 ((uint64_t) 1 << 23) | ||
2047 | |||
2048 | /* Base float instruction (803f & 810f). */ | ||
2049 | -#define CSKY_ISA_FLOAT_E1 ((bfd_uint64_t)1 << 25) | ||
2050 | +#define CSKY_ISA_FLOAT_E1 ((uint64_t) 1 << 25) | ||
2051 | /* M_FLOAT support (810f). */ | ||
2052 | -#define CSKY_ISA_FLOAT_1E2 ((bfd_uint64_t)1 << 26) | ||
2053 | +#define CSKY_ISA_FLOAT_1E2 ((uint64_t) 1 << 26) | ||
2054 | /* 803 support (803f). */ | ||
2055 | -#define CSKY_ISA_FLOAT_1E3 ((bfd_uint64_t)1 << 27) | ||
2056 | +#define CSKY_ISA_FLOAT_1E3 ((uint64_t) 1 << 27) | ||
2057 | /* 807 support (803f & 807f). */ | ||
2058 | -#define CSKY_ISA_FLOAT_3E4 ((bfd_uint64_t)1 << 28) | ||
2059 | +#define CSKY_ISA_FLOAT_3E4 ((uint64_t) 1 << 28) | ||
2060 | /* 860 support. */ | ||
2061 | -#define CSKY_ISA_FLOAT_7E60 ((bfd_uint64_t)1 << 36) | ||
2062 | +#define CSKY_ISA_FLOAT_7E60 ((uint64_t) 1 << 36) | ||
2063 | /* Vector DSP support. */ | ||
2064 | -#define CSKY_ISA_VDSP ((bfd_uint64_t)1 << 29) | ||
2065 | -#define CSKY_ISA_VDSP_2 ((bfd_uint64_t)1 << 30) | ||
2066 | +#define CSKY_ISA_VDSP ((uint64_t) 1 << 29) | ||
2067 | +#define CSKY_ISA_VDSP_2 ((uint64_t) 1 << 30) | ||
2068 | |||
2069 | /* The following bitmasks control cpu architecture for CSKY. */ | ||
2070 | #define CSKY_ABI_V1 (1 << 28) | ||
2071 | diff --git a/include/opcode/ia64.h b/include/opcode/ia64.h | ||
2072 | index fbdd8f14e65..42a6812c3f8 100644 | ||
2073 | --- a/include/opcode/ia64.h | ||
2074 | +++ b/include/opcode/ia64.h | ||
2075 | @@ -29,7 +29,7 @@ | ||
2076 | extern "C" { | ||
2077 | #endif | ||
2078 | |||
2079 | -typedef BFD_HOST_U_64_BIT ia64_insn; | ||
2080 | +typedef uint64_t ia64_insn; | ||
2081 | |||
2082 | enum ia64_insn_type | ||
2083 | { | ||
2084 | diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c | ||
2085 | index b7c833623e5..99103ff57b5 100644 | ||
2086 | --- a/opcodes/csky-dis.c | ||
2087 | +++ b/opcodes/csky-dis.c | ||
2088 | @@ -49,7 +49,7 @@ struct csky_dis_info | ||
2089 | disassemble_info *info; | ||
2090 | /* Opcode information. */ | ||
2091 | struct csky_opcode_info const *opinfo; | ||
2092 | - BFD_HOST_U_64_BIT isa; | ||
2093 | + uint64_t isa; | ||
2094 | /* The value of operand to show. */ | ||
2095 | int value; | ||
2096 | /* Whether to look up/print a symbol name. */ | ||
2097 | diff --git a/opcodes/csky-opc.h b/opcodes/csky-opc.h | ||
2098 | index b65efe19d9f..d2db90ede95 100644 | ||
2099 | --- a/opcodes/csky-opc.h | ||
2100 | +++ b/opcodes/csky-opc.h | ||
2101 | @@ -271,8 +271,8 @@ struct csky_opcode | ||
2102 | /* Encodings for 32-bit opcodes. */ | ||
2103 | struct csky_opcode_info op32[OP_TABLE_NUM]; | ||
2104 | /* Instruction set flag. */ | ||
2105 | - BFD_HOST_U_64_BIT isa_flag16; | ||
2106 | - BFD_HOST_U_64_BIT isa_flag32; | ||
2107 | + uint64_t isa_flag16; | ||
2108 | + uint64_t isa_flag32; | ||
2109 | /* Whether this insn needs relocation, 0: no, !=0: yes. */ | ||
2110 | signed int reloc16; | ||
2111 | signed int reloc32; | ||
2112 | diff --git a/opcodes/ia64-dis.c b/opcodes/ia64-dis.c | ||
2113 | index 5eb37277a5d..e76f40393c6 100644 | ||
2114 | --- a/opcodes/ia64-dis.c | ||
2115 | +++ b/opcodes/ia64-dis.c | ||
2116 | @@ -73,7 +73,7 @@ print_insn_ia64 (bfd_vma memaddr, struct disassemble_info *info) | ||
2117 | const struct ia64_operand *odesc; | ||
2118 | const struct ia64_opcode *idesc; | ||
2119 | const char *err, *str, *tname; | ||
2120 | - BFD_HOST_U_64_BIT value; | ||
2121 | + uint64_t value; | ||
2122 | bfd_byte bundle[16]; | ||
2123 | enum ia64_unit unit; | ||
2124 | char regname[16]; | ||
2125 | -- | ||
2126 | 2.31.1 | ||
2127 | |||
diff --git a/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-3.patch b/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-3.patch new file mode 100644 index 0000000000..6a838ea3ea --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-3.patch | |||
@@ -0,0 +1,156 @@ | |||
1 | From 31d6c13defeba7716ebc9d5c8f81f2f35fe39980 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alan Modra <amodra@gmail.com> | ||
3 | Date: Tue, 14 Jun 2022 12:46:42 +0930 | ||
4 | Subject: [PATCH] PR29230, segv in lookup_symbol_in_variable_table | ||
5 | |||
6 | The PR23230 testcase uses indexed strings without specifying | ||
7 | SW_AT_str_offsets_base. In this case we left u.str with garbage (from | ||
8 | u.val) which then led to a segfault when attempting to access the | ||
9 | string. Fix that by clearing u.str. The patch also adds missing | ||
10 | sanity checks in the recently committed read_indexed_address and | ||
11 | read_indexed_string functions. | ||
12 | |||
13 | PR 29230 | ||
14 | * dwarf2.c (read_indexed_address): Return uint64_t. Sanity check idx. | ||
15 | (read_indexed_string): Use uint64_t for str_offset. Sanity check idx. | ||
16 | (read_attribute_value): Clear u.str for indexed string forms when | ||
17 | DW_AT_str_offsets_base is not yet read or missing. | ||
18 | |||
19 | Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=31d6c13defeba7716ebc9d5c8f81f2f35fe39980] | ||
20 | |||
21 | CVE: CVE-2023-1579 | ||
22 | |||
23 | Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com> | ||
24 | |||
25 | --- | ||
26 | bfd/dwarf2.c | 51 ++++++++++++++++++++++++++++++++++++++++++--------- | ||
27 | 1 file changed, 42 insertions(+), 9 deletions(-) | ||
28 | |||
29 | diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c | ||
30 | index 51018e1ab45..aaa2d84887f 100644 | ||
31 | --- a/bfd/dwarf2.c | ||
32 | +++ b/bfd/dwarf2.c | ||
33 | @@ -1353,13 +1353,13 @@ is_addrx_form (enum dwarf_form form) | ||
34 | |||
35 | /* Returns the address in .debug_addr section using DW_AT_addr_base. | ||
36 | Used to implement DW_FORM_addrx*. */ | ||
37 | -static bfd_vma | ||
38 | +static uint64_t | ||
39 | read_indexed_address (uint64_t idx, struct comp_unit *unit) | ||
40 | { | ||
41 | struct dwarf2_debug *stash = unit->stash; | ||
42 | struct dwarf2_debug_file *file = unit->file; | ||
43 | - size_t addr_base = unit->dwarf_addr_offset; | ||
44 | bfd_byte *info_ptr; | ||
45 | + size_t offset; | ||
46 | |||
47 | if (stash == NULL) | ||
48 | return 0; | ||
49 | @@ -1369,12 +1369,23 @@ read_indexed_address (uint64_t idx, struct comp_unit *unit) | ||
50 | &file->dwarf_addr_buffer, &file->dwarf_addr_size)) | ||
51 | return 0; | ||
52 | |||
53 | - info_ptr = file->dwarf_addr_buffer + addr_base + idx * unit->offset_size; | ||
54 | + if (_bfd_mul_overflow (idx, unit->offset_size, &offset)) | ||
55 | + return 0; | ||
56 | + | ||
57 | + offset += unit->dwarf_addr_offset; | ||
58 | + if (offset < unit->dwarf_addr_offset | ||
59 | + || offset > file->dwarf_addr_size | ||
60 | + || file->dwarf_addr_size - offset < unit->offset_size) | ||
61 | + return 0; | ||
62 | + | ||
63 | + info_ptr = file->dwarf_addr_buffer + offset; | ||
64 | |||
65 | if (unit->offset_size == 4) | ||
66 | return bfd_get_32 (unit->abfd, info_ptr); | ||
67 | - else | ||
68 | + else if (unit->offset_size == 8) | ||
69 | return bfd_get_64 (unit->abfd, info_ptr); | ||
70 | + else | ||
71 | + return 0; | ||
72 | } | ||
73 | |||
74 | /* Returns the string using DW_AT_str_offsets_base. | ||
75 | @@ -1385,7 +1396,8 @@ read_indexed_string (uint64_t idx, struct comp_unit *unit) | ||
76 | struct dwarf2_debug *stash = unit->stash; | ||
77 | struct dwarf2_debug_file *file = unit->file; | ||
78 | bfd_byte *info_ptr; | ||
79 | - unsigned long str_offset; | ||
80 | + uint64_t str_offset; | ||
81 | + size_t offset; | ||
82 | |||
83 | if (stash == NULL) | ||
84 | return NULL; | ||
85 | @@ -1401,15 +1413,26 @@ read_indexed_string (uint64_t idx, struct comp_unit *unit) | ||
86 | &file->dwarf_str_offsets_size)) | ||
87 | return NULL; | ||
88 | |||
89 | - info_ptr = (file->dwarf_str_offsets_buffer | ||
90 | - + unit->dwarf_str_offset | ||
91 | - + idx * unit->offset_size); | ||
92 | + if (_bfd_mul_overflow (idx, unit->offset_size, &offset)) | ||
93 | + return NULL; | ||
94 | + | ||
95 | + offset += unit->dwarf_str_offset; | ||
96 | + if (offset < unit->dwarf_str_offset | ||
97 | + || offset > file->dwarf_str_offsets_size | ||
98 | + || file->dwarf_str_offsets_size - offset < unit->offset_size) | ||
99 | + return NULL; | ||
100 | + | ||
101 | + info_ptr = file->dwarf_str_offsets_buffer + offset; | ||
102 | |||
103 | if (unit->offset_size == 4) | ||
104 | str_offset = bfd_get_32 (unit->abfd, info_ptr); | ||
105 | - else | ||
106 | + else if (unit->offset_size == 8) | ||
107 | str_offset = bfd_get_64 (unit->abfd, info_ptr); | ||
108 | + else | ||
109 | + return NULL; | ||
110 | |||
111 | + if (str_offset >= file->dwarf_str_size) | ||
112 | + return NULL; | ||
113 | return (const char *) file->dwarf_str_buffer + str_offset; | ||
114 | } | ||
115 | |||
116 | @@ -1534,27 +1557,37 @@ read_attribute_value (struct attribute * attr, | ||
117 | is not yet read. */ | ||
118 | if (unit->dwarf_str_offset != 0) | ||
119 | attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
120 | + else | ||
121 | + attr->u.str = NULL; | ||
122 | break; | ||
123 | case DW_FORM_strx2: | ||
124 | attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); | ||
125 | if (unit->dwarf_str_offset != 0) | ||
126 | attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
127 | + else | ||
128 | + attr->u.str = NULL; | ||
129 | break; | ||
130 | case DW_FORM_strx3: | ||
131 | attr->u.val = read_3_bytes (abfd, &info_ptr, info_ptr_end); | ||
132 | if (unit->dwarf_str_offset != 0) | ||
133 | attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
134 | + else | ||
135 | + attr->u.str = NULL; | ||
136 | break; | ||
137 | case DW_FORM_strx4: | ||
138 | attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); | ||
139 | if (unit->dwarf_str_offset != 0) | ||
140 | attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
141 | + else | ||
142 | + attr->u.str = NULL; | ||
143 | break; | ||
144 | case DW_FORM_strx: | ||
145 | attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, | ||
146 | false, info_ptr_end); | ||
147 | if (unit->dwarf_str_offset != 0) | ||
148 | attr->u.str = (char *) read_indexed_string (attr->u.val, unit); | ||
149 | + else | ||
150 | + attr->u.str = NULL; | ||
151 | break; | ||
152 | case DW_FORM_exprloc: | ||
153 | case DW_FORM_block: | ||
154 | -- | ||
155 | 2.31.1 | ||
156 | |||
diff --git a/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-4.patch b/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-4.patch new file mode 100644 index 0000000000..c5a869ca9d --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0021-CVE-2023-1579-4.patch | |||
@@ -0,0 +1,37 @@ | |||
1 | From 3e307d538c351aa9327cbad672c884059ecc20dd Mon Sep 17 00:00:00 2001 | ||
2 | From: Nick Clifton <nickc@redhat.com> | ||
3 | Date: Wed, 11 Jan 2023 12:13:46 +0000 | ||
4 | Subject: [PATCH] Fix a potential illegal memory access in the BFD library when | ||
5 | parsing a corrupt DWARF file. | ||
6 | |||
7 | PR 29988 | ||
8 | * dwarf2.c (read_indexed_address): Fix check for an out of range | ||
9 | offset. | ||
10 | |||
11 | Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3e307d538c351aa9327cbad672c884059ecc20dd] | ||
12 | |||
13 | CVE: CVE-2023-1579 | ||
14 | |||
15 | Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com> | ||
16 | |||
17 | --- | ||
18 | bfd/ChangeLog | 6 ++++++ | ||
19 | bfd/dwarf2.c | 2 +- | ||
20 | 2 files changed, 7 insertions(+), 1 deletion(-) | ||
21 | |||
22 | diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c | ||
23 | index 6eb6e04e6e5..4ec0053a111 100644 | ||
24 | --- a/bfd/dwarf2.c | ||
25 | +++ b/bfd/dwarf2.c | ||
26 | @@ -1412,7 +1412,7 @@ read_indexed_address (uint64_t idx, struct comp_unit *unit) | ||
27 | offset += unit->dwarf_addr_offset; | ||
28 | if (offset < unit->dwarf_addr_offset | ||
29 | || offset > file->dwarf_addr_size | ||
30 | - || file->dwarf_addr_size - offset < unit->offset_size) | ||
31 | + || file->dwarf_addr_size - offset < unit->addr_size) | ||
32 | return 0; | ||
33 | |||
34 | info_ptr = file->dwarf_addr_buffer + offset; | ||
35 | -- | ||
36 | 2.31.1 | ||
37 | |||