diff options
Diffstat (limited to 'meta-microblaze/recipes-devtools/binutils/binutils/0019-fixing-the-.bss-relocation-issue.patch')
-rw-r--r-- | meta-microblaze/recipes-devtools/binutils/binutils/0019-fixing-the-.bss-relocation-issue.patch | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils/0019-fixing-the-.bss-relocation-issue.patch b/meta-microblaze/recipes-devtools/binutils/binutils/0019-fixing-the-.bss-relocation-issue.patch new file mode 100644 index 00000000..5826f0a3 --- /dev/null +++ b/meta-microblaze/recipes-devtools/binutils/binutils/0019-fixing-the-.bss-relocation-issue.patch | |||
@@ -0,0 +1,113 @@ | |||
1 | From 35e89c09636e2ce2f5eafcf62941d15ece79a172 Mon Sep 17 00:00:00 2001 | ||
2 | From: Nagaraju Mekala <nmekala@xilix.com> | ||
3 | Date: Wed, 24 Oct 2018 12:34:37 +0530 | ||
4 | Subject: [PATCH 19/34] fixing the .bss relocation issue | ||
5 | |||
6 | Conflicts: | ||
7 | bfd/elf64-microblaze.c | ||
8 | |||
9 | Conflicts: | ||
10 | bfd/elf64-microblaze.c | ||
11 | --- | ||
12 | bfd/elf64-microblaze.c | 41 +++++++++++++++++++++++++++++------------ | ||
13 | 1 file changed, 29 insertions(+), 12 deletions(-) | ||
14 | |||
15 | diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c | ||
16 | index 355e9131987..eb7f9138884 100644 | ||
17 | --- a/bfd/elf64-microblaze.c | ||
18 | +++ b/bfd/elf64-microblaze.c | ||
19 | @@ -1555,14 +1555,14 @@ microblaze_elf_relocate_section (bfd *output_bfd, | ||
20 | bfd_put_16 (input_bfd, relocation & 0xffff, | ||
21 | contents + offset + endian); | ||
22 | |||
23 | - unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian); | ||
24 | - if (insn == 0xb2000000 || insn == 0xb2ffffff) | ||
25 | - { | ||
26 | - insn &= ~0x00ffffff; | ||
27 | - insn |= (relocation >> 16) & 0xffffff; | ||
28 | - bfd_put_32 (input_bfd, insn, | ||
29 | - contents + offset + endian); | ||
30 | - } | ||
31 | + unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian); | ||
32 | + if ((insn & 0xff000000) == 0xb2000000) | ||
33 | + { | ||
34 | + insn &= ~0x00ffffff; | ||
35 | + insn |= (relocation >> 16) & 0xffffff; | ||
36 | + bfd_put_32 (input_bfd, insn, | ||
37 | + contents + offset + endian); | ||
38 | + } | ||
39 | else | ||
40 | { | ||
41 | bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, | ||
42 | @@ -1673,7 +1673,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, | ||
43 | contents + offset + endian); | ||
44 | } | ||
45 | unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian); | ||
46 | - if (insn == 0xb2000000 || insn == 0xb2ffffff) | ||
47 | + if ((insn & 0xff000000) == 0xb2000000) | ||
48 | { | ||
49 | insn &= ~0x00ffffff; | ||
50 | insn |= (relocation >> 16) & 0xffffff; | ||
51 | @@ -1791,7 +1791,7 @@ microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val) | ||
52 | { | ||
53 | unsigned long instr = bfd_get_32 (abfd, bfd_addr); | ||
54 | |||
55 | - if (instr == 0xb2000000 || instr == 0xb2ffffff) | ||
56 | + if ((instr & 0xff000000) == 0xb2000000) | ||
57 | { | ||
58 | instr &= ~0x00ffffff; | ||
59 | instr |= (val & 0xffffff); | ||
60 | @@ -1814,7 +1814,7 @@ microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val) | ||
61 | unsigned long instr_lo; | ||
62 | |||
63 | instr_hi = bfd_get_32 (abfd, bfd_addr); | ||
64 | - if (instr_hi == 0xb2000000 || instr_hi == 0xb2ffffff) | ||
65 | + if ((instr_hi & 0xff000000) == 0xb2000000) | ||
66 | { | ||
67 | instr_hi &= ~0x00ffffff; | ||
68 | instr_hi |= (val >> 16) & 0xffffff; | ||
69 | @@ -2294,6 +2294,8 @@ microblaze_elf_relax_section (bfd *abfd, | ||
70 | if (isym->st_shndx == shndx | ||
71 | && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION)) | ||
72 | { | ||
73 | + bfd_vma immediate; | ||
74 | + | ||
75 | if (ocontents == NULL) | ||
76 | { | ||
77 | if (elf_section_data (o)->this_hdr.contents != NULL) | ||
78 | @@ -2316,8 +2318,20 @@ microblaze_elf_relax_section (bfd *abfd, | ||
79 | elf_section_data (o)->this_hdr.contents = ocontents; | ||
80 | } | ||
81 | } | ||
82 | + unsigned long instr_hi = bfd_get_32 (abfd, ocontents | ||
83 | + + irelscan->r_offset); | ||
84 | + unsigned long instr_lo = bfd_get_32 (abfd, ocontents | ||
85 | + + irelscan->r_offset | ||
86 | + + INST_WORD_SIZE); | ||
87 | + if ((instr_hi & 0xff000000) == 0xb2000000) | ||
88 | + immediate = (instr_hi & 0x00ffffff) << 24; | ||
89 | + else | ||
90 | + immediate = (instr_hi & 0x0000ffff) << 16; | ||
91 | + immediate |= (instr_lo & 0x0000ffff); | ||
92 | offset = calc_fixup (irelscan->r_addend, 0, sec); | ||
93 | + immediate -= offset; | ||
94 | irelscan->r_addend -= offset; | ||
95 | + | ||
96 | } | ||
97 | } | ||
98 | else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_PCREL) | ||
99 | @@ -2357,7 +2371,10 @@ microblaze_elf_relax_section (bfd *abfd, | ||
100 | unsigned long instr_lo = bfd_get_32 (abfd, ocontents | ||
101 | + irelscan->r_offset | ||
102 | + INST_WORD_SIZE); | ||
103 | - immediate = (instr_hi & 0x0000ffff) << 16; | ||
104 | + if ((instr_hi & 0xff000000) == 0xb2000000) | ||
105 | + immediate = (instr_hi & 0x00ffffff) << 24; | ||
106 | + else | ||
107 | + immediate = (instr_hi & 0x0000ffff) << 16; | ||
108 | immediate |= (instr_lo & 0x0000ffff); | ||
109 | target_address = immediate; | ||
110 | offset = calc_fixup (target_address, 0, sec); | ||
111 | -- | ||
112 | 2.37.1 (Apple Git-137.1) | ||
113 | |||