diff options
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r-- | meta/recipes-devtools/binutils/binutils-2.35.inc | 1 | ||||
-rw-r--r-- | meta/recipes-devtools/binutils/binutils/0001-aarch64-Return-an-error-on-conditional-branch-to-an-.patch | 135 |
2 files changed, 136 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils-2.35.inc b/meta/recipes-devtools/binutils/binutils-2.35.inc index bc9107b084..aa02063b19 100644 --- a/meta/recipes-devtools/binutils/binutils-2.35.inc +++ b/meta/recipes-devtools/binutils/binutils-2.35.inc | |||
@@ -42,5 +42,6 @@ SRC_URI = "\ | |||
42 | file://0015-sync-with-OE-libtool-changes.patch \ | 42 | file://0015-sync-with-OE-libtool-changes.patch \ |
43 | file://0016-Check-for-clang-before-checking-gcc-version.patch \ | 43 | file://0016-Check-for-clang-before-checking-gcc-version.patch \ |
44 | file://0017-gas-improve-reproducibility-for-stabs-debugging-data.patch \ | 44 | file://0017-gas-improve-reproducibility-for-stabs-debugging-data.patch \ |
45 | file://0001-aarch64-Return-an-error-on-conditional-branch-to-an-.patch \ | ||
45 | " | 46 | " |
46 | S = "${WORKDIR}/git" | 47 | S = "${WORKDIR}/git" |
diff --git a/meta/recipes-devtools/binutils/binutils/0001-aarch64-Return-an-error-on-conditional-branch-to-an-.patch b/meta/recipes-devtools/binutils/binutils/0001-aarch64-Return-an-error-on-conditional-branch-to-an-.patch new file mode 100644 index 0000000000..f46ddab415 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0001-aarch64-Return-an-error-on-conditional-branch-to-an-.patch | |||
@@ -0,0 +1,135 @@ | |||
1 | From c7cd291722779c9d4703ed0010388fe394c644c8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Siddhesh Poyarekar <siddesh.poyarekar@arm.com> | ||
3 | Date: Tue, 1 Sep 2020 14:25:52 +0530 | ||
4 | Subject: [PATCH] aarch64: Return an error on conditional branch to an undefined symbol | ||
5 | |||
6 | The fix in 7e05773767820b441b23a16628b55c98cb1aef46 introduced a PLT | ||
7 | for conditional jumps when the target symbol is undefined. This is | ||
8 | incorrect because conditional branch relocations are not allowed to | ||
9 | clobber IP0/IP1 and hence, should not result in a dynamic relocation. | ||
10 | |||
11 | Revert that change and in its place, issue an error when the target | ||
12 | symbol is undefined. | ||
13 | |||
14 | bfd/ | ||
15 | |||
16 | 2020-09-10 Siddhesh Poyarekar <siddesh.poyarekar@arm.com> | ||
17 | |||
18 | * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Revert | ||
19 | changes in 7e05773767820b441b23a16628b55c98cb1aef46. Set | ||
20 | error for undefined symbol in BFD_RELOC_AARCH64_BRANCH19 and | ||
21 | BFD_RELOC_AARCH64_TSTBR14 relocations. | ||
22 | |||
23 | ld/ | ||
24 | |||
25 | 2020-09-10 Siddhesh Poyarekar <siddesh.poyarekar@arm.com> | ||
26 | |||
27 | * testsuite/ld-aarch64/emit-relocs-560.d: Expect error instead | ||
28 | of valid output. | ||
29 | --- | ||
30 | Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c7cd291722779c9d4703ed0010388fe394c644c8] | ||
31 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
32 | |||
33 | bfd/ChangeLog | 7 +++++ | ||
34 | bfd/elfnn-aarch64.c | 37 ++++++++++++----------- | ||
35 | ld/ChangeLog | 5 +++ | ||
36 | ld/testsuite/ld-aarch64/emit-relocs-560.d | 7 +---- | ||
37 | 4 files changed, 32 insertions(+), 24 deletions(-) | ||
38 | |||
39 | diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c | ||
40 | index 5b4c189b593..a9924e7ec56 100644 | ||
41 | --- a/bfd/elfnn-aarch64.c | ||
42 | +++ b/bfd/elfnn-aarch64.c | ||
43 | @@ -5447,7 +5447,6 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, | ||
44 | bfd_vma orig_value = value; | ||
45 | bfd_boolean resolved_to_zero; | ||
46 | bfd_boolean abs_symbol_p; | ||
47 | - bfd_boolean via_plt_p; | ||
48 | |||
49 | globals = elf_aarch64_hash_table (info); | ||
50 | |||
51 | @@ -5469,8 +5468,6 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, | ||
52 | : bfd_is_und_section (sym_sec)); | ||
53 | abs_symbol_p = h != NULL && bfd_is_abs_symbol (&h->root); | ||
54 | |||
55 | - via_plt_p = (globals->root.splt != NULL && h != NULL | ||
56 | - && h->plt.offset != (bfd_vma) - 1); | ||
57 | |||
58 | /* Since STT_GNU_IFUNC symbol must go through PLT, we handle | ||
59 | it here if it is defined in a non-shared object. */ | ||
60 | @@ -5806,23 +5803,12 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, | ||
61 | value += signed_addend; | ||
62 | break; | ||
63 | |||
64 | - case BFD_RELOC_AARCH64_BRANCH19: | ||
65 | - case BFD_RELOC_AARCH64_TSTBR14: | ||
66 | - /* A conditional branch to an undefined weak symbol is converted to a | ||
67 | - branch to itself. */ | ||
68 | - if (weak_undef_p && !via_plt_p) | ||
69 | - { | ||
70 | - value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, | ||
71 | - place, value, | ||
72 | - signed_addend, | ||
73 | - weak_undef_p); | ||
74 | - break; | ||
75 | - } | ||
76 | - /* Fall through. */ | ||
77 | case BFD_RELOC_AARCH64_CALL26: | ||
78 | case BFD_RELOC_AARCH64_JUMP26: | ||
79 | { | ||
80 | asection *splt = globals->root.splt; | ||
81 | + bfd_boolean via_plt_p = | ||
82 | + splt != NULL && h != NULL && h->plt.offset != (bfd_vma) - 1; | ||
83 | |||
84 | /* A call to an undefined weak symbol is converted to a jump to | ||
85 | the next instruction unless a PLT entry will be created. | ||
86 | @@ -5903,6 +5889,23 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, | ||
87 | bfd_set_error (bfd_error_bad_value); | ||
88 | return bfd_reloc_notsupported; | ||
89 | } | ||
90 | + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, | ||
91 | + place, value, | ||
92 | + signed_addend, | ||
93 | + weak_undef_p); | ||
94 | + break; | ||
95 | + | ||
96 | + case BFD_RELOC_AARCH64_BRANCH19: | ||
97 | + case BFD_RELOC_AARCH64_TSTBR14: | ||
98 | + if (h && h->root.type == bfd_link_hash_undefined) | ||
99 | + { | ||
100 | + _bfd_error_handler | ||
101 | + /* xgettext:c-format */ | ||
102 | + (_("%pB: conditional branch to undefined symbol `%s' " | ||
103 | + "not allowed"), input_bfd, h->root.root.string); | ||
104 | + bfd_set_error (bfd_error_bad_value); | ||
105 | + return bfd_reloc_notsupported; | ||
106 | + } | ||
107 | /* Fall through. */ | ||
108 | |||
109 | case BFD_RELOC_AARCH64_16: | ||
110 | @@ -7968,8 +7971,6 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
111 | break; | ||
112 | } | ||
113 | |||
114 | - case BFD_RELOC_AARCH64_BRANCH19: | ||
115 | - case BFD_RELOC_AARCH64_TSTBR14: | ||
116 | case BFD_RELOC_AARCH64_CALL26: | ||
117 | case BFD_RELOC_AARCH64_JUMP26: | ||
118 | /* If this is a local symbol then we resolve it | ||
119 | diff --git a/ld/testsuite/ld-aarch64/emit-relocs-560.d b/ld/testsuite/ld-aarch64/emit-relocs-560.d | ||
120 | index 153532457b4..8751b743bd4 100644 | ||
121 | --- a/ld/testsuite/ld-aarch64/emit-relocs-560.d | ||
122 | +++ b/ld/testsuite/ld-aarch64/emit-relocs-560.d | ||
123 | @@ -1,8 +1,3 @@ | ||
124 | #source: emit-relocs-560.s | ||
125 | #ld: -shared | ||
126 | -#readelf: -r | ||
127 | - | ||
128 | -Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 2 entries: | ||
129 | - Offset Info Type Sym. Value Sym. Name \+ Addend | ||
130 | -[0-9a-f]+ 000100000402 R_AARCH64_JUMP_SL 0000000000000000 baz \+ 0 | ||
131 | -[0-9a-f]+ 000200000402 R_AARCH64_JUMP_SL 0000000000000000 bar \+ 0 | ||
132 | +#error: .*: conditional branch to undefined symbol `bar' not allowed | ||
133 | -- | ||
134 | 2.29.2 | ||
135 | |||