diff options
Diffstat (limited to 'meta')
10 files changed, 1061 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils-2.27.inc b/meta/recipes-devtools/binutils/binutils-2.27.inc index fdc1252c23..b38a9583cf 100644 --- a/meta/recipes-devtools/binutils/binutils-2.27.inc +++ b/meta/recipes-devtools/binutils/binutils-2.27.inc | |||
@@ -91,6 +91,15 @@ SRC_URI = "\ | |||
91 | file://CVE-2017-9756.patch \ | 91 | file://CVE-2017-9756.patch \ |
92 | file://CVE-2017-9745.patch \ | 92 | file://CVE-2017-9745.patch \ |
93 | file://CVE-2017-9954.patch \ | 93 | file://CVE-2017-9954.patch \ |
94 | file://CVE-2017-9955_1.patch \ | ||
95 | file://CVE-2017-9955_2.patch \ | ||
96 | file://CVE-2017-9955_3.patch \ | ||
97 | file://CVE-2017-9955_4.patch \ | ||
98 | file://CVE-2017-9955_5.patch \ | ||
99 | file://CVE-2017-9955_6.patch \ | ||
100 | file://CVE-2017-9955_7.patch \ | ||
101 | file://CVE-2017-9955_8.patch \ | ||
102 | file://CVE-2017-9955_9.patch \ | ||
94 | " | 103 | " |
95 | S = "${WORKDIR}/git" | 104 | S = "${WORKDIR}/git" |
96 | 105 | ||
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_1.patch b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_1.patch new file mode 100644 index 0000000000..6cd86c2a30 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_1.patch | |||
@@ -0,0 +1,93 @@ | |||
1 | commit cfd14a500e0485374596234de4db10e88ebc7618 | ||
2 | Author: Nick Clifton <nickc@redhat.com> | ||
3 | Date: Mon Jun 26 15:25:08 2017 +0100 | ||
4 | |||
5 | Fix address violations when atempting to parse fuzzed binaries. | ||
6 | |||
7 | PR binutils/21665 | ||
8 | * compress.c (bfd_get_full_section_contents): Check for and reject | ||
9 | a section whoes size is greater than the size of the entire file. | ||
10 | * elf32-v850.c (v850_elf_copy_notes): Allow for the ouput to not | ||
11 | contain a notes section. | ||
12 | |||
13 | binutils* objdump.c (disassemble_section): Skip any section that is bigger | ||
14 | than the entire file. | ||
15 | |||
16 | Upstream-Status: Backport | ||
17 | |||
18 | CVE: CVE-2017-9955 | ||
19 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
20 | |||
21 | Index: git/bfd/compress.c | ||
22 | =================================================================== | ||
23 | --- git.orig/bfd/compress.c 2017-09-21 17:32:51.645611404 +0530 | ||
24 | +++ git/bfd/compress.c 2017-09-21 17:32:52.965622987 +0530 | ||
25 | @@ -239,6 +239,12 @@ | ||
26 | *ptr = NULL; | ||
27 | return TRUE; | ||
28 | } | ||
29 | + else if (bfd_get_file_size (abfd) > 0 | ||
30 | + && sz > (bfd_size_type) bfd_get_file_size (abfd)) | ||
31 | + { | ||
32 | + *ptr = NULL; | ||
33 | + return FALSE; | ||
34 | + } | ||
35 | |||
36 | switch (sec->compress_status) | ||
37 | { | ||
38 | Index: git/bfd/elf32-v850.c | ||
39 | =================================================================== | ||
40 | --- git.orig/bfd/elf32-v850.c 2017-09-21 17:32:35.053465773 +0530 | ||
41 | +++ git/bfd/elf32-v850.c 2017-09-21 17:32:52.965622987 +0530 | ||
42 | @@ -2448,7 +2448,9 @@ | ||
43 | BFD_ASSERT (bfd_malloc_and_get_section (ibfd, inotes, & icont)); | ||
44 | |||
45 | if ((ocont = elf_section_data (onotes)->this_hdr.contents) == NULL) | ||
46 | - BFD_ASSERT (bfd_malloc_and_get_section (obfd, onotes, & ocont)); | ||
47 | + /* If the output is being stripped then it is possible for | ||
48 | + the notes section to disappear. In this case do nothing. */ | ||
49 | + return; | ||
50 | |||
51 | /* Copy/overwrite notes from the input to the output. */ | ||
52 | memcpy (ocont, icont, bfd_section_size (obfd, onotes)); | ||
53 | Index: git/binutils/objdump.c | ||
54 | =================================================================== | ||
55 | --- git.orig/binutils/objdump.c 2017-09-21 17:32:52.337617476 +0530 | ||
56 | +++ git/binutils/objdump.c 2017-09-21 17:32:52.965622987 +0530 | ||
57 | @@ -1973,7 +1973,7 @@ | ||
58 | return; | ||
59 | |||
60 | datasize = bfd_get_section_size (section); | ||
61 | - if (datasize == 0) | ||
62 | + if (datasize == 0 || datasize >= (bfd_size_type) bfd_get_file_size (abfd)) | ||
63 | return; | ||
64 | |||
65 | if (start_address == (bfd_vma) -1 | ||
66 | @@ -2839,7 +2839,7 @@ | ||
67 | static void | ||
68 | dump_section (bfd *abfd, asection *section, void *dummy ATTRIBUTE_UNUSED) | ||
69 | { | ||
70 | - bfd_byte *data = 0; | ||
71 | + bfd_byte *data = NULL; | ||
72 | bfd_size_type datasize; | ||
73 | bfd_vma addr_offset; | ||
74 | bfd_vma start_offset; | ||
75 | Index: git/bfd/ChangeLog | ||
76 | =================================================================== | ||
77 | --- git.orig/bfd/ChangeLog 2017-09-21 17:32:52.909622495 +0530 | ||
78 | +++ git/bfd/ChangeLog 2017-09-21 17:35:57.863164167 +0530 | ||
79 | @@ -11,6 +11,14 @@ | ||
80 | of end pointer. | ||
81 | (evax_bfd_print_emh): Check for invalid string lengths. | ||
82 | |||
83 | +2017-06-26 Nick Clifton <nickc@redhat.com> | ||
84 | + | ||
85 | + PR binutils/21665 | ||
86 | + * compress.c (bfd_get_full_section_contents): Check for and reject | ||
87 | + a section whoes size is greater than the size of the entire file. | ||
88 | + * elf32-v850.c (v850_elf_copy_notes): Allow for the ouput to not | ||
89 | + contain a notes section. | ||
90 | + | ||
91 | 2017-07-24 Nick Clifton <nickc@redhat.com> | ||
92 | |||
93 | PR 21813 | ||
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_2.patch b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_2.patch new file mode 100644 index 0000000000..6e1824bbab --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_2.patch | |||
@@ -0,0 +1,112 @@ | |||
1 | commit 0630b49c470ca2e3c3f74da4c7e4ff63440dd71f | ||
2 | Author: H.J. Lu <hjl.tools@gmail.com> | ||
3 | Date: Mon Jun 26 09:24:49 2017 -0700 | ||
4 | |||
5 | Check file size before getting section contents | ||
6 | |||
7 | Don't check the section size in bfd_get_full_section_contents since | ||
8 | the size of a decompressed section may be larger than the file size. | ||
9 | Instead, check file size in _bfd_generic_get_section_contents. | ||
10 | |||
11 | PR binutils/21665 | ||
12 | * compress.c (bfd_get_full_section_contents): Don't check the | ||
13 | file size here. | ||
14 | * libbfd.c (_bfd_generic_get_section_contents): Check for and | ||
15 | reject a section whoes size + offset is greater than the size | ||
16 | of the entire file. | ||
17 | (_bfd_generic_get_section_contents_in_window): Likewise. | ||
18 | |||
19 | Upstream-Status: Backport | ||
20 | |||
21 | CVE: CVE-2017-9955 | ||
22 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
23 | |||
24 | Index: git/bfd/libbfd.c | ||
25 | =================================================================== | ||
26 | --- git.orig/bfd/libbfd.c 2017-09-21 17:41:59.457841691 +0530 | ||
27 | +++ git/bfd/libbfd.c 2017-09-21 17:42:18.269987768 +0530 | ||
28 | @@ -780,6 +780,7 @@ | ||
29 | bfd_size_type count) | ||
30 | { | ||
31 | bfd_size_type sz; | ||
32 | + file_ptr filesz; | ||
33 | if (count == 0) | ||
34 | return TRUE; | ||
35 | |||
36 | @@ -801,8 +802,15 @@ | ||
37 | sz = section->rawsize; | ||
38 | else | ||
39 | sz = section->size; | ||
40 | + filesz = bfd_get_file_size (abfd); | ||
41 | + if (filesz < 0) | ||
42 | + { | ||
43 | + /* This should never happen. */ | ||
44 | + abort (); | ||
45 | + } | ||
46 | if (offset + count < count | ||
47 | - || offset + count > sz) | ||
48 | + || offset + count > sz | ||
49 | + || (section->filepos + offset + sz) > (bfd_size_type) filesz) | ||
50 | { | ||
51 | bfd_set_error (bfd_error_invalid_operation); | ||
52 | return FALSE; | ||
53 | @@ -825,6 +833,7 @@ | ||
54 | { | ||
55 | #ifdef USE_MMAP | ||
56 | bfd_size_type sz; | ||
57 | + file_ptr filesz; | ||
58 | |||
59 | if (count == 0) | ||
60 | return TRUE; | ||
61 | @@ -857,7 +866,13 @@ | ||
62 | sz = section->rawsize; | ||
63 | else | ||
64 | sz = section->size; | ||
65 | + filesz = bfd_get_file_size (abfd); | ||
66 | + { | ||
67 | + /* This should never happen. */ | ||
68 | + abort (); | ||
69 | + } | ||
70 | if (offset + count > sz | ||
71 | + || (section->filepos + offset + sz) > (bfd_size_type) filesz | ||
72 | || ! bfd_get_file_window (abfd, section->filepos + offset, count, w, | ||
73 | TRUE)) | ||
74 | return FALSE; | ||
75 | Index: git/bfd/compress.c | ||
76 | =================================================================== | ||
77 | --- git.orig/bfd/compress.c 2017-09-21 17:42:18.213987332 +0530 | ||
78 | +++ git/bfd/compress.c 2017-09-21 17:45:17.107399434 +0530 | ||
79 | @@ -239,12 +239,6 @@ | ||
80 | *ptr = NULL; | ||
81 | return TRUE; | ||
82 | } | ||
83 | - else if (bfd_get_file_size (abfd) > 0 | ||
84 | - && sz > (bfd_size_type) bfd_get_file_size (abfd)) | ||
85 | - { | ||
86 | - *ptr = NULL; | ||
87 | - return FALSE; | ||
88 | - } | ||
89 | |||
90 | switch (sec->compress_status) | ||
91 | { | ||
92 | Index: git/bfd/ChangeLog | ||
93 | =================================================================== | ||
94 | --- git.orig/bfd/ChangeLog 2017-09-21 17:42:18.213987332 +0530 | ||
95 | +++ git/bfd/ChangeLog 2017-09-21 17:47:03.668256850 +0530 | ||
96 | @@ -11,6 +11,16 @@ | ||
97 | of end pointer. | ||
98 | (evax_bfd_print_emh): Check for invalid string lengths. | ||
99 | |||
100 | +2017-06-26 H.J. Lu <hongjiu.lu@intel.com> | ||
101 | + | ||
102 | + PR binutils/21665 | ||
103 | + * compress.c (bfd_get_full_section_contents): Don't check the | ||
104 | + file size here. | ||
105 | + * libbfd.c (_bfd_generic_get_section_contents): Check for and | ||
106 | + reject a section whoes size + offset is greater than the size | ||
107 | + of the entire file. | ||
108 | + (_bfd_generic_get_section_contents_in_window): Likewise. | ||
109 | + | ||
110 | 2017-06-26 Nick Clifton <nickc@redhat.com> | ||
111 | |||
112 | PR binutils/21665 | ||
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_3.patch b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_3.patch new file mode 100644 index 0000000000..c8741b13ca --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_3.patch | |||
@@ -0,0 +1,44 @@ | |||
1 | commit 1f473e3d0ad285195934e6a077c7ed32afe66437 | ||
2 | Author: H.J. Lu <hjl.tools@gmail.com> | ||
3 | Date: Mon Jun 26 15:47:16 2017 -0700 | ||
4 | |||
5 | Add a missing line to _bfd_generic_get_section_contents_in_window | ||
6 | |||
7 | PR binutils/21665 | ||
8 | * libbfd.c (_bfd_generic_get_section_contents_in_window): Add | ||
9 | a missing line. | ||
10 | |||
11 | Upstream-Status: Backport | ||
12 | |||
13 | CVE: CVE-2017-9955 | ||
14 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
15 | |||
16 | Index: git/bfd/libbfd.c | ||
17 | =================================================================== | ||
18 | --- git.orig/bfd/libbfd.c 2017-09-21 17:57:11.424955516 +0530 | ||
19 | +++ git/bfd/libbfd.c 2017-09-21 17:58:57.000000000 +0530 | ||
20 | @@ -867,6 +867,7 @@ | ||
21 | else | ||
22 | sz = section->size; | ||
23 | filesz = bfd_get_file_size (abfd); | ||
24 | + if (filesz < 0) | ||
25 | { | ||
26 | /* This should never happen. */ | ||
27 | abort (); | ||
28 | Index: git/bfd/ChangeLog | ||
29 | =================================================================== | ||
30 | --- git.orig/bfd/ChangeLog 2017-09-21 17:57:11.424955516 +0530 | ||
31 | +++ git/bfd/ChangeLog 2017-09-21 18:01:32.258884464 +0530 | ||
32 | @@ -14,6 +14,12 @@ | ||
33 | 2017-06-26 H.J. Lu <hongjiu.lu@intel.com> | ||
34 | |||
35 | PR binutils/21665 | ||
36 | + * libbfd.c (_bfd_generic_get_section_contents_in_window): Add | ||
37 | + a missing line. | ||
38 | + | ||
39 | +2017-06-26 H.J. Lu <hongjiu.lu@intel.com> | ||
40 | + | ||
41 | + PR binutils/21665 | ||
42 | * compress.c (bfd_get_full_section_contents): Don't check the | ||
43 | file size here. | ||
44 | * libbfd.c (_bfd_generic_get_section_contents): Check for and | ||
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_4.patch b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_4.patch new file mode 100644 index 0000000000..d6b6a14254 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_4.patch | |||
@@ -0,0 +1,50 @@ | |||
1 | commit ab27f80c5dceaa23c4ba7f62c0d5d22a5d5dd7a1 | ||
2 | Author: Pedro Alves <palves@redhat.com> | ||
3 | Date: Tue Jun 27 00:21:25 2017 +0100 | ||
4 | |||
5 | Fix GDB regressions caused by previous bfd_get_section_contents changes | ||
6 | |||
7 | Ref: https://sourceware.org/ml/binutils/2017-06/msg00343.html | ||
8 | |||
9 | bfd/ChangeLog: | ||
10 | 2017-06-26 Pedro Alves <palves@redhat.com> | ||
11 | |||
12 | PR binutils/21665 | ||
13 | * libbfd.c (_bfd_generic_get_section_contents): Add "count", not | ||
14 | "sz". | ||
15 | |||
16 | Upstream-Status: Backport | ||
17 | |||
18 | CVE: CVE-2017-9955 | ||
19 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
20 | |||
21 | Index: git/bfd/libbfd.c | ||
22 | =================================================================== | ||
23 | --- git.orig/bfd/libbfd.c 2017-09-21 18:01:58.079078554 +0530 | ||
24 | +++ git/bfd/libbfd.c 2017-09-21 18:01:58.063078433 +0530 | ||
25 | @@ -810,7 +810,7 @@ | ||
26 | } | ||
27 | if (offset + count < count | ||
28 | || offset + count > sz | ||
29 | - || (section->filepos + offset + sz) > (bfd_size_type) filesz) | ||
30 | + || (section->filepos + offset + count) > (bfd_size_type) filesz) | ||
31 | { | ||
32 | bfd_set_error (bfd_error_invalid_operation); | ||
33 | return FALSE; | ||
34 | Index: git/bfd/ChangeLog | ||
35 | =================================================================== | ||
36 | --- git.orig/bfd/ChangeLog 2017-09-21 18:01:32.258884464 +0530 | ||
37 | +++ git/bfd/ChangeLog 2017-09-21 18:03:42.955872017 +0530 | ||
38 | @@ -11,6 +11,12 @@ | ||
39 | of end pointer. | ||
40 | (evax_bfd_print_emh): Check for invalid string lengths. | ||
41 | |||
42 | +2017-06-26 Pedro Alves <palves@redhat.com> | ||
43 | + | ||
44 | + PR binutils/21665 | ||
45 | + * libbfd.c (_bfd_generic_get_section_contents): Add "count", not | ||
46 | + "sz". | ||
47 | + | ||
48 | 2017-06-26 H.J. Lu <hongjiu.lu@intel.com> | ||
49 | |||
50 | PR binutils/21665 | ||
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_5.patch b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_5.patch new file mode 100644 index 0000000000..3634421923 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_5.patch | |||
@@ -0,0 +1,89 @@ | |||
1 | commit 7211ae501eb0de1044983f2dfb00091a58fbd66c | ||
2 | Author: Alan Modra <amodra@gmail.com> | ||
3 | Date: Tue Jun 27 09:45:04 2017 +0930 | ||
4 | |||
5 | More fixes for bfd_get_section_contents change | ||
6 | |||
7 | PR binutils/21665 | ||
8 | * libbfd.c (_bfd_generic_get_section_contents): Delete abort. | ||
9 | Use unsigned file pointer type, and remove cast. | ||
10 | * libbfd.c (_bfd_generic_get_section_contents_in_window): Likewise. | ||
11 | Add "count", not "sz". | ||
12 | |||
13 | Upstream-Status: Backport | ||
14 | |||
15 | CVE: CVE-2017-9955 | ||
16 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
17 | |||
18 | Index: git/bfd/libbfd.c | ||
19 | =================================================================== | ||
20 | --- git.orig/bfd/libbfd.c 2017-09-21 18:04:47.316362760 +0530 | ||
21 | +++ git/bfd/libbfd.c 2017-09-21 18:04:47.300362638 +0530 | ||
22 | @@ -780,7 +780,7 @@ | ||
23 | bfd_size_type count) | ||
24 | { | ||
25 | bfd_size_type sz; | ||
26 | - file_ptr filesz; | ||
27 | + ufile_ptr filesz; | ||
28 | if (count == 0) | ||
29 | return TRUE; | ||
30 | |||
31 | @@ -803,14 +803,9 @@ | ||
32 | else | ||
33 | sz = section->size; | ||
34 | filesz = bfd_get_file_size (abfd); | ||
35 | - if (filesz < 0) | ||
36 | - { | ||
37 | - /* This should never happen. */ | ||
38 | - abort (); | ||
39 | - } | ||
40 | if (offset + count < count | ||
41 | || offset + count > sz | ||
42 | - || (section->filepos + offset + count) > (bfd_size_type) filesz) | ||
43 | + || section->filepos + offset + count > filesz) | ||
44 | { | ||
45 | bfd_set_error (bfd_error_invalid_operation); | ||
46 | return FALSE; | ||
47 | @@ -833,7 +828,7 @@ | ||
48 | { | ||
49 | #ifdef USE_MMAP | ||
50 | bfd_size_type sz; | ||
51 | - file_ptr filesz; | ||
52 | + ufile_ptr filesz; | ||
53 | |||
54 | if (count == 0) | ||
55 | return TRUE; | ||
56 | @@ -867,13 +862,8 @@ | ||
57 | else | ||
58 | sz = section->size; | ||
59 | filesz = bfd_get_file_size (abfd); | ||
60 | - if (filesz < 0) | ||
61 | - { | ||
62 | - /* This should never happen. */ | ||
63 | - abort (); | ||
64 | - } | ||
65 | if (offset + count > sz | ||
66 | - || (section->filepos + offset + sz) > (bfd_size_type) filesz | ||
67 | + || section->filepos + offset + count > filesz | ||
68 | || ! bfd_get_file_window (abfd, section->filepos + offset, count, w, | ||
69 | TRUE)) | ||
70 | return FALSE; | ||
71 | Index: git/bfd/ChangeLog | ||
72 | =================================================================== | ||
73 | --- git.orig/bfd/ChangeLog 2017-09-21 18:03:42.955872017 +0530 | ||
74 | +++ git/bfd/ChangeLog 2017-09-21 18:06:39.973228125 +0530 | ||
75 | @@ -11,6 +11,14 @@ | ||
76 | of end pointer. | ||
77 | (evax_bfd_print_emh): Check for invalid string lengths. | ||
78 | |||
79 | +2017-06-27 Alan Modra <amodra@gmail.com> | ||
80 | + | ||
81 | + PR binutils/21665 | ||
82 | + * libbfd.c (_bfd_generic_get_section_contents): Delete abort. | ||
83 | + Use unsigned file pointer type, and remove cast. | ||
84 | + * libbfd.c (_bfd_generic_get_section_contents_in_window): Likewise. | ||
85 | + Add "count", not "sz". | ||
86 | + | ||
87 | 2017-06-26 Pedro Alves <palves@redhat.com> | ||
88 | |||
89 | PR binutils/21665 | ||
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_6.patch b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_6.patch new file mode 100644 index 0000000000..55feb79c17 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_6.patch | |||
@@ -0,0 +1,55 @@ | |||
1 | commit ea9aafc41a764e4e2dbb88a7b031e886b481b99a | ||
2 | Author: Alan Modra <amodra@gmail.com> | ||
3 | Date: Tue Jun 27 14:43:49 2017 +0930 | ||
4 | |||
5 | Warning fix | ||
6 | |||
7 | PR binutils/21665 | ||
8 | * libbfd.c (_bfd_generic_get_section_contents): Warning fix. | ||
9 | (_bfd_generic_get_section_contents_in_window): Likewise. | ||
10 | |||
11 | Upstream-Status: Backport | ||
12 | |||
13 | CVE: CVE-2017-9955 | ||
14 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
15 | |||
16 | |||
17 | Index: git/bfd/libbfd.c | ||
18 | =================================================================== | ||
19 | --- git.orig/bfd/libbfd.c 2017-09-21 18:07:34.777651818 +0530 | ||
20 | +++ git/bfd/libbfd.c 2017-09-21 18:07:34.761651695 +0530 | ||
21 | @@ -805,7 +805,7 @@ | ||
22 | filesz = bfd_get_file_size (abfd); | ||
23 | if (offset + count < count | ||
24 | || offset + count > sz | ||
25 | - || section->filepos + offset + count > filesz) | ||
26 | + || (ufile_ptr) section->filepos + offset + count > filesz) | ||
27 | { | ||
28 | bfd_set_error (bfd_error_invalid_operation); | ||
29 | return FALSE; | ||
30 | @@ -863,7 +863,7 @@ | ||
31 | sz = section->size; | ||
32 | filesz = bfd_get_file_size (abfd); | ||
33 | if (offset + count > sz | ||
34 | - || section->filepos + offset + count > filesz | ||
35 | + || (ufile_ptr) section->filepos + offset + count > filesz | ||
36 | || ! bfd_get_file_window (abfd, section->filepos + offset, count, w, | ||
37 | TRUE)) | ||
38 | return FALSE; | ||
39 | Index: git/bfd/ChangeLog | ||
40 | =================================================================== | ||
41 | --- git.orig/bfd/ChangeLog 2017-09-21 18:06:39.973228125 +0530 | ||
42 | +++ git/bfd/ChangeLog 2017-09-21 18:09:41.798640031 +0530 | ||
43 | @@ -19,6 +19,12 @@ | ||
44 | * libbfd.c (_bfd_generic_get_section_contents_in_window): Likewise. | ||
45 | Add "count", not "sz". | ||
46 | |||
47 | +2017-06-27 Alan Modra <amodra@gmail.com> | ||
48 | + | ||
49 | + PR binutils/21665 | ||
50 | + * libbfd.c (_bfd_generic_get_section_contents): Warning fix. | ||
51 | + (_bfd_generic_get_section_contents_in_window): Likewise. | ||
52 | + | ||
53 | 2017-06-26 Pedro Alves <palves@redhat.com> | ||
54 | |||
55 | PR binutils/21665 | ||
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_7.patch b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_7.patch new file mode 100644 index 0000000000..0950561e10 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_7.patch | |||
@@ -0,0 +1,79 @@ | |||
1 | commit 60a02042bacf8d25814430080adda61ed086bca6 | ||
2 | Author: Nick Clifton <nickc@redhat.com> | ||
3 | Date: Fri Jun 30 11:03:37 2017 +0100 | ||
4 | |||
5 | Fix failures in MMIX linker tests introduced by fix for PR 21665. | ||
6 | |||
7 | PR binutils/21665 | ||
8 | * objdump.c (disassemble_section): Move check for an overlarge | ||
9 | section to just before the allocation of memory. Do not check | ||
10 | section size against file size, but instead use an arbitrary 2Gb | ||
11 | limit. Issue a warning message if the section is too big. | ||
12 | |||
13 | Upstream-Status: CVE-2017-9955 | ||
14 | |||
15 | CVE: CVE-2017-9955 | ||
16 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
17 | |||
18 | Index: git/binutils/objdump.c | ||
19 | =================================================================== | ||
20 | --- git.orig/binutils/objdump.c 2017-09-21 18:10:55.499217078 +0530 | ||
21 | +++ git/binutils/objdump.c 2017-09-21 18:10:55.483216953 +0530 | ||
22 | @@ -1973,7 +1973,7 @@ | ||
23 | return; | ||
24 | |||
25 | datasize = bfd_get_section_size (section); | ||
26 | - if (datasize == 0 || datasize >= (bfd_size_type) bfd_get_file_size (abfd)) | ||
27 | + if (datasize == 0) | ||
28 | return; | ||
29 | |||
30 | if (start_address == (bfd_vma) -1 | ||
31 | @@ -2037,6 +2037,29 @@ | ||
32 | } | ||
33 | rel_ppend = rel_pp + rel_count; | ||
34 | |||
35 | + /* PR 21665: Check for overlarge datasizes. | ||
36 | + Note - we used to check for "datasize > bfd_get_file_size (abfd)" but | ||
37 | + this fails when using compressed sections or compressed file formats | ||
38 | + (eg MMO, tekhex). | ||
39 | + | ||
40 | + The call to xmalloc below will fail if too much memory is requested, | ||
41 | + which will catch the problem in the normal use case. But if a memory | ||
42 | + checker is in use, eg valgrind or sanitize, then an exception will | ||
43 | + be still generated, so we try to catch the problem first. | ||
44 | + | ||
45 | + Unfortunately there is no simple way to determine how much memory can | ||
46 | + be allocated by calling xmalloc. So instead we use a simple, arbitrary | ||
47 | + limit of 2Gb. Hopefully this should be enough for most users. If | ||
48 | + someone does start trying to disassemble sections larger then 2Gb in | ||
49 | + size they will doubtless complain and we can increase the limit. */ | ||
50 | +#define MAX_XMALLOC (1024 * 1024 * 1024 * 2UL) /* 2Gb */ | ||
51 | + if (datasize > MAX_XMALLOC) | ||
52 | + { | ||
53 | + non_fatal (_("Reading section %s failed because it is too big (%#lx)"), | ||
54 | + section->name, (unsigned long) datasize); | ||
55 | + return; | ||
56 | + } | ||
57 | + | ||
58 | data = (bfd_byte *) xmalloc (datasize); | ||
59 | |||
60 | bfd_get_section_contents (abfd, section, data, 0, datasize); | ||
61 | Index: git/binutils/ChangeLog | ||
62 | =================================================================== | ||
63 | --- git.orig/binutils/ChangeLog 2017-09-21 17:57:10.448948416 +0530 | ||
64 | +++ git/binutils/ChangeLog 2017-09-21 18:13:09.052268892 +0530 | ||
65 | @@ -4,6 +4,14 @@ | ||
66 | * rddbg.c (read_symbol_stabs_debugging_info): Check for an empty | ||
67 | string whilst concatenating symbol names. | ||
68 | |||
69 | +2017-06-30 Nick Clifton <nickc@redhat.com> | ||
70 | + | ||
71 | + PR binutils/21665 | ||
72 | + * objdump.c (disassemble_section): Move check for an overlarge | ||
73 | + section to just before the allocation of memory. Do not check | ||
74 | + section size against file size, but instead use an arbitrary 2Gb | ||
75 | + limit. Issue a warning message if the section is too big. | ||
76 | + | ||
77 | 2017-05-02 Nick Clifton <nickc@redhat.com> | ||
78 | |||
79 | PR 21440 | ||
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_8.patch b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_8.patch new file mode 100644 index 0000000000..8035ab38cb --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_8.patch | |||
@@ -0,0 +1,170 @@ | |||
1 | commit bae7501e87ab614115d9d3213b4dd18d96e604db | ||
2 | Author: Alan Modra <amodra@gmail.com> | ||
3 | Date: Sat Jul 1 21:58:10 2017 +0930 | ||
4 | |||
5 | Use bfd_malloc_and_get_section | ||
6 | |||
7 | It's nicer than xmalloc followed by bfd_get_section_contents, since | ||
8 | xmalloc exits on failure and needs a check that its size_t arg doesn't | ||
9 | lose high bits when converted from bfd_size_type. | ||
10 | |||
11 | PR binutils/21665 | ||
12 | * objdump.c (strtab): Make var a bfd_byte*. | ||
13 | (disassemble_section): Don't limit malloc size. Instead, use | ||
14 | bfd_malloc_and_get_section. | ||
15 | (read_section_stabs): Use bfd_malloc_and_get_section. Return | ||
16 | bfd_byte*. | ||
17 | (find_stabs_section): Remove now unnecessary cast. | ||
18 | * objcopy.c (copy_object): Use bfd_malloc_and_get_section. Free | ||
19 | contents on error return. | ||
20 | * nlmconv.c (copy_sections): Use bfd_malloc_and_get_section. | ||
21 | |||
22 | Upstream-Status: Backport | ||
23 | |||
24 | CVE: CVE-2017-9955 | ||
25 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
26 | |||
27 | Index: git/binutils/nlmconv.c | ||
28 | =================================================================== | ||
29 | --- git.orig/binutils/nlmconv.c 2017-09-21 18:14:15.792797232 +0530 | ||
30 | +++ git/binutils/nlmconv.c 2017-09-21 18:14:15.776797105 +0530 | ||
31 | @@ -1224,7 +1224,7 @@ | ||
32 | const char *inname; | ||
33 | asection *outsec; | ||
34 | bfd_size_type size; | ||
35 | - void *contents; | ||
36 | + bfd_byte *contents; | ||
37 | long reloc_size; | ||
38 | bfd_byte buf[4]; | ||
39 | bfd_size_type add; | ||
40 | @@ -1240,9 +1240,7 @@ | ||
41 | contents = NULL; | ||
42 | else | ||
43 | { | ||
44 | - contents = xmalloc (size); | ||
45 | - if (! bfd_get_section_contents (inbfd, insec, contents, | ||
46 | - (file_ptr) 0, size)) | ||
47 | + if (!bfd_malloc_and_get_section (inbfd, insec, &contents)) | ||
48 | bfd_fatal (bfd_get_filename (inbfd)); | ||
49 | } | ||
50 | |||
51 | Index: git/binutils/objdump.c | ||
52 | =================================================================== | ||
53 | --- git.orig/binutils/objdump.c 2017-09-21 18:14:15.792797232 +0530 | ||
54 | +++ git/binutils/objdump.c 2017-09-21 18:23:30.420895459 +0530 | ||
55 | @@ -180,7 +180,7 @@ | ||
56 | static bfd_byte *stabs; | ||
57 | static bfd_size_type stab_size; | ||
58 | |||
59 | -static char *strtab; | ||
60 | +static bfd_byte *strtab; | ||
61 | static bfd_size_type stabstr_size; | ||
62 | |||
63 | static bfd_boolean is_relocatable = FALSE; | ||
64 | @@ -2037,33 +2037,13 @@ | ||
65 | } | ||
66 | rel_ppend = rel_pp + rel_count; | ||
67 | |||
68 | - /* PR 21665: Check for overlarge datasizes. | ||
69 | - Note - we used to check for "datasize > bfd_get_file_size (abfd)" but | ||
70 | - this fails when using compressed sections or compressed file formats | ||
71 | - (eg MMO, tekhex). | ||
72 | - | ||
73 | - The call to xmalloc below will fail if too much memory is requested, | ||
74 | - which will catch the problem in the normal use case. But if a memory | ||
75 | - checker is in use, eg valgrind or sanitize, then an exception will | ||
76 | - be still generated, so we try to catch the problem first. | ||
77 | - | ||
78 | - Unfortunately there is no simple way to determine how much memory can | ||
79 | - be allocated by calling xmalloc. So instead we use a simple, arbitrary | ||
80 | - limit of 2Gb. Hopefully this should be enough for most users. If | ||
81 | - someone does start trying to disassemble sections larger then 2Gb in | ||
82 | - size they will doubtless complain and we can increase the limit. */ | ||
83 | -#define MAX_XMALLOC (1024 * 1024 * 1024 * 2UL) /* 2Gb */ | ||
84 | - if (datasize > MAX_XMALLOC) | ||
85 | + if (!bfd_malloc_and_get_section (abfd, section, &data)) | ||
86 | { | ||
87 | - non_fatal (_("Reading section %s failed because it is too big (%#lx)"), | ||
88 | - section->name, (unsigned long) datasize); | ||
89 | + non_fatal (_("Reading section %s failed because: %s"), | ||
90 | + section->name, bfd_errmsg (bfd_get_error ())); | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | - data = (bfd_byte *) xmalloc (datasize); | ||
95 | - | ||
96 | - bfd_get_section_contents (abfd, section, data, 0, datasize); | ||
97 | - | ||
98 | paux->sec = section; | ||
99 | pinfo->buffer = data; | ||
100 | pinfo->buffer_vma = section->vma; | ||
101 | @@ -2579,12 +2559,11 @@ | ||
102 | /* Read ABFD's stabs section STABSECT_NAME, and return a pointer to | ||
103 | it. Return NULL on failure. */ | ||
104 | |||
105 | -static char * | ||
106 | +static bfd_byte * | ||
107 | read_section_stabs (bfd *abfd, const char *sect_name, bfd_size_type *size_ptr) | ||
108 | { | ||
109 | asection *stabsect; | ||
110 | - bfd_size_type size; | ||
111 | - char *contents; | ||
112 | + bfd_byte *contents; | ||
113 | |||
114 | stabsect = bfd_get_section_by_name (abfd, sect_name); | ||
115 | if (stabsect == NULL) | ||
116 | @@ -2593,10 +2572,7 @@ | ||
117 | return FALSE; | ||
118 | } | ||
119 | |||
120 | - size = bfd_section_size (abfd, stabsect); | ||
121 | - contents = (char *) xmalloc (size); | ||
122 | - | ||
123 | - if (! bfd_get_section_contents (abfd, stabsect, contents, 0, size)) | ||
124 | + if (!bfd_malloc_and_get_section (abfd, stabsect, &contents)) | ||
125 | { | ||
126 | non_fatal (_("reading %s section of %s failed: %s"), | ||
127 | sect_name, bfd_get_filename (abfd), | ||
128 | @@ -2606,7 +2582,7 @@ | ||
129 | return NULL; | ||
130 | } | ||
131 | |||
132 | - *size_ptr = size; | ||
133 | + *size_ptr = bfd_section_size (abfd, stabsect); | ||
134 | |||
135 | return contents; | ||
136 | } | ||
137 | @@ -2733,8 +2709,7 @@ | ||
138 | |||
139 | if (strtab) | ||
140 | { | ||
141 | - stabs = (bfd_byte *) read_section_stabs (abfd, section->name, | ||
142 | - &stab_size); | ||
143 | + stabs = read_section_stabs (abfd, section->name, &stab_size); | ||
144 | if (stabs) | ||
145 | print_section_stabs (abfd, section->name, &sought->string_offset); | ||
146 | } | ||
147 | Index: git/binutils/ChangeLog | ||
148 | =================================================================== | ||
149 | --- git.orig/binutils/ChangeLog 2017-09-21 18:13:09.052268892 +0530 | ||
150 | +++ git/binutils/ChangeLog 2017-09-21 18:25:00.195937741 +0530 | ||
151 | @@ -4,6 +4,19 @@ | ||
152 | * rddbg.c (read_symbol_stabs_debugging_info): Check for an empty | ||
153 | string whilst concatenating symbol names. | ||
154 | |||
155 | +2017-07-01 Alan Modra <amodra@gmail.com> | ||
156 | + | ||
157 | + PR binutils/21665 | ||
158 | + * objdump.c (strtab): Make var a bfd_byte*. | ||
159 | + (disassemble_section): Don't limit malloc size. Instead, use | ||
160 | + bfd_malloc_and_get_section. | ||
161 | + (read_section_stabs): Use bfd_malloc_and_get_section. Return | ||
162 | + bfd_byte*. | ||
163 | + (find_stabs_section): Remove now unnecessary cast. | ||
164 | + * objcopy.c (copy_object): Use bfd_malloc_and_get_section. Free | ||
165 | + contents on error return. | ||
166 | + * nlmconv.c (copy_sections): Use bfd_malloc_and_get_section. | ||
167 | + | ||
168 | 2017-06-30 Nick Clifton <nickc@redhat.com> | ||
169 | |||
170 | PR binutils/21665 | ||
diff --git a/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_9.patch b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_9.patch new file mode 100644 index 0000000000..2f50337dab --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/CVE-2017-9955_9.patch | |||
@@ -0,0 +1,360 @@ | |||
1 | commit 8e2f54bcee7e3e8315d4a39a302eaf8e4389e07d | ||
2 | Author: H.J. Lu <hjl.tools@gmail.com> | ||
3 | Date: Tue May 30 06:34:05 2017 -0700 | ||
4 | |||
5 | Add bfd_get_file_size to get archive element size | ||
6 | |||
7 | We can't use stat() to get archive element size. Add bfd_get_file_size | ||
8 | to get size for both normal files and archive elements. | ||
9 | |||
10 | bfd/ | ||
11 | |||
12 | PR binutils/21519 | ||
13 | * bfdio.c (bfd_get_file_size): New function. | ||
14 | * bfd-in2.h: Regenerated. | ||
15 | |||
16 | binutils/ | ||
17 | |||
18 | PR binutils/21519 | ||
19 | * objdump.c (dump_relocs_in_section): Replace get_file_size | ||
20 | with bfd_get_file_size to get archive element size. | ||
21 | * testsuite/binutils-all/objdump.exp (test_objdump_f): New | ||
22 | proc. | ||
23 | (test_objdump_h): Likewise. | ||
24 | (test_objdump_t): Likewise. | ||
25 | (test_objdump_r): Likewise. | ||
26 | (test_objdump_s): Likewise. | ||
27 | Add objdump tests on archive. | ||
28 | |||
29 | Upstream-Status: Backport | ||
30 | |||
31 | CVE: CVE-2017-9955 | ||
32 | Signed-off-by: Thiruvadi Rajaraman <trajaraman@mvista.com> | ||
33 | |||
34 | Index: git/bfd/bfd-in2.h | ||
35 | =================================================================== | ||
36 | --- git.orig/bfd/bfd-in2.h 2017-09-21 20:09:13.475032861 +0530 | ||
37 | +++ git/bfd/bfd-in2.h 2017-09-21 20:09:16.375051269 +0530 | ||
38 | @@ -1208,6 +1208,8 @@ | ||
39 | |||
40 | file_ptr bfd_get_size (bfd *abfd); | ||
41 | |||
42 | +file_ptr bfd_get_file_size (bfd *abfd); | ||
43 | + | ||
44 | void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len, | ||
45 | int prot, int flags, file_ptr offset, | ||
46 | void **map_addr, bfd_size_type *map_len); | ||
47 | Index: git/bfd/bfdio.c | ||
48 | =================================================================== | ||
49 | --- git.orig/bfd/bfdio.c 2017-09-21 20:08:55.774919453 +0530 | ||
50 | +++ git/bfd/bfdio.c 2017-09-21 20:09:16.375051269 +0530 | ||
51 | @@ -434,6 +434,29 @@ | ||
52 | return buf.st_size; | ||
53 | } | ||
54 | |||
55 | +/* | ||
56 | +FUNCTION | ||
57 | + bfd_get_file_size | ||
58 | + | ||
59 | +SYNOPSIS | ||
60 | + file_ptr bfd_get_file_size (bfd *abfd); | ||
61 | + | ||
62 | +DESCRIPTION | ||
63 | + Return the file size (as read from file system) for the file | ||
64 | + associated with BFD @var{abfd}. It supports both normal files | ||
65 | + and archive elements. | ||
66 | + | ||
67 | +*/ | ||
68 | + | ||
69 | +file_ptr | ||
70 | +bfd_get_file_size (bfd *abfd) | ||
71 | +{ | ||
72 | + if (abfd->my_archive != NULL | ||
73 | + && !bfd_is_thin_archive (abfd->my_archive)) | ||
74 | + return arelt_size (abfd); | ||
75 | + | ||
76 | + return bfd_get_size (abfd); | ||
77 | +} | ||
78 | |||
79 | /* | ||
80 | FUNCTION | ||
81 | Index: git/binutils/objdump.c | ||
82 | =================================================================== | ||
83 | --- git.orig/binutils/objdump.c 2017-09-21 20:09:16.319050914 +0530 | ||
84 | +++ git/binutils/objdump.c 2017-09-21 20:09:16.375051269 +0530 | ||
85 | @@ -3240,7 +3240,7 @@ | ||
86 | } | ||
87 | |||
88 | if ((bfd_get_file_flags (abfd) & (BFD_IN_MEMORY | BFD_LINKER_CREATED)) == 0 | ||
89 | - && relsize > get_file_size (bfd_get_filename (abfd))) | ||
90 | + && relsize > bfd_get_file_size (abfd)) | ||
91 | { | ||
92 | printf (" (too many: 0x%x)\n", section->reloc_count); | ||
93 | bfd_set_error (bfd_error_file_truncated); | ||
94 | Index: git/binutils/testsuite/binutils-all/objdump.exp | ||
95 | =================================================================== | ||
96 | --- git.orig/binutils/testsuite/binutils-all/objdump.exp 2017-09-21 20:08:55.982920797 +0530 | ||
97 | +++ git/binutils/testsuite/binutils-all/objdump.exp 2017-09-21 20:09:16.375051269 +0530 | ||
98 | @@ -64,96 +64,168 @@ | ||
99 | if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then { | ||
100 | return | ||
101 | } | ||
102 | +if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest2.o]} then { | ||
103 | + return | ||
104 | +} | ||
105 | if [is_remote host] { | ||
106 | set testfile [remote_download host tmpdir/bintest.o] | ||
107 | + set testfile2 [remote_download host tmpdir/bintest2.o] | ||
108 | } else { | ||
109 | set testfile tmpdir/bintest.o | ||
110 | + set testfile2 tmpdir/bintest2.o | ||
111 | +} | ||
112 | + | ||
113 | +if { ![istarget "alpha-*-*"] || [is_elf_format] } then { | ||
114 | + remote_file host file delete tmpdir/bintest.a | ||
115 | + set got [binutils_run $AR "rc tmpdir/bintest.a $testfile2"] | ||
116 | + if ![string match "" $got] then { | ||
117 | + fail "bintest.a" | ||
118 | + remote_file host delete tmpdir/bintest.a | ||
119 | + } else { | ||
120 | + if [is_remote host] { | ||
121 | + set testarchive [remote_download host tmpdir/bintest.a] | ||
122 | + } else { | ||
123 | + set testarchive tmpdir/bintest.a | ||
124 | + } | ||
125 | + } | ||
126 | + remote_file host delete tmpdir/bintest2.o | ||
127 | } | ||
128 | |||
129 | # Test objdump -f | ||
130 | |||
131 | -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $testfile"] | ||
132 | +proc test_objdump_f { testfile dumpfile } { | ||
133 | + global OBJDUMP | ||
134 | + global OBJDUMPFLAGS | ||
135 | + global cpus_regex | ||
136 | |||
137 | -set want "$testfile:\[ \]*file format.*architecture:\[ \]*${cpus_regex}.*HAS_RELOC.*HAS_SYMS" | ||
138 | + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f $testfile"] | ||
139 | |||
140 | -if ![regexp $want $got] then { | ||
141 | - fail "objdump -f" | ||
142 | -} else { | ||
143 | - pass "objdump -f" | ||
144 | + set want "$dumpfile:\[ \]*file format.*architecture:\[ \]*${cpus_regex}.*HAS_RELOC.*HAS_SYMS" | ||
145 | + | ||
146 | + if ![regexp $want $got] then { | ||
147 | + fail "objdump -f ($testfile, $dumpfile)" | ||
148 | + } else { | ||
149 | + pass "objdump -f ($testfile, $dumpfile)" | ||
150 | + } | ||
151 | +} | ||
152 | + | ||
153 | +test_objdump_f $testfile $testfile | ||
154 | +if { [ remote_file host exists $testarchive ] } then { | ||
155 | + test_objdump_f $testarchive bintest2.o | ||
156 | } | ||
157 | |||
158 | # Test objdump -h | ||
159 | |||
160 | -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $testfile"] | ||
161 | +proc test_objdump_h { testfile dumpfile } { | ||
162 | + global OBJDUMP | ||
163 | + global OBJDUMPFLAGS | ||
164 | |||
165 | -set want "$testfile:\[ \]*file format.*Sections.*\[0-9\]+\[ \]+\[^ \]*(text|TEXT|P|\\\$CODE\\\$)\[^ \]*\[ \]*(\[0-9a-fA-F\]+).*\[0-9\]+\[ \]+\[^ \]*(\\.data|DATA|D_1)\[^ \]*\[ \]*(\[0-9a-fA-F\]+)" | ||
166 | + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -h $testfile"] | ||
167 | |||
168 | -if ![regexp $want $got all text_name text_size data_name data_size] then { | ||
169 | - fail "objdump -h" | ||
170 | -} else { | ||
171 | - verbose "text name is $text_name size is $text_size" | ||
172 | - verbose "data name is $data_name size is $data_size" | ||
173 | - set ets 8 | ||
174 | - set eds 4 | ||
175 | - # The [ti]c4x target has the property sizeof(char)=sizeof(long)=1 | ||
176 | - if [istarget *c4x*-*-*] then { | ||
177 | - set ets 2 | ||
178 | - set eds 1 | ||
179 | - } | ||
180 | - # c54x section sizes are in bytes, not octets; adjust accordingly | ||
181 | - if [istarget *c54x*-*-*] then { | ||
182 | - set ets 4 | ||
183 | - set eds 2 | ||
184 | - } | ||
185 | - if {[expr "0x$text_size"] < $ets || [expr "0x$data_size"] < $eds} then { | ||
186 | - send_log "sizes too small\n" | ||
187 | - fail "objdump -h" | ||
188 | + set want "$dumpfile:\[ \]*file format.*Sections.*\[0-9\]+\[ \]+\[^ \]*(text|TEXT|P|\\\$CODE\\\$)\[^ \]*\[ \]*(\[0-9a-fA-F\]+).*\[0-9\]+\[ \]+\[^ \]*(\\.data|DATA|D_1)\[^ \]*\[ \]*(\[0-9a-fA-F\]+)" | ||
189 | + | ||
190 | + if ![regexp $want $got all text_name text_size data_name data_size] then { | ||
191 | + fail "objdump -h ($testfile, $dumpfile)" | ||
192 | } else { | ||
193 | - pass "objdump -h" | ||
194 | + verbose "text name is $text_name size is $text_size" | ||
195 | + verbose "data name is $data_name size is $data_size" | ||
196 | + set ets 8 | ||
197 | + set eds 4 | ||
198 | + # The [ti]c4x target has the property sizeof(char)=sizeof(long)=1 | ||
199 | + if [istarget *c4x*-*-*] then { | ||
200 | + set ets 2 | ||
201 | + set eds 1 | ||
202 | + } | ||
203 | + # c54x section sizes are in bytes, not octets; adjust accordingly | ||
204 | + if [istarget *c54x*-*-*] then { | ||
205 | + set ets 4 | ||
206 | + set eds 2 | ||
207 | + } | ||
208 | + if {[expr "0x$text_size"] < $ets || [expr "0x$data_size"] < $eds} then { | ||
209 | + send_log "sizes too small\n" | ||
210 | + fail "objdump -h ($testfile, $dumpfile)" | ||
211 | + } else { | ||
212 | + pass "objdump -h ($testfile, $dumpfile)" | ||
213 | + } | ||
214 | } | ||
215 | } | ||
216 | |||
217 | +test_objdump_h $testfile $testfile | ||
218 | +if { [ remote_file host exists $testarchive ] } then { | ||
219 | + test_objdump_h $testarchive bintest2.o | ||
220 | +} | ||
221 | + | ||
222 | # Test objdump -t | ||
223 | |||
224 | -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"] | ||
225 | +proc test_objdump_t { testfile} { | ||
226 | + global OBJDUMP | ||
227 | + global OBJDUMPFLAGS | ||
228 | + | ||
229 | + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -t $testfile"] | ||
230 | + | ||
231 | + if [info exists vars] then { unset vars } | ||
232 | + while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} { | ||
233 | + set vars($symbol) 1 | ||
234 | + set got $rest | ||
235 | + } | ||
236 | |||
237 | -if [info exists vars] then { unset vars } | ||
238 | -while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} { | ||
239 | - set vars($symbol) 1 | ||
240 | - set got $rest | ||
241 | + if {![info exists vars(text_symbol)] \ | ||
242 | + || ![info exists vars(data_symbol)] \ | ||
243 | + || ![info exists vars(common_symbol)] \ | ||
244 | + || ![info exists vars(external_symbol)]} then { | ||
245 | + fail "objdump -t ($testfile)" | ||
246 | + } else { | ||
247 | + pass "objdump -t ($testfile)" | ||
248 | + } | ||
249 | } | ||
250 | |||
251 | -if {![info exists vars(text_symbol)] \ | ||
252 | - || ![info exists vars(data_symbol)] \ | ||
253 | - || ![info exists vars(common_symbol)] \ | ||
254 | - || ![info exists vars(external_symbol)]} then { | ||
255 | - fail "objdump -t" | ||
256 | -} else { | ||
257 | - pass "objdump -t" | ||
258 | +test_objdump_t $testfile | ||
259 | +if { [ remote_file host exists $testarchive ] } then { | ||
260 | + test_objdump_t $testarchive | ||
261 | } | ||
262 | |||
263 | # Test objdump -r | ||
264 | |||
265 | -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"] | ||
266 | +proc test_objdump_r { testfile dumpfile } { | ||
267 | + global OBJDUMP | ||
268 | + global OBJDUMPFLAGS | ||
269 | |||
270 | -set want "$testfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|P|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol" | ||
271 | + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -r $testfile"] | ||
272 | |||
273 | -if [regexp $want $got] then { | ||
274 | - pass "objdump -r" | ||
275 | -} else { | ||
276 | - fail "objdump -r" | ||
277 | + set want "$dumpfile:\[ \]*file format.*RELOCATION RECORDS FOR \\\[\[^\]\]*(text|TEXT|P|\\\$CODE\\\$)\[^\]\]*\\\].*external_symbol" | ||
278 | + | ||
279 | + if [regexp $want $got] then { | ||
280 | + pass "objdump -r ($testfile, $dumpfile)" | ||
281 | + } else { | ||
282 | + fail "objdump -r ($testfile, $dumpfile)" | ||
283 | + } | ||
284 | +} | ||
285 | + | ||
286 | +test_objdump_r $testfile $testfile | ||
287 | +if { [ remote_file host exists $testarchive ] } then { | ||
288 | + test_objdump_r $testarchive bintest2.o | ||
289 | } | ||
290 | |||
291 | # Test objdump -s | ||
292 | |||
293 | -set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"] | ||
294 | +proc test_objdump_s { testfile dumpfile } { | ||
295 | + global OBJDUMP | ||
296 | + global OBJDUMPFLAGS | ||
297 | |||
298 | -set want "$testfile:\[ \]*file format.*Contents.*(text|TEXT|P|\\\$CODE\\\$)\[^0-9\]*\[ \]*\[0-9a-fA-F\]*\[ \]*(00000001|01000000|00000100).*Contents.*(data|DATA|D_1)\[^0-9\]*\[ \]*\[0-9a-fA-F\]*\[ \]*(00000002|02000000|00000200)" | ||
299 | + set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -s $testfile"] | ||
300 | |||
301 | -if [regexp $want $got] then { | ||
302 | - pass "objdump -s" | ||
303 | -} else { | ||
304 | - fail "objdump -s" | ||
305 | + set want "$dumpfile:\[ \]*file format.*Contents.*(text|TEXT|P|\\\$CODE\\\$)\[^0-9\]*\[ \]*\[0-9a-fA-F\]*\[ \]*(00000001|01000000|00000100).*Contents.*(data|DATA|D_1)\[^0-9\]*\[ \]*\[0-9a-fA-F\]*\[ \]*(00000002|02000000|00000200)" | ||
306 | + | ||
307 | + if [regexp $want $got] then { | ||
308 | + pass "objdump -s ($testfile, $dumpfile)" | ||
309 | + } else { | ||
310 | + fail "objdump -s ($testfile, $dumpfile)" | ||
311 | + } | ||
312 | +} | ||
313 | + | ||
314 | +test_objdump_s $testfile $testfile | ||
315 | +if { [ remote_file host exists $testarchive ] } then { | ||
316 | + test_objdump_s $testarchive bintest2.o | ||
317 | } | ||
318 | |||
319 | # Test objdump -s on a file that contains a compressed .debug section | ||
320 | Index: git/bfd/ChangeLog | ||
321 | =================================================================== | ||
322 | --- git.orig/bfd/ChangeLog 2017-09-21 20:09:16.207050204 +0530 | ||
323 | +++ git/bfd/ChangeLog 2017-09-21 20:13:41.504562787 +0530 | ||
324 | @@ -158,6 +158,12 @@ | ||
325 | (bfd_perform_relocation, bfd_install_relocation): Use it. | ||
326 | (_bfd_final_link_relocate): Likewise. | ||
327 | |||
328 | +2017-05-30 H.J. Lu <hongjiu.lu@intel.com> | ||
329 | + | ||
330 | + PR binutils/21519 | ||
331 | + * bfdio.c (bfd_get_file_size): New function. | ||
332 | + * bfd-in2.h: Regenerated. | ||
333 | + | ||
334 | 2017-04-26 Nick Clifton <nickc@redhat.com> | ||
335 | |||
336 | PR binutils/21434 | ||
337 | Index: git/binutils/ChangeLog | ||
338 | =================================================================== | ||
339 | --- git.orig/binutils/ChangeLog 2017-09-21 20:09:16.319050914 +0530 | ||
340 | +++ git/binutils/ChangeLog 2017-09-21 20:12:42.624252645 +0530 | ||
341 | @@ -25,6 +25,19 @@ | ||
342 | section size against file size, but instead use an arbitrary 2Gb | ||
343 | limit. Issue a warning message if the section is too big. | ||
344 | |||
345 | +2017-05-30 H.J. Lu <hongjiu.lu@intel.com> | ||
346 | + | ||
347 | + PR binutils/21519 | ||
348 | + * objdump.c (dump_relocs_in_section): Replace get_file_size | ||
349 | + with bfd_get_file_size to get archive element size. | ||
350 | + * testsuite/binutils-all/objdump.exp (test_objdump_f): New | ||
351 | + proc. | ||
352 | + (test_objdump_h): Likewise. | ||
353 | + (test_objdump_t): Likewise. | ||
354 | + (test_objdump_r): Likewise. | ||
355 | + (test_objdump_s): Likewise. | ||
356 | + Add objdump tests on archive. | ||
357 | + | ||
358 | 2017-05-02 Nick Clifton <nickc@redhat.com> | ||
359 | |||
360 | PR 21440 | ||