summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManjukumar Matha <manjukumar.harthikote-matha@xilinx.com>2019-04-03 21:53:58 -0700
committerManjukumar Matha <manjukumar.harthikote-matha@xilinx.com>2019-06-28 16:36:24 -0700
commit4060e68585b60489aaac3c39adcda81a889e8691 (patch)
tree974e1643c4b2333423390d11ad3c190385feb5da
parent9c2a6d07c4f64c65eb0aab901d65fa4659b4dcf9 (diff)
downloadmeta-xilinx-4060e68585b60489aaac3c39adcda81a889e8691.tar.gz
binutils%.bbappend: Update Microblaze binutils patches to v2.31
Update Microblaze binutils patches to v2.31 Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils%.bbappend45
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch (renamed from meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0001-MicroBlaze-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch)14
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0002-Add-mlittle-endian-and-mbig-endian-flags.patch (renamed from meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0002-MicroBlaze-add-mlittle-endian-and-mbig-endian-flags.patch)22
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0003-Disable-the-warning-message-for-eh_frame_hdr.patch47
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0004-Fix-relaxation-of-assembler-resolved-references.patch33
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch (renamed from meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0005-Fixup-MicroBlaze-debug_loc-sections-after-linker-rel.patch)166
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch40
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0007-Fix-bug-in-TLSTPREL-Relocation.patch (renamed from meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0006-Fix-bug-in-MicroBlaze-TLSTPREL-Relocation.patch)16
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0008-Added-Address-extension-instructions.patch (renamed from meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0007-Add-MicroBlaze-address-extension-instructions.patch)40
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0009-fixing-the-MAX_OPCODES-to-correct-value.patch26
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0010-Add-new-bit-field-instructions.patch (renamed from meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0008-Add-new-MicroBlaze-bit-field-instructions.patch)48
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0011-fixing-the-imm-bug.patch (renamed from meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0009-Fixing-MicroBlaze-IMM-bug.patch)21
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0012-MicroBlaze-fix-mask-for-barrel-shift-instructions.patch36
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0012-Patch-Microblaze-fixed-bug-in-GCC-so-that-It-will-su.patch (renamed from meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0010-Fixed-bug-in-GCC-so-that-it-will-support-.long-0U-an.patch)17
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0013-fixing-the-constant-range-check-issue.patch (renamed from meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0011-Fixing-MicroBlaze-constant-range-check-issue.patch)21
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch38
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0015-intial-commit-of-MB-64-bit.patch4740
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0016-MB-X-initial-commit.patch694
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch38
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0018-Added-relocations-for-MB-X.patch350
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0019-Fixed-MB-x-relocation-issues.patch375
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0020-Fixing-the-branch-related-issues.patch27
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0021-Fixed-address-computation-issues-with-64bit-address.patch219
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0022-Adding-new-relocation-to-support-64bit-rodata.patch168
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0023-fixing-the-.bss-relocation-issue.patch78
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch46
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch70
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch33
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0027-Patch-Microblaze-PR22471-undefined-reference-to-link.patch363
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0028-Revert-ld-Remove-unused-expression-state.patch97
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0029-Patch-Microblaze-Binutils-security-check-is-causing-.patch35
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0030-fixing-the-long-long-long-mingw-toolchain-issue.patch59
-rw-r--r--meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0031-fixing-the-_STACK_SIZE-issue-with-the-flto-flag.patch57
33 files changed, 7799 insertions, 280 deletions
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils%.bbappend b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils%.bbappend
index 44709727..bf6cf464 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils%.bbappend
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils%.bbappend
@@ -1,15 +1,34 @@
1FILESEXTRAPATHS_append_microblaze := "${THISDIR}/binutils-2.31:" 1FILESEXTRAPATHS_append_microblaze := "${THISDIR}/binutils-2.31:"
2SRC_URI_append_microblaze = " \ 2SRC_URI_append_microblaze = " \
3 file://0001-MicroBlaze-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch \ 3 file://0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch \
4 file://0002-MicroBlaze-add-mlittle-endian-and-mbig-endian-flags.patch \ 4 file://0002-Add-mlittle-endian-and-mbig-endian-flags.patch \
5 file://0003-Disable-the-warning-message-for-eh_frame_hdr.patch \ 5 file://0003-Disable-the-warning-message-for-eh_frame_hdr.patch \
6 file://0004-Fix-relaxation-of-assembler-resolved-references.patch \ 6 file://0004-Fix-relaxation-of-assembler-resolved-references.patch \
7 file://0005-Fixup-MicroBlaze-debug_loc-sections-after-linker-rel.patch \ 7 file://0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch \
8 file://0006-Fix-bug-in-MicroBlaze-TLSTPREL-Relocation.patch \ 8 file://0006-upstream-change-to-garbage-collection-sweep-causes-m.patch \
9 file://0007-Add-MicroBlaze-address-extension-instructions.patch \ 9 file://0007-Fix-bug-in-TLSTPREL-Relocation.patch \
10 file://0008-Add-new-MicroBlaze-bit-field-instructions.patch \ 10 file://0008-Added-Address-extension-instructions.patch \
11 file://0009-Fixing-MicroBlaze-IMM-bug.patch \ 11 file://0009-fixing-the-MAX_OPCODES-to-correct-value.patch \
12 file://0010-Fixed-bug-in-GCC-so-that-it-will-support-.long-0U-an.patch \ 12 file://0010-Add-new-bit-field-instructions.patch \
13 file://0011-Fixing-MicroBlaze-constant-range-check-issue.patch \ 13 file://0011-fixing-the-imm-bug.patch \
14 file://0012-MicroBlaze-fix-mask-for-barrel-shift-instructions.patch \ 14 file://0012-Patch-Microblaze-fixed-bug-in-GCC-so-that-It-will-su.patch \
15 " 15 file://0013-fixing-the-constant-range-check-issue.patch \
16 file://0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch \
17 file://0015-intial-commit-of-MB-64-bit.patch \
18 file://0016-MB-X-initial-commit.patch \
19 file://0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch \
20 file://0018-Added-relocations-for-MB-X.patch \
21 file://0019-Fixed-MB-x-relocation-issues.patch \
22 file://0020-Fixing-the-branch-related-issues.patch \
23 file://0021-Fixed-address-computation-issues-with-64bit-address.patch \
24 file://0022-Adding-new-relocation-to-support-64bit-rodata.patch \
25 file://0023-fixing-the-.bss-relocation-issue.patch \
26 file://0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch \
27 file://0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch \
28 file://0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch \
29 file://0027-Patch-Microblaze-PR22471-undefined-reference-to-link.patch \
30 file://0028-Revert-ld-Remove-unused-expression-state.patch \
31 file://0029-Patch-Microblaze-Binutils-security-check-is-causing-.patch \
32 file://0030-fixing-the-long-long-long-mingw-toolchain-issue.patch \
33 file://0031-fixing-the-_STACK_SIZE-issue-with-the-flto-flag.patch \
34 "
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0001-MicroBlaze-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch
index 878bb321..4ea2f12c 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0001-MicroBlaze-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch
@@ -1,17 +1,14 @@
1From 91f39b692c48336117c092e4afd80899c97779e6 Mon Sep 17 00:00:00 2001 1From 6958c0c056b1597992d72d4b75e763e65862e1ad Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com> 2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Mon, 28 Aug 2017 19:53:52 -0700 3Date: Wed, 8 May 2013 11:03:36 +1000
4Subject: [PATCH] MicroBlaze Add wdc.ext.clear and wdc.ext.flush insns 4Subject: [PATCH 01/31] Add wdc.ext.clear and wdc.ext.flush insns
5 5
6Added two new instructions, wdc.ext.clear and wdc.ext.flush, 6Added two new instructions, wdc.ext.clear and wdc.ext.flush,
7to enable MicroBlaze to flush an external cache, which is 7to enable MicroBlaze to flush an external cache, which is
8used with the new coherency support for multiprocessing. 8used with the new coherency support for multiprocessing.
9 9
10Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
11Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 10Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
12Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com> 11Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
13Upstream-Status: Pending
14
15--- 12---
16 opcodes/microblaze-opc.h | 5 ++++- 13 opcodes/microblaze-opc.h | 5 ++++-
17 opcodes/microblaze-opcm.h | 4 ++-- 14 opcodes/microblaze-opcm.h | 4 ++--
@@ -63,3 +60,6 @@ index 92f3f19..7338f6a 100644
63 bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni, 60 bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni,
64 imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid, 61 imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid,
65 brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti, 62 brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti,
63--
642.7.4
65
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0002-MicroBlaze-add-mlittle-endian-and-mbig-endian-flags.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0002-Add-mlittle-endian-and-mbig-endian-flags.patch
index edeecfd2..12f2f639 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0002-MicroBlaze-add-mlittle-endian-and-mbig-endian-flags.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0002-Add-mlittle-endian-and-mbig-endian-flags.patch
@@ -1,7 +1,7 @@
1From 8b733a61ab54ba4cedb234020562502d20eebcbb Mon Sep 17 00:00:00 2001 1From a570d7ef1fce2a1e4d4fde5f3ac36a741a01587b Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 2From: nagaraju <nmekala@xilix.com>
3Date: Mon, 28 Aug 2017 19:53:53 -0700 3Date: Tue, 19 Mar 2013 17:18:23 +0530
4Subject: [PATCH] MicroBlaze add mlittle-endian and mbig-endian flags 4Subject: [PATCH 02/31] Add mlittle-endian and mbig-endian flags
5 5
6Added support in gas for mlittle-endian and mbig-endian flags 6Added support in gas for mlittle-endian and mbig-endian flags
7as options. 7as options.
@@ -11,15 +11,12 @@ to include new entries.
11 11
12Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 12Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
13Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com> 13Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
14Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
15Upstream-Status: Pending
16
17--- 14---
18 gas/config/tc-microblaze.c | 9 +++++++++ 15 gas/config/tc-microblaze.c | 9 +++++++++
19 1 file changed, 9 insertions(+) 16 1 file changed, 9 insertions(+)
20 17
21diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c 18diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
22index 0194cd9..42dd7ae 100644 19index ba6eabb..360ccba 100644
23--- a/gas/config/tc-microblaze.c 20--- a/gas/config/tc-microblaze.c
24+++ b/gas/config/tc-microblaze.c 21+++ b/gas/config/tc-microblaze.c
25@@ -37,6 +37,8 @@ 22@@ -37,6 +37,8 @@
@@ -31,7 +28,7 @@ index 0194cd9..42dd7ae 100644
31 28
32 void microblaze_generate_symbol (char *sym); 29 void microblaze_generate_symbol (char *sym);
33 static bfd_boolean check_spl_reg (unsigned *); 30 static bfd_boolean check_spl_reg (unsigned *);
34@@ -1837,6 +1839,8 @@ struct option md_longopts[] = 31@@ -1845,6 +1847,8 @@ struct option md_longopts[] =
35 { 32 {
36 {"EB", no_argument, NULL, OPTION_EB}, 33 {"EB", no_argument, NULL, OPTION_EB},
37 {"EL", no_argument, NULL, OPTION_EL}, 34 {"EL", no_argument, NULL, OPTION_EL},
@@ -40,7 +37,7 @@ index 0194cd9..42dd7ae 100644
40 { NULL, no_argument, NULL, 0} 37 { NULL, no_argument, NULL, 0}
41 }; 38 };
42 39
43@@ -2471,9 +2475,11 @@ md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED) 40@@ -2498,9 +2502,11 @@ md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
44 switch (c) 41 switch (c)
45 { 42 {
46 case OPTION_EB: 43 case OPTION_EB:
@@ -52,7 +49,7 @@ index 0194cd9..42dd7ae 100644
52 target_big_endian = 0; 49 target_big_endian = 0;
53 break; 50 break;
54 default: 51 default:
55@@ -2488,6 +2494,9 @@ md_show_usage (FILE * stream ATTRIBUTE_UNUSED) 52@@ -2515,6 +2521,9 @@ md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
56 /* fprintf(stream, _("\ 53 /* fprintf(stream, _("\
57 MicroBlaze options:\n\ 54 MicroBlaze options:\n\
58 -noSmall Data in the comm and data sections do not go into the small data section\n")); */ 55 -noSmall Data in the comm and data sections do not go into the small data section\n")); */
@@ -62,3 +59,6 @@ index 0194cd9..42dd7ae 100644
62 } 59 }
63 60
64 61
62--
632.7.4
64
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0003-Disable-the-warning-message-for-eh_frame_hdr.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0003-Disable-the-warning-message-for-eh_frame_hdr.patch
index aee0c01e..ec3e2192 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0003-Disable-the-warning-message-for-eh_frame_hdr.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0003-Disable-the-warning-message-for-eh_frame_hdr.patch
@@ -1,39 +1,32 @@
1From dac72d809be9faf9380b181df0c19a2c6d744c54 Mon Sep 17 00:00:00 2001 1From 311a3a3dc3f5b2ab1ee276cb5626a85d0fd1027a Mon Sep 17 00:00:00 2001
2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com> 2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
3Date: Mon, 28 Aug 2017 19:53:54 -0700 3Date: Fri, 22 Jun 2012 01:20:20 +0200
4Subject: [PATCH] Disable the warning message for eh_frame_hdr 4Subject: [PATCH 03/31] Disable the warning message for eh_frame_hdr
5 5
6Upstream-Status: Inappropriate [workaround]
7
8Rebased to 2.31
9 - Error hanlder changed
10
11Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>
12Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> 6Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com> 7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
14
15--- 8---
16 bfd/elf-eh-frame.c | 9 ++++++--- 9 bfd/elf-eh-frame.c | 3 +++
17 1 file changed, 6 insertions(+), 3 deletions(-) 10 1 file changed, 3 insertions(+)
18 11
19Index: git/bfd/elf-eh-frame.c 12diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
20=================================================================== 13index 12f06ef..e144922 100644
21--- git.orig/bfd/elf-eh-frame.c 14--- a/bfd/elf-eh-frame.c
22+++ git/bfd/elf-eh-frame.c 15+++ b/bfd/elf-eh-frame.c
23@@ -1042,10 +1042,13 @@ _bfd_elf_parse_eh_frame (bfd *abfd, stru 16@@ -1042,10 +1042,13 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
24 goto success; 17 goto success;
25 18
26 free_no_table: 19 free_no_table:
27- _bfd_error_handler 20+/* FIXME: Remove the microblaze specifics when relaxing gets fixed. */
28+ /* FIXME: Remove the microblaze specifics when relaxing gets fixed. */ 21+if (bfd_get_arch(abfd) != bfd_arch_microblaze) {
29+ if (bfd_get_arch(abfd) != bfd_arch_microblaze) { 22 _bfd_error_handler
30 /* xgettext:c-format */ 23 /* xgettext:c-format */
31- (_("error in %pB(%pA); no .eh_frame_hdr table will be created"), 24 (_("error in %pB(%pA); no .eh_frame_hdr table will be created"),
32- abfd, sec); 25 abfd, sec);
33+ _bfd_error_handler 26+}
34+ (_("error in %pB(%pA); no .eh_frame_hdr table will be created"),
35+ abfd, sec);
36+ }
37 hdr_info->u.dwarf.table = FALSE; 27 hdr_info->u.dwarf.table = FALSE;
38 if (sec_info) 28 if (sec_info)
39 free (sec_info); 29 free (sec_info);
30--
312.7.4
32
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0004-Fix-relaxation-of-assembler-resolved-references.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0004-Fix-relaxation-of-assembler-resolved-references.patch
index b543c54e..d77c6120 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0004-Fix-relaxation-of-assembler-resolved-references.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0004-Fix-relaxation-of-assembler-resolved-references.patch
@@ -1,27 +1,20 @@
1From 927ef228dfedf229dc915b273a308ab2c7bf9e19 Mon Sep 17 00:00:00 2001 1From cafd454afbd2722b9249024332182e3e96b1bcc7 Mon Sep 17 00:00:00 2001
2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com> 2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
3Date: Mon, 28 Aug 2017 19:53:55 -0700 3Date: Tue, 14 Feb 2012 01:00:22 +0100
4Subject: [PATCH] Fix relaxation of assembler resolved references 4Subject: [PATCH 04/31] Fix relaxation of assembler resolved references
5
603/2018
7Rebased for binutils 2.30
8 5
9Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> 6Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com> 7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
11Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>
12
13Upstream-Status: Pending
14
15--- 8---
16 bfd/elf32-microblaze.c | 39 +++++++++++++++++++++++++++++++++++++++ 9 bfd/elf32-microblaze.c | 38 ++++++++++++++++++++++++++++++++++++++
17 gas/config/tc-microblaze.c | 1 + 10 gas/config/tc-microblaze.c | 1 +
18 2 files changed, 40 insertions(+) 11 2 files changed, 39 insertions(+)
19 12
20diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c 13diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
21index f1808bc..a1d810c 100644 14index 3d131bc..56c82ae 100644
22--- a/bfd/elf32-microblaze.c 15--- a/bfd/elf32-microblaze.c
23+++ b/bfd/elf32-microblaze.c 16+++ b/bfd/elf32-microblaze.c
24@@ -1887,6 +1887,45 @@ microblaze_elf_relax_section (bfd *abfd, 17@@ -1973,6 +1973,44 @@ microblaze_elf_relax_section (bfd *abfd,
25 irelscanend = irelocs + o->reloc_count; 18 irelscanend = irelocs + o->reloc_count;
26 for (irelscan = irelocs; irelscan < irelscanend; irelscan++) 19 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
27 { 20 {
@@ -54,8 +47,7 @@ index f1808bc..a1d810c 100644
54+ elf_section_data (o)->this_hdr.contents = ocontents; 47+ elf_section_data (o)->this_hdr.contents = ocontents;
55+ } 48+ }
56+ } 49+ }
57+ 50+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
58+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
59+ + isym->st_value, sec); 51+ + isym->st_value, sec);
60+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset); 52+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
61+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset, 53+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
@@ -68,10 +60,10 @@ index f1808bc..a1d810c 100644
68 { 60 {
69 isym = isymbuf + ELF32_R_SYM (irelscan->r_info); 61 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
70diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c 62diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
71index 42dd7ae..50dbfc7 100644 63index 360ccba..e3dd1e0 100644
72--- a/gas/config/tc-microblaze.c 64--- a/gas/config/tc-microblaze.c
73+++ b/gas/config/tc-microblaze.c 65+++ b/gas/config/tc-microblaze.c
74@@ -2183,6 +2183,7 @@ md_apply_fix (fixS * fixP, 66@@ -2205,6 +2205,7 @@ md_apply_fix (fixS * fixP,
75 else 67 else
76 fixP->fx_r_type = BFD_RELOC_NONE; 68 fixP->fx_r_type = BFD_RELOC_NONE;
77 fixP->fx_addsy = section_symbol (absolute_section); 69 fixP->fx_addsy = section_symbol (absolute_section);
@@ -79,3 +71,6 @@ index 42dd7ae..50dbfc7 100644
79 } 71 }
80 return; 72 return;
81 } 73 }
74--
752.7.4
76
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0005-Fixup-MicroBlaze-debug_loc-sections-after-linker-rel.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch
index 6cdd2cc2..1b64bff1 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0005-Fixup-MicroBlaze-debug_loc-sections-after-linker-rel.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch
@@ -1,42 +1,31 @@
1From 5bf68bc39976903929f730b6eed18686c3563c05 Mon Sep 17 00:00:00 2001 1From 9c0639469318b3a88aa7cb5e776eed85b586c5d0 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 28 Aug 2017 19:53:56 -0700 3Date: Mon, 6 Feb 2017 15:53:08 +0530
4Subject: [PATCH] Fixup MicroBlaze debug_loc sections after linker relaxation 4Subject: [PATCH 05/31] [LOCAL]: Fixup debug_loc sections after linker
5 5 relaxation Adds a new reloctype R_MICROBLAZE_32_NONE, used for passing reloc
6Fixup debug_loc sections after linker relaxation Adds a new reloctype 6 info from the assembler to the linker when the linker manages to fully
7R_MICROBLAZE_32_NONE, used for passing reloc info from the assembler to 7 resolve a local symbol reference.
8the linker when the linker manages to fully resolve a local symbol
9reference.
10 8
11This is a workaround for design flaws in the assembler to 9This is a workaround for design flaws in the assembler to
12linker interface with regards to linker relaxation. 10linker interface with regards to linker relaxation.
13 11
1408/2018
15Rebased for binutils 2.31
16 - Some RELOC_NUMBERs were added upstream, rebased to use 33 instead of 30
17
18Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> 12Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
19Signed-off-by: Nagaraju Mekala <nmekala@xilinx.com> 13Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
20Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
21Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>
22
23Upstream-Status: Pending
24
25--- 14---
26 bfd/bfd-in2.h | 9 +++++++-- 15 bfd/bfd-in2.h | 9 ++++++--
27 bfd/elf32-microblaze.c | 45 ++++++++++++++++++++++++++++++++++++++------- 16 bfd/elf32-microblaze.c | 53 ++++++++++++++++++++++++++++++++++------------
28 bfd/libbfd.h | 1 + 17 bfd/libbfd.h | 1 +
29 bfd/reloc.c | 6 ++++++ 18 bfd/reloc.c | 6 ++++++
30 binutils/readelf.c | 4 ++++ 19 binutils/readelf.c | 4 ++++
31 gas/config/tc-microblaze.c | 5 ++++- 20 gas/config/tc-microblaze.c | 5 ++++-
32 include/elf/microblaze.h | 1 + 21 include/elf/microblaze.h | 2 ++
33 7 files changed, 61 insertions(+), 10 deletions(-) 22 7 files changed, 64 insertions(+), 16 deletions(-)
34 23
35Index: git/bfd/bfd-in2.h 24diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
36=================================================================== 25index f53dbb5..5807f70 100644
37--- git.orig/bfd/bfd-in2.h 26--- a/bfd/bfd-in2.h
38+++ git/bfd/bfd-in2.h 27+++ b/bfd/bfd-in2.h
39@@ -5791,10 +5791,15 @@ value relative to the read-write small d 28@@ -5790,10 +5790,15 @@ value relative to the read-write small data area anchor */
40 expressions of the form "Symbol Op Symbol" */ 29 expressions of the form "Symbol Op Symbol" */
41 BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM, 30 BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM,
42 31
@@ -54,14 +43,15 @@ Index: git/bfd/bfd-in2.h
54 43
55 /* This is a 64 bit reloc that stores the 32 bit pc relative 44 /* This is a 64 bit reloc that stores the 32 bit pc relative
56 value in two words (with an imm instruction). The relocation is 45 value in two words (with an imm instruction). The relocation is
57Index: git/bfd/elf32-microblaze.c 46diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
58=================================================================== 47index 56c82ae..a377790 100644
59--- git.orig/bfd/elf32-microblaze.c 48--- a/bfd/elf32-microblaze.c
60+++ git/bfd/elf32-microblaze.c 49+++ b/bfd/elf32-microblaze.c
61@@ -176,6 +176,20 @@ static reloc_howto_type microblaze_elf_h 50@@ -176,7 +176,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
62 0x0000ffff, /* Dest Mask. */ 51 0x0000ffff, /* Dest Mask. */
63 FALSE), /* PC relative offset? */ 52 FALSE), /* PC relative offset? */
64 53
54- /* This reloc does nothing. Used for relaxation. */
65+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */ 55+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
66+ 0, /* Rightshift. */ 56+ 0, /* Rightshift. */
67+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 57+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
@@ -76,10 +66,11 @@ Index: git/bfd/elf32-microblaze.c
76+ 0, /* Dest Mask. */ 66+ 0, /* Dest Mask. */
77+ FALSE), /* PC relative offset? */ 67+ FALSE), /* PC relative offset? */
78+ 68+
79 /* This reloc does nothing. Used for relaxation. */ 69+ /* This reloc does nothing. Used for relaxation. */
80 HOWTO (R_MICROBLAZE_64_NONE, /* Type. */ 70 HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
81 0, /* Rightshift. */ 71 0, /* Rightshift. */
82@@ -562,6 +576,9 @@ microblaze_elf_reloc_type_lookup (bfd * 72 3, /* Size (0 = byte, 1 = short, 2 = long). */
73@@ -562,6 +576,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
83 case BFD_RELOC_NONE: 74 case BFD_RELOC_NONE:
84 microblaze_reloc = R_MICROBLAZE_NONE; 75 microblaze_reloc = R_MICROBLAZE_NONE;
85 break; 76 break;
@@ -89,36 +80,41 @@ Index: git/bfd/elf32-microblaze.c
89 case BFD_RELOC_MICROBLAZE_64_NONE: 80 case BFD_RELOC_MICROBLAZE_64_NONE:
90 microblaze_reloc = R_MICROBLAZE_64_NONE; 81 microblaze_reloc = R_MICROBLAZE_64_NONE;
91 break; 82 break;
92@@ -1918,14 +1935,23 @@ microblaze_elf_relax_section (bfd *abfd, 83@@ -1918,6 +1935,7 @@ microblaze_elf_relax_section (bfd *abfd,
93 } 84 }
94 break; 85 break;
95 case R_MICROBLAZE_NONE: 86 case R_MICROBLAZE_NONE:
96+ case R_MICROBLAZE_32_NONE: 87+ case R_MICROBLAZE_32_NONE:
97 { 88 {
98 /* This was a PC-relative instruction that was 89 /* This was a PC-relative instruction that was
99 completely resolved. */ 90 completely resolved. */
100 int sfix, efix; 91@@ -1926,12 +1944,18 @@ microblaze_elf_relax_section (bfd *abfd,
101+ unsigned int val;
102 bfd_vma target_address;
103 target_address = irel->r_addend + irel->r_offset; 92 target_address = irel->r_addend + irel->r_offset;
104 sfix = calc_fixup (irel->r_offset, 0, sec); 93 sfix = calc_fixup (irel->r_offset, 0, sec);
105 efix = calc_fixup (target_address, 0, sec); 94 efix = calc_fixup (target_address, 0, sec);
106+ 95+
107+ /* Validate the in-band val. */ 96+ /* Validate the in-band val. */
108+ val = bfd_get_32 (abfd, contents + irel->r_offset); 97+ val = bfd_get_32 (abfd, contents + irel->r_offset);
109+ if (val != irel->r_addend && ELF32_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) { 98+ if (val != irel->r_addend && ELF32_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
110+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend); 99+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
111+ } 100+ }
112+
113 irel->r_addend -= (efix - sfix); 101 irel->r_addend -= (efix - sfix);
114 /* Should use HOWTO. */ 102 /* Should use HOWTO. */
115 microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset, 103 microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
116@@ -1973,12 +1999,16 @@ microblaze_elf_relax_section (bfd *abfd, 104 irel->r_addend);
105- }
106- break;
107+ }
108+ break;
109 case R_MICROBLAZE_64_NONE:
110 {
111 /* This was a PC-relative 64-bit instruction that was
112@@ -1973,12 +1997,16 @@ microblaze_elf_relax_section (bfd *abfd,
117 irelscanend = irelocs + o->reloc_count; 113 irelscanend = irelocs + o->reloc_count;
118 for (irelscan = irelocs; irelscan < irelscanend; irelscan++) 114 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
119 { 115 {
120- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE) 116- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
121+ if (1 && ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE) 117+ if (1 && ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
122 { 118 {
123 unsigned int val; 119 unsigned int val;
124 120
@@ -131,19 +127,23 @@ Index: git/bfd/elf32-microblaze.c
131 /* This was a PC-relative instruction that was completely resolved. */ 127 /* This was a PC-relative instruction that was completely resolved. */
132 if (ocontents == NULL) 128 if (ocontents == NULL)
133 { 129 {
134@@ -2003,15 +2033,16 @@ microblaze_elf_relax_section (bfd *abfd, 130@@ -1999,18 +2027,17 @@ microblaze_elf_relax_section (bfd *abfd,
135 } 131 (file_ptr) 0,
136 } 132 o->rawsize))
137 133 goto error_return;
138- irelscan->r_addend -= calc_fixup (irelscan->r_addend 134- elf_section_data (o)->this_hdr.contents = ocontents;
135- }
136- }
137- irelscan->r_addend -= calc_fixup (irelscan->r_addend
139- + isym->st_value, sec); 138- + isym->st_value, sec);
139+ elf_section_data (o)->this_hdr.contents = ocontents;
140+ }
141+ }
140 val = bfd_get_32 (abfd, ocontents + irelscan->r_offset); 142 val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
141+
142+ if (val != irelscan->r_addend) { 143+ if (val != irelscan->r_addend) {
143+ fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend); 144+ fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend);
144+ } 145+ }
145+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec); 146+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
146+
147 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset, 147 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
148 irelscan->r_addend); 148 irelscan->r_addend);
149 } 149 }
@@ -153,7 +153,7 @@ Index: git/bfd/elf32-microblaze.c
153 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32) 153 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
154 { 154 {
155 isym = isymbuf + ELF32_R_SYM (irelscan->r_info); 155 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
156@@ -2071,7 +2102,7 @@ microblaze_elf_relax_section (bfd *abfd, 156@@ -2070,7 +2097,7 @@ microblaze_elf_relax_section (bfd *abfd,
157 elf_section_data (o)->this_hdr.contents = ocontents; 157 elf_section_data (o)->this_hdr.contents = ocontents;
158 } 158 }
159 } 159 }
@@ -162,11 +162,11 @@ Index: git/bfd/elf32-microblaze.c
162 + isym->st_value, 162 + isym->st_value,
163 0, 163 0,
164 sec); 164 sec);
165Index: git/bfd/libbfd.h 165diff --git a/bfd/libbfd.h b/bfd/libbfd.h
166=================================================================== 166index 85f61b2..261086c 100644
167--- git.orig/bfd/libbfd.h 167--- a/bfd/libbfd.h
168+++ git/bfd/libbfd.h 168+++ b/bfd/libbfd.h
169@@ -2862,6 +2862,7 @@ static const char *const bfd_reloc_code_ 169@@ -2862,6 +2862,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
170 "BFD_RELOC_MICROBLAZE_32_ROSDA", 170 "BFD_RELOC_MICROBLAZE_32_ROSDA",
171 "BFD_RELOC_MICROBLAZE_32_RWSDA", 171 "BFD_RELOC_MICROBLAZE_32_RWSDA",
172 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM", 172 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
@@ -174,10 +174,10 @@ Index: git/bfd/libbfd.h
174 "BFD_RELOC_MICROBLAZE_64_NONE", 174 "BFD_RELOC_MICROBLAZE_64_NONE",
175 "BFD_RELOC_MICROBLAZE_64_GOTPC", 175 "BFD_RELOC_MICROBLAZE_64_GOTPC",
176 "BFD_RELOC_MICROBLAZE_64_GOT", 176 "BFD_RELOC_MICROBLAZE_64_GOT",
177Index: git/bfd/reloc.c 177diff --git a/bfd/reloc.c b/bfd/reloc.c
178=================================================================== 178index 68bc8a8..d89bc5d 100644
179--- git.orig/bfd/reloc.c 179--- a/bfd/reloc.c
180+++ git/bfd/reloc.c 180+++ b/bfd/reloc.c
181@@ -6865,6 +6865,12 @@ ENUMDOC 181@@ -6865,6 +6865,12 @@ ENUMDOC
182 This is a 32 bit reloc for the microblaze to handle 182 This is a 32 bit reloc for the microblaze to handle
183 expressions of the form "Symbol Op Symbol" 183 expressions of the form "Symbol Op Symbol"
@@ -191,25 +191,25 @@ Index: git/bfd/reloc.c
191 BFD_RELOC_MICROBLAZE_64_NONE 191 BFD_RELOC_MICROBLAZE_64_NONE
192 ENUMDOC 192 ENUMDOC
193 This is a 64 bit reloc that stores the 32 bit pc relative 193 This is a 64 bit reloc that stores the 32 bit pc relative
194Index: git/binutils/readelf.c 194diff --git a/binutils/readelf.c b/binutils/readelf.c
195=================================================================== 195index 1b50ba7..13e794d 100644
196--- git.orig/binutils/readelf.c 196--- a/binutils/readelf.c
197+++ git/binutils/readelf.c 197+++ b/binutils/readelf.c
198@@ -12908,6 +12908,10 @@ is_none_reloc (Filedata * filedata, unsi 198@@ -12907,6 +12907,10 @@ is_none_reloc (Filedata * filedata, unsigned int reloc_type)
199 || reloc_type == 32 /* R_AVR_DIFF32. */); 199 || reloc_type == 32 /* R_AVR_DIFF32. */);
200 case EM_METAG: 200 case EM_METAG:
201 return reloc_type == 3; /* R_METAG_NONE. */ 201 return reloc_type == 3; /* R_METAG_NONE. */
202+ case EM_MICROBLAZE: 202+ case EM_MICROBLAZE:
203+ return reloc_type == 33 /* R_MICROBLAZE_32_NONE. */ 203+ return reloc_type == 30 /* R_MICROBLAZE_32_NONE. */
204+ || reloc_type == 0 /* R_MICROBLAZE_NONE. */ 204+ || reloc_type == 0 /* R_MICROBLAZE_NONE. */
205+ || reloc_type == 9; /* R_MICROBLAZE_64_NONE. */ 205+ || reloc_type == 9; /* R_MICROBLAZE_64_NONE. */
206 case EM_NDS32: 206 case EM_NDS32:
207 return (reloc_type == 0 /* R_XTENSA_NONE. */ 207 return (reloc_type == 0 /* R_XTENSA_NONE. */
208 || reloc_type == 204 /* R_NDS32_DIFF8. */ 208 || reloc_type == 204 /* R_NDS32_DIFF8. */
209Index: git/gas/config/tc-microblaze.c 209diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
210=================================================================== 210index e3dd1e0..b34796c 100644
211--- git.orig/gas/config/tc-microblaze.c 211--- a/gas/config/tc-microblaze.c
212+++ git/gas/config/tc-microblaze.c 212+++ b/gas/config/tc-microblaze.c
213@@ -2201,7 +2201,9 @@ md_apply_fix (fixS * fixP, 213@@ -2201,7 +2201,9 @@ md_apply_fix (fixS * fixP,
214 /* This fixup has been resolved. Create a reloc in case the linker 214 /* This fixup has been resolved. Create a reloc in case the linker
215 moves code around due to relaxing. */ 215 moves code around due to relaxing. */
@@ -221,7 +221,7 @@ Index: git/gas/config/tc-microblaze.c
221 else 221 else
222 fixP->fx_r_type = BFD_RELOC_NONE; 222 fixP->fx_r_type = BFD_RELOC_NONE;
223 fixP->fx_addsy = section_symbol (absolute_section); 223 fixP->fx_addsy = section_symbol (absolute_section);
224@@ -2426,6 +2428,7 @@ tc_gen_reloc (asection * section ATTRIBU 224@@ -2426,6 +2428,7 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
225 switch (fixp->fx_r_type) 225 switch (fixp->fx_r_type)
226 { 226 {
227 case BFD_RELOC_NONE: 227 case BFD_RELOC_NONE:
@@ -229,15 +229,19 @@ Index: git/gas/config/tc-microblaze.c
229 case BFD_RELOC_MICROBLAZE_64_NONE: 229 case BFD_RELOC_MICROBLAZE_64_NONE:
230 case BFD_RELOC_32: 230 case BFD_RELOC_32:
231 case BFD_RELOC_MICROBLAZE_32_LO: 231 case BFD_RELOC_MICROBLAZE_32_LO:
232Index: git/include/elf/microblaze.h 232diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h
233=================================================================== 233index dbaa16c..7bdba67 100644
234--- git.orig/include/elf/microblaze.h 234--- a/include/elf/microblaze.h
235+++ git/include/elf/microblaze.h 235+++ b/include/elf/microblaze.h
236@@ -61,6 +61,7 @@ START_RELOC_NUMBERS (elf_microblaze_relo 236@@ -61,6 +61,8 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type)
237 RELOC_NUMBER (R_MICROBLAZE_TEXTPCREL_64, 30) /* PC-relative TEXT offset. */ 237 RELOC_NUMBER (R_MICROBLAZE_TEXTPCREL_64, 30) /* PC-relative TEXT offset. */
238 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_64, 31) /* TEXT Entry offset 64-bit. */ 238 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_64, 31) /* TEXT Entry offset 64-bit. */
239 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_32_LO, 32) /* TEXT Entry offset 32-bit. */ 239 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_32_LO, 32) /* TEXT Entry offset 32-bit. */
240+ RELOC_NUMBER (R_MICROBLAZE_32_NONE, 33) 240+ RELOC_NUMBER (R_MICROBLAZE_32_NONE, 33)
241+
241 END_RELOC_NUMBERS (R_MICROBLAZE_max) 242 END_RELOC_NUMBERS (R_MICROBLAZE_max)
242 243
243 /* Global base address names. */ 244 /* Global base address names. */
245--
2462.7.4
247
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch
new file mode 100644
index 00000000..0c7b95b4
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch
@@ -0,0 +1,40 @@
1From 1bb6a80a2ae3cff3a3cc8526ec09e60f66b7cb96 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Wed, 27 Feb 2013 13:56:11 +1000
4Subject: [PATCH 06/31] upstream change to garbage collection sweep causes mb
5 regression
6
7Upstream change for PR13177 now clears the def_regular during gc_sweep of a
8section. (All other archs in binutils/bfd/elf32-*.c received an update
9to a warning about unresolvable relocations - this warning is not present
10in binutils/bfd/elf32-microblaze.c, but this warning check would not
11prevent the error being seen)
12
13The visible issue with this change is when running a c++ application
14in Petalinux which links libstdc++.so for exception handling it segfaults
15on execution.
16
17This does not occur if static linking libstdc++.a, so its during the
18relocations for a shared lib with garbage collection this occurs
19
20Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
21Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
22---
23 bfd/elflink.c | 1 -
24 1 file changed, 1 deletion(-)
25
26diff --git a/bfd/elflink.c b/bfd/elflink.c
27index b24fb95..b316149 100644
28--- a/bfd/elflink.c
29+++ b/bfd/elflink.c
30@@ -6172,7 +6172,6 @@ elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
31
32 inf = (struct elf_gc_sweep_symbol_info *) data;
33 (*inf->hide_symbol) (inf->info, h, TRUE);
34- h->def_regular = 0;
35 h->ref_regular = 0;
36 h->ref_regular_nonweak = 0;
37 }
38--
392.7.4
40
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0006-Fix-bug-in-MicroBlaze-TLSTPREL-Relocation.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0007-Fix-bug-in-TLSTPREL-Relocation.patch
index 8d3d5387..8d880f12 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0006-Fix-bug-in-MicroBlaze-TLSTPREL-Relocation.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0007-Fix-bug-in-TLSTPREL-Relocation.patch
@@ -1,7 +1,7 @@
1From ca0336a49c33ccb78962530f2affff8982027e8e Mon Sep 17 00:00:00 2001 1From 7bfa31fb09557bc33f4965cd08c865df9c67fbc4 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 28 Aug 2017 19:53:58 -0700 3Date: Mon, 15 Jun 2015 16:50:30 +0530
4Subject: [PATCH] Fix bug in MicroBlaze TLSTPREL Relocation 4Subject: [PATCH 07/31] Fix bug in TLSTPREL Relocation
5 5
6Fixed the problem related to the fixup/relocations TLSTPREL. 6Fixed the problem related to the fixup/relocations TLSTPREL.
7When the fixup is applied the addend is not added at the correct offset 7When the fixup is applied the addend is not added at the correct offset
@@ -10,15 +10,12 @@ and it fails for Little endian. This patch allows support for both
10big & little-endian compilers 10big & little-endian compilers
11 11
12Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 12Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
13Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
14Upstream-Status: Pending
15
16--- 13---
17 bfd/elf32-microblaze.c | 4 ++-- 14 bfd/elf32-microblaze.c | 4 ++--
18 1 file changed, 2 insertions(+), 2 deletions(-) 15 1 file changed, 2 insertions(+), 2 deletions(-)
19 16
20diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c 17diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
21index 1dc56f7..d4e53de 100644 18index a377790..474bd0e 100644
22--- a/bfd/elf32-microblaze.c 19--- a/bfd/elf32-microblaze.c
23+++ b/bfd/elf32-microblaze.c 20+++ b/bfd/elf32-microblaze.c
24@@ -1451,9 +1451,9 @@ microblaze_elf_relocate_section (bfd *output_bfd, 21@@ -1451,9 +1451,9 @@ microblaze_elf_relocate_section (bfd *output_bfd,
@@ -33,3 +30,6 @@ index 1dc56f7..d4e53de 100644
33 break; 30 break;
34 case (int) R_MICROBLAZE_TEXTREL_64: 31 case (int) R_MICROBLAZE_TEXTREL_64:
35 case (int) R_MICROBLAZE_TEXTREL_32_LO: 32 case (int) R_MICROBLAZE_TEXTREL_32_LO:
33--
342.7.4
35
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0007-Add-MicroBlaze-address-extension-instructions.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0008-Added-Address-extension-instructions.patch
index 9672c516..b7eaf383 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0007-Add-MicroBlaze-address-extension-instructions.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0008-Added-Address-extension-instructions.patch
@@ -1,38 +1,29 @@
1From 3895968b5c55321d203cadb7630a2baee8699e17 Mon Sep 17 00:00:00 2001 1From 693a9f95f2fd78b334ed9bb7265ad2f95b536a2d Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 28 Aug 2017 19:53:59 -0700 3Date: Mon, 18 Jan 2016 12:28:21 +0530
4Subject: [PATCH] Add MicroBlaze address extension instructions 4Subject: [PATCH 08/31] Added Address extension instructions
5 5
6This patch adds the support of new instructions which are required 6This patch adds the support of new instructions which are required
7for supporting Address extension feature. 7for supporting Address extension feature.
8 8
92016-01-18 Nagaraju Mekala <nagaraju.mekala@xilinx.com> 9Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
10 10
11 * microblaze-opc.h (op_code_struct): Added new instructions 11ChangeLog:
12 * microblaze-opcm.h (microblaze_instr): Added new instructions 12 2016-01-18 Nagaraju Mekala <nmekala@xilix.com>
13
14Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
15Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
16Upstream-Status: Pending
17 13
14 *microblaze-opc.h (op_code_struct): Update
15 Added new instructions
16 *microblaze-opcm.h (microblaze_instr): Update
17 Added new instructions
18--- 18---
19 opcodes/microblaze-opc.h | 13 ++++++++++++- 19 opcodes/microblaze-opc.h | 11 +++++++++++
20 opcodes/microblaze-opcm.h | 10 +++++----- 20 opcodes/microblaze-opcm.h | 10 +++++-----
21 2 files changed, 17 insertions(+), 6 deletions(-) 21 2 files changed, 16 insertions(+), 5 deletions(-)
22 22
23diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h 23diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
24index 773dc81..4e69f76 100644 24index 773dc81..292e3a4 100644
25--- a/opcodes/microblaze-opc.h 25--- a/opcodes/microblaze-opc.h
26+++ b/opcodes/microblaze-opc.h 26+++ b/opcodes/microblaze-opc.h
27@@ -102,7 +102,7 @@
28 #define DELAY_SLOT 1
29 #define NO_DELAY_SLOT 0
30
31-#define MAX_OPCODES 291
32+#define MAX_OPCODES 299
33
34 struct op_code_struct
35 {
36@@ -178,8 +178,11 @@ struct op_code_struct 27@@ -178,8 +178,11 @@ struct op_code_struct
37 {"wdc.ext.clear", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000466, OPCODE_MASK_H35B, wdcextclear, special_inst }, 28 {"wdc.ext.clear", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000466, OPCODE_MASK_H35B, wdcextclear, special_inst },
38 {"wdc.flush", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000074, OPCODE_MASK_H34B, wdcflush, special_inst }, 29 {"wdc.flush", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000074, OPCODE_MASK_H34B, wdcflush, special_inst },
@@ -102,3 +93,6 @@ index 7338f6a..c75f10a 100644
102 sbi, shi, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv, 93 sbi, shi, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv,
103 fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, flt, 94 fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, flt,
104 fint, fsqrt, 95 fint, fsqrt,
96--
972.7.4
98
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0009-fixing-the-MAX_OPCODES-to-correct-value.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0009-fixing-the-MAX_OPCODES-to-correct-value.patch
new file mode 100644
index 00000000..a8e33af9
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0009-fixing-the-MAX_OPCODES-to-correct-value.patch
@@ -0,0 +1,26 @@
1From c96e1cac59722005484ff5051b03fcc43efd246f Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 28 Jan 2016 14:07:34 +0530
4Subject: [PATCH 09/31] fixing the MAX_OPCODES to correct value
5
6Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
7---
8 opcodes/microblaze-opc.h | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
12index 292e3a4..4e69f76 100644
13--- a/opcodes/microblaze-opc.h
14+++ b/opcodes/microblaze-opc.h
15@@ -102,7 +102,7 @@
16 #define DELAY_SLOT 1
17 #define NO_DELAY_SLOT 0
18
19-#define MAX_OPCODES 291
20+#define MAX_OPCODES 299
21
22 struct op_code_struct
23 {
24--
252.7.4
26
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0008-Add-new-MicroBlaze-bit-field-instructions.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0010-Add-new-bit-field-instructions.patch
index 0bc01177..5410bad9 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0008-Add-new-MicroBlaze-bit-field-instructions.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0010-Add-new-bit-field-instructions.patch
@@ -1,19 +1,17 @@
1From 5c4dacaae2ba93569c1d37cda9859c57d6649dc0 Mon Sep 17 00:00:00 2001 1From bcb1dcdb9349fb2f6863daf9206552916bd4149b Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 28 Aug 2017 19:54:01 -0700 3Date: Mon, 18 Jul 2016 12:24:28 +0530
4Subject: [PATCH] Add new MicroBlaze bit-field instructions 4Subject: [PATCH 10/31] Add new bit-field instructions
5 5
6This patches adds new bsefi and bsifi instructions. BSEFI- The 6This patches adds new bsefi and bsifi instructions.
7instruction shall extract a bit field from a register and place it 7BSEFI- The instruction shall extract a bit field from a
8right-adjusted in the destination register. The other bits in the 8register and place it right-adjusted in the destination register.
9destination register shall be set to zero BSIFI- The instruction shall 9The other bits in the destination register shall be set to zero
10insert a right-adjusted bit field from a register at another position in 10BSIFI- The instruction shall insert a right-adjusted bit field
11the destination register. The rest of the bits in the destination 11from a register at another position in the destination register.
12register shall be unchanged 12The rest of the bits in the destination register shall be unchanged
13 13
14Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 14Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
15Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
16Upstream-Status: Pending
17--- 15---
18 gas/config/tc-microblaze.c | 71 +++++++++++++++++++++++++++++++++++++++++++++- 16 gas/config/tc-microblaze.c | 71 +++++++++++++++++++++++++++++++++++++++++++++-
19 opcodes/microblaze-dis.c | 16 +++++++++++ 17 opcodes/microblaze-dis.c | 16 +++++++++++
@@ -22,10 +20,10 @@ Upstream-Status: Pending
22 4 files changed, 102 insertions(+), 3 deletions(-) 20 4 files changed, 102 insertions(+), 3 deletions(-)
23 21
24diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c 22diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
25index e135547e62..34cb80fac2 100644 23index b34796c..7b42c99 100644
26--- a/gas/config/tc-microblaze.c 24--- a/gas/config/tc-microblaze.c
27+++ b/gas/config/tc-microblaze.c 25+++ b/gas/config/tc-microblaze.c
28@@ -909,7 +909,7 @@ md_assemble (char * str) 26@@ -917,7 +917,7 @@ md_assemble (char * str)
29 unsigned reg2; 27 unsigned reg2;
30 unsigned reg3; 28 unsigned reg3;
31 unsigned isize; 29 unsigned isize;
@@ -34,7 +32,7 @@ index e135547e62..34cb80fac2 100644
34 expressionS exp; 32 expressionS exp;
35 char name[20]; 33 char name[20];
36 34
37@@ -1164,7 +1164,76 @@ md_assemble (char * str) 35@@ -1172,7 +1172,76 @@ md_assemble (char * str)
38 inst |= (reg2 << RA_LOW) & RA_MASK; 36 inst |= (reg2 << RA_LOW) & RA_MASK;
39 inst |= (immed << IMM_LOW) & IMM5_MASK; 37 inst |= (immed << IMM_LOW) & IMM5_MASK;
40 break; 38 break;
@@ -112,14 +110,13 @@ index e135547e62..34cb80fac2 100644
112 if (strcmp (op_end, "")) 110 if (strcmp (op_end, ""))
113 op_end = parse_reg (op_end + 1, &reg1); /* Get r1. */ 111 op_end = parse_reg (op_end + 1, &reg1); /* Get r1. */
114diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c 112diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
115index 6a174b0eb9..80a47ad2fc 100644 113index 3b676d8..5101ceb 100644
116--- a/opcodes/microblaze-dis.c 114--- a/opcodes/microblaze-dis.c
117+++ b/opcodes/microblaze-dis.c 115+++ b/opcodes/microblaze-dis.c
118@@ -73,6 +73,18 @@ get_field_imm5_mbar (long instr) 116@@ -74,6 +74,18 @@ get_field_imm5_mbar (long instr)
119 return(strdup(tmpstr));
120 } 117 }
121 118
122+static char * 119 static char *
123+get_field_imm5width (long instr) 120+get_field_imm5width (long instr)
124+{ 121+{
125+ char tmpstr[25]; 122+ char tmpstr[25];
@@ -131,9 +128,10 @@ index 6a174b0eb9..80a47ad2fc 100644
131+ return (strdup (tmpstr)); 128+ return (strdup (tmpstr));
132+} 129+}
133+ 130+
134 static char * 131+static char *
135 get_field_rfsl (long instr) 132 get_field_rfsl (long instr)
136 { 133 {
134 char tmpstr[25];
137@@ -396,6 +408,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info) 135@@ -396,6 +408,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
138 /* For mbar 16 or sleep insn. */ 136 /* For mbar 16 or sleep insn. */
139 case INST_TYPE_NONE: 137 case INST_TYPE_NONE:
@@ -146,7 +144,7 @@ index 6a174b0eb9..80a47ad2fc 100644
146 case INST_TYPE_RD: 144 case INST_TYPE_RD:
147 print_func (stream, "\t%s", get_field_rd (inst)); 145 print_func (stream, "\t%s", get_field_rd (inst));
148diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h 146diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
149index a64f8362da..afb34989d9 100644 147index 4e69f76..4bc400a 100644
150--- a/opcodes/microblaze-opc.h 148--- a/opcodes/microblaze-opc.h
151+++ b/opcodes/microblaze-opc.h 149+++ b/opcodes/microblaze-opc.h
152@@ -59,6 +59,9 @@ 150@@ -59,6 +59,9 @@
@@ -197,7 +195,7 @@ index a64f8362da..afb34989d9 100644
197 #endif /* MICROBLAZE_OPC */ 195 #endif /* MICROBLAZE_OPC */
198 196
199diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h 197diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
200index 21a3dc8d76..dd6be7f65c 100644 198index c75f10a..b69e6a4 100644
201--- a/opcodes/microblaze-opcm.h 199--- a/opcodes/microblaze-opcm.h
202+++ b/opcodes/microblaze-opcm.h 200+++ b/opcodes/microblaze-opcm.h
203@@ -29,7 +29,7 @@ enum microblaze_instr 201@@ -29,7 +29,7 @@ enum microblaze_instr
@@ -228,5 +226,5 @@ index 21a3dc8d76..dd6be7f65c 100644
228 #define RFSL_MASK 0x000000F 226 #define RFSL_MASK 0x000000F
229 227
230-- 228--
2312.15.0 2292.7.4
232 230
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0009-Fixing-MicroBlaze-IMM-bug.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0011-fixing-the-imm-bug.patch
index bb7e91cc..1b903e64 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0009-Fixing-MicroBlaze-IMM-bug.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0011-fixing-the-imm-bug.patch
@@ -1,23 +1,19 @@
1From f649406ccaea992f3931e0d9ca9fbd6efb0c553b Mon Sep 17 00:00:00 2001 1From f61fb7af045c67c8c1c48cabecf568205d6f9637 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 28 Aug 2017 19:54:02 -0700 3Date: Mon, 10 Jul 2017 16:07:28 +0530
4Subject: [PATCH] Fixing MicroBlaze IMM bug 4Subject: [PATCH 11/31] fixing the imm bug. with relax option imm -1 is also
5 5 getting removed this is corrected now.
6Fixing the imm bug. with relax option imm -1 is also getting removed this is corrected now.
7 6
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
10Upstream-Status: Pending
11
12--- 8---
13 bfd/elf32-microblaze.c | 3 +-- 9 bfd/elf32-microblaze.c | 3 +--
14 1 file changed, 1 insertion(+), 2 deletions(-) 10 1 file changed, 1 insertion(+), 2 deletions(-)
15 11
16diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c 12diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
17index a94799f..74b00d2 100644 13index 474bd0e..94fa3cf 100644
18--- a/bfd/elf32-microblaze.c 14--- a/bfd/elf32-microblaze.c
19+++ b/bfd/elf32-microblaze.c 15+++ b/bfd/elf32-microblaze.c
20@@ -1789,8 +1789,7 @@ microblaze_elf_relax_section (bfd *abfd, 16@@ -1869,8 +1869,7 @@ microblaze_elf_relax_section (bfd *abfd,
21 else 17 else
22 symval += irel->r_addend; 18 symval += irel->r_addend;
23 19
@@ -27,3 +23,6 @@ index a94799f..74b00d2 100644
27 { 23 {
28 /* We can delete this instruction. */ 24 /* We can delete this instruction. */
29 sec->relax[sec->relax_count].addr = irel->r_offset; 25 sec->relax[sec->relax_count].addr = irel->r_offset;
26--
272.7.4
28
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0012-MicroBlaze-fix-mask-for-barrel-shift-instructions.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0012-MicroBlaze-fix-mask-for-barrel-shift-instructions.patch
deleted file mode 100644
index e340c506..00000000
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0012-MicroBlaze-fix-mask-for-barrel-shift-instructions.patch
+++ /dev/null
@@ -1,36 +0,0 @@
1From 732b5a44a0a032da5ebb775b5df2ee2a36af988f Mon Sep 17 00:00:00 2001
2From: Nathan Rossi <nathan@nathanrossi.com>
3Date: Sun, 5 Nov 2017 22:17:39 +1000
4Subject: [PATCH] MicroBlaze fix mask for barrel shift instructions
5
6As of v10.0 the bsi (bslli/bsrai/bsrli/bsefi/bsifi) instructions have
7bits 16 and 17 defined as 'Insert' and 'Extract' respectively to support
8bit field insert/extract operations. For the bslli/bsrai/bsrli
9instructions these bits must be 0, as such update the opcode mask so
10that the bslli/bsrai/bsrli instructions do not also match the bsefi and
11bsifi instructions.
12
13Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
14Upstream-Status: Pending
15
16---
17 opcodes/microblaze-opc.h | 6 +++---
18 1 file changed, 3 insertions(+), 3 deletions(-)
19
20diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
21index 4bc400a..9482d81 100644
22--- a/opcodes/microblaze-opc.h
23+++ b/opcodes/microblaze-opc.h
24@@ -161,9 +161,9 @@ struct op_code_struct
25 {"ncget", INST_TYPE_RD_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C006000, OPCODE_MASK_H32, ncget, anyware_inst },
26 {"ncput", INST_TYPE_R1_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00E000, OPCODE_MASK_H32, ncput, anyware_inst },
27 {"muli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x60000000, OPCODE_MASK_H, muli, mult_inst },
28- {"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3, bslli, barrel_shift_inst },
29- {"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3, bsrai, barrel_shift_inst },
30- {"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3, bsrli, barrel_shift_inst },
31+ {"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3B, bslli, barrel_shift_inst },
32+ {"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3B, bsrai, barrel_shift_inst },
33+ {"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3B, bsrli, barrel_shift_inst },
34 {"bsefi", INST_TYPE_RD_R1_IMM5_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64004000, OPCODE_MASK_H32B, bsefi, barrel_shift_inst },
35 {"bsifi", INST_TYPE_RD_R1_IMM5_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64008000, OPCODE_MASK_H32B, bsifi, barrel_shift_inst },
36 {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst },
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0010-Fixed-bug-in-GCC-so-that-it-will-support-.long-0U-an.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0012-Patch-Microblaze-fixed-bug-in-GCC-so-that-It-will-su.patch
index 077343e6..b1eb240d 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0010-Fixed-bug-in-GCC-so-that-it-will-support-.long-0U-an.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0012-Patch-Microblaze-fixed-bug-in-GCC-so-that-It-will-su.patch
@@ -1,19 +1,17 @@
1From e1bacaa7c1aa387f167afff74876c5acdffc39d9 Mon Sep 17 00:00:00 2001 1From ff25d91969293aeddfffc8ae6d87f3f910a69d7b Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 15 Nov 2017 17:45:35 -0800 3Date: Fri, 29 Sep 2017 18:00:23 +0530
4Subject: [PATCH] Fixed bug in GCC so that it will support .long 0U and .long 4Subject: [PATCH 12/31] [Patch,Microblaze]: fixed bug in GCC so that It will
5 0u 5 support .long 0U and .long 0u
6 6
7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com> 7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
8Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com> 8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9Upstream-Status: Pending
10
11--- 9---
12 gas/expr.c | 9 +++++++++ 10 gas/expr.c | 9 +++++++++
13 1 file changed, 9 insertions(+) 11 1 file changed, 9 insertions(+)
14 12
15diff --git a/gas/expr.c b/gas/expr.c 13diff --git a/gas/expr.c b/gas/expr.c
16index 3e28af6..0b7cc76 100644 14index 074e0b3..993aaca 100644
17--- a/gas/expr.c 15--- a/gas/expr.c
18+++ b/gas/expr.c 16+++ b/gas/expr.c
19@@ -810,6 +810,15 @@ operand (expressionS *expressionP, enum expr_mode mode) 17@@ -810,6 +810,15 @@ operand (expressionS *expressionP, enum expr_mode mode)
@@ -32,3 +30,6 @@ index 3e28af6..0b7cc76 100644
32 c = *input_line_pointer; 30 c = *input_line_pointer;
33 switch (c) 31 switch (c)
34 { 32 {
33--
342.7.4
35
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0011-Fixing-MicroBlaze-constant-range-check-issue.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0013-fixing-the-constant-range-check-issue.patch
index 244a7ade..03e4c701 100644
--- a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0011-Fixing-MicroBlaze-constant-range-check-issue.patch
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0013-fixing-the-constant-range-check-issue.patch
@@ -1,23 +1,19 @@
1From 9393a3e346d2ccbb86761117260c1dd89070a507 Mon Sep 17 00:00:00 2001 1From 85e4d02730d657ddc9ce25f3e7eccf4818bc25eb Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Wed, 15 Nov 2017 17:45:34 -0800 3Date: Mon, 16 Oct 2017 15:44:23 +0530
4Subject: [PATCH] Fixing MicroBlaze constant range check issue 4Subject: [PATCH 13/31] fixing the constant range check issue sample error: not
5 5 in range ffffffff80000000..7fffffff, not ffffffff70000000
6Sample error: not in range ffffffff80000000..7fffffff, not ffffffff70000000
7 6
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com> 7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
10Upstream-Status: Pending
11
12--- 8---
13 gas/config/tc-microblaze.c | 2 +- 9 gas/config/tc-microblaze.c | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-) 10 1 file changed, 1 insertion(+), 1 deletion(-)
15 11
16diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c 12diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
17index 21a5a0c..c614556 100644 13index 7b42c99..f1d97b9 100644
18--- a/gas/config/tc-microblaze.c 14--- a/gas/config/tc-microblaze.c
19+++ b/gas/config/tc-microblaze.c 15+++ b/gas/config/tc-microblaze.c
20@@ -749,7 +749,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max) 16@@ -757,7 +757,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
21 if ((e->X_add_number >> 31) == 1) 17 if ((e->X_add_number >> 31) == 1)
22 e->X_add_number |= -((addressT) (1U << 31)); 18 e->X_add_number |= -((addressT) (1U << 31));
23 19
@@ -26,3 +22,6 @@ index 21a5a0c..c614556 100644
26 { 22 {
27 as_fatal (_("operand must be absolute in range %lx..%lx, not %lx"), 23 as_fatal (_("operand must be absolute in range %lx..%lx, not %lx"),
28 (long) min, (long) max, (long) e->X_add_number); 24 (long) min, (long) max, (long) e->X_add_number);
25--
262.7.4
27
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch
new file mode 100644
index 00000000..52274e02
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch
@@ -0,0 +1,38 @@
1From 3d1e635a4223f6c0a0b938b94911740b4aa0db8f Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 21 Feb 2018 12:32:02 +0530
4Subject: [PATCH 14/31] [Patch,Microblaze]: Compiler will give error messages
5 in more detail for mxl-gp-opt flag..
6
7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9---
10 ld/ldmain.c | 12 ++++++++++++
11 1 file changed, 12 insertions(+)
12
13diff --git a/ld/ldmain.c b/ld/ldmain.c
14index f31eeb2..04e96ca 100644
15--- a/ld/ldmain.c
16+++ b/ld/ldmain.c
17@@ -1434,6 +1434,18 @@ reloc_overflow (struct bfd_link_info *info,
18 break;
19 case bfd_link_hash_defined:
20 case bfd_link_hash_defweak:
21+
22+ if((strcmp(reloc_name,"R_MICROBLAZE_SRW32") == 0) && entry->type == bfd_link_hash_defined)
23+ {
24+ einfo (_(" relocation truncated to fit: don't enable small data pointer optimizations[mxl-gp-opt] if extern or multiple declarations used: "
25+ "%s against symbol `%T' defined in %A section in %B"),
26+ reloc_name, entry->root.string,
27+ entry->u.def.section,
28+ entry->u.def.section == bfd_abs_section_ptr
29+ ? info->output_bfd : entry->u.def.section->owner);
30+ break;
31+ }
32+
33 einfo (_(" relocation truncated to fit: "
34 "%s against symbol `%pT' defined in %pA section in %pB"),
35 reloc_name, entry->root.string,
36--
372.7.4
38
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0015-intial-commit-of-MB-64-bit.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0015-intial-commit-of-MB-64-bit.patch
new file mode 100644
index 00000000..eb4eaf1d
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0015-intial-commit-of-MB-64-bit.patch
@@ -0,0 +1,4740 @@
1From f548b7a7d92d8f06afee253a7faf71f5bb1cb163 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Sun, 30 Sep 2018 16:28:28 +0530
4Subject: [PATCH 15/31] intial commit of MB 64-bit
5
6Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
8---
9 bfd/Makefile.am | 2 +
10 bfd/Makefile.in | 3 +
11 bfd/config.bfd | 4 +
12 bfd/configure | 2 +
13 bfd/configure.ac | 2 +
14 bfd/cpu-microblaze.c | 52 +-
15 bfd/elf64-microblaze.c | 3584 ++++++++++++++++++++++++++++++++++++
16 bfd/targets.c | 6 +
17 gas/config/tc-microblaze.c | 274 ++-
18 gas/config/tc-microblaze.h | 4 +-
19 include/elf/common.h | 1 +
20 ld/Makefile.am | 8 +
21 ld/Makefile.in | 10 +
22 ld/configure.tgt | 3 +
23 ld/emulparams/elf64microblaze.sh | 23 +
24 ld/emulparams/elf64microblazeel.sh | 23 +
25 opcodes/microblaze-dis.c | 39 +-
26 opcodes/microblaze-opc.h | 162 +-
27 opcodes/microblaze-opcm.h | 20 +-
28 19 files changed, 4181 insertions(+), 41 deletions(-)
29 create mode 100644 bfd/elf64-microblaze.c
30 create mode 100644 ld/emulparams/elf64microblaze.sh
31 create mode 100644 ld/emulparams/elf64microblazeel.sh
32
33diff --git a/bfd/Makefile.am b/bfd/Makefile.am
34index 3f3487f..ae6bf3e 100644
35--- a/bfd/Makefile.am
36+++ b/bfd/Makefile.am
37@@ -568,6 +568,7 @@ BFD64_BACKENDS = \
38 elf64-riscv.lo \
39 elfxx-riscv.lo \
40 elf64-s390.lo \
41+ elf64-microblaze.lo \
42 elf64-sparc.lo \
43 elf64-tilegx.lo \
44 elf64-x86-64.lo \
45@@ -601,6 +602,7 @@ BFD64_BACKENDS_CFILES = \
46 elf64-nfp.c \
47 elf64-ppc.c \
48 elf64-s390.c \
49+ elf64-microblaze.c \
50 elf64-sparc.c \
51 elf64-tilegx.c \
52 elf64-x86-64.c \
53diff --git a/bfd/Makefile.in b/bfd/Makefile.in
54index cc27ef0..3ba6eee 100644
55--- a/bfd/Makefile.in
56+++ b/bfd/Makefile.in
57@@ -992,6 +992,7 @@ BFD64_BACKENDS = \
58 elf64-riscv.lo \
59 elfxx-riscv.lo \
60 elf64-s390.lo \
61+ elf64-microblaze.lo \
62 elf64-sparc.lo \
63 elf64-tilegx.lo \
64 elf64-x86-64.lo \
65@@ -1025,6 +1026,7 @@ BFD64_BACKENDS_CFILES = \
66 elf64-nfp.c \
67 elf64-ppc.c \
68 elf64-s390.c \
69+ elf64-microblaze.c \
70 elf64-sparc.c \
71 elf64-tilegx.c \
72 elf64-x86-64.c \
73@@ -1489,6 +1491,7 @@ distclean-compile:
74 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-ppc.Plo@am__quote@
75 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-riscv.Plo@am__quote@
76 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-s390.Plo@am__quote@
77+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-microblaze.Plo@am__quote@
78 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-sparc.Plo@am__quote@
79 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-tilegx.Plo@am__quote@
80 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-x86-64.Plo@am__quote@
81diff --git a/bfd/config.bfd b/bfd/config.bfd
82index 6391f35..cde27b4 100644
83--- a/bfd/config.bfd
84+++ b/bfd/config.bfd
85@@ -844,11 +844,15 @@ case "${targ}" in
86 microblazeel*-*)
87 targ_defvec=microblaze_elf32_le_vec
88 targ_selvecs=microblaze_elf32_vec
89+ targ64_selvecs=microblaze_elf64_vec
90+ targ64_selvecs=microblaze_elf64_le_vec
91 ;;
92
93 microblaze*-*)
94 targ_defvec=microblaze_elf32_vec
95 targ_selvecs=microblaze_elf32_le_vec
96+ targ64_selvecs=microblaze_elf64_vec
97+ targ64_selvecs=microblaze_elf64_le_vec
98 ;;
99
100 #ifdef BFD64
101diff --git a/bfd/configure b/bfd/configure
102index 3c32a83..5934afd 100755
103--- a/bfd/configure
104+++ b/bfd/configure
105@@ -14844,6 +14844,8 @@ do
106 rx_elf32_le_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;;
107 s390_elf32_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
108 s390_elf64_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
109+ microblaze_elf64_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
110+ microblaze_elf64_le_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
111 score_elf32_be_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
112 score_elf32_le_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
113 sh_coff_vec) tb="$tb coff-sh.lo $coff" ;;
114diff --git a/bfd/configure.ac b/bfd/configure.ac
115index c6193cd..901977d 100644
116--- a/bfd/configure.ac
117+++ b/bfd/configure.ac
118@@ -612,6 +612,8 @@ do
119 rx_elf32_le_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;;
120 s390_elf32_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
121 s390_elf64_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
122+ microblaze_elf64_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
123+ microblaze_elf64_le_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
124 score_elf32_be_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
125 score_elf32_le_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
126 sh_coff_vec) tb="$tb coff-sh.lo $coff" ;;
127diff --git a/bfd/cpu-microblaze.c b/bfd/cpu-microblaze.c
128index 2ccf724..dd2d6ab 100644
129--- a/bfd/cpu-microblaze.c
130+++ b/bfd/cpu-microblaze.c
131@@ -23,7 +23,24 @@
132 #include "bfd.h"
133 #include "libbfd.h"
134
135-const bfd_arch_info_type bfd_microblaze_arch =
136+const bfd_arch_info_type bfd_microblaze_arch[] =
137+{
138+#if BFD_DEFAULT_TARGET_SIZE == 64
139+{
140+ 64, /* 32 bits in a word. */
141+ 64, /* 32 bits in an address. */
142+ 8, /* 8 bits in a byte. */
143+ bfd_arch_microblaze, /* Architecture. */
144+ 0, /* Machine number - 0 for now. */
145+ "microblaze", /* Architecture name. */
146+ "MicroBlaze", /* Printable name. */
147+ 3, /* Section align power. */
148+ FALSE, /* Is this the default architecture ? */
149+ bfd_default_compatible, /* Architecture comparison function. */
150+ bfd_default_scan, /* String to architecture conversion. */
151+ bfd_arch_default_fill, /* Default fill. */
152+ &bfd_microblaze_arch[1] /* Next in list. */
153+},
154 {
155 32, /* 32 bits in a word. */
156 32, /* 32 bits in an address. */
157@@ -38,4 +55,37 @@ const bfd_arch_info_type bfd_microblaze_arch =
158 bfd_default_scan, /* String to architecture conversion. */
159 bfd_arch_default_fill, /* Default fill. */
160 NULL /* Next in list. */
161+}
162+#else
163+{
164+ 32, /* 32 bits in a word. */
165+ 32, /* 32 bits in an address. */
166+ 8, /* 8 bits in a byte. */
167+ bfd_arch_microblaze, /* Architecture. */
168+ 0, /* Machine number - 0 for now. */
169+ "microblaze", /* Architecture name. */
170+ "MicroBlaze", /* Printable name. */
171+ 3, /* Section align power. */
172+ TRUE, /* Is this the default architecture ? */
173+ bfd_default_compatible, /* Architecture comparison function. */
174+ bfd_default_scan, /* String to architecture conversion. */
175+ bfd_arch_default_fill, /* Default fill. */
176+ &bfd_microblaze_arch[1] /* Next in list. */
177+},
178+{
179+ 64, /* 32 bits in a word. */
180+ 64, /* 32 bits in an address. */
181+ 8, /* 8 bits in a byte. */
182+ bfd_arch_microblaze, /* Architecture. */
183+ 0, /* Machine number - 0 for now. */
184+ "microblaze", /* Architecture name. */
185+ "MicroBlaze", /* Printable name. */
186+ 3, /* Section align power. */
187+ FALSE, /* Is this the default architecture ? */
188+ bfd_default_compatible, /* Architecture comparison function. */
189+ bfd_default_scan, /* String to architecture conversion. */
190+ bfd_arch_default_fill, /* Default fill. */
191+ NULL /* Next in list. */
192+}
193+#endif
194 };
195diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
196new file mode 100644
197index 0000000..0f43ae6
198--- /dev/null
199+++ b/bfd/elf64-microblaze.c
200@@ -0,0 +1,3584 @@
201+/* Xilinx MicroBlaze-specific support for 32-bit ELF
202+
203+ Copyright (C) 2009-2016 Free Software Foundation, Inc.
204+
205+ This file is part of BFD, the Binary File Descriptor library.
206+
207+ This program is free software; you can redistribute it and/or modify
208+ it under the terms of the GNU General Public License as published by
209+ the Free Software Foundation; either version 3 of the License, or
210+ (at your option) any later version.
211+
212+ This program is distributed in the hope that it will be useful,
213+ but WITHOUT ANY WARRANTY; without even the implied warranty of
214+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
215+ GNU General Public License for more details.
216+
217+ You should have received a copy of the GNU General Public License
218+ along with this program; if not, write to the
219+ Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
220+ Boston, MA 02110-1301, USA. */
221+
222+
223+int dbg1 = 0;
224+
225+#include "sysdep.h"
226+#include "bfd.h"
227+#include "bfdlink.h"
228+#include "libbfd.h"
229+#include "elf-bfd.h"
230+#include "elf/microblaze.h"
231+#include <assert.h>
232+
233+#define USE_RELA /* Only USE_REL is actually significant, but this is
234+ here are a reminder... */
235+#define INST_WORD_SIZE 4
236+
237+static int ro_small_data_pointer = 0;
238+static int rw_small_data_pointer = 0;
239+
240+static reloc_howto_type * microblaze_elf_howto_table [(int) R_MICROBLAZE_max];
241+
242+static reloc_howto_type microblaze_elf_howto_raw[] =
243+{
244+ /* This reloc does nothing. */
245+ HOWTO (R_MICROBLAZE_NONE, /* Type. */
246+ 0, /* Rightshift. */
247+ 3, /* Size (0 = byte, 1 = short, 2 = long). */
248+ 0, /* Bitsize. */
249+ FALSE, /* PC_relative. */
250+ 0, /* Bitpos. */
251+ complain_overflow_dont, /* Complain on overflow. */
252+ NULL, /* Special Function. */
253+ "R_MICROBLAZE_NONE", /* Name. */
254+ FALSE, /* Partial Inplace. */
255+ 0, /* Source Mask. */
256+ 0, /* Dest Mask. */
257+ FALSE), /* PC relative offset? */
258+
259+ /* A standard 32 bit relocation. */
260+ HOWTO (R_MICROBLAZE_32, /* Type. */
261+ 0, /* Rightshift. */
262+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
263+ 32, /* Bitsize. */
264+ FALSE, /* PC_relative. */
265+ 0, /* Bitpos. */
266+ complain_overflow_bitfield, /* Complain on overflow. */
267+ bfd_elf_generic_reloc,/* Special Function. */
268+ "R_MICROBLAZE_32", /* Name. */
269+ FALSE, /* Partial Inplace. */
270+ 0, /* Source Mask. */
271+ 0xffffffff, /* Dest Mask. */
272+ FALSE), /* PC relative offset? */
273+
274+ /* A standard PCREL 32 bit relocation. */
275+ HOWTO (R_MICROBLAZE_32_PCREL,/* Type. */
276+ 0, /* Rightshift. */
277+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
278+ 32, /* Bitsize. */
279+ TRUE, /* PC_relative. */
280+ 0, /* Bitpos. */
281+ complain_overflow_bitfield, /* Complain on overflow. */
282+ bfd_elf_generic_reloc,/* Special Function. */
283+ "R_MICROBLAZE_32_PCREL", /* Name. */
284+ TRUE, /* Partial Inplace. */
285+ 0, /* Source Mask. */
286+ 0xffffffff, /* Dest Mask. */
287+ TRUE), /* PC relative offset? */
288+
289+ /* A 64 bit PCREL relocation. Table-entry not really used. */
290+ HOWTO (R_MICROBLAZE_64_PCREL,/* Type. */
291+ 0, /* Rightshift. */
292+ 4, /* Size (0 = byte, 1 = short, 2 = long). */
293+ 64, /* Bitsize. */
294+ TRUE, /* PC_relative. */
295+ 0, /* Bitpos. */
296+ complain_overflow_dont, /* Complain on overflow. */
297+ bfd_elf_generic_reloc,/* Special Function. */
298+ "R_MICROBLAZE_64_PCREL", /* Name. */
299+ FALSE, /* Partial Inplace. */
300+ 0, /* Source Mask. */
301+ 0x0000ffff, /* Dest Mask. */
302+ TRUE), /* PC relative offset? */
303+
304+ /* The low half of a PCREL 32 bit relocation. */
305+ HOWTO (R_MICROBLAZE_32_PCREL_LO, /* Type. */
306+ 0, /* Rightshift. */
307+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
308+ 16, /* Bitsize. */
309+ TRUE, /* PC_relative. */
310+ 0, /* Bitpos. */
311+ complain_overflow_signed, /* Complain on overflow. */
312+ bfd_elf_generic_reloc, /* Special Function. */
313+ "R_MICROBLAZE_32_PCREL_LO", /* Name. */
314+ FALSE, /* Partial Inplace. */
315+ 0, /* Source Mask. */
316+ 0x0000ffff, /* Dest Mask. */
317+ TRUE), /* PC relative offset? */
318+
319+ /* A 64 bit relocation. Table entry not really used. */
320+ HOWTO (R_MICROBLAZE_64, /* Type. */
321+ 0, /* Rightshift. */
322+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
323+ 16, /* Bitsize. */
324+ FALSE, /* PC_relative. */
325+ 0, /* Bitpos. */
326+ complain_overflow_dont, /* Complain on overflow. */
327+ bfd_elf_generic_reloc,/* Special Function. */
328+ "R_MICROBLAZE_64", /* Name. */
329+ FALSE, /* Partial Inplace. */
330+ 0, /* Source Mask. */
331+ 0x0000ffff, /* Dest Mask. */
332+ FALSE), /* PC relative offset? */
333+
334+ /* The low half of a 32 bit relocation. */
335+ HOWTO (R_MICROBLAZE_32_LO, /* Type. */
336+ 0, /* Rightshift. */
337+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
338+ 16, /* Bitsize. */
339+ FALSE, /* PC_relative. */
340+ 0, /* Bitpos. */
341+ complain_overflow_signed, /* Complain on overflow. */
342+ bfd_elf_generic_reloc,/* Special Function. */
343+ "R_MICROBLAZE_32_LO", /* Name. */
344+ FALSE, /* Partial Inplace. */
345+ 0, /* Source Mask. */
346+ 0x0000ffff, /* Dest Mask. */
347+ FALSE), /* PC relative offset? */
348+
349+ /* Read-only small data section relocation. */
350+ HOWTO (R_MICROBLAZE_SRO32, /* Type. */
351+ 0, /* Rightshift. */
352+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
353+ 16, /* Bitsize. */
354+ FALSE, /* PC_relative. */
355+ 0, /* Bitpos. */
356+ complain_overflow_bitfield, /* Complain on overflow. */
357+ bfd_elf_generic_reloc,/* Special Function. */
358+ "R_MICROBLAZE_SRO32", /* Name. */
359+ FALSE, /* Partial Inplace. */
360+ 0, /* Source Mask. */
361+ 0x0000ffff, /* Dest Mask. */
362+ FALSE), /* PC relative offset? */
363+
364+ /* Read-write small data area relocation. */
365+ HOWTO (R_MICROBLAZE_SRW32, /* Type. */
366+ 0, /* Rightshift. */
367+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
368+ 16, /* Bitsize. */
369+ FALSE, /* PC_relative. */
370+ 0, /* Bitpos. */
371+ complain_overflow_bitfield, /* Complain on overflow. */
372+ bfd_elf_generic_reloc,/* Special Function. */
373+ "R_MICROBLAZE_SRW32", /* Name. */
374+ FALSE, /* Partial Inplace. */
375+ 0, /* Source Mask. */
376+ 0x0000ffff, /* Dest Mask. */
377+ FALSE), /* PC relative offset? */
378+
379+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
380+ 0, /* Rightshift. */
381+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
382+ 32, /* Bitsize. */
383+ TRUE, /* PC_relative. */
384+ 0, /* Bitpos. */
385+ complain_overflow_bitfield, /* Complain on overflow. */
386+ NULL, /* Special Function. */
387+ "R_MICROBLAZE_32_NONE",/* Name. */
388+ FALSE, /* Partial Inplace. */
389+ 0, /* Source Mask. */
390+ 0, /* Dest Mask. */
391+ FALSE), /* PC relative offset? */
392+
393+ /* This reloc does nothing. Used for relaxation. */
394+ HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
395+ 0, /* Rightshift. */
396+ 3, /* Size (0 = byte, 1 = short, 2 = long). */
397+ 0, /* Bitsize. */
398+ TRUE, /* PC_relative. */
399+ 0, /* Bitpos. */
400+ complain_overflow_dont, /* Complain on overflow. */
401+ NULL, /* Special Function. */
402+ "R_MICROBLAZE_64_NONE",/* Name. */
403+ FALSE, /* Partial Inplace. */
404+ 0, /* Source Mask. */
405+ 0, /* Dest Mask. */
406+ FALSE), /* PC relative offset? */
407+
408+ /* Symbol Op Symbol relocation. */
409+ HOWTO (R_MICROBLAZE_32_SYM_OP_SYM, /* Type. */
410+ 0, /* Rightshift. */
411+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
412+ 32, /* Bitsize. */
413+ FALSE, /* PC_relative. */
414+ 0, /* Bitpos. */
415+ complain_overflow_bitfield, /* Complain on overflow. */
416+ bfd_elf_generic_reloc,/* Special Function. */
417+ "R_MICROBLAZE_32_SYM_OP_SYM", /* Name. */
418+ FALSE, /* Partial Inplace. */
419+ 0, /* Source Mask. */
420+ 0xffffffff, /* Dest Mask. */
421+ FALSE), /* PC relative offset? */
422+
423+ /* GNU extension to record C++ vtable hierarchy. */
424+ HOWTO (R_MICROBLAZE_GNU_VTINHERIT, /* Type. */
425+ 0, /* Rightshift. */
426+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
427+ 0, /* Bitsize. */
428+ FALSE, /* PC_relative. */
429+ 0, /* Bitpos. */
430+ complain_overflow_dont,/* Complain on overflow. */
431+ NULL, /* Special Function. */
432+ "R_MICROBLAZE_GNU_VTINHERIT", /* Name. */
433+ FALSE, /* Partial Inplace. */
434+ 0, /* Source Mask. */
435+ 0, /* Dest Mask. */
436+ FALSE), /* PC relative offset? */
437+
438+ /* GNU extension to record C++ vtable member usage. */
439+ HOWTO (R_MICROBLAZE_GNU_VTENTRY, /* Type. */
440+ 0, /* Rightshift. */
441+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
442+ 0, /* Bitsize. */
443+ FALSE, /* PC_relative. */
444+ 0, /* Bitpos. */
445+ complain_overflow_dont,/* Complain on overflow. */
446+ _bfd_elf_rel_vtable_reloc_fn, /* Special Function. */
447+ "R_MICROBLAZE_GNU_VTENTRY", /* Name. */
448+ FALSE, /* Partial Inplace. */
449+ 0, /* Source Mask. */
450+ 0, /* Dest Mask. */
451+ FALSE), /* PC relative offset? */
452+
453+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
454+ HOWTO (R_MICROBLAZE_GOTPC_64, /* Type. */
455+ 0, /* Rightshift. */
456+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
457+ 16, /* Bitsize. */
458+ TRUE, /* PC_relative. */
459+ 0, /* Bitpos. */
460+ complain_overflow_dont, /* Complain on overflow. */
461+ bfd_elf_generic_reloc, /* Special Function. */
462+ "R_MICROBLAZE_GOTPC_64", /* Name. */
463+ FALSE, /* Partial Inplace. */
464+ 0, /* Source Mask. */
465+ 0x0000ffff, /* Dest Mask. */
466+ TRUE), /* PC relative offset? */
467+
468+ /* A 64 bit GOT relocation. Table-entry not really used. */
469+ HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
470+ 0, /* Rightshift. */
471+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
472+ 16, /* Bitsize. */
473+ FALSE, /* PC_relative. */
474+ 0, /* Bitpos. */
475+ complain_overflow_dont, /* Complain on overflow. */
476+ bfd_elf_generic_reloc,/* Special Function. */
477+ "R_MICROBLAZE_GOT_64",/* Name. */
478+ FALSE, /* Partial Inplace. */
479+ 0, /* Source Mask. */
480+ 0x0000ffff, /* Dest Mask. */
481+ FALSE), /* PC relative offset? */
482+
483+ /* A 64 bit PLT relocation. Table-entry not really used. */
484+ HOWTO (R_MICROBLAZE_PLT_64, /* Type. */
485+ 0, /* Rightshift. */
486+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
487+ 16, /* Bitsize. */
488+ TRUE, /* PC_relative. */
489+ 0, /* Bitpos. */
490+ complain_overflow_dont, /* Complain on overflow. */
491+ bfd_elf_generic_reloc,/* Special Function. */
492+ "R_MICROBLAZE_PLT_64",/* Name. */
493+ FALSE, /* Partial Inplace. */
494+ 0, /* Source Mask. */
495+ 0x0000ffff, /* Dest Mask. */
496+ TRUE), /* PC relative offset? */
497+
498+ /* Table-entry not really used. */
499+ HOWTO (R_MICROBLAZE_REL, /* Type. */
500+ 0, /* Rightshift. */
501+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
502+ 16, /* Bitsize. */
503+ TRUE, /* PC_relative. */
504+ 0, /* Bitpos. */
505+ complain_overflow_dont, /* Complain on overflow. */
506+ bfd_elf_generic_reloc,/* Special Function. */
507+ "R_MICROBLAZE_REL", /* Name. */
508+ FALSE, /* Partial Inplace. */
509+ 0, /* Source Mask. */
510+ 0x0000ffff, /* Dest Mask. */
511+ TRUE), /* PC relative offset? */
512+
513+ /* Table-entry not really used. */
514+ HOWTO (R_MICROBLAZE_JUMP_SLOT,/* Type. */
515+ 0, /* Rightshift. */
516+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
517+ 16, /* Bitsize. */
518+ TRUE, /* PC_relative. */
519+ 0, /* Bitpos. */
520+ complain_overflow_dont, /* Complain on overflow. */
521+ bfd_elf_generic_reloc,/* Special Function. */
522+ "R_MICROBLAZE_JUMP_SLOT", /* Name. */
523+ FALSE, /* Partial Inplace. */
524+ 0, /* Source Mask. */
525+ 0x0000ffff, /* Dest Mask. */
526+ TRUE), /* PC relative offset? */
527+
528+ /* Table-entry not really used. */
529+ HOWTO (R_MICROBLAZE_GLOB_DAT,/* Type. */
530+ 0, /* Rightshift. */
531+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
532+ 16, /* Bitsize. */
533+ TRUE, /* PC_relative. */
534+ 0, /* Bitpos. */
535+ complain_overflow_dont, /* Complain on overflow. */
536+ bfd_elf_generic_reloc,/* Special Function. */
537+ "R_MICROBLAZE_GLOB_DAT", /* Name. */
538+ FALSE, /* Partial Inplace. */
539+ 0, /* Source Mask. */
540+ 0x0000ffff, /* Dest Mask. */
541+ TRUE), /* PC relative offset? */
542+
543+ /* A 64 bit GOT relative relocation. Table-entry not really used. */
544+ HOWTO (R_MICROBLAZE_GOTOFF_64, /* Type. */
545+ 0, /* Rightshift. */
546+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
547+ 16, /* Bitsize. */
548+ FALSE, /* PC_relative. */
549+ 0, /* Bitpos. */
550+ complain_overflow_dont, /* Complain on overflow. */
551+ bfd_elf_generic_reloc,/* Special Function. */
552+ "R_MICROBLAZE_GOTOFF_64", /* Name. */
553+ FALSE, /* Partial Inplace. */
554+ 0, /* Source Mask. */
555+ 0x0000ffff, /* Dest Mask. */
556+ FALSE), /* PC relative offset? */
557+
558+ /* A 32 bit GOT relative relocation. Table-entry not really used. */
559+ HOWTO (R_MICROBLAZE_GOTOFF_32, /* Type. */
560+ 0, /* Rightshift. */
561+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
562+ 16, /* Bitsize. */
563+ FALSE, /* PC_relative. */
564+ 0, /* Bitpos. */
565+ complain_overflow_dont, /* Complain on overflow. */
566+ bfd_elf_generic_reloc, /* Special Function. */
567+ "R_MICROBLAZE_GOTOFF_32", /* Name. */
568+ FALSE, /* Partial Inplace. */
569+ 0, /* Source Mask. */
570+ 0x0000ffff, /* Dest Mask. */
571+ FALSE), /* PC relative offset? */
572+
573+ /* COPY relocation. Table-entry not really used. */
574+ HOWTO (R_MICROBLAZE_COPY, /* Type. */
575+ 0, /* Rightshift. */
576+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
577+ 16, /* Bitsize. */
578+ FALSE, /* PC_relative. */
579+ 0, /* Bitpos. */
580+ complain_overflow_dont, /* Complain on overflow. */
581+ bfd_elf_generic_reloc,/* Special Function. */
582+ "R_MICROBLAZE_COPY", /* Name. */
583+ FALSE, /* Partial Inplace. */
584+ 0, /* Source Mask. */
585+ 0x0000ffff, /* Dest Mask. */
586+ FALSE), /* PC relative offset? */
587+
588+ /* Marker relocs for TLS. */
589+ HOWTO (R_MICROBLAZE_TLS,
590+ 0, /* rightshift */
591+ 2, /* size (0 = byte, 1 = short, 2 = long) */
592+ 32, /* bitsize */
593+ FALSE, /* pc_relative */
594+ 0, /* bitpos */
595+ complain_overflow_dont, /* complain_on_overflow */
596+ bfd_elf_generic_reloc, /* special_function */
597+ "R_MICROBLAZE_TLS", /* name */
598+ FALSE, /* partial_inplace */
599+ 0, /* src_mask */
600+ 0x0000ffff, /* dst_mask */
601+ FALSE), /* pcrel_offset */
602+
603+ HOWTO (R_MICROBLAZE_TLSGD,
604+ 0, /* rightshift */
605+ 2, /* size (0 = byte, 1 = short, 2 = long) */
606+ 32, /* bitsize */
607+ FALSE, /* pc_relative */
608+ 0, /* bitpos */
609+ complain_overflow_dont, /* complain_on_overflow */
610+ bfd_elf_generic_reloc, /* special_function */
611+ "R_MICROBLAZE_TLSGD", /* name */
612+ FALSE, /* partial_inplace */
613+ 0, /* src_mask */
614+ 0x0000ffff, /* dst_mask */
615+ FALSE), /* pcrel_offset */
616+
617+ HOWTO (R_MICROBLAZE_TLSLD,
618+ 0, /* rightshift */
619+ 2, /* size (0 = byte, 1 = short, 2 = long) */
620+ 32, /* bitsize */
621+ FALSE, /* pc_relative */
622+ 0, /* bitpos */
623+ complain_overflow_dont, /* complain_on_overflow */
624+ bfd_elf_generic_reloc, /* special_function */
625+ "R_MICROBLAZE_TLSLD", /* name */
626+ FALSE, /* partial_inplace */
627+ 0, /* src_mask */
628+ 0x0000ffff, /* dst_mask */
629+ FALSE), /* pcrel_offset */
630+
631+ /* Computes the load module index of the load module that contains the
632+ definition of its TLS sym. */
633+ HOWTO (R_MICROBLAZE_TLSDTPMOD32,
634+ 0, /* rightshift */
635+ 2, /* size (0 = byte, 1 = short, 2 = long) */
636+ 32, /* bitsize */
637+ FALSE, /* pc_relative */
638+ 0, /* bitpos */
639+ complain_overflow_dont, /* complain_on_overflow */
640+ bfd_elf_generic_reloc, /* special_function */
641+ "R_MICROBLAZE_TLSDTPMOD32", /* name */
642+ FALSE, /* partial_inplace */
643+ 0, /* src_mask */
644+ 0x0000ffff, /* dst_mask */
645+ FALSE), /* pcrel_offset */
646+
647+ /* Computes a dtv-relative displacement, the difference between the value
648+ of sym+add and the base address of the thread-local storage block that
649+ contains the definition of sym, minus 0x8000. Used for initializing GOT */
650+ HOWTO (R_MICROBLAZE_TLSDTPREL32,
651+ 0, /* rightshift */
652+ 2, /* size (0 = byte, 1 = short, 2 = long) */
653+ 32, /* bitsize */
654+ FALSE, /* pc_relative */
655+ 0, /* bitpos */
656+ complain_overflow_dont, /* complain_on_overflow */
657+ bfd_elf_generic_reloc, /* special_function */
658+ "R_MICROBLAZE_TLSDTPREL32", /* name */
659+ FALSE, /* partial_inplace */
660+ 0, /* src_mask */
661+ 0x0000ffff, /* dst_mask */
662+ FALSE), /* pcrel_offset */
663+
664+ /* Computes a dtv-relative displacement, the difference between the value
665+ of sym+add and the base address of the thread-local storage block that
666+ contains the definition of sym, minus 0x8000. */
667+ HOWTO (R_MICROBLAZE_TLSDTPREL64,
668+ 0, /* rightshift */
669+ 2, /* size (0 = byte, 1 = short, 2 = long) */
670+ 32, /* bitsize */
671+ FALSE, /* pc_relative */
672+ 0, /* bitpos */
673+ complain_overflow_dont, /* complain_on_overflow */
674+ bfd_elf_generic_reloc, /* special_function */
675+ "R_MICROBLAZE_TLSDTPREL64", /* name */
676+ FALSE, /* partial_inplace */
677+ 0, /* src_mask */
678+ 0x0000ffff, /* dst_mask */
679+ FALSE), /* pcrel_offset */
680+
681+ /* Computes a tp-relative displacement, the difference between the value of
682+ sym+add and the value of the thread pointer (r13). */
683+ HOWTO (R_MICROBLAZE_TLSGOTTPREL32,
684+ 0, /* rightshift */
685+ 2, /* size (0 = byte, 1 = short, 2 = long) */
686+ 32, /* bitsize */
687+ FALSE, /* pc_relative */
688+ 0, /* bitpos */
689+ complain_overflow_dont, /* complain_on_overflow */
690+ bfd_elf_generic_reloc, /* special_function */
691+ "R_MICROBLAZE_TLSGOTTPREL32", /* name */
692+ FALSE, /* partial_inplace */
693+ 0, /* src_mask */
694+ 0x0000ffff, /* dst_mask */
695+ FALSE), /* pcrel_offset */
696+
697+ /* Computes a tp-relative displacement, the difference between the value of
698+ sym+add and the value of the thread pointer (r13). */
699+ HOWTO (R_MICROBLAZE_TLSTPREL32,
700+ 0, /* rightshift */
701+ 2, /* size (0 = byte, 1 = short, 2 = long) */
702+ 32, /* bitsize */
703+ FALSE, /* pc_relative */
704+ 0, /* bitpos */
705+ complain_overflow_dont, /* complain_on_overflow */
706+ bfd_elf_generic_reloc, /* special_function */
707+ "R_MICROBLAZE_TLSTPREL32", /* name */
708+ FALSE, /* partial_inplace */
709+ 0, /* src_mask */
710+ 0x0000ffff, /* dst_mask */
711+ FALSE), /* pcrel_offset */
712+
713+};
714+
715+#ifndef NUM_ELEM
716+#define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0])
717+#endif
718+
719+/* Initialize the microblaze_elf_howto_table, so that linear accesses can be done. */
720+
721+static void
722+microblaze_elf_howto_init (void)
723+{
724+ unsigned int i;
725+
726+ for (i = NUM_ELEM (microblaze_elf_howto_raw); i--;)
727+ {
728+ unsigned int type;
729+
730+ type = microblaze_elf_howto_raw[i].type;
731+
732+ BFD_ASSERT (type < NUM_ELEM (microblaze_elf_howto_table));
733+
734+ microblaze_elf_howto_table [type] = & microblaze_elf_howto_raw [i];
735+ }
736+}
737+
738+static reloc_howto_type *
739+microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
740+ bfd_reloc_code_real_type code)
741+{
742+ enum elf_microblaze_reloc_type microblaze_reloc = R_MICROBLAZE_NONE;
743+
744+ switch (code)
745+ {
746+ case BFD_RELOC_NONE:
747+ microblaze_reloc = R_MICROBLAZE_NONE;
748+ break;
749+ case BFD_RELOC_MICROBLAZE_32_NONE:
750+ microblaze_reloc = R_MICROBLAZE_32_NONE;
751+ break;
752+ case BFD_RELOC_MICROBLAZE_64_NONE:
753+ microblaze_reloc = R_MICROBLAZE_64_NONE;
754+ break;
755+ case BFD_RELOC_32:
756+ microblaze_reloc = R_MICROBLAZE_32;
757+ break;
758+ /* RVA is treated the same as 32 */
759+ case BFD_RELOC_RVA:
760+ microblaze_reloc = R_MICROBLAZE_32;
761+ break;
762+ case BFD_RELOC_32_PCREL:
763+ microblaze_reloc = R_MICROBLAZE_32_PCREL;
764+ break;
765+ case BFD_RELOC_64_PCREL:
766+ microblaze_reloc = R_MICROBLAZE_64_PCREL;
767+ break;
768+ case BFD_RELOC_MICROBLAZE_32_LO_PCREL:
769+ microblaze_reloc = R_MICROBLAZE_32_PCREL_LO;
770+ break;
771+ case BFD_RELOC_64:
772+ microblaze_reloc = R_MICROBLAZE_64;
773+ break;
774+ case BFD_RELOC_MICROBLAZE_32_LO:
775+ microblaze_reloc = R_MICROBLAZE_32_LO;
776+ break;
777+ case BFD_RELOC_MICROBLAZE_32_ROSDA:
778+ microblaze_reloc = R_MICROBLAZE_SRO32;
779+ break;
780+ case BFD_RELOC_MICROBLAZE_32_RWSDA:
781+ microblaze_reloc = R_MICROBLAZE_SRW32;
782+ break;
783+ case BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM:
784+ microblaze_reloc = R_MICROBLAZE_32_SYM_OP_SYM;
785+ break;
786+ case BFD_RELOC_VTABLE_INHERIT:
787+ microblaze_reloc = R_MICROBLAZE_GNU_VTINHERIT;
788+ break;
789+ case BFD_RELOC_VTABLE_ENTRY:
790+ microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
791+ break;
792+ case BFD_RELOC_MICROBLAZE_64_GOTPC:
793+ microblaze_reloc = R_MICROBLAZE_GOTPC_64;
794+ break;
795+ case BFD_RELOC_MICROBLAZE_64_GOT:
796+ microblaze_reloc = R_MICROBLAZE_GOT_64;
797+ break;
798+ case BFD_RELOC_MICROBLAZE_64_PLT:
799+ microblaze_reloc = R_MICROBLAZE_PLT_64;
800+ break;
801+ case BFD_RELOC_MICROBLAZE_64_GOTOFF:
802+ microblaze_reloc = R_MICROBLAZE_GOTOFF_64;
803+ break;
804+ case BFD_RELOC_MICROBLAZE_32_GOTOFF:
805+ microblaze_reloc = R_MICROBLAZE_GOTOFF_32;
806+ break;
807+ case BFD_RELOC_MICROBLAZE_64_TLSGD:
808+ microblaze_reloc = R_MICROBLAZE_TLSGD;
809+ break;
810+ case BFD_RELOC_MICROBLAZE_64_TLSLD:
811+ microblaze_reloc = R_MICROBLAZE_TLSLD;
812+ break;
813+ case BFD_RELOC_MICROBLAZE_32_TLSDTPREL:
814+ microblaze_reloc = R_MICROBLAZE_TLSDTPREL32;
815+ break;
816+ case BFD_RELOC_MICROBLAZE_64_TLSDTPREL:
817+ microblaze_reloc = R_MICROBLAZE_TLSDTPREL64;
818+ break;
819+ case BFD_RELOC_MICROBLAZE_32_TLSDTPMOD:
820+ microblaze_reloc = R_MICROBLAZE_TLSDTPMOD32;
821+ break;
822+ case BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL:
823+ microblaze_reloc = R_MICROBLAZE_TLSGOTTPREL32;
824+ break;
825+ case BFD_RELOC_MICROBLAZE_64_TLSTPREL:
826+ microblaze_reloc = R_MICROBLAZE_TLSTPREL32;
827+ break;
828+ case BFD_RELOC_MICROBLAZE_COPY:
829+ microblaze_reloc = R_MICROBLAZE_COPY;
830+ break;
831+ default:
832+ return (reloc_howto_type *) NULL;
833+ }
834+
835+ if (!microblaze_elf_howto_table [R_MICROBLAZE_32])
836+ /* Initialize howto table if needed. */
837+ microblaze_elf_howto_init ();
838+
839+ return microblaze_elf_howto_table [(int) microblaze_reloc];
840+};
841+
842+static reloc_howto_type *
843+microblaze_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
844+ const char *r_name)
845+{
846+ unsigned int i;
847+
848+ for (i = 0; i < NUM_ELEM (microblaze_elf_howto_raw); i++)
849+ if (microblaze_elf_howto_raw[i].name != NULL
850+ && strcasecmp (microblaze_elf_howto_raw[i].name, r_name) == 0)
851+ return &microblaze_elf_howto_raw[i];
852+
853+ return NULL;
854+}
855+
856+/* Set the howto pointer for a RCE ELF reloc. */
857+
858+static void
859+microblaze_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
860+ arelent * cache_ptr,
861+ Elf_Internal_Rela * dst)
862+{
863+ unsigned int r_type;
864+
865+ if (!microblaze_elf_howto_table [R_MICROBLAZE_32])
866+ /* Initialize howto table if needed. */
867+ microblaze_elf_howto_init ();
868+
869+ r_type = ELF64_R_TYPE (dst->r_info);
870+ if (r_type >= R_MICROBLAZE_max)
871+ {
872+ (*_bfd_error_handler) (_("%B: unrecognised MicroBlaze reloc number: %d"),
873+ abfd, r_type);
874+ bfd_set_error (bfd_error_bad_value);
875+ r_type = R_MICROBLAZE_NONE;
876+ }
877+
878+ cache_ptr->howto = microblaze_elf_howto_table [r_type];
879+}
880+
881+/* Microblaze ELF local labels start with 'L.' or '$L', not '.L'. */
882+
883+static bfd_boolean
884+microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
885+{
886+ if (name[0] == 'L' && name[1] == '.')
887+ return TRUE;
888+
889+ if (name[0] == '$' && name[1] == 'L')
890+ return TRUE;
891+
892+ /* With gcc, the labels go back to starting with '.', so we accept
893+ the generic ELF local label syntax as well. */
894+ return _bfd_elf_is_local_label_name (abfd, name);
895+}
896+
897+/* The microblaze linker (like many others) needs to keep track of
898+ the number of relocs that it decides to copy as dynamic relocs in
899+ check_relocs for each symbol. This is so that it can later discard
900+ them if they are found to be unnecessary. We store the information
901+ in a field extending the regular ELF linker hash table. */
902+
903+struct elf64_mb_dyn_relocs
904+{
905+ struct elf64_mb_dyn_relocs *next;
906+
907+ /* The input section of the reloc. */
908+ asection *sec;
909+
910+ /* Total number of relocs copied for the input section. */
911+ bfd_size_type count;
912+
913+ /* Number of pc-relative relocs copied for the input section. */
914+ bfd_size_type pc_count;
915+};
916+
917+/* ELF linker hash entry. */
918+
919+struct elf64_mb_link_hash_entry
920+{
921+ struct elf_link_hash_entry elf;
922+
923+ /* Track dynamic relocs copied for this symbol. */
924+ struct elf64_mb_dyn_relocs *dyn_relocs;
925+
926+ /* TLS Reference Types for the symbol; Updated by check_relocs */
927+#define TLS_GD 1 /* GD reloc. */
928+#define TLS_LD 2 /* LD reloc. */
929+#define TLS_TPREL 4 /* TPREL reloc, => IE. */
930+#define TLS_DTPREL 8 /* DTPREL reloc, => LD. */
931+#define TLS_TLS 16 /* Any TLS reloc. */
932+ unsigned char tls_mask;
933+
934+};
935+
936+#define IS_TLS_GD(x) (x == (TLS_TLS | TLS_GD))
937+#define IS_TLS_LD(x) (x == (TLS_TLS | TLS_LD))
938+#define IS_TLS_DTPREL(x) (x == (TLS_TLS | TLS_DTPREL))
939+#define IS_TLS_NONE(x) (x == 0)
940+
941+#define elf64_mb_hash_entry(ent) ((struct elf64_mb_link_hash_entry *)(ent))
942+
943+/* ELF linker hash table. */
944+
945+struct elf64_mb_link_hash_table
946+{
947+ struct elf_link_hash_table elf;
948+
949+ /* Short-cuts to get to dynamic linker sections. */
950+ asection *sgot;
951+ asection *sgotplt;
952+ asection *srelgot;
953+ asection *splt;
954+ asection *srelplt;
955+ asection *sdynbss;
956+ asection *srelbss;
957+
958+ /* Small local sym to section mapping cache. */
959+ struct sym_cache sym_sec;
960+
961+ /* TLS Local Dynamic GOT Entry */
962+ union {
963+ bfd_signed_vma refcount;
964+ bfd_vma offset;
965+ } tlsld_got;
966+};
967+
968+/* Nonzero if this section has TLS related relocations. */
969+#define has_tls_reloc sec_flg0
970+
971+/* Get the ELF linker hash table from a link_info structure. */
972+
973+#define elf64_mb_hash_table(p) \
974+ (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
975+ == MICROBLAZE_ELF_DATA ? ((struct elf64_mb_link_hash_table *) ((p)->hash)) : NULL)
976+
977+/* Create an entry in a microblaze ELF linker hash table. */
978+
979+static struct bfd_hash_entry *
980+link_hash_newfunc (struct bfd_hash_entry *entry,
981+ struct bfd_hash_table *table,
982+ const char *string)
983+{
984+ /* Allocate the structure if it has not already been allocated by a
985+ subclass. */
986+ if (entry == NULL)
987+ {
988+ entry = bfd_hash_allocate (table,
989+ sizeof (struct elf64_mb_link_hash_entry));
990+ if (entry == NULL)
991+ return entry;
992+ }
993+
994+ /* Call the allocation method of the superclass. */
995+ entry = _bfd_elf_link_hash_newfunc (entry, table, string);
996+ if (entry != NULL)
997+ {
998+ struct elf64_mb_link_hash_entry *eh;
999+
1000+ eh = (struct elf64_mb_link_hash_entry *) entry;
1001+ eh->dyn_relocs = NULL;
1002+ eh->tls_mask = 0;
1003+ }
1004+
1005+ return entry;
1006+}
1007+
1008+/* Create a mb ELF linker hash table. */
1009+
1010+static struct bfd_link_hash_table *
1011+microblaze_elf_link_hash_table_create (bfd *abfd)
1012+{
1013+ struct elf64_mb_link_hash_table *ret;
1014+ bfd_size_type amt = sizeof (struct elf64_mb_link_hash_table);
1015+
1016+ ret = (struct elf64_mb_link_hash_table *) bfd_zmalloc (amt);
1017+ if (ret == NULL)
1018+ return NULL;
1019+
1020+ if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
1021+ sizeof (struct elf64_mb_link_hash_entry),
1022+ MICROBLAZE_ELF_DATA))
1023+ {
1024+ free (ret);
1025+ return NULL;
1026+ }
1027+
1028+ return &ret->elf.root;
1029+}
1030+
1031+/* Set the values of the small data pointers. */
1032+
1033+static void
1034+microblaze_elf_final_sdp (struct bfd_link_info *info)
1035+{
1036+ struct bfd_link_hash_entry *h;
1037+
1038+ h = bfd_link_hash_lookup (info->hash, RO_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE);
1039+ if (h != (struct bfd_link_hash_entry *) NULL
1040+ && h->type == bfd_link_hash_defined)
1041+ ro_small_data_pointer = (h->u.def.value
1042+ + h->u.def.section->output_section->vma
1043+ + h->u.def.section->output_offset);
1044+
1045+ h = bfd_link_hash_lookup (info->hash, RW_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE);
1046+ if (h != (struct bfd_link_hash_entry *) NULL
1047+ && h->type == bfd_link_hash_defined)
1048+ rw_small_data_pointer = (h->u.def.value
1049+ + h->u.def.section->output_section->vma
1050+ + h->u.def.section->output_offset);
1051+}
1052+
1053+static bfd_vma
1054+dtprel_base (struct bfd_link_info *info)
1055+{
1056+ /* If tls_sec is NULL, we should have signalled an error already. */
1057+ if (elf_hash_table (info)->tls_sec == NULL)
1058+ return 0;
1059+ return elf_hash_table (info)->tls_sec->vma;
1060+}
1061+
1062+/* The size of the thread control block. */
1063+#define TCB_SIZE 8
1064+
1065+/* Output a simple dynamic relocation into SRELOC. */
1066+
1067+static void
1068+microblaze_elf_output_dynamic_relocation (bfd *output_bfd,
1069+ asection *sreloc,
1070+ unsigned long reloc_index,
1071+ unsigned long indx,
1072+ int r_type,
1073+ bfd_vma offset,
1074+ bfd_vma addend)
1075+{
1076+
1077+ Elf_Internal_Rela rel;
1078+
1079+ rel.r_info = ELF64_R_INFO (indx, r_type);
1080+ rel.r_offset = offset;
1081+ rel.r_addend = addend;
1082+
1083+ bfd_elf64_swap_reloca_out (output_bfd, &rel,
1084+ (sreloc->contents + reloc_index * sizeof (Elf64_External_Rela)));
1085+}
1086+
1087+/* This code is taken from elf64-m32r.c
1088+ There is some attempt to make this function usable for many architectures,
1089+ both USE_REL and USE_RELA ['twould be nice if such a critter existed],
1090+ if only to serve as a learning tool.
1091+
1092+ The RELOCATE_SECTION function is called by the new ELF backend linker
1093+ to handle the relocations for a section.
1094+
1095+ The relocs are always passed as Rela structures; if the section
1096+ actually uses Rel structures, the r_addend field will always be
1097+ zero.
1098+
1099+ This function is responsible for adjust the section contents as
1100+ necessary, and (if using Rela relocs and generating a
1101+ relocatable output file) adjusting the reloc addend as
1102+ necessary.
1103+
1104+ This function does not have to worry about setting the reloc
1105+ address or the reloc symbol index.
1106+
1107+ LOCAL_SYMS is a pointer to the swapped in local symbols.
1108+
1109+ LOCAL_SECTIONS is an array giving the section in the input file
1110+ corresponding to the st_shndx field of each local symbol.
1111+
1112+ The global hash table entry for the global symbols can be found
1113+ via elf_sym_hashes (input_bfd).
1114+
1115+ When generating relocatable output, this function must handle
1116+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is
1117+ going to be the section symbol corresponding to the output
1118+ section, which means that the addend must be adjusted
1119+ accordingly. */
1120+
1121+static bfd_boolean
1122+microblaze_elf_relocate_section (bfd *output_bfd,
1123+ struct bfd_link_info *info,
1124+ bfd *input_bfd,
1125+ asection *input_section,
1126+ bfd_byte *contents,
1127+ Elf_Internal_Rela *relocs,
1128+ Elf_Internal_Sym *local_syms,
1129+ asection **local_sections)
1130+{
1131+ struct elf64_mb_link_hash_table *htab;
1132+ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1133+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
1134+ Elf_Internal_Rela *rel, *relend;
1135+ int endian = (bfd_little_endian (output_bfd)) ? 0 : 2;
1136+ /* Assume success. */
1137+ bfd_boolean ret = TRUE;
1138+ asection *sreloc;
1139+ bfd_vma *local_got_offsets;
1140+ unsigned int tls_type;
1141+
1142+ if (!microblaze_elf_howto_table[R_MICROBLAZE_max-1])
1143+ microblaze_elf_howto_init ();
1144+
1145+ htab = elf64_mb_hash_table (info);
1146+ if (htab == NULL)
1147+ return FALSE;
1148+
1149+ local_got_offsets = elf_local_got_offsets (input_bfd);
1150+
1151+ sreloc = elf_section_data (input_section)->sreloc;
1152+
1153+ rel = relocs;
1154+ relend = relocs + input_section->reloc_count;
1155+ for (; rel < relend; rel++)
1156+ {
1157+ int r_type;
1158+ reloc_howto_type *howto;
1159+ unsigned long r_symndx;
1160+ bfd_vma addend = rel->r_addend;
1161+ bfd_vma offset = rel->r_offset;
1162+ struct elf_link_hash_entry *h;
1163+ Elf_Internal_Sym *sym;
1164+ asection *sec;
1165+ const char *sym_name;
1166+ bfd_reloc_status_type r = bfd_reloc_ok;
1167+ const char *errmsg = NULL;
1168+ bfd_boolean unresolved_reloc = FALSE;
1169+
1170+ h = NULL;
1171+ r_type = ELF64_R_TYPE (rel->r_info);
1172+ tls_type = 0;
1173+
1174+ if (r_type < 0 || r_type >= (int) R_MICROBLAZE_max)
1175+ {
1176+ (*_bfd_error_handler) (_("%s: unknown relocation type %d"),
1177+ bfd_get_filename (input_bfd), (int) r_type);
1178+ bfd_set_error (bfd_error_bad_value);
1179+ ret = FALSE;
1180+ continue;
1181+ }
1182+
1183+ howto = microblaze_elf_howto_table[r_type];
1184+ r_symndx = ELF64_R_SYM (rel->r_info);
1185+
1186+ if (bfd_link_relocatable (info))
1187+ {
1188+ /* This is a relocatable link. We don't have to change
1189+ anything, unless the reloc is against a section symbol,
1190+ in which case we have to adjust according to where the
1191+ section symbol winds up in the output section. */
1192+ sec = NULL;
1193+ if (r_symndx >= symtab_hdr->sh_info)
1194+ /* External symbol. */
1195+ continue;
1196+
1197+ /* Local symbol. */
1198+ sym = local_syms + r_symndx;
1199+ sym_name = "<local symbol>";
1200+ /* STT_SECTION: symbol is associated with a section. */
1201+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
1202+ /* Symbol isn't associated with a section. Nothing to do. */
1203+ continue;
1204+
1205+ sec = local_sections[r_symndx];
1206+ addend += sec->output_offset + sym->st_value;
1207+#ifndef USE_REL
1208+ /* This can't be done for USE_REL because it doesn't mean anything
1209+ and elf_link_input_bfd asserts this stays zero. */
1210+ /* rel->r_addend = addend; */
1211+#endif
1212+
1213+#ifndef USE_REL
1214+ /* Addends are stored with relocs. We're done. */
1215+ continue;
1216+#else /* USE_REL */
1217+ /* If partial_inplace, we need to store any additional addend
1218+ back in the section. */
1219+ if (!howto->partial_inplace)
1220+ continue;
1221+ /* ??? Here is a nice place to call a special_function like handler. */
1222+ r = _bfd_relocate_contents (howto, input_bfd, addend,
1223+ contents + offset);
1224+#endif /* USE_REL */
1225+ }
1226+ else
1227+ {
1228+ bfd_vma relocation;
1229+
1230+ /* This is a final link. */
1231+ sym = NULL;
1232+ sec = NULL;
1233+ unresolved_reloc = FALSE;
1234+
1235+ if (r_symndx < symtab_hdr->sh_info)
1236+ {
1237+ /* Local symbol. */
1238+ sym = local_syms + r_symndx;
1239+ sec = local_sections[r_symndx];
1240+ if (sec == 0)
1241+ continue;
1242+ sym_name = "<local symbol>";
1243+ relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
1244+ /* r_addend may have changed if the reference section was
1245+ a merge section. */
1246+ addend = rel->r_addend;
1247+ }
1248+ else
1249+ {
1250+ /* External symbol. */
1251+ bfd_boolean warned ATTRIBUTE_UNUSED;
1252+ bfd_boolean ignored ATTRIBUTE_UNUSED;
1253+
1254+ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
1255+ r_symndx, symtab_hdr, sym_hashes,
1256+ h, sec, relocation,
1257+ unresolved_reloc, warned, ignored);
1258+ sym_name = h->root.root.string;
1259+ }
1260+
1261+ /* Sanity check the address. */
1262+ if (offset > bfd_get_section_limit (input_bfd, input_section))
1263+ {
1264+ r = bfd_reloc_outofrange;
1265+ goto check_reloc;
1266+ }
1267+
1268+ switch ((int) r_type)
1269+ {
1270+ case (int) R_MICROBLAZE_SRO32 :
1271+ {
1272+ const char *name;
1273+
1274+ /* Only relocate if the symbol is defined. */
1275+ if (sec)
1276+ {
1277+ name = bfd_get_section_name (sec->owner, sec);
1278+
1279+ if (strcmp (name, ".sdata2") == 0
1280+ || strcmp (name, ".sbss2") == 0)
1281+ {
1282+ if (ro_small_data_pointer == 0)
1283+ microblaze_elf_final_sdp (info);
1284+ if (ro_small_data_pointer == 0)
1285+ {
1286+ ret = FALSE;
1287+ r = bfd_reloc_undefined;
1288+ goto check_reloc;
1289+ }
1290+
1291+ /* At this point `relocation' contains the object's
1292+ address. */
1293+ relocation -= ro_small_data_pointer;
1294+ /* Now it contains the offset from _SDA2_BASE_. */
1295+ r = _bfd_final_link_relocate (howto, input_bfd,
1296+ input_section,
1297+ contents, offset,
1298+ relocation, addend);
1299+ }
1300+ else
1301+ {
1302+ (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
1303+ bfd_get_filename (input_bfd),
1304+ sym_name,
1305+ microblaze_elf_howto_table[(int) r_type]->name,
1306+ bfd_get_section_name (sec->owner, sec));
1307+ /*bfd_set_error (bfd_error_bad_value); ??? why? */
1308+ ret = FALSE;
1309+ continue;
1310+ }
1311+ }
1312+ }
1313+ break;
1314+
1315+ case (int) R_MICROBLAZE_SRW32 :
1316+ {
1317+ const char *name;
1318+
1319+ /* Only relocate if the symbol is defined. */
1320+ if (sec)
1321+ {
1322+ name = bfd_get_section_name (sec->owner, sec);
1323+
1324+ if (strcmp (name, ".sdata") == 0
1325+ || strcmp (name, ".sbss") == 0)
1326+ {
1327+ if (rw_small_data_pointer == 0)
1328+ microblaze_elf_final_sdp (info);
1329+ if (rw_small_data_pointer == 0)
1330+ {
1331+ ret = FALSE;
1332+ r = bfd_reloc_undefined;
1333+ goto check_reloc;
1334+ }
1335+
1336+ /* At this point `relocation' contains the object's
1337+ address. */
1338+ relocation -= rw_small_data_pointer;
1339+ /* Now it contains the offset from _SDA_BASE_. */
1340+ r = _bfd_final_link_relocate (howto, input_bfd,
1341+ input_section,
1342+ contents, offset,
1343+ relocation, addend);
1344+ }
1345+ else
1346+ {
1347+ (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
1348+ bfd_get_filename (input_bfd),
1349+ sym_name,
1350+ microblaze_elf_howto_table[(int) r_type]->name,
1351+ bfd_get_section_name (sec->owner, sec));
1352+ /*bfd_set_error (bfd_error_bad_value); ??? why? */
1353+ ret = FALSE;
1354+ continue;
1355+ }
1356+ }
1357+ }
1358+ break;
1359+
1360+ case (int) R_MICROBLAZE_32_SYM_OP_SYM:
1361+ break; /* Do nothing. */
1362+
1363+ case (int) R_MICROBLAZE_GOTPC_64:
1364+ relocation = htab->sgotplt->output_section->vma
1365+ + htab->sgotplt->output_offset;
1366+ relocation -= (input_section->output_section->vma
1367+ + input_section->output_offset
1368+ + offset + INST_WORD_SIZE);
1369+ relocation += addend;
1370+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1371+ contents + offset + endian);
1372+ bfd_put_16 (input_bfd, relocation & 0xffff,
1373+ contents + offset + endian + INST_WORD_SIZE);
1374+ break;
1375+
1376+ case (int) R_MICROBLAZE_PLT_64:
1377+ {
1378+ bfd_vma immediate;
1379+ if (htab->splt != NULL && h != NULL
1380+ && h->plt.offset != (bfd_vma) -1)
1381+ {
1382+ relocation = (htab->splt->output_section->vma
1383+ + htab->splt->output_offset
1384+ + h->plt.offset);
1385+ unresolved_reloc = FALSE;
1386+ immediate = relocation - (input_section->output_section->vma
1387+ + input_section->output_offset
1388+ + offset + INST_WORD_SIZE);
1389+ bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff,
1390+ contents + offset + endian);
1391+ bfd_put_16 (input_bfd, immediate & 0xffff,
1392+ contents + offset + endian + INST_WORD_SIZE);
1393+ }
1394+ else
1395+ {
1396+ relocation -= (input_section->output_section->vma
1397+ + input_section->output_offset
1398+ + offset + INST_WORD_SIZE);
1399+ immediate = relocation;
1400+ bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff,
1401+ contents + offset + endian);
1402+ bfd_put_16 (input_bfd, immediate & 0xffff,
1403+ contents + offset + endian + INST_WORD_SIZE);
1404+ }
1405+ break;
1406+ }
1407+
1408+ case (int) R_MICROBLAZE_TLSGD:
1409+ tls_type = (TLS_TLS | TLS_GD);
1410+ goto dogot;
1411+ case (int) R_MICROBLAZE_TLSLD:
1412+ tls_type = (TLS_TLS | TLS_LD);
1413+ dogot:
1414+ case (int) R_MICROBLAZE_GOT_64:
1415+ {
1416+ bfd_vma *offp;
1417+ bfd_vma off, off2;
1418+ unsigned long indx;
1419+ bfd_vma static_value;
1420+
1421+ bfd_boolean need_relocs = FALSE;
1422+ if (htab->sgot == NULL)
1423+ abort ();
1424+
1425+ indx = 0;
1426+ offp = NULL;
1427+
1428+ /* 1. Identify GOT Offset;
1429+ 2. Compute Static Values
1430+ 3. Process Module Id, Process Offset
1431+ 4. Fixup Relocation with GOT offset value. */
1432+
1433+ /* 1. Determine GOT Offset to use : TLS_LD, global, local */
1434+ if (IS_TLS_LD (tls_type))
1435+ offp = &htab->tlsld_got.offset;
1436+ else if (h != NULL)
1437+ {
1438+ if (htab->sgotplt != NULL && h->got.offset != (bfd_vma) -1)
1439+ offp = &h->got.offset;
1440+ else
1441+ abort ();
1442+ }
1443+ else
1444+ {
1445+ if (local_got_offsets == NULL)
1446+ abort ();
1447+ offp = &local_got_offsets[r_symndx];
1448+ }
1449+
1450+ if (!offp)
1451+ abort ();
1452+
1453+ off = (*offp) & ~1;
1454+ off2 = off;
1455+
1456+ if (IS_TLS_LD(tls_type) || IS_TLS_GD(tls_type))
1457+ off2 = off + 4;
1458+
1459+ /* Symbol index to use for relocs */
1460+ if (h != NULL)
1461+ {
1462+ bfd_boolean dyn =
1463+ elf_hash_table (info)->dynamic_sections_created;
1464+
1465+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
1466+ bfd_link_pic (info),
1467+ h)
1468+ && (!bfd_link_pic (info)
1469+ || !SYMBOL_REFERENCES_LOCAL (info, h)))
1470+ indx = h->dynindx;
1471+ }
1472+
1473+ /* Need to generate relocs ? */
1474+ if ((bfd_link_pic (info) || indx != 0)
1475+ && (h == NULL
1476+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
1477+ || h->root.type != bfd_link_hash_undefweak))
1478+ need_relocs = TRUE;
1479+
1480+ /* 2. Compute/Emit Static value of r-expression */
1481+ static_value = relocation + addend;
1482+
1483+ /* 3. Process module-id and offset */
1484+ if (! ((*offp) & 1) )
1485+ {
1486+ bfd_vma got_offset;
1487+
1488+ got_offset = (htab->sgot->output_section->vma
1489+ + htab->sgot->output_offset
1490+ + off);
1491+
1492+ /* Process module-id */
1493+ if (IS_TLS_LD(tls_type))
1494+ {
1495+ if (! bfd_link_pic (info))
1496+ {
1497+ bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
1498+ }
1499+ else
1500+ {
1501+ microblaze_elf_output_dynamic_relocation (output_bfd,
1502+ htab->srelgot, htab->srelgot->reloc_count++,
1503+ /* symindex= */ 0, R_MICROBLAZE_TLSDTPMOD32,
1504+ got_offset, 0);
1505+ }
1506+ }
1507+ else if (IS_TLS_GD(tls_type))
1508+ {
1509+ if (! need_relocs)
1510+ {
1511+ bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
1512+ }
1513+ else
1514+ {
1515+ microblaze_elf_output_dynamic_relocation (output_bfd,
1516+ htab->srelgot,
1517+ htab->srelgot->reloc_count++,
1518+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPMOD32,
1519+ got_offset, indx ? 0 : static_value);
1520+ }
1521+ }
1522+
1523+ /* Process Offset */
1524+ if (htab->srelgot == NULL)
1525+ abort ();
1526+
1527+ got_offset = (htab->sgot->output_section->vma
1528+ + htab->sgot->output_offset
1529+ + off2);
1530+ if (IS_TLS_LD(tls_type))
1531+ {
1532+ /* For LD, offset should be 0 */
1533+ *offp |= 1;
1534+ bfd_put_32 (output_bfd, 0, htab->sgot->contents + off2);
1535+ }
1536+ else if (IS_TLS_GD(tls_type))
1537+ {
1538+ *offp |= 1;
1539+ static_value -= dtprel_base(info);
1540+ if (need_relocs)
1541+ {
1542+ microblaze_elf_output_dynamic_relocation (output_bfd,
1543+ htab->srelgot, htab->srelgot->reloc_count++,
1544+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPREL32,
1545+ got_offset, indx ? 0 : static_value);
1546+ }
1547+ else
1548+ {
1549+ bfd_put_32 (output_bfd, static_value,
1550+ htab->sgot->contents + off2);
1551+ }
1552+ }
1553+ else
1554+ {
1555+ bfd_put_32 (output_bfd, static_value,
1556+ htab->sgot->contents + off2);
1557+
1558+ /* Relocs for dyn symbols generated by
1559+ finish_dynamic_symbols */
1560+ if (bfd_link_pic (info) && h == NULL)
1561+ {
1562+ *offp |= 1;
1563+ microblaze_elf_output_dynamic_relocation (output_bfd,
1564+ htab->srelgot, htab->srelgot->reloc_count++,
1565+ /* symindex= */ indx, R_MICROBLAZE_REL,
1566+ got_offset, static_value);
1567+ }
1568+ }
1569+ }
1570+
1571+ /* 4. Fixup Relocation with GOT offset value
1572+ Compute relative address of GOT entry for applying
1573+ the current relocation */
1574+ relocation = htab->sgot->output_section->vma
1575+ + htab->sgot->output_offset
1576+ + off
1577+ - htab->sgotplt->output_section->vma
1578+ - htab->sgotplt->output_offset;
1579+
1580+ /* Apply Current Relocation */
1581+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1582+ contents + offset + endian);
1583+ bfd_put_16 (input_bfd, relocation & 0xffff,
1584+ contents + offset + endian + INST_WORD_SIZE);
1585+
1586+ unresolved_reloc = FALSE;
1587+ break;
1588+ }
1589+
1590+ case (int) R_MICROBLAZE_GOTOFF_64:
1591+ {
1592+ bfd_vma immediate;
1593+ unsigned short lo, high;
1594+ relocation += addend;
1595+ relocation -= htab->sgotplt->output_section->vma
1596+ + htab->sgotplt->output_offset;
1597+ /* Write this value into correct location. */
1598+ immediate = relocation;
1599+ lo = immediate & 0x0000ffff;
1600+ high = (immediate >> 16) & 0x0000ffff;
1601+ bfd_put_16 (input_bfd, high, contents + offset + endian);
1602+ bfd_put_16 (input_bfd, lo, contents + offset + INST_WORD_SIZE + endian);
1603+ break;
1604+ }
1605+
1606+ case (int) R_MICROBLAZE_GOTOFF_32:
1607+ {
1608+ relocation += addend;
1609+ relocation -= htab->sgotplt->output_section->vma
1610+ + htab->sgotplt->output_offset;
1611+ /* Write this value into correct location. */
1612+ bfd_put_32 (input_bfd, relocation, contents + offset);
1613+ break;
1614+ }
1615+
1616+ case (int) R_MICROBLAZE_TLSDTPREL64:
1617+ relocation += addend;
1618+ relocation -= dtprel_base(info);
1619+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1620+ contents + offset + endian);
1621+ bfd_put_16 (input_bfd, relocation & 0xffff,
1622+ contents + offset + endian + INST_WORD_SIZE);
1623+ break;
1624+ case (int) R_MICROBLAZE_64_PCREL :
1625+ case (int) R_MICROBLAZE_64:
1626+ case (int) R_MICROBLAZE_32:
1627+ {
1628+ /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
1629+ from removed linkonce sections, or sections discarded by
1630+ a linker script. */
1631+ if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
1632+ {
1633+ relocation += addend;
1634+ if (r_type == R_MICROBLAZE_32)
1635+ bfd_put_32 (input_bfd, relocation, contents + offset);
1636+ else
1637+ {
1638+ if (r_type == R_MICROBLAZE_64_PCREL)
1639+ relocation -= (input_section->output_section->vma
1640+ + input_section->output_offset
1641+ + offset + INST_WORD_SIZE);
1642+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1643+ contents + offset + endian);
1644+ bfd_put_16 (input_bfd, relocation & 0xffff,
1645+ contents + offset + endian + INST_WORD_SIZE);
1646+ }
1647+ break;
1648+ }
1649+
1650+ if ((bfd_link_pic (info)
1651+ && (h == NULL
1652+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
1653+ || h->root.type != bfd_link_hash_undefweak)
1654+ && (!howto->pc_relative
1655+ || (h != NULL
1656+ && h->dynindx != -1
1657+ && (!info->symbolic
1658+ || !h->def_regular))))
1659+ || (!bfd_link_pic (info)
1660+ && h != NULL
1661+ && h->dynindx != -1
1662+ && !h->non_got_ref
1663+ && ((h->def_dynamic
1664+ && !h->def_regular)
1665+ || h->root.type == bfd_link_hash_undefweak
1666+ || h->root.type == bfd_link_hash_undefined)))
1667+ {
1668+ Elf_Internal_Rela outrel;
1669+ bfd_byte *loc;
1670+ bfd_boolean skip;
1671+
1672+ /* When generating a shared object, these relocations
1673+ are copied into the output file to be resolved at run
1674+ time. */
1675+
1676+ BFD_ASSERT (sreloc != NULL);
1677+
1678+ skip = FALSE;
1679+
1680+ outrel.r_offset =
1681+ _bfd_elf_section_offset (output_bfd, info, input_section,
1682+ rel->r_offset);
1683+ if (outrel.r_offset == (bfd_vma) -1)
1684+ skip = TRUE;
1685+ else if (outrel.r_offset == (bfd_vma) -2)
1686+ skip = TRUE;
1687+ outrel.r_offset += (input_section->output_section->vma
1688+ + input_section->output_offset);
1689+
1690+ if (skip)
1691+ memset (&outrel, 0, sizeof outrel);
1692+ /* h->dynindx may be -1 if the symbol was marked to
1693+ become local. */
1694+ else if (h != NULL
1695+ && ((! info->symbolic && h->dynindx != -1)
1696+ || !h->def_regular))
1697+ {
1698+ BFD_ASSERT (h->dynindx != -1);
1699+ outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
1700+ outrel.r_addend = addend;
1701+ }
1702+ else
1703+ {
1704+ if (r_type == R_MICROBLAZE_32)
1705+ {
1706+ outrel.r_info = ELF64_R_INFO (0, R_MICROBLAZE_REL);
1707+ outrel.r_addend = relocation + addend;
1708+ }
1709+ else
1710+ {
1711+ BFD_FAIL ();
1712+ (*_bfd_error_handler)
1713+ (_("%B: probably compiled without -fPIC?"),
1714+ input_bfd);
1715+ bfd_set_error (bfd_error_bad_value);
1716+ return FALSE;
1717+ }
1718+ }
1719+
1720+ loc = sreloc->contents;
1721+ loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
1722+ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
1723+ break;
1724+ }
1725+ else
1726+ {
1727+ relocation += addend;
1728+ if (r_type == R_MICROBLAZE_32)
1729+ bfd_put_32 (input_bfd, relocation, contents + offset);
1730+ else
1731+ {
1732+ if (r_type == R_MICROBLAZE_64_PCREL)
1733+ relocation -= (input_section->output_section->vma
1734+ + input_section->output_offset
1735+ + offset + INST_WORD_SIZE);
1736+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1737+ contents + offset + endian);
1738+ bfd_put_16 (input_bfd, relocation & 0xffff,
1739+ contents + offset + endian + INST_WORD_SIZE);
1740+ }
1741+ break;
1742+ }
1743+ }
1744+
1745+ default :
1746+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
1747+ contents, offset,
1748+ relocation, addend);
1749+ break;
1750+ }
1751+ }
1752+
1753+ check_reloc:
1754+
1755+ if (r != bfd_reloc_ok)
1756+ {
1757+ /* FIXME: This should be generic enough to go in a utility. */
1758+ const char *name;
1759+
1760+ if (h != NULL)
1761+ name = h->root.root.string;
1762+ else
1763+ {
1764+ name = (bfd_elf_string_from_elf_section
1765+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
1766+ if (name == NULL || *name == '\0')
1767+ name = bfd_section_name (input_bfd, sec);
1768+ }
1769+
1770+ if (errmsg != NULL)
1771+ goto common_error;
1772+
1773+ switch (r)
1774+ {
1775+ case bfd_reloc_overflow:
1776+ (*info->callbacks->reloc_overflow)
1777+ (info, (h ? &h->root : NULL), name, howto->name,
1778+ (bfd_vma) 0, input_bfd, input_section, offset);
1779+ break;
1780+
1781+ case bfd_reloc_undefined:
1782+ (*info->callbacks->undefined_symbol)
1783+ (info, name, input_bfd, input_section, offset, TRUE);
1784+ break;
1785+
1786+ case bfd_reloc_outofrange:
1787+ errmsg = _("internal error: out of range error");
1788+ goto common_error;
1789+
1790+ case bfd_reloc_notsupported:
1791+ errmsg = _("internal error: unsupported relocation error");
1792+ goto common_error;
1793+
1794+ case bfd_reloc_dangerous:
1795+ errmsg = _("internal error: dangerous error");
1796+ goto common_error;
1797+
1798+ default:
1799+ errmsg = _("internal error: unknown error");
1800+ /* Fall through. */
1801+ common_error:
1802+ (*info->callbacks->warning) (info, errmsg, name, input_bfd,
1803+ input_section, offset);
1804+ break;
1805+ }
1806+ }
1807+ }
1808+
1809+ return ret;
1810+}
1811+
1812+/* Merge backend specific data from an object file to the output
1813+ object file when linking.
1814+
1815+ Note: We only use this hook to catch endian mismatches. */
1816+static bfd_boolean
1817+microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
1818+{
1819+ /* Check if we have the same endianess. */
1820+ if (! _bfd_generic_verify_endian_match (ibfd, obfd))
1821+ return FALSE;
1822+
1823+ return TRUE;
1824+}
1825+
1826+
1827+/* Calculate fixup value for reference. */
1828+
1829+static int
1830+calc_fixup (bfd_vma start, bfd_vma size, asection *sec)
1831+{
1832+ bfd_vma end = start + size;
1833+ int i, fixup = 0;
1834+
1835+ if (sec == NULL || sec->relax == NULL)
1836+ return 0;
1837+
1838+ /* Look for addr in relax table, total fixup value. */
1839+ for (i = 0; i < sec->relax_count; i++)
1840+ {
1841+ if (end <= sec->relax[i].addr)
1842+ break;
1843+ if ((end != start) && (start > sec->relax[i].addr))
1844+ continue;
1845+ fixup += sec->relax[i].size;
1846+ }
1847+ return fixup;
1848+}
1849+
1850+/* Read-modify-write into the bfd, an immediate value into appropriate fields of
1851+ a 32-bit instruction. */
1852+static void
1853+microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
1854+{
1855+ unsigned long instr = bfd_get_32 (abfd, bfd_addr);
1856+ instr &= ~0x0000ffff;
1857+ instr |= (val & 0x0000ffff);
1858+ bfd_put_32 (abfd, instr, bfd_addr);
1859+}
1860+
1861+/* Read-modify-write into the bfd, an immediate value into appropriate fields of
1862+ two consecutive 32-bit instructions. */
1863+static void
1864+microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
1865+{
1866+ unsigned long instr_hi;
1867+ unsigned long instr_lo;
1868+
1869+ instr_hi = bfd_get_32 (abfd, bfd_addr);
1870+ instr_hi &= ~0x0000ffff;
1871+ instr_hi |= ((val >> 16) & 0x0000ffff);
1872+ bfd_put_32 (abfd, instr_hi, bfd_addr);
1873+
1874+ instr_lo = bfd_get_32 (abfd, bfd_addr + INST_WORD_SIZE);
1875+ instr_lo &= ~0x0000ffff;
1876+ instr_lo |= (val & 0x0000ffff);
1877+ bfd_put_32 (abfd, instr_lo, bfd_addr + INST_WORD_SIZE);
1878+}
1879+
1880+static bfd_boolean
1881+microblaze_elf_relax_section (bfd *abfd,
1882+ asection *sec,
1883+ struct bfd_link_info *link_info,
1884+ bfd_boolean *again)
1885+{
1886+ Elf_Internal_Shdr *symtab_hdr;
1887+ Elf_Internal_Rela *internal_relocs;
1888+ Elf_Internal_Rela *free_relocs = NULL;
1889+ Elf_Internal_Rela *irel, *irelend;
1890+ bfd_byte *contents = NULL;
1891+ bfd_byte *free_contents = NULL;
1892+ int rel_count;
1893+ unsigned int shndx;
1894+ int i, sym_index;
1895+ asection *o;
1896+ struct elf_link_hash_entry *sym_hash;
1897+ Elf_Internal_Sym *isymbuf, *isymend;
1898+ Elf_Internal_Sym *isym;
1899+ int symcount;
1900+ int offset;
1901+ bfd_vma src, dest;
1902+
1903+ /* We only do this once per section. We may be able to delete some code
1904+ by running multiple passes, but it is not worth it. */
1905+ *again = FALSE;
1906+
1907+ /* Only do this for a text section. */
1908+ if (bfd_link_relocatable (link_info)
1909+ || (sec->flags & SEC_RELOC) == 0
1910+ || (sec->reloc_count == 0)
1911+ || (sec->flags & SEC_CODE) == 0)
1912+ return TRUE;
1913+
1914+ BFD_ASSERT ((sec->size > 0) || (sec->rawsize > 0));
1915+
1916+ /* If this is the first time we have been called for this section,
1917+ initialize the cooked size. */
1918+ if (sec->size == 0)
1919+ sec->size = sec->rawsize;
1920+
1921+ /* Get symbols for this section. */
1922+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1923+ isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
1924+ symcount = symtab_hdr->sh_size / sizeof (Elf64_External_Sym);
1925+ if (isymbuf == NULL)
1926+ isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr, symcount,
1927+ 0, NULL, NULL, NULL);
1928+ BFD_ASSERT (isymbuf != NULL);
1929+
1930+ internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, link_info->keep_memory);
1931+ if (internal_relocs == NULL)
1932+ goto error_return;
1933+ if (! link_info->keep_memory)
1934+ free_relocs = internal_relocs;
1935+
1936+ sec->relax = (struct relax_table *) bfd_malloc ((sec->reloc_count + 1)
1937+ * sizeof (struct relax_table));
1938+ if (sec->relax == NULL)
1939+ goto error_return;
1940+ sec->relax_count = 0;
1941+
1942+ irelend = internal_relocs + sec->reloc_count;
1943+ rel_count = 0;
1944+ for (irel = internal_relocs; irel < irelend; irel++, rel_count++)
1945+ {
1946+ bfd_vma symval;
1947+ if ((ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64_PCREL)
1948+ && (ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64 ))
1949+ continue; /* Can't delete this reloc. */
1950+
1951+ /* Get the section contents. */
1952+ if (contents == NULL)
1953+ {
1954+ if (elf_section_data (sec)->this_hdr.contents != NULL)
1955+ contents = elf_section_data (sec)->this_hdr.contents;
1956+ else
1957+ {
1958+ contents = (bfd_byte *) bfd_malloc (sec->size);
1959+ if (contents == NULL)
1960+ goto error_return;
1961+ free_contents = contents;
1962+
1963+ if (!bfd_get_section_contents (abfd, sec, contents,
1964+ (file_ptr) 0, sec->size))
1965+ goto error_return;
1966+ elf_section_data (sec)->this_hdr.contents = contents;
1967+ }
1968+ }
1969+
1970+ /* Get the value of the symbol referred to by the reloc. */
1971+ if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
1972+ {
1973+ /* A local symbol. */
1974+ asection *sym_sec;
1975+
1976+ isym = isymbuf + ELF64_R_SYM (irel->r_info);
1977+ if (isym->st_shndx == SHN_UNDEF)
1978+ sym_sec = bfd_und_section_ptr;
1979+ else if (isym->st_shndx == SHN_ABS)
1980+ sym_sec = bfd_abs_section_ptr;
1981+ else if (isym->st_shndx == SHN_COMMON)
1982+ sym_sec = bfd_com_section_ptr;
1983+ else
1984+ sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
1985+
1986+ symval = _bfd_elf_rela_local_sym (abfd, isym, &sym_sec, irel);
1987+ }
1988+ else
1989+ {
1990+ unsigned long indx;
1991+ struct elf_link_hash_entry *h;
1992+
1993+ indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
1994+ h = elf_sym_hashes (abfd)[indx];
1995+ BFD_ASSERT (h != NULL);
1996+
1997+ if (h->root.type != bfd_link_hash_defined
1998+ && h->root.type != bfd_link_hash_defweak)
1999+ /* This appears to be a reference to an undefined
2000+ symbol. Just ignore it--it will be caught by the
2001+ regular reloc processing. */
2002+ continue;
2003+
2004+ symval = (h->root.u.def.value
2005+ + h->root.u.def.section->output_section->vma
2006+ + h->root.u.def.section->output_offset);
2007+ }
2008+
2009+ /* If this is a PC-relative reloc, subtract the instr offset from
2010+ the symbol value. */
2011+ if (ELF64_R_TYPE (irel->r_info) == (int) R_MICROBLAZE_64_PCREL)
2012+ {
2013+ symval = symval + irel->r_addend
2014+ - (irel->r_offset
2015+ + sec->output_section->vma
2016+ + sec->output_offset);
2017+ }
2018+ else
2019+ symval += irel->r_addend;
2020+
2021+ if ((symval & 0xffff8000) == 0)
2022+ {
2023+ /* We can delete this instruction. */
2024+ sec->relax[sec->relax_count].addr = irel->r_offset;
2025+ sec->relax[sec->relax_count].size = INST_WORD_SIZE;
2026+ sec->relax_count++;
2027+
2028+ /* Rewrite relocation type. */
2029+ switch ((enum elf_microblaze_reloc_type) ELF64_R_TYPE (irel->r_info))
2030+ {
2031+ case R_MICROBLAZE_64_PCREL:
2032+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
2033+ (int) R_MICROBLAZE_32_PCREL_LO);
2034+ break;
2035+ case R_MICROBLAZE_64:
2036+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
2037+ (int) R_MICROBLAZE_32_LO);
2038+ break;
2039+ default:
2040+ /* Cannot happen. */
2041+ BFD_ASSERT (FALSE);
2042+ }
2043+ }
2044+ } /* Loop through all relocations. */
2045+
2046+ /* Loop through the relocs again, and see if anything needs to change. */
2047+ if (sec->relax_count > 0)
2048+ {
2049+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
2050+ rel_count = 0;
2051+ sec->relax[sec->relax_count].addr = sec->size;
2052+
2053+ for (irel = internal_relocs; irel < irelend; irel++, rel_count++)
2054+ {
2055+ bfd_vma nraddr;
2056+
2057+ /* Get the new reloc address. */
2058+ nraddr = irel->r_offset - calc_fixup (irel->r_offset, 0, sec);
2059+ switch ((enum elf_microblaze_reloc_type) ELF64_R_TYPE (irel->r_info))
2060+ {
2061+ default:
2062+ break;
2063+ case R_MICROBLAZE_64_PCREL:
2064+ break;
2065+ case R_MICROBLAZE_64:
2066+ case R_MICROBLAZE_32_LO:
2067+ /* If this reloc is against a symbol defined in this
2068+ section, we must check the addend to see it will put the value in
2069+ range to be adjusted, and hence must be changed. */
2070+ if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
2071+ {
2072+ isym = isymbuf + ELF64_R_SYM (irel->r_info);
2073+ /* Only handle relocs against .text. */
2074+ if (isym->st_shndx == shndx
2075+ && ELF64_ST_TYPE (isym->st_info) == STT_SECTION)
2076+ irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
2077+ }
2078+ break;
2079+ case R_MICROBLAZE_NONE:
2080+ case R_MICROBLAZE_32_NONE:
2081+ {
2082+ /* This was a PC-relative instruction that was
2083+ completely resolved. */
2084+ int sfix, efix;
2085+ unsigned int val;
2086+ bfd_vma target_address;
2087+ target_address = irel->r_addend + irel->r_offset;
2088+ sfix = calc_fixup (irel->r_offset, 0, sec);
2089+ efix = calc_fixup (target_address, 0, sec);
2090+
2091+ /* Validate the in-band val. */
2092+ val = bfd_get_32 (abfd, contents + irel->r_offset);
2093+ if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
2094+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
2095+ }
2096+ irel->r_addend -= (efix - sfix);
2097+ /* Should use HOWTO. */
2098+ microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
2099+ irel->r_addend);
2100+ }
2101+ break;
2102+ case R_MICROBLAZE_64_NONE:
2103+ {
2104+ /* This was a PC-relative 64-bit instruction that was
2105+ completely resolved. */
2106+ int sfix, efix;
2107+ bfd_vma target_address;
2108+ target_address = irel->r_addend + irel->r_offset + INST_WORD_SIZE;
2109+ sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
2110+ efix = calc_fixup (target_address, 0, sec);
2111+ irel->r_addend -= (efix - sfix);
2112+ microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
2113+ + INST_WORD_SIZE, irel->r_addend);
2114+ }
2115+ break;
2116+ }
2117+ irel->r_offset = nraddr;
2118+ } /* Change all relocs in this section. */
2119+
2120+ /* Look through all other sections. */
2121+ for (o = abfd->sections; o != NULL; o = o->next)
2122+ {
2123+ Elf_Internal_Rela *irelocs;
2124+ Elf_Internal_Rela *irelscan, *irelscanend;
2125+ bfd_byte *ocontents;
2126+
2127+ if (o == sec
2128+ || (o->flags & SEC_RELOC) == 0
2129+ || o->reloc_count == 0)
2130+ continue;
2131+
2132+ /* We always cache the relocs. Perhaps, if info->keep_memory is
2133+ FALSE, we should free them, if we are permitted to. */
2134+
2135+ irelocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, TRUE);
2136+ if (irelocs == NULL)
2137+ goto error_return;
2138+
2139+ ocontents = NULL;
2140+ irelscanend = irelocs + o->reloc_count;
2141+ for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
2142+ {
2143+ if (1 && ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
2144+ {
2145+ unsigned int val;
2146+
2147+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2148+
2149+ /* hax: We only do the following fixup for debug location lists. */
2150+ if (strcmp(".debug_loc", o->name))
2151+ continue;
2152+
2153+ /* This was a PC-relative instruction that was completely resolved. */
2154+ if (ocontents == NULL)
2155+ {
2156+ if (elf_section_data (o)->this_hdr.contents != NULL)
2157+ ocontents = elf_section_data (o)->this_hdr.contents;
2158+ else
2159+ {
2160+ /* We always cache the section contents.
2161+ Perhaps, if info->keep_memory is FALSE, we
2162+ should free them, if we are permitted to. */
2163+
2164+ if (o->rawsize == 0)
2165+ o->rawsize = o->size;
2166+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2167+ if (ocontents == NULL)
2168+ goto error_return;
2169+ if (!bfd_get_section_contents (abfd, o, ocontents,
2170+ (file_ptr) 0,
2171+ o->rawsize))
2172+ goto error_return;
2173+ elf_section_data (o)->this_hdr.contents = ocontents;
2174+ }
2175+ }
2176+
2177+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
2178+ if (val != irelscan->r_addend) {
2179+ fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend);
2180+ }
2181+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
2182+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
2183+ irelscan->r_addend);
2184+ }
2185+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
2186+ {
2187+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2188+
2189+ /* Look at the reloc only if the value has been resolved. */
2190+ if (isym->st_shndx == shndx
2191+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2192+ {
2193+ if (ocontents == NULL)
2194+ {
2195+ if (elf_section_data (o)->this_hdr.contents != NULL)
2196+ ocontents = elf_section_data (o)->this_hdr.contents;
2197+ else
2198+ {
2199+ /* We always cache the section contents.
2200+ Perhaps, if info->keep_memory is FALSE, we
2201+ should free them, if we are permitted to. */
2202+ if (o->rawsize == 0)
2203+ o->rawsize = o->size;
2204+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2205+ if (ocontents == NULL)
2206+ goto error_return;
2207+ if (!bfd_get_section_contents (abfd, o, ocontents,
2208+ (file_ptr) 0,
2209+ o->rawsize))
2210+ goto error_return;
2211+ elf_section_data (o)->this_hdr.contents = ocontents;
2212+ }
2213+
2214+ }
2215+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
2216+ }
2217+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_SYM_OP_SYM)
2218+ {
2219+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2220+
2221+ /* Look at the reloc only if the value has been resolved. */
2222+ if (ocontents == NULL)
2223+ {
2224+ if (elf_section_data (o)->this_hdr.contents != NULL)
2225+ ocontents = elf_section_data (o)->this_hdr.contents;
2226+ else
2227+ {
2228+ /* We always cache the section contents.
2229+ Perhaps, if info->keep_memory is FALSE, we
2230+ should free them, if we are permitted to. */
2231+
2232+ if (o->rawsize == 0)
2233+ o->rawsize = o->size;
2234+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2235+ if (ocontents == NULL)
2236+ goto error_return;
2237+ if (!bfd_get_section_contents (abfd, o, ocontents,
2238+ (file_ptr) 0,
2239+ o->rawsize))
2240+ goto error_return;
2241+ elf_section_data (o)->this_hdr.contents = ocontents;
2242+ }
2243+ }
2244+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
2245+ + isym->st_value,
2246+ 0,
2247+ sec);
2248+ }
2249+ }
2250+ else if ((ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_PCREL_LO)
2251+ || (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_LO))
2252+ {
2253+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2254+
2255+ /* Look at the reloc only if the value has been resolved. */
2256+ if (isym->st_shndx == shndx
2257+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2258+ {
2259+ bfd_vma immediate;
2260+ bfd_vma target_address;
2261+
2262+ if (ocontents == NULL)
2263+ {
2264+ if (elf_section_data (o)->this_hdr.contents != NULL)
2265+ ocontents = elf_section_data (o)->this_hdr.contents;
2266+ else
2267+ {
2268+ /* We always cache the section contents.
2269+ Perhaps, if info->keep_memory is FALSE, we
2270+ should free them, if we are permitted to. */
2271+ if (o->rawsize == 0)
2272+ o->rawsize = o->size;
2273+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2274+ if (ocontents == NULL)
2275+ goto error_return;
2276+ if (!bfd_get_section_contents (abfd, o, ocontents,
2277+ (file_ptr) 0,
2278+ o->rawsize))
2279+ goto error_return;
2280+ elf_section_data (o)->this_hdr.contents = ocontents;
2281+ }
2282+ }
2283+
2284+ unsigned long instr = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
2285+ immediate = instr & 0x0000ffff;
2286+ target_address = immediate;
2287+ offset = calc_fixup (target_address, 0, sec);
2288+ immediate -= offset;
2289+ irelscan->r_addend -= offset;
2290+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
2291+ irelscan->r_addend);
2292+ }
2293+ }
2294+
2295+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64)
2296+ {
2297+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2298+
2299+ /* Look at the reloc only if the value has been resolved. */
2300+ if (isym->st_shndx == shndx
2301+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2302+ {
2303+ bfd_vma immediate;
2304+
2305+ if (ocontents == NULL)
2306+ {
2307+ if (elf_section_data (o)->this_hdr.contents != NULL)
2308+ ocontents = elf_section_data (o)->this_hdr.contents;
2309+ else
2310+ {
2311+ /* We always cache the section contents.
2312+ Perhaps, if info->keep_memory is FALSE, we
2313+ should free them, if we are permitted to. */
2314+
2315+ if (o->rawsize == 0)
2316+ o->rawsize = o->size;
2317+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2318+ if (ocontents == NULL)
2319+ goto error_return;
2320+ if (!bfd_get_section_contents (abfd, o, ocontents,
2321+ (file_ptr) 0,
2322+ o->rawsize))
2323+ goto error_return;
2324+ elf_section_data (o)->this_hdr.contents = ocontents;
2325+ }
2326+ }
2327+ unsigned long instr_hi = bfd_get_32 (abfd, ocontents
2328+ + irelscan->r_offset);
2329+ unsigned long instr_lo = bfd_get_32 (abfd, ocontents
2330+ + irelscan->r_offset
2331+ + INST_WORD_SIZE);
2332+ immediate = (instr_hi & 0x0000ffff) << 16;
2333+ immediate |= (instr_lo & 0x0000ffff);
2334+ offset = calc_fixup (irelscan->r_addend, 0, sec);
2335+ immediate -= offset;
2336+ irelscan->r_addend -= offset;
2337+ }
2338+ }
2339+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_PCREL)
2340+ {
2341+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2342+
2343+ /* Look at the reloc only if the value has been resolved. */
2344+ if (isym->st_shndx == shndx
2345+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2346+ {
2347+ bfd_vma immediate;
2348+ bfd_vma target_address;
2349+
2350+ if (ocontents == NULL)
2351+ {
2352+ if (elf_section_data (o)->this_hdr.contents != NULL)
2353+ ocontents = elf_section_data (o)->this_hdr.contents;
2354+ else
2355+ {
2356+ /* We always cache the section contents.
2357+ Perhaps, if info->keep_memory is FALSE, we
2358+ should free them, if we are permitted to. */
2359+ if (o->rawsize == 0)
2360+ o->rawsize = o->size;
2361+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2362+ if (ocontents == NULL)
2363+ goto error_return;
2364+ if (!bfd_get_section_contents (abfd, o, ocontents,
2365+ (file_ptr) 0,
2366+ o->rawsize))
2367+ goto error_return;
2368+ elf_section_data (o)->this_hdr.contents = ocontents;
2369+ }
2370+ }
2371+ unsigned long instr_hi = bfd_get_32 (abfd, ocontents
2372+ + irelscan->r_offset);
2373+ unsigned long instr_lo = bfd_get_32 (abfd, ocontents
2374+ + irelscan->r_offset
2375+ + INST_WORD_SIZE);
2376+ immediate = (instr_hi & 0x0000ffff) << 16;
2377+ immediate |= (instr_lo & 0x0000ffff);
2378+ target_address = immediate;
2379+ offset = calc_fixup (target_address, 0, sec);
2380+ immediate -= offset;
2381+ irelscan->r_addend -= offset;
2382+ microblaze_bfd_write_imm_value_64 (abfd, ocontents
2383+ + irelscan->r_offset, immediate);
2384+ }
2385+ }
2386+ }
2387+ }
2388+
2389+ /* Adjust the local symbols defined in this section. */
2390+ isymend = isymbuf + symtab_hdr->sh_info;
2391+ for (isym = isymbuf; isym < isymend; isym++)
2392+ {
2393+ if (isym->st_shndx == shndx)
2394+ {
2395+ isym->st_value -= calc_fixup (isym->st_value, 0, sec);
2396+ if (isym->st_size)
2397+ isym->st_size -= calc_fixup (isym->st_value, isym->st_size, sec);
2398+ }
2399+ }
2400+
2401+ /* Now adjust the global symbols defined in this section. */
2402+ isym = isymbuf + symtab_hdr->sh_info;
2403+ symcount = (symtab_hdr->sh_size / sizeof (Elf64_External_Sym)) - symtab_hdr->sh_info;
2404+ for (sym_index = 0; sym_index < symcount; sym_index++)
2405+ {
2406+ sym_hash = elf_sym_hashes (abfd)[sym_index];
2407+ if ((sym_hash->root.type == bfd_link_hash_defined
2408+ || sym_hash->root.type == bfd_link_hash_defweak)
2409+ && sym_hash->root.u.def.section == sec)
2410+ {
2411+ sym_hash->root.u.def.value -= calc_fixup (sym_hash->root.u.def.value,
2412+ 0, sec);
2413+ if (sym_hash->size)
2414+ sym_hash->size -= calc_fixup (sym_hash->root.u.def.value,
2415+ sym_hash->size, sec);
2416+ }
2417+ }
2418+
2419+ /* Physically move the code and change the cooked size. */
2420+ dest = sec->relax[0].addr;
2421+ for (i = 0; i < sec->relax_count; i++)
2422+ {
2423+ int len;
2424+ src = sec->relax[i].addr + sec->relax[i].size;
2425+ len = sec->relax[i+1].addr - sec->relax[i].addr - sec->relax[i].size;
2426+
2427+ memmove (contents + dest, contents + src, len);
2428+ sec->size -= sec->relax[i].size;
2429+ dest += len;
2430+ }
2431+
2432+ elf_section_data (sec)->relocs = internal_relocs;
2433+ free_relocs = NULL;
2434+
2435+ elf_section_data (sec)->this_hdr.contents = contents;
2436+ free_contents = NULL;
2437+
2438+ symtab_hdr->contents = (bfd_byte *) isymbuf;
2439+ }
2440+
2441+ if (free_relocs != NULL)
2442+ {
2443+ free (free_relocs);
2444+ free_relocs = NULL;
2445+ }
2446+
2447+ if (free_contents != NULL)
2448+ {
2449+ if (!link_info->keep_memory)
2450+ free (free_contents);
2451+ else
2452+ /* Cache the section contents for elf_link_input_bfd. */
2453+ elf_section_data (sec)->this_hdr.contents = contents;
2454+ free_contents = NULL;
2455+ }
2456+
2457+ if (sec->relax_count == 0)
2458+ {
2459+ *again = FALSE;
2460+ free (sec->relax);
2461+ sec->relax = NULL;
2462+ }
2463+ else
2464+ *again = TRUE;
2465+ return TRUE;
2466+
2467+ error_return:
2468+ if (free_relocs != NULL)
2469+ free (free_relocs);
2470+ if (free_contents != NULL)
2471+ free (free_contents);
2472+ if (sec->relax != NULL)
2473+ {
2474+ free (sec->relax);
2475+ sec->relax = NULL;
2476+ sec->relax_count = 0;
2477+ }
2478+ return FALSE;
2479+}
2480+
2481+/* Return the section that should be marked against GC for a given
2482+ relocation. */
2483+
2484+static asection *
2485+microblaze_elf_gc_mark_hook (asection *sec,
2486+ struct bfd_link_info * info,
2487+ Elf_Internal_Rela * rel,
2488+ struct elf_link_hash_entry * h,
2489+ Elf_Internal_Sym * sym)
2490+{
2491+ if (h != NULL)
2492+ switch (ELF64_R_TYPE (rel->r_info))
2493+ {
2494+ case R_MICROBLAZE_GNU_VTINHERIT:
2495+ case R_MICROBLAZE_GNU_VTENTRY:
2496+ return NULL;
2497+ }
2498+
2499+ return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
2500+}
2501+
2502+/* Update the got entry reference counts for the section being removed. */
2503+
2504+static bfd_boolean
2505+microblaze_elf_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED,
2506+ struct bfd_link_info * info ATTRIBUTE_UNUSED,
2507+ asection * sec ATTRIBUTE_UNUSED,
2508+ const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
2509+{
2510+ return TRUE;
2511+}
2512+
2513+/* PIC support. */
2514+
2515+#define PLT_ENTRY_SIZE 16
2516+
2517+#define PLT_ENTRY_WORD_0 0xb0000000 /* "imm 0". */
2518+#define PLT_ENTRY_WORD_1 0xe9940000 /* "lwi r12,r20,0" - relocated to lwi r12,r20,func@GOT. */
2519+#define PLT_ENTRY_WORD_1_NOPIC 0xe9800000 /* "lwi r12,r0,0" - non-PIC object. */
2520+#define PLT_ENTRY_WORD_2 0x98186000 /* "brad r12". */
2521+#define PLT_ENTRY_WORD_3 0x80000000 /* "nop". */
2522+
2523+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
2524+ shortcuts to them in our hash table. */
2525+
2526+static bfd_boolean
2527+create_got_section (bfd *dynobj, struct bfd_link_info *info)
2528+{
2529+ struct elf64_mb_link_hash_table *htab;
2530+
2531+ if (! _bfd_elf_create_got_section (dynobj, info))
2532+ return FALSE;
2533+ htab = elf64_mb_hash_table (info);
2534+ if (htab == NULL)
2535+ return FALSE;
2536+
2537+ htab->sgot = bfd_get_linker_section (dynobj, ".got");
2538+ htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
2539+ if (!htab->sgot || !htab->sgotplt)
2540+ return FALSE;
2541+
2542+ if ((htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got")) == NULL)
2543+ htab->srelgot = bfd_make_section_anyway (dynobj, ".rela.got");
2544+ if (htab->srelgot == NULL
2545+ || ! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC
2546+ | SEC_LOAD
2547+ | SEC_HAS_CONTENTS
2548+ | SEC_IN_MEMORY
2549+ | SEC_LINKER_CREATED
2550+ | SEC_READONLY)
2551+ || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
2552+ return FALSE;
2553+ return TRUE;
2554+}
2555+
2556+static bfd_boolean
2557+update_local_sym_info (bfd *abfd,
2558+ Elf_Internal_Shdr *symtab_hdr,
2559+ unsigned long r_symndx,
2560+ unsigned int tls_type)
2561+{
2562+ bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd);
2563+ unsigned char *local_got_tls_masks;
2564+
2565+ if (local_got_refcounts == NULL)
2566+ {
2567+ bfd_size_type size = symtab_hdr->sh_info;
2568+
2569+ size *= (sizeof (*local_got_refcounts) + sizeof (*local_got_tls_masks));
2570+ local_got_refcounts = bfd_zalloc (abfd, size);
2571+ if (local_got_refcounts == NULL)
2572+ return FALSE;
2573+ elf_local_got_refcounts (abfd) = local_got_refcounts;
2574+ }
2575+
2576+ local_got_tls_masks =
2577+ (unsigned char *) (local_got_refcounts + symtab_hdr->sh_info);
2578+ local_got_tls_masks[r_symndx] |= tls_type;
2579+ local_got_refcounts[r_symndx] += 1;
2580+
2581+ return TRUE;
2582+}
2583+/* Look through the relocs for a section during the first phase. */
2584+
2585+static bfd_boolean
2586+microblaze_elf_check_relocs (bfd * abfd,
2587+ struct bfd_link_info * info,
2588+ asection * sec,
2589+ const Elf_Internal_Rela * relocs)
2590+{
2591+ Elf_Internal_Shdr * symtab_hdr;
2592+ struct elf_link_hash_entry ** sym_hashes;
2593+ struct elf_link_hash_entry ** sym_hashes_end;
2594+ const Elf_Internal_Rela * rel;
2595+ const Elf_Internal_Rela * rel_end;
2596+ struct elf64_mb_link_hash_table *htab;
2597+ asection *sreloc = NULL;
2598+
2599+ if (bfd_link_relocatable (info))
2600+ return TRUE;
2601+
2602+ htab = elf64_mb_hash_table (info);
2603+ if (htab == NULL)
2604+ return FALSE;
2605+
2606+ symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
2607+ sym_hashes = elf_sym_hashes (abfd);
2608+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size / sizeof (Elf64_External_Sym);
2609+ if (!elf_bad_symtab (abfd))
2610+ sym_hashes_end -= symtab_hdr->sh_info;
2611+
2612+ rel_end = relocs + sec->reloc_count;
2613+
2614+ for (rel = relocs; rel < rel_end; rel++)
2615+ {
2616+ unsigned int r_type;
2617+ struct elf_link_hash_entry * h;
2618+ unsigned long r_symndx;
2619+ unsigned char tls_type = 0;
2620+
2621+ r_symndx = ELF64_R_SYM (rel->r_info);
2622+ r_type = ELF64_R_TYPE (rel->r_info);
2623+
2624+ if (r_symndx < symtab_hdr->sh_info)
2625+ h = NULL;
2626+ else
2627+ {
2628+ h = sym_hashes [r_symndx - symtab_hdr->sh_info];
2629+
2630+ /* PR15323, ref flags aren't set for references in the same
2631+ object. */
2632+ h->root.non_ir_ref = 1;
2633+ }
2634+
2635+ switch (r_type)
2636+ {
2637+ /* This relocation describes the C++ object vtable hierarchy.
2638+ Reconstruct it for later use during GC. */
2639+ case R_MICROBLAZE_GNU_VTINHERIT:
2640+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
2641+ return FALSE;
2642+ break;
2643+
2644+ /* This relocation describes which C++ vtable entries are actually
2645+ used. Record for later use during GC. */
2646+ case R_MICROBLAZE_GNU_VTENTRY:
2647+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
2648+ return FALSE;
2649+ break;
2650+
2651+ /* This relocation requires .plt entry. */
2652+ case R_MICROBLAZE_PLT_64:
2653+ if (h != NULL)
2654+ {
2655+ h->needs_plt = 1;
2656+ h->plt.refcount += 1;
2657+ }
2658+ break;
2659+
2660+ /* This relocation requires .got entry. */
2661+ case R_MICROBLAZE_TLSGD:
2662+ tls_type |= (TLS_TLS | TLS_GD);
2663+ goto dogottls;
2664+ case R_MICROBLAZE_TLSLD:
2665+ tls_type |= (TLS_TLS | TLS_LD);
2666+ dogottls:
2667+ sec->has_tls_reloc = 1;
2668+ case R_MICROBLAZE_GOT_64:
2669+ if (htab->sgot == NULL)
2670+ {
2671+ if (htab->elf.dynobj == NULL)
2672+ htab->elf.dynobj = abfd;
2673+ if (!create_got_section (htab->elf.dynobj, info))
2674+ return FALSE;
2675+ }
2676+ if (h != NULL)
2677+ {
2678+ h->got.refcount += 1;
2679+ elf64_mb_hash_entry (h)->tls_mask |= tls_type;
2680+ }
2681+ else
2682+ {
2683+ if (! update_local_sym_info(abfd, symtab_hdr, r_symndx, tls_type) )
2684+ return FALSE;
2685+ }
2686+ break;
2687+
2688+ case R_MICROBLAZE_64:
2689+ case R_MICROBLAZE_64_PCREL:
2690+ case R_MICROBLAZE_32:
2691+ {
2692+ if (h != NULL && !bfd_link_pic (info))
2693+ {
2694+ /* we may need a copy reloc. */
2695+ h->non_got_ref = 1;
2696+
2697+ /* we may also need a .plt entry. */
2698+ h->plt.refcount += 1;
2699+ if (ELF64_R_TYPE (rel->r_info) != R_MICROBLAZE_64_PCREL)
2700+ h->pointer_equality_needed = 1;
2701+ }
2702+
2703+
2704+ /* If we are creating a shared library, and this is a reloc
2705+ against a global symbol, or a non PC relative reloc
2706+ against a local symbol, then we need to copy the reloc
2707+ into the shared library. However, if we are linking with
2708+ -Bsymbolic, we do not need to copy a reloc against a
2709+ global symbol which is defined in an object we are
2710+ including in the link (i.e., DEF_REGULAR is set). At
2711+ this point we have not seen all the input files, so it is
2712+ possible that DEF_REGULAR is not set now but will be set
2713+ later (it is never cleared). In case of a weak definition,
2714+ DEF_REGULAR may be cleared later by a strong definition in
2715+ a shared library. We account for that possibility below by
2716+ storing information in the relocs_copied field of the hash
2717+ table entry. A similar situation occurs when creating
2718+ shared libraries and symbol visibility changes render the
2719+ symbol local.
2720+
2721+ If on the other hand, we are creating an executable, we
2722+ may need to keep relocations for symbols satisfied by a
2723+ dynamic library if we manage to avoid copy relocs for the
2724+ symbol. */
2725+
2726+ if ((bfd_link_pic (info)
2727+ && (sec->flags & SEC_ALLOC) != 0
2728+ && (r_type != R_MICROBLAZE_64_PCREL
2729+ || (h != NULL
2730+ && (! info->symbolic
2731+ || h->root.type == bfd_link_hash_defweak
2732+ || !h->def_regular))))
2733+ || (!bfd_link_pic (info)
2734+ && (sec->flags & SEC_ALLOC) != 0
2735+ && h != NULL
2736+ && (h->root.type == bfd_link_hash_defweak
2737+ || !h->def_regular)))
2738+ {
2739+ struct elf64_mb_dyn_relocs *p;
2740+ struct elf64_mb_dyn_relocs **head;
2741+
2742+ /* When creating a shared object, we must copy these
2743+ relocs into the output file. We create a reloc
2744+ section in dynobj and make room for the reloc. */
2745+
2746+ if (sreloc == NULL)
2747+ {
2748+ bfd *dynobj;
2749+
2750+ if (htab->elf.dynobj == NULL)
2751+ htab->elf.dynobj = abfd;
2752+ dynobj = htab->elf.dynobj;
2753+
2754+ sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj,
2755+ 2, abfd, 1);
2756+ if (sreloc == NULL)
2757+ return FALSE;
2758+ }
2759+
2760+ /* If this is a global symbol, we count the number of
2761+ relocations we need for this symbol. */
2762+ if (h != NULL)
2763+ head = &((struct elf64_mb_link_hash_entry *) h)->dyn_relocs;
2764+ else
2765+ {
2766+ /* Track dynamic relocs needed for local syms too.
2767+ We really need local syms available to do this
2768+ easily. Oh well. */
2769+
2770+ asection *s;
2771+ Elf_Internal_Sym *isym;
2772+ void *vpp;
2773+
2774+ isym = bfd_sym_from_r_symndx (&htab->sym_sec,
2775+ abfd, r_symndx);
2776+ if (isym == NULL)
2777+ return FALSE;
2778+
2779+ s = bfd_section_from_elf_index (abfd, isym->st_shndx);
2780+ if (s == NULL)
2781+ return FALSE;
2782+
2783+ vpp = &elf_section_data (s)->local_dynrel;
2784+ head = (struct elf64_mb_dyn_relocs **) vpp;
2785+ }
2786+
2787+ p = *head;
2788+ if (p == NULL || p->sec != sec)
2789+ {
2790+ bfd_size_type amt = sizeof *p;
2791+ p = ((struct elf64_mb_dyn_relocs *)
2792+ bfd_alloc (htab->elf.dynobj, amt));
2793+ if (p == NULL)
2794+ return FALSE;
2795+ p->next = *head;
2796+ *head = p;
2797+ p->sec = sec;
2798+ p->count = 0;
2799+ p->pc_count = 0;
2800+ }
2801+
2802+ p->count += 1;
2803+ if (r_type == R_MICROBLAZE_64_PCREL)
2804+ p->pc_count += 1;
2805+ }
2806+ }
2807+ break;
2808+ }
2809+ }
2810+
2811+ return TRUE;
2812+}
2813+
2814+static bfd_boolean
2815+microblaze_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
2816+{
2817+ struct elf64_mb_link_hash_table *htab;
2818+
2819+ htab = elf64_mb_hash_table (info);
2820+ if (htab == NULL)
2821+ return FALSE;
2822+
2823+ if (!htab->sgot && !create_got_section (dynobj, info))
2824+ return FALSE;
2825+
2826+ if (!_bfd_elf_create_dynamic_sections (dynobj, info))
2827+ return FALSE;
2828+
2829+ htab->splt = bfd_get_linker_section (dynobj, ".plt");
2830+ htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
2831+ htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
2832+ if (!bfd_link_pic (info))
2833+ htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
2834+
2835+ if (!htab->splt || !htab->srelplt || !htab->sdynbss
2836+ || (!bfd_link_pic (info) && !htab->srelbss))
2837+ abort ();
2838+
2839+ return TRUE;
2840+}
2841+
2842+/* Copy the extra info we tack onto an elf_link_hash_entry. */
2843+
2844+static void
2845+microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info,
2846+ struct elf_link_hash_entry *dir,
2847+ struct elf_link_hash_entry *ind)
2848+{
2849+ struct elf64_mb_link_hash_entry *edir, *eind;
2850+
2851+ edir = (struct elf64_mb_link_hash_entry *) dir;
2852+ eind = (struct elf64_mb_link_hash_entry *) ind;
2853+
2854+ if (eind->dyn_relocs != NULL)
2855+ {
2856+ if (edir->dyn_relocs != NULL)
2857+ {
2858+ struct elf64_mb_dyn_relocs **pp;
2859+ struct elf64_mb_dyn_relocs *p;
2860+
2861+ if (ind->root.type == bfd_link_hash_indirect)
2862+ abort ();
2863+
2864+ /* Add reloc counts against the weak sym to the strong sym
2865+ list. Merge any entries against the same section. */
2866+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
2867+ {
2868+ struct elf64_mb_dyn_relocs *q;
2869+
2870+ for (q = edir->dyn_relocs; q != NULL; q = q->next)
2871+ if (q->sec == p->sec)
2872+ {
2873+ q->pc_count += p->pc_count;
2874+ q->count += p->count;
2875+ *pp = p->next;
2876+ break;
2877+ }
2878+ if (q == NULL)
2879+ pp = &p->next;
2880+ }
2881+ *pp = edir->dyn_relocs;
2882+ }
2883+
2884+ edir->dyn_relocs = eind->dyn_relocs;
2885+ eind->dyn_relocs = NULL;
2886+ }
2887+
2888+ edir->tls_mask |= eind->tls_mask;
2889+
2890+ _bfd_elf_link_hash_copy_indirect (info, dir, ind);
2891+}
2892+
2893+static bfd_boolean
2894+microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
2895+ struct elf_link_hash_entry *h)
2896+{
2897+ struct elf64_mb_link_hash_table *htab;
2898+ struct elf64_mb_link_hash_entry * eh;
2899+ struct elf64_mb_dyn_relocs *p;
2900+ asection *sdynbss, *s;
2901+ unsigned int power_of_two;
2902+ bfd *dynobj;
2903+
2904+ htab = elf64_mb_hash_table (info);
2905+ if (htab == NULL)
2906+ return FALSE;
2907+
2908+ /* If this is a function, put it in the procedure linkage table. We
2909+ will fill in the contents of the procedure linkage table later,
2910+ when we know the address of the .got section. */
2911+ if (h->type == STT_FUNC
2912+ || h->needs_plt)
2913+ {
2914+ if (h->plt.refcount <= 0
2915+ || SYMBOL_CALLS_LOCAL (info, h)
2916+ || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
2917+ && h->root.type == bfd_link_hash_undefweak))
2918+ {
2919+ /* This case can occur if we saw a PLT reloc in an input
2920+ file, but the symbol was never referred to by a dynamic
2921+ object, or if all references were garbage collected. In
2922+ such a case, we don't actually need to build a procedure
2923+ linkage table, and we can just do a PC32 reloc instead. */
2924+ h->plt.offset = (bfd_vma) -1;
2925+ h->needs_plt = 0;
2926+ }
2927+
2928+ return TRUE;
2929+ }
2930+ else
2931+ /* It's possible that we incorrectly decided a .plt reloc was
2932+ needed for an R_MICROBLAZE_64_PCREL reloc to a non-function sym in
2933+ check_relocs. We can't decide accurately between function and
2934+ non-function syms in check-relocs; Objects loaded later in
2935+ the link may change h->type. So fix it now. */
2936+ h->plt.offset = (bfd_vma) -1;
2937+
2938+ /* If this is a weak symbol, and there is a real definition, the
2939+ processor independent code will have arranged for us to see the
2940+ real definition first, and we can just use the same value. */
2941+ if (h->u.weakdef != NULL)
2942+ {
2943+ BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
2944+ || h->u.weakdef->root.type == bfd_link_hash_defweak);
2945+ h->root.u.def.section = h->u.weakdef->root.u.def.section;
2946+ h->root.u.def.value = h->u.weakdef->root.u.def.value;
2947+ return TRUE;
2948+ }
2949+
2950+ /* This is a reference to a symbol defined by a dynamic object which
2951+ is not a function. */
2952+
2953+ /* If we are creating a shared library, we must presume that the
2954+ only references to the symbol are via the global offset table.
2955+ For such cases we need not do anything here; the relocations will
2956+ be handled correctly by relocate_section. */
2957+ if (bfd_link_pic (info))
2958+ return TRUE;
2959+
2960+ /* If there are no references to this symbol that do not use the
2961+ GOT, we don't need to generate a copy reloc. */
2962+ if (!h->non_got_ref)
2963+ return TRUE;
2964+
2965+ /* If -z nocopyreloc was given, we won't generate them either. */
2966+ if (info->nocopyreloc)
2967+ {
2968+ h->non_got_ref = 0;
2969+ return TRUE;
2970+ }
2971+
2972+ eh = (struct elf64_mb_link_hash_entry *) h;
2973+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
2974+ {
2975+ s = p->sec->output_section;
2976+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
2977+ break;
2978+ }
2979+
2980+ /* If we didn't find any dynamic relocs in read-only sections, then
2981+ we'll be keeping the dynamic relocs and avoiding the copy reloc. */
2982+ if (p == NULL)
2983+ {
2984+ h->non_got_ref = 0;
2985+ return TRUE;
2986+ }
2987+
2988+ /* We must allocate the symbol in our .dynbss section, which will
2989+ become part of the .bss section of the executable. There will be
2990+ an entry for this symbol in the .dynsym section. The dynamic
2991+ object will contain position independent code, so all references
2992+ from the dynamic object to this symbol will go through the global
2993+ offset table. The dynamic linker will use the .dynsym entry to
2994+ determine the address it must put in the global offset table, so
2995+ both the dynamic object and the regular object will refer to the
2996+ same memory location for the variable. */
2997+
2998+ /* We must generate a R_MICROBLAZE_COPY reloc to tell the dynamic linker
2999+ to copy the initial value out of the dynamic object and into the
3000+ runtime process image. */
3001+ dynobj = elf_hash_table (info)->dynobj;
3002+ BFD_ASSERT (dynobj != NULL);
3003+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
3004+ {
3005+ htab->srelbss->size += sizeof (Elf64_External_Rela);
3006+ h->needs_copy = 1;
3007+ }
3008+
3009+ /* We need to figure out the alignment required for this symbol. I
3010+ have no idea how ELF linkers handle this. */
3011+ power_of_two = bfd_log2 (h->size);
3012+ if (power_of_two > 3)
3013+ power_of_two = 3;
3014+
3015+ sdynbss = htab->sdynbss;
3016+ /* Apply the required alignment. */
3017+ sdynbss->size = BFD_ALIGN (sdynbss->size, (bfd_size_type) (1 << power_of_two));
3018+ if (power_of_two > bfd_get_section_alignment (dynobj, sdynbss))
3019+ {
3020+ if (! bfd_set_section_alignment (dynobj, sdynbss, power_of_two))
3021+ return FALSE;
3022+ }
3023+
3024+ /* Define the symbol as being at this point in the section. */
3025+ h->root.u.def.section = sdynbss;
3026+ h->root.u.def.value = sdynbss->size;
3027+
3028+ /* Increment the section size to make room for the symbol. */
3029+ sdynbss->size += h->size;
3030+ return TRUE;
3031+}
3032+
3033+/* Allocate space in .plt, .got and associated reloc sections for
3034+ dynamic relocs. */
3035+
3036+static bfd_boolean
3037+allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
3038+{
3039+ struct bfd_link_info *info;
3040+ struct elf64_mb_link_hash_table *htab;
3041+ struct elf64_mb_link_hash_entry *eh;
3042+ struct elf64_mb_dyn_relocs *p;
3043+
3044+ if (h->root.type == bfd_link_hash_indirect)
3045+ return TRUE;
3046+
3047+ info = (struct bfd_link_info *) dat;
3048+ htab = elf64_mb_hash_table (info);
3049+ if (htab == NULL)
3050+ return FALSE;
3051+
3052+ if (htab->elf.dynamic_sections_created
3053+ && h->plt.refcount > 0)
3054+ {
3055+ /* Make sure this symbol is output as a dynamic symbol.
3056+ Undefined weak syms won't yet be marked as dynamic. */
3057+ if (h->dynindx == -1
3058+ && !h->forced_local)
3059+ {
3060+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3061+ return FALSE;
3062+ }
3063+
3064+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
3065+ {
3066+ asection *s = htab->splt;
3067+
3068+ /* The first entry in .plt is reserved. */
3069+ if (s->size == 0)
3070+ s->size = PLT_ENTRY_SIZE;
3071+
3072+ h->plt.offset = s->size;
3073+
3074+ /* If this symbol is not defined in a regular file, and we are
3075+ not generating a shared library, then set the symbol to this
3076+ location in the .plt. This is required to make function
3077+ pointers compare as equal between the normal executable and
3078+ the shared library. */
3079+ if (! bfd_link_pic (info)
3080+ && !h->def_regular)
3081+ {
3082+ h->root.u.def.section = s;
3083+ h->root.u.def.value = h->plt.offset;
3084+ }
3085+
3086+ /* Make room for this entry. */
3087+ s->size += PLT_ENTRY_SIZE;
3088+
3089+ /* We also need to make an entry in the .got.plt section, which
3090+ will be placed in the .got section by the linker script. */
3091+ htab->sgotplt->size += 4;
3092+
3093+ /* We also need to make an entry in the .rel.plt section. */
3094+ htab->srelplt->size += sizeof (Elf64_External_Rela);
3095+ }
3096+ else
3097+ {
3098+ h->plt.offset = (bfd_vma) -1;
3099+ h->needs_plt = 0;
3100+ }
3101+ }
3102+ else
3103+ {
3104+ h->plt.offset = (bfd_vma) -1;
3105+ h->needs_plt = 0;
3106+ }
3107+
3108+ eh = (struct elf64_mb_link_hash_entry *) h;
3109+ if (h->got.refcount > 0)
3110+ {
3111+ unsigned int need;
3112+ asection *s;
3113+
3114+ /* Make sure this symbol is output as a dynamic symbol.
3115+ Undefined weak syms won't yet be marked as dynamic. */
3116+ if (h->dynindx == -1
3117+ && !h->forced_local)
3118+ {
3119+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3120+ return FALSE;
3121+ }
3122+
3123+ need = 0;
3124+ if ((eh->tls_mask & TLS_TLS) != 0)
3125+ {
3126+ /* Handle TLS Symbol */
3127+ if ((eh->tls_mask & TLS_LD) != 0)
3128+ {
3129+ if (!eh->elf.def_dynamic)
3130+ /* We'll just use htab->tlsld_got.offset. This should
3131+ always be the case. It's a little odd if we have
3132+ a local dynamic reloc against a non-local symbol. */
3133+ htab->tlsld_got.refcount += 1;
3134+ else
3135+ need += 8;
3136+ }
3137+ if ((eh->tls_mask & TLS_GD) != 0)
3138+ need += 8;
3139+ }
3140+ else
3141+ {
3142+ /* Regular (non-TLS) symbol */
3143+ need += 4;
3144+ }
3145+ if (need == 0)
3146+ {
3147+ h->got.offset = (bfd_vma) -1;
3148+ }
3149+ else
3150+ {
3151+ s = htab->sgot;
3152+ h->got.offset = s->size;
3153+ s->size += need;
3154+ htab->srelgot->size += need * (sizeof (Elf64_External_Rela) / 4);
3155+ }
3156+ }
3157+ else
3158+ h->got.offset = (bfd_vma) -1;
3159+
3160+ if (eh->dyn_relocs == NULL)
3161+ return TRUE;
3162+
3163+ /* In the shared -Bsymbolic case, discard space allocated for
3164+ dynamic pc-relative relocs against symbols which turn out to be
3165+ defined in regular objects. For the normal shared case, discard
3166+ space for pc-relative relocs that have become local due to symbol
3167+ visibility changes. */
3168+
3169+ if (bfd_link_pic (info))
3170+ {
3171+ if (h->def_regular
3172+ && (h->forced_local
3173+ || info->symbolic))
3174+ {
3175+ struct elf64_mb_dyn_relocs **pp;
3176+
3177+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
3178+ {
3179+ p->count -= p->pc_count;
3180+ p->pc_count = 0;
3181+ if (p->count == 0)
3182+ *pp = p->next;
3183+ else
3184+ pp = &p->next;
3185+ }
3186+ }
3187+ }
3188+ else
3189+ {
3190+ /* For the non-shared case, discard space for relocs against
3191+ symbols which turn out to need copy relocs or are not
3192+ dynamic. */
3193+
3194+ if (!h->non_got_ref
3195+ && ((h->def_dynamic
3196+ && !h->def_regular)
3197+ || (htab->elf.dynamic_sections_created
3198+ && (h->root.type == bfd_link_hash_undefweak
3199+ || h->root.type == bfd_link_hash_undefined))))
3200+ {
3201+ /* Make sure this symbol is output as a dynamic symbol.
3202+ Undefined weak syms won't yet be marked as dynamic. */
3203+ if (h->dynindx == -1
3204+ && !h->forced_local)
3205+ {
3206+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3207+ return FALSE;
3208+ }
3209+
3210+ /* If that succeeded, we know we'll be keeping all the
3211+ relocs. */
3212+ if (h->dynindx != -1)
3213+ goto keep;
3214+ }
3215+
3216+ eh->dyn_relocs = NULL;
3217+
3218+ keep: ;
3219+ }
3220+
3221+ /* Finally, allocate space. */
3222+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
3223+ {
3224+ asection *sreloc = elf_section_data (p->sec)->sreloc;
3225+ sreloc->size += p->count * sizeof (Elf64_External_Rela);
3226+ }
3227+
3228+ return TRUE;
3229+}
3230+
3231+/* Set the sizes of the dynamic sections. */
3232+
3233+static bfd_boolean
3234+microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
3235+ struct bfd_link_info *info)
3236+{
3237+ struct elf64_mb_link_hash_table *htab;
3238+ bfd *dynobj;
3239+ asection *s;
3240+ bfd *ibfd;
3241+
3242+ htab = elf64_mb_hash_table (info);
3243+ if (htab == NULL)
3244+ return FALSE;
3245+
3246+ dynobj = htab->elf.dynobj;
3247+ BFD_ASSERT (dynobj != NULL);
3248+
3249+ /* Set up .got offsets for local syms, and space for local dynamic
3250+ relocs. */
3251+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
3252+ {
3253+ bfd_signed_vma *local_got;
3254+ bfd_signed_vma *end_local_got;
3255+ bfd_size_type locsymcount;
3256+ Elf_Internal_Shdr *symtab_hdr;
3257+ unsigned char *lgot_masks;
3258+ asection *srel;
3259+
3260+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
3261+ continue;
3262+
3263+ for (s = ibfd->sections; s != NULL; s = s->next)
3264+ {
3265+ struct elf64_mb_dyn_relocs *p;
3266+
3267+ for (p = ((struct elf64_mb_dyn_relocs *)
3268+ elf_section_data (s)->local_dynrel);
3269+ p != NULL;
3270+ p = p->next)
3271+ {
3272+ if (!bfd_is_abs_section (p->sec)
3273+ && bfd_is_abs_section (p->sec->output_section))
3274+ {
3275+ /* Input section has been discarded, either because
3276+ it is a copy of a linkonce section or due to
3277+ linker script /DISCARD/, so we'll be discarding
3278+ the relocs too. */
3279+ }
3280+ else if (p->count != 0)
3281+ {
3282+ srel = elf_section_data (p->sec)->sreloc;
3283+ srel->size += p->count * sizeof (Elf64_External_Rela);
3284+ if ((p->sec->output_section->flags & SEC_READONLY) != 0)
3285+ info->flags |= DF_TEXTREL;
3286+ }
3287+ }
3288+ }
3289+
3290+ local_got = elf_local_got_refcounts (ibfd);
3291+ if (!local_got)
3292+ continue;
3293+
3294+ symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
3295+ locsymcount = symtab_hdr->sh_info;
3296+ end_local_got = local_got + locsymcount;
3297+ lgot_masks = (unsigned char *) end_local_got;
3298+ s = htab->sgot;
3299+ srel = htab->srelgot;
3300+
3301+ for (; local_got < end_local_got; ++local_got, ++lgot_masks)
3302+ {
3303+ if (*local_got > 0)
3304+ {
3305+ unsigned int need = 0;
3306+ if ((*lgot_masks & TLS_TLS) != 0)
3307+ {
3308+ if ((*lgot_masks & TLS_GD) != 0)
3309+ need += 8;
3310+ if ((*lgot_masks & TLS_LD) != 0)
3311+ htab->tlsld_got.refcount += 1;
3312+ }
3313+ else
3314+ need += 4;
3315+
3316+ if (need == 0)
3317+ {
3318+ *local_got = (bfd_vma) -1;
3319+ }
3320+ else
3321+ {
3322+ *local_got = s->size;
3323+ s->size += need;
3324+ if (bfd_link_pic (info))
3325+ srel->size += need * (sizeof (Elf64_External_Rela) / 4);
3326+ }
3327+ }
3328+ else
3329+ *local_got = (bfd_vma) -1;
3330+ }
3331+ }
3332+
3333+ /* Allocate global sym .plt and .got entries, and space for global
3334+ sym dynamic relocs. */
3335+ elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info);
3336+
3337+ if (htab->tlsld_got.refcount > 0)
3338+ {
3339+ htab->tlsld_got.offset = htab->sgot->size;
3340+ htab->sgot->size += 8;
3341+ if (bfd_link_pic (info))
3342+ htab->srelgot->size += sizeof (Elf64_External_Rela);
3343+ }
3344+ else
3345+ htab->tlsld_got.offset = (bfd_vma) -1;
3346+
3347+ if (elf_hash_table (info)->dynamic_sections_created)
3348+ {
3349+ /* Make space for the trailing nop in .plt. */
3350+ if (htab->splt->size > 0)
3351+ htab->splt->size += 4;
3352+ }
3353+
3354+ /* The check_relocs and adjust_dynamic_symbol entry points have
3355+ determined the sizes of the various dynamic sections. Allocate
3356+ memory for them. */
3357+ for (s = dynobj->sections; s != NULL; s = s->next)
3358+ {
3359+ const char *name;
3360+ bfd_boolean strip = FALSE;
3361+
3362+ if ((s->flags & SEC_LINKER_CREATED) == 0)
3363+ continue;
3364+
3365+ /* It's OK to base decisions on the section name, because none
3366+ of the dynobj section names depend upon the input files. */
3367+ name = bfd_get_section_name (dynobj, s);
3368+
3369+ if (strncmp (name, ".rela", 5) == 0)
3370+ {
3371+ if (s->size == 0)
3372+ {
3373+ /* If we don't need this section, strip it from the
3374+ output file. This is to handle .rela.bss and
3375+ .rela.plt. We must create it in
3376+ create_dynamic_sections, because it must be created
3377+ before the linker maps input sections to output
3378+ sections. The linker does that before
3379+ adjust_dynamic_symbol is called, and it is that
3380+ function which decides whether anything needs to go
3381+ into these sections. */
3382+ strip = TRUE;
3383+ }
3384+ else
3385+ {
3386+ /* We use the reloc_count field as a counter if we need
3387+ to copy relocs into the output file. */
3388+ s->reloc_count = 0;
3389+ }
3390+ }
3391+ else if (s != htab->splt && s != htab->sgot && s != htab->sgotplt)
3392+ {
3393+ /* It's not one of our sections, so don't allocate space. */
3394+ continue;
3395+ }
3396+
3397+ if (strip)
3398+ {
3399+ s->flags |= SEC_EXCLUDE;
3400+ continue;
3401+ }
3402+
3403+ /* Allocate memory for the section contents. */
3404+ /* FIXME: This should be a call to bfd_alloc not bfd_zalloc.
3405+ Unused entries should be reclaimed before the section's contents
3406+ are written out, but at the moment this does not happen. Thus in
3407+ order to prevent writing out garbage, we initialise the section's
3408+ contents to zero. */
3409+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
3410+ if (s->contents == NULL && s->size != 0)
3411+ return FALSE;
3412+ }
3413+
3414+ if (elf_hash_table (info)->dynamic_sections_created)
3415+ {
3416+ /* Add some entries to the .dynamic section. We fill in the
3417+ values later, in microblaze_elf_finish_dynamic_sections, but we
3418+ must add the entries now so that we get the correct size for
3419+ the .dynamic section. The DT_DEBUG entry is filled in by the
3420+ dynamic linker and used by the debugger. */
3421+#define add_dynamic_entry(TAG, VAL) \
3422+ _bfd_elf_add_dynamic_entry (info, TAG, VAL)
3423+
3424+ if (bfd_link_executable (info))
3425+ {
3426+ if (!add_dynamic_entry (DT_DEBUG, 0))
3427+ return FALSE;
3428+ }
3429+
3430+ if (!add_dynamic_entry (DT_RELA, 0)
3431+ || !add_dynamic_entry (DT_RELASZ, 0)
3432+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
3433+ return FALSE;
3434+
3435+ if (htab->splt->size != 0)
3436+ {
3437+ if (!add_dynamic_entry (DT_PLTGOT, 0)
3438+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
3439+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
3440+ || !add_dynamic_entry (DT_JMPREL, 0)
3441+ || !add_dynamic_entry (DT_BIND_NOW, 1))
3442+ return FALSE;
3443+ }
3444+
3445+ if (info->flags & DF_TEXTREL)
3446+ {
3447+ if (!add_dynamic_entry (DT_TEXTREL, 0))
3448+ return FALSE;
3449+ }
3450+ }
3451+#undef add_dynamic_entry
3452+ return TRUE;
3453+}
3454+
3455+/* Finish up dynamic symbol handling. We set the contents of various
3456+ dynamic sections here. */
3457+
3458+static bfd_boolean
3459+microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
3460+ struct bfd_link_info *info,
3461+ struct elf_link_hash_entry *h,
3462+ Elf_Internal_Sym *sym)
3463+{
3464+ struct elf64_mb_link_hash_table *htab;
3465+ struct elf64_mb_link_hash_entry *eh = elf64_mb_hash_entry(h);
3466+
3467+ htab = elf64_mb_hash_table (info);
3468+ if (htab == NULL)
3469+ return FALSE;
3470+
3471+ if (h->plt.offset != (bfd_vma) -1)
3472+ {
3473+ asection *splt;
3474+ asection *srela;
3475+ asection *sgotplt;
3476+ Elf_Internal_Rela rela;
3477+ bfd_byte *loc;
3478+ bfd_vma plt_index;
3479+ bfd_vma got_offset;
3480+ bfd_vma got_addr;
3481+
3482+ /* This symbol has an entry in the procedure linkage table. Set
3483+ it up. */
3484+ BFD_ASSERT (h->dynindx != -1);
3485+
3486+ splt = htab->splt;
3487+ srela = htab->srelplt;
3488+ sgotplt = htab->sgotplt;
3489+ BFD_ASSERT (splt != NULL && srela != NULL && sgotplt != NULL);
3490+
3491+ plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; /* first entry reserved. */
3492+ got_offset = (plt_index + 3) * 4; /* 3 reserved ??? */
3493+ got_addr = got_offset;
3494+
3495+ /* For non-PIC objects we need absolute address of the GOT entry. */
3496+ if (!bfd_link_pic (info))
3497+ got_addr += htab->sgotplt->output_section->vma + sgotplt->output_offset;
3498+
3499+ /* Fill in the entry in the procedure linkage table. */
3500+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_0 + ((got_addr >> 16) & 0xffff),
3501+ splt->contents + h->plt.offset);
3502+ if (bfd_link_pic (info))
3503+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_1 + (got_addr & 0xffff),
3504+ splt->contents + h->plt.offset + 4);
3505+ else
3506+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_1_NOPIC + (got_addr & 0xffff),
3507+ splt->contents + h->plt.offset + 4);
3508+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD_2,
3509+ splt->contents + h->plt.offset + 8);
3510+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD_3,
3511+ splt->contents + h->plt.offset + 12);
3512+
3513+ /* Any additions to the .got section??? */
3514+ /* bfd_put_32 (output_bfd,
3515+ splt->output_section->vma + splt->output_offset + h->plt.offset + 4,
3516+ sgotplt->contents + got_offset); */
3517+
3518+ /* Fill in the entry in the .rela.plt section. */
3519+ rela.r_offset = (sgotplt->output_section->vma
3520+ + sgotplt->output_offset
3521+ + got_offset);
3522+ rela.r_info = ELF64_R_INFO (h->dynindx, R_MICROBLAZE_JUMP_SLOT);
3523+ rela.r_addend = 0;
3524+ loc = srela->contents;
3525+ loc += plt_index * sizeof (Elf64_External_Rela);
3526+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
3527+
3528+ if (!h->def_regular)
3529+ {
3530+ /* Mark the symbol as undefined, rather than as defined in
3531+ the .plt section. Zero the value. */
3532+ sym->st_shndx = SHN_UNDEF;
3533+ sym->st_value = 0;
3534+ }
3535+ }
3536+
3537+ /* h->got.refcount to be checked ? */
3538+ if (h->got.offset != (bfd_vma) -1 &&
3539+ ! ((h->got.offset & 1) ||
3540+ IS_TLS_LD(eh->tls_mask) || IS_TLS_GD(eh->tls_mask)))
3541+ {
3542+ asection *sgot;
3543+ asection *srela;
3544+ bfd_vma offset;
3545+
3546+ /* This symbol has an entry in the global offset table. Set it
3547+ up. */
3548+
3549+ sgot = htab->sgot;
3550+ srela = htab->srelgot;
3551+ BFD_ASSERT (sgot != NULL && srela != NULL);
3552+
3553+ offset = (sgot->output_section->vma + sgot->output_offset
3554+ + (h->got.offset &~ (bfd_vma) 1));
3555+
3556+ /* If this is a -Bsymbolic link, and the symbol is defined
3557+ locally, we just want to emit a RELATIVE reloc. Likewise if
3558+ the symbol was forced to be local because of a version file.
3559+ The entry in the global offset table will already have been
3560+ initialized in the relocate_section function. */
3561+ if (bfd_link_pic (info)
3562+ && ((info->symbolic && h->def_regular)
3563+ || h->dynindx == -1))
3564+ {
3565+ asection *sec = h->root.u.def.section;
3566+ microblaze_elf_output_dynamic_relocation (output_bfd,
3567+ srela, srela->reloc_count++,
3568+ /* symindex= */ 0,
3569+ R_MICROBLAZE_REL, offset,
3570+ h->root.u.def.value
3571+ + sec->output_section->vma
3572+ + sec->output_offset);
3573+ }
3574+ else
3575+ {
3576+ microblaze_elf_output_dynamic_relocation (output_bfd,
3577+ srela, srela->reloc_count++,
3578+ h->dynindx,
3579+ R_MICROBLAZE_GLOB_DAT,
3580+ offset, 0);
3581+ }
3582+
3583+ bfd_put_32 (output_bfd, (bfd_vma) 0,
3584+ sgot->contents + (h->got.offset &~ (bfd_vma) 1));
3585+ }
3586+
3587+ if (h->needs_copy)
3588+ {
3589+ asection *s;
3590+ Elf_Internal_Rela rela;
3591+ bfd_byte *loc;
3592+
3593+ /* This symbols needs a copy reloc. Set it up. */
3594+
3595+ BFD_ASSERT (h->dynindx != -1);
3596+
3597+ s = bfd_get_linker_section (htab->elf.dynobj, ".rela.bss");
3598+ BFD_ASSERT (s != NULL);
3599+
3600+ rela.r_offset = (h->root.u.def.value
3601+ + h->root.u.def.section->output_section->vma
3602+ + h->root.u.def.section->output_offset);
3603+ rela.r_info = ELF64_R_INFO (h->dynindx, R_MICROBLAZE_COPY);
3604+ rela.r_addend = 0;
3605+ loc = s->contents + s->reloc_count++ * sizeof (Elf64_External_Rela);
3606+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
3607+ }
3608+
3609+ /* Mark some specially defined symbols as absolute. */
3610+ if (h == htab->elf.hdynamic
3611+ || h == htab->elf.hgot
3612+ || h == htab->elf.hplt)
3613+ sym->st_shndx = SHN_ABS;
3614+
3615+ return TRUE;
3616+}
3617+
3618+
3619+/* Finish up the dynamic sections. */
3620+
3621+static bfd_boolean
3622+microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
3623+ struct bfd_link_info *info)
3624+{
3625+ bfd *dynobj;
3626+ asection *sdyn, *sgot;
3627+ struct elf64_mb_link_hash_table *htab;
3628+
3629+ htab = elf64_mb_hash_table (info);
3630+ if (htab == NULL)
3631+ return FALSE;
3632+
3633+ dynobj = htab->elf.dynobj;
3634+
3635+ sdyn = bfd_get_linker_section (dynobj, ".dynamic");
3636+
3637+ if (htab->elf.dynamic_sections_created)
3638+ {
3639+ asection *splt;
3640+ Elf64_External_Dyn *dyncon, *dynconend;
3641+
3642+ splt = bfd_get_linker_section (dynobj, ".plt");
3643+ BFD_ASSERT (splt != NULL && sdyn != NULL);
3644+
3645+ dyncon = (Elf64_External_Dyn *) sdyn->contents;
3646+ dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
3647+ for (; dyncon < dynconend; dyncon++)
3648+ {
3649+ Elf_Internal_Dyn dyn;
3650+ const char *name;
3651+ bfd_boolean size;
3652+
3653+ bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
3654+
3655+ switch (dyn.d_tag)
3656+ {
3657+ case DT_PLTGOT: name = ".got.plt"; size = FALSE; break;
3658+ case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break;
3659+ case DT_JMPREL: name = ".rela.plt"; size = FALSE; break;
3660+ case DT_RELA: name = ".rela.dyn"; size = FALSE; break;
3661+ case DT_RELASZ: name = ".rela.dyn"; size = TRUE; break;
3662+ default: name = NULL; size = FALSE; break;
3663+ }
3664+
3665+ if (name != NULL)
3666+ {
3667+ asection *s;
3668+
3669+ s = bfd_get_section_by_name (output_bfd, name);
3670+ if (s == NULL)
3671+ dyn.d_un.d_val = 0;
3672+ else
3673+ {
3674+ if (! size)
3675+ dyn.d_un.d_ptr = s->vma;
3676+ else
3677+ dyn.d_un.d_val = s->size;
3678+ }
3679+ bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
3680+ }
3681+ }
3682+
3683+ /* Clear the first entry in the procedure linkage table,
3684+ and put a nop in the last four bytes. */
3685+ if (splt->size > 0)
3686+ {
3687+ memset (splt->contents, 0, PLT_ENTRY_SIZE);
3688+ bfd_put_32 (output_bfd, (bfd_vma) 0x80000000 /* nop. */,
3689+ splt->contents + splt->size - 4);
3690+ }
3691+
3692+ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
3693+ }
3694+
3695+ /* Set the first entry in the global offset table to the address of
3696+ the dynamic section. */
3697+ sgot = bfd_get_linker_section (dynobj, ".got.plt");
3698+ if (sgot && sgot->size > 0)
3699+ {
3700+ if (sdyn == NULL)
3701+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
3702+ else
3703+ bfd_put_32 (output_bfd,
3704+ sdyn->output_section->vma + sdyn->output_offset,
3705+ sgot->contents);
3706+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
3707+ }
3708+
3709+ if (htab->sgot && htab->sgot->size > 0)
3710+ elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4;
3711+
3712+ return TRUE;
3713+}
3714+
3715+/* Hook called by the linker routine which adds symbols from an object
3716+ file. We use it to put .comm items in .sbss, and not .bss. */
3717+
3718+static bfd_boolean
3719+microblaze_elf_add_symbol_hook (bfd *abfd,
3720+ struct bfd_link_info *info,
3721+ Elf_Internal_Sym *sym,
3722+ const char **namep ATTRIBUTE_UNUSED,
3723+ flagword *flagsp ATTRIBUTE_UNUSED,
3724+ asection **secp,
3725+ bfd_vma *valp)
3726+{
3727+ if (sym->st_shndx == SHN_COMMON
3728+ && !bfd_link_relocatable (info)
3729+ && sym->st_size <= elf_gp_size (abfd))
3730+ {
3731+ /* Common symbols less than or equal to -G nn bytes are automatically
3732+ put into .sbss. */
3733+ *secp = bfd_make_section_old_way (abfd, ".sbss");
3734+ if (*secp == NULL
3735+ || ! bfd_set_section_flags (abfd, *secp, SEC_IS_COMMON))
3736+ return FALSE;
3737+
3738+ *valp = sym->st_size;
3739+ }
3740+
3741+ return TRUE;
3742+}
3743+
3744+#define TARGET_LITTLE_SYM microblaze_elf64_le_vec
3745+#define TARGET_LITTLE_NAME "elf64-microblazeel"
3746+
3747+#define TARGET_BIG_SYM microblaze_elf64_vec
3748+#define TARGET_BIG_NAME "elf64-microblaze"
3749+
3750+#define ELF_ARCH bfd_arch_microblaze
3751+#define ELF_TARGET_ID MICROBLAZE_ELF_DATA
3752+#define ELF_MACHINE_CODE EM_MICROBLAZE
3753+#define ELF_MACHINE_ALT1 EM_MICROBLAZE_OLD
3754+#define ELF_MAXPAGESIZE 0x1000
3755+#define elf_info_to_howto microblaze_elf_info_to_howto
3756+#define elf_info_to_howto_rel NULL
3757+
3758+#define bfd_elf64_bfd_reloc_type_lookup microblaze_elf_reloc_type_lookup
3759+#define bfd_elf64_bfd_is_local_label_name microblaze_elf_is_local_label_name
3760+#define elf_backend_relocate_section microblaze_elf_relocate_section
3761+#define bfd_elf64_bfd_relax_section microblaze_elf_relax_section
3762+#define bfd_elf64_bfd_merge_private_bfd_data microblaze_elf_merge_private_bfd_data
3763+#define bfd_elf64_bfd_reloc_name_lookup microblaze_elf_reloc_name_lookup
3764+
3765+#define elf_backend_gc_mark_hook microblaze_elf_gc_mark_hook
3766+#define elf_backend_gc_sweep_hook microblaze_elf_gc_sweep_hook
3767+#define elf_backend_check_relocs microblaze_elf_check_relocs
3768+#define elf_backend_copy_indirect_symbol microblaze_elf_copy_indirect_symbol
3769+#define bfd_elf64_bfd_link_hash_table_create microblaze_elf_link_hash_table_create
3770+#define elf_backend_can_gc_sections 1
3771+#define elf_backend_can_refcount 1
3772+#define elf_backend_want_got_plt 1
3773+#define elf_backend_plt_readonly 1
3774+#define elf_backend_got_header_size 12
3775+#define elf_backend_rela_normal 1
3776+
3777+#define elf_backend_adjust_dynamic_symbol microblaze_elf_adjust_dynamic_symbol
3778+#define elf_backend_create_dynamic_sections microblaze_elf_create_dynamic_sections
3779+#define elf_backend_finish_dynamic_sections microblaze_elf_finish_dynamic_sections
3780+#define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
3781+#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
3782+#define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
3783+
3784+#include "elf64-target.h"
3785diff --git a/bfd/targets.c b/bfd/targets.c
3786index 531703d..8ddbd39 100644
3787--- a/bfd/targets.c
3788+++ b/bfd/targets.c
3789@@ -704,6 +704,8 @@ extern const bfd_target mep_elf32_le_vec;
3790 extern const bfd_target metag_elf32_vec;
3791 extern const bfd_target microblaze_elf32_vec;
3792 extern const bfd_target microblaze_elf32_le_vec;
3793+extern const bfd_target microblaze_elf64_vec;
3794+extern const bfd_target microblaze_elf64_le_vec;
3795 extern const bfd_target mips_ecoff_be_vec;
3796 extern const bfd_target mips_ecoff_le_vec;
3797 extern const bfd_target mips_ecoff_bele_vec;
3798@@ -1067,6 +1069,10 @@ static const bfd_target * const _bfd_target_vector[] =
3799
3800 &metag_elf32_vec,
3801
3802+#ifdef BFD64
3803+ &microblaze_elf64_vec,
3804+ &microblaze_elf64_le_vec,
3805+#endif
3806 &microblaze_elf32_vec,
3807
3808 &mips_ecoff_be_vec,
3809diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
3810index f1d97b9..eb7998f 100644
3811--- a/gas/config/tc-microblaze.c
3812+++ b/gas/config/tc-microblaze.c
3813@@ -35,10 +35,13 @@
3814 #define streq(a,b) (strcmp (a, b) == 0)
3815 #endif
3816
3817+static int microblaze_arch_size = 0;
3818+
3819 #define OPTION_EB (OPTION_MD_BASE + 0)
3820 #define OPTION_EL (OPTION_MD_BASE + 1)
3821 #define OPTION_LITTLE (OPTION_MD_BASE + 2)
3822 #define OPTION_BIG (OPTION_MD_BASE + 3)
3823+#define OPTION_M64 (OPTION_MD_BASE + 4)
3824
3825 void microblaze_generate_symbol (char *sym);
3826 static bfd_boolean check_spl_reg (unsigned *);
3827@@ -773,6 +776,74 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
3828 return new_pointer;
3829 }
3830
3831+ static char *
3832+parse_imml (char * s, expressionS * e, long min, long max)
3833+{
3834+ char *new_pointer;
3835+ char *atp;
3836+ int itype, ilen;
3837+
3838+ ilen = 0;
3839+
3840+ /* Find the start of "@GOT" or "@PLT" suffix (if any) */
3841+ for (atp = s; *atp != '@'; atp++)
3842+ if (is_end_of_line[(unsigned char) *atp])
3843+ break;
3844+
3845+ if (*atp == '@')
3846+ {
3847+ itype = match_imm (atp + 1, &ilen);
3848+ if (itype != 0)
3849+ {
3850+ *atp = 0;
3851+ e->X_md = itype;
3852+ }
3853+ else
3854+ {
3855+ atp = NULL;
3856+ e->X_md = 0;
3857+ ilen = 0;
3858+ }
3859+ *atp = 0;
3860+ }
3861+ else
3862+ {
3863+ atp = NULL;
3864+ e->X_md = 0;
3865+ }
3866+
3867+ if (atp && !GOT_symbol)
3868+ {
3869+ GOT_symbol = symbol_find_or_make (GOT_SYMBOL_NAME);
3870+ }
3871+
3872+ new_pointer = parse_exp (s, e);
3873+
3874+ if (!GOT_symbol && ! strncmp (s, GOT_SYMBOL_NAME, 20))
3875+ {
3876+ GOT_symbol = symbol_find_or_make (GOT_SYMBOL_NAME);
3877+ }
3878+
3879+ if (e->X_op == O_absent)
3880+ ; /* An error message has already been emitted. */
3881+ else if ((e->X_op != O_constant && e->X_op != O_symbol) )
3882+ as_fatal (_("operand must be a constant or a label"));
3883+ else if ((e->X_op == O_constant) && ((long) e->X_add_number < min
3884+ || (long) e->X_add_number > max))
3885+ {
3886+ as_fatal (_("operand must be absolute in range %ld..%ld, not %ld"),
3887+ min, max, (long) e->X_add_number);
3888+ }
3889+
3890+ if (atp)
3891+ {
3892+ *atp = '@'; /* restore back (needed?) */
3893+ if (new_pointer >= atp)
3894+ new_pointer += ilen + 1; /* sizeof (imm_suffix) + 1 for '@' */
3895+ }
3896+ return new_pointer;
3897+}
3898+
3899 static char *
3900 check_got (int * got_type, int * got_len)
3901 {
3902@@ -920,6 +991,7 @@ md_assemble (char * str)
3903 unsigned int immed, immed2, temp;
3904 expressionS exp;
3905 char name[20];
3906+ long immedl;
3907
3908 /* Drop leading whitespace. */
3909 while (ISSPACE (* str))
3910@@ -1129,7 +1201,7 @@ md_assemble (char * str)
3911 }
3912 break;
3913
3914- case INST_TYPE_RD_R1_IMM5:
3915+ case INST_TYPE_RD_R1_IMMS:
3916 if (strcmp (op_end, ""))
3917 op_end = parse_reg (op_end + 1, &reg1); /* Get rd. */
3918 else
3919@@ -1163,16 +1235,22 @@ md_assemble (char * str)
3920 immed = exp.X_add_number;
3921 }
3922
3923- if (immed != (immed % 32))
3924+ if ((immed != (immed % 32)) &&
3925+ (opcode->instr == bslli || opcode->instr == bsrai || opcode->instr == bsrli))
3926 {
3927 as_warn (_("Shift value > 32. using <value %% 32>"));
3928 immed = immed % 32;
3929 }
3930+ else if (immed != (immed % 64))
3931+ {
3932+ as_warn (_("Shift value > 64. using <value %% 64>"));
3933+ immed = immed % 64;
3934+ }
3935 inst |= (reg1 << RD_LOW) & RD_MASK;
3936 inst |= (reg2 << RA_LOW) & RA_MASK;
3937- inst |= (immed << IMM_LOW) & IMM5_MASK;
3938+ inst |= (immed << IMM_LOW) & IMM6_MASK;
3939 break;
3940- case INST_TYPE_RD_R1_IMM5_IMM5:
3941+ case INST_TYPE_RD_R1_IMMW_IMMS:
3942 if (strcmp (op_end, ""))
3943 op_end = parse_reg (op_end + 1, &reg1); /* Get rd. */
3944 else
3945@@ -1196,7 +1274,7 @@ md_assemble (char * str)
3946
3947 /* Width immediate value. */
3948 if (strcmp (op_end, ""))
3949- op_end = parse_imm (op_end + 1, &exp, MIN_IMM_WIDTH, MAX_IMM_WIDTH);
3950+ op_end = parse_imm (op_end + 1, &exp, MIN_IMM, MAX_IMM);
3951 else
3952 as_fatal (_("Error in statement syntax"));
3953 if (exp.X_op != O_constant)
3954@@ -1208,6 +1286,8 @@ md_assemble (char * str)
3955 immed = exp.X_add_number;
3956 if (opcode->instr == bsefi && immed > 31)
3957 as_fatal (_("Width value must be less than 32"));
3958+ else if (opcode->instr == bslefi && immed > 63)
3959+ as_fatal (_("Width value must be less than 64"));
3960
3961 /* Shift immediate value. */
3962 if (strcmp (op_end, ""))
3963@@ -1215,32 +1295,40 @@ md_assemble (char * str)
3964 else
3965 as_fatal (_("Error in statement syntax"));
3966 if (exp.X_op != O_constant)
3967- {
3968+ {
3969 as_warn (_("Symbol used as immediate shift value for bit field instruction"));
3970 immed2 = 0;
3971 }
3972 else
3973- {
3974+ {
3975 output = frag_more (isize);
3976 immed2 = exp.X_add_number;
3977- }
3978- if (immed2 != (immed2 % 32))
3979- {
3980- as_warn (_("Shift value greater than 32. using <value %% 32>"));
3981+ }
3982+ if ((immed2 != (immed2 % 32)) && (opcode->instr == bsefi || opcode->instr == bsifi))
3983+ {
3984+
3985+ as_warn (_("Shift value greater than 32. using <value %% 32>"));
3986 immed2 = immed2 % 32;
3987 }
3988+ else if (immed2 != (immed2 % 64))
3989+ {
3990+ as_warn (_("Shift value greater than 64. using <value %% 64>"));
3991+ immed2 = immed2 % 64;
3992+ }
3993
3994 /* Check combined value. */
3995- if (immed + immed2 > 32)
3996+ if ((immed + immed2 > 32) && (opcode->instr == bsefi || opcode->instr == bsifi))
3997 as_fatal (_("Width value + shift value must not be greater than 32"));
3998
3999+ else if (immed + immed2 > 64)
4000+ as_fatal (_("Width value + shift value must not be greater than 64"));
4001 inst |= (reg1 << RD_LOW) & RD_MASK;
4002 inst |= (reg2 << RA_LOW) & RA_MASK;
4003- if (opcode->instr == bsefi)
4004- inst |= (immed & IMM5_MASK) << IMM_WIDTH_LOW; /* bsefi */
4005+ if (opcode->instr == bsefi || opcode->instr == bslefi)
4006+ inst |= (immed & IMM6_MASK) << IMM_WIDTH_LOW; /* bsefi or bslefi */
4007 else
4008- inst |= ((immed + immed2 - 1) & IMM5_MASK) << IMM_WIDTH_LOW; /* bsifi */
4009- inst |= (immed2 << IMM_LOW) & IMM5_MASK;
4010+ inst |= ((immed + immed2 - 1) & IMM6_MASK) << IMM_WIDTH_LOW; /* bsifi or bslifi */
4011+ inst |= (immed2 << IMM_LOW) & IMM6_MASK;
4012 break;
4013 case INST_TYPE_R1_R2:
4014 if (strcmp (op_end, ""))
4015@@ -1808,6 +1896,142 @@ md_assemble (char * str)
4016 }
4017 inst |= (immed << IMM_MBAR);
4018 break;
4019+ /* For 64-bit instructions */
4020+ case INST_TYPE_RD_R1_IMML:
4021+ if (strcmp (op_end, ""))
4022+ op_end = parse_reg (op_end + 1, &reg1); /* Get rd. */
4023+ else
4024+ {
4025+ as_fatal (_("Error in statement syntax"));
4026+ reg1 = 0;
4027+ }
4028+ if (strcmp (op_end, ""))
4029+ op_end = parse_reg (op_end + 1, &reg2); /* Get r1. */
4030+ else
4031+ {
4032+ as_fatal (_("Error in statement syntax"));
4033+ reg2 = 0;
4034+ }
4035+ if (strcmp (op_end, ""))
4036+ op_end = parse_imml (op_end + 1, & exp, MIN_IMML, MAX_IMML);
4037+ else
4038+ as_fatal (_("Error in statement syntax"));
4039+
4040+ /* Check for spl registers. */
4041+ if (check_spl_reg (& reg1))
4042+ as_fatal (_("Cannot use special register with this instruction"));
4043+ if (check_spl_reg (& reg2))
4044+ as_fatal (_("Cannot use special register with this instruction"));
4045+
4046+ if (exp.X_op != O_constant)
4047+ {
4048+ char *opc = NULL;
4049+ relax_substateT subtype;
4050+
4051+ if (exp.X_md != 0)
4052+ subtype = get_imm_otype(exp.X_md);
4053+ else
4054+ subtype = opcode->inst_offset_type;
4055+
4056+ output = frag_var (rs_machine_dependent,
4057+ isize * 2, /* maxm of 2 words. */
4058+ isize * 2, /* minm of 2 words. */
4059+ subtype, /* PC-relative or not. */
4060+ exp.X_add_symbol,
4061+ exp.X_add_number,
4062+ opc);
4063+ immedl = 0L;
4064+ }
4065+ else
4066+ {
4067+ output = frag_more (isize);
4068+ immedl = exp.X_add_number;
4069+
4070+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
4071+ if (opcode1 == NULL)
4072+ {
4073+ as_bad (_("unknown opcode \"%s\""), "imml");
4074+ return;
4075+ }
4076+
4077+ inst1 = opcode1->bit_sequence;
4078+ inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
4079+ output[0] = INST_BYTE0 (inst1);
4080+ output[1] = INST_BYTE1 (inst1);
4081+ output[2] = INST_BYTE2 (inst1);
4082+ output[3] = INST_BYTE3 (inst1);
4083+ output = frag_more (isize);
4084+ }
4085+
4086+ inst |= (reg1 << RD_LOW) & RD_MASK;
4087+ inst |= (reg2 << RA_LOW) & RA_MASK;
4088+ inst |= (immedl << IMM_LOW) & IMM_MASK;
4089+ break;
4090+
4091+ case INST_TYPE_R1_IMML:
4092+ if (strcmp (op_end, ""))
4093+ op_end = parse_reg (op_end + 1, &reg1); /* Get r1. */
4094+ else
4095+ {
4096+ as_fatal (_("Error in statement syntax"));
4097+ reg1 = 0;
4098+ }
4099+ if (strcmp (op_end, ""))
4100+ op_end = parse_imml (op_end + 1, & exp, MIN_IMM, MAX_IMM);
4101+ else
4102+ as_fatal (_("Error in statement syntax"));
4103+
4104+ /* Check for spl registers. */
4105+ if (check_spl_reg (&reg1))
4106+ as_fatal (_("Cannot use special register with this instruction"));
4107+
4108+ if (exp.X_op != O_constant)
4109+ {
4110+ char *opc = NULL;
4111+ relax_substateT subtype;
4112+
4113+ if (exp.X_md != 0)
4114+ subtype = get_imm_otype(exp.X_md);
4115+ else
4116+ subtype = opcode->inst_offset_type;
4117+
4118+ output = frag_var (rs_machine_dependent,
4119+ isize * 2, /* maxm of 2 words. */
4120+ isize * 2, /* minm of 2 words. */
4121+ subtype, /* PC-relative or not. */
4122+ exp.X_add_symbol,
4123+ exp.X_add_number,
4124+ opc);
4125+ immedl = 0L;
4126+ }
4127+ else
4128+ {
4129+ output = frag_more (isize);
4130+ immedl = exp.X_add_number;
4131+
4132+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
4133+ if (opcode1 == NULL)
4134+ {
4135+ as_bad (_("unknown opcode \"%s\""), "imml");
4136+ return;
4137+ }
4138+
4139+ inst1 = opcode1->bit_sequence;
4140+ inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
4141+ output[0] = INST_BYTE0 (inst1);
4142+ output[1] = INST_BYTE1 (inst1);
4143+ output[2] = INST_BYTE2 (inst1);
4144+ output[3] = INST_BYTE3 (inst1);
4145+ output = frag_more (isize);
4146+ }
4147+
4148+ inst |= (reg1 << RA_LOW) & RA_MASK;
4149+ inst |= (immedl << IMM_LOW) & IMM_MASK;
4150+ break;
4151+
4152+ case INST_TYPE_IMML:
4153+ as_fatal (_("An IMML instruction should not be present in the .s file"));
4154+ break;
4155
4156 default:
4157 as_fatal (_("unimplemented opcode \"%s\""), name);
4158@@ -1918,6 +2142,7 @@ struct option md_longopts[] =
4159 {"EL", no_argument, NULL, OPTION_EL},
4160 {"mlittle-endian", no_argument, NULL, OPTION_LITTLE},
4161 {"mbig-endian", no_argument, NULL, OPTION_BIG},
4162+ {"m64", no_argument, NULL, OPTION_M64},
4163 { NULL, no_argument, NULL, 0}
4164 };
4165
4166@@ -2569,6 +2794,18 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
4167 return rel;
4168 }
4169
4170+/* Called by TARGET_FORMAT. */
4171+const char *
4172+microblaze_target_format (void)
4173+{
4174+
4175+ if (microblaze_arch_size == 64)
4176+ return "elf64-microblazeel";
4177+ else
4178+ return target_big_endian ? "elf32-microblaze" : "elf32-microblazeel";
4179+}
4180+
4181+
4182 int
4183 md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
4184 {
4185@@ -2582,6 +2819,10 @@ md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
4186 case OPTION_LITTLE:
4187 target_big_endian = 0;
4188 break;
4189+ case OPTION_M64:
4190+ //if (arg != NULL && strcmp (arg, "64") == 0)
4191+ microblaze_arch_size = 64;
4192+ break;
4193 default:
4194 return 0;
4195 }
4196@@ -2597,6 +2838,7 @@ md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
4197 fprintf (stream, _(" MicroBlaze specific assembler options:\n"));
4198 fprintf (stream, " -%-23s%s\n", "mbig-endian", N_("assemble for a big endian cpu"));
4199 fprintf (stream, " -%-23s%s\n", "mlittle-endian", N_("assemble for a little endian cpu"));
4200+ fprintf (stream, " -%-23s%s\n", "m64", N_("generate 64-bit elf"));
4201 }
4202
4203
4204diff --git a/gas/config/tc-microblaze.h b/gas/config/tc-microblaze.h
4205index 1263f57..7a991ae 100644
4206--- a/gas/config/tc-microblaze.h
4207+++ b/gas/config/tc-microblaze.h
4208@@ -78,7 +78,9 @@ extern const struct relax_type md_relax_table[];
4209
4210 #ifdef OBJ_ELF
4211
4212-#define TARGET_FORMAT (target_big_endian ? "elf32-microblaze" : "elf32-microblazeel")
4213+#define TARGET_FORMAT microblaze_target_format()
4214+extern const char *microblaze_target_format (void);
4215+//#define TARGET_FORMAT (target_big_endian ? "elf32-microblaze" : "elf32-microblazeel")
4216
4217 #define ELF_TC_SPECIAL_SECTIONS \
4218 { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
4219diff --git a/include/elf/common.h b/include/elf/common.h
4220index 773f378..cd2114e 100644
4221--- a/include/elf/common.h
4222+++ b/include/elf/common.h
4223@@ -339,6 +339,7 @@
4224 #define EM_RISCV 243 /* RISC-V */
4225 #define EM_LANAI 244 /* Lanai 32-bit processor. */
4226 #define EM_BPF 247 /* Linux BPF – in-kernel virtual machine. */
4227+#define EM_MB_64 248 /* Xilinx MicroBlaze 32-bit RISC soft processor core */
4228 #define EM_NFP 250 /* Netronome Flow Processor. */
4229
4230 /* If it is necessary to assign new unofficial EM_* values, please pick large
4231diff --git a/ld/Makefile.am b/ld/Makefile.am
4232index d86ad09..f531471 100644
4233--- a/ld/Makefile.am
4234+++ b/ld/Makefile.am
4235@@ -420,6 +420,8 @@ ALL_64_EMULATION_SOURCES = \
4236 eelf32ltsmipn32.c \
4237 eelf32ltsmipn32_fbsd.c \
4238 eelf32mipswindiss.c \
4239+ eelf64microblazeel.c \
4240+ eelf64microblaze.c \
4241 eelf64_aix.c \
4242 eelf64_ia64.c \
4243 eelf64_ia64_fbsd.c \
4244@@ -1688,6 +1690,12 @@ eelf32_x86_64_nacl.c: $(srcdir)/emulparams/elf32_x86_64_nacl.sh \
4245 $(srcdir)/emulparams/elf_nacl.sh \
4246 $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
4247
4248+eelf64microblazeel.c: $(srcdir)/emulparams/elf64microblazeel.sh \
4249+ $(ELF_DEPS) $(srcdir)/scripttempl/elfmicroblaze.sc ${GEN_DEPENDS}
4250+
4251+eelf64microblaze.c: $(srcdir)/emulparams/elf64microblaze.sh \
4252+ $(ELF_DEPS) $(srcdir)/scripttempl/elfmicroblaze.sc ${GEN_DEPENDS}
4253+
4254 eelf64_aix.c: $(srcdir)/emulparams/elf64_aix.sh \
4255 $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
4256
4257diff --git a/ld/Makefile.in b/ld/Makefile.in
4258index 4792b2b..1f75a81 100644
4259--- a/ld/Makefile.in
4260+++ b/ld/Makefile.in
4261@@ -905,6 +905,8 @@ ALL_64_EMULATION_SOURCES = \
4262 eelf32ltsmipn32.c \
4263 eelf32ltsmipn32_fbsd.c \
4264 eelf32mipswindiss.c \
4265+ eelf64microblazeel.c \
4266+ eelf64microblaze.c \
4267 eelf64_aix.c \
4268 eelf64_ia64.c \
4269 eelf64_ia64_fbsd.c \
4270@@ -1350,6 +1352,8 @@ distclean-compile:
4271 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32xc16xs.Po@am__quote@
4272 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32xstormy16.Po@am__quote@
4273 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32xtensa.Po@am__quote@
4274+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64microblazeel.Po@am__quote@
4275+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64microblaze.Po@am__quote@
4276 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64_aix.Po@am__quote@
4277 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64_ia64.Po@am__quote@
4278 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64_ia64_fbsd.Po@am__quote@
4279@@ -3289,6 +3293,12 @@ eelf32_x86_64_nacl.c: $(srcdir)/emulparams/elf32_x86_64_nacl.sh \
4280 $(srcdir)/emulparams/elf_nacl.sh \
4281 $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
4282
4283+eelf64microblazeel.c: $(srcdir)/emulparams/elf64microblazeel.sh \
4284+ $(ELF_DEPS) $(srcdir)/scripttempl/elfmicroblaze.sc ${GEN_DEPENDS}
4285+
4286+eelf64microblaze.c: $(srcdir)/emulparams/elf64microblaze.sh \
4287+ $(ELF_DEPS) $(srcdir)/scripttempl/elfmicroblaze.sc ${GEN_DEPENDS}
4288+
4289 eelf64_aix.c: $(srcdir)/emulparams/elf64_aix.sh \
4290 $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
4291
4292diff --git a/ld/configure.tgt b/ld/configure.tgt
4293index fad8b2e..25615ea 100644
4294--- a/ld/configure.tgt
4295+++ b/ld/configure.tgt
4296@@ -419,6 +419,9 @@ microblaze*-linux*) targ_emul="elf32mb_linux"
4297 microblazeel*) targ_emul=elf32microblazeel
4298 targ_extra_emuls=elf32microblaze
4299 ;;
4300+microblazeel64*) targ_emul=elf64microblazeel
4301+ targ_extra_emuls=elf64microblaze
4302+ ;;
4303 microblaze*) targ_emul=elf32microblaze
4304 targ_extra_emuls=elf32microblazeel
4305 ;;
4306diff --git a/ld/emulparams/elf64microblaze.sh b/ld/emulparams/elf64microblaze.sh
4307new file mode 100644
4308index 0000000..9c7b0eb
4309--- /dev/null
4310+++ b/ld/emulparams/elf64microblaze.sh
4311@@ -0,0 +1,23 @@
4312+SCRIPT_NAME=elfmicroblaze
4313+OUTPUT_FORMAT="elf64-microblazeel"
4314+#BIG_OUTPUT_FORMAT="elf64-microblaze"
4315+LITTLE_OUTPUT_FORMAT="elf64-microblazeel"
4316+#TEXT_START_ADDR=0
4317+NONPAGED_TEXT_START_ADDR=0x28
4318+ALIGNMENT=4
4319+MAXPAGESIZE=4
4320+ARCH=microblaze
4321+EMBEDDED=yes
4322+
4323+NOP=0x80000000
4324+
4325+# Hmmm, there's got to be a better way. This sets the stack to the
4326+# top of the simulator memory (2^19 bytes).
4327+#PAGE_SIZE=0x1000
4328+#DATA_ADDR=0x10000
4329+#OTHER_RELOCATING_SECTIONS='.stack 0x7000 : { _stack = .; *(.stack) }'
4330+#$@{RELOCATING+ PROVIDE (__stack = 0x7000);@}
4331+#OTHER_RELOCATING_SECTIONS='PROVIDE (_stack = _end + 0x1000);'
4332+
4333+TEMPLATE_NAME=elf32
4334+#GENERATE_SHLIB_SCRIPT=yes
4335diff --git a/ld/emulparams/elf64microblazeel.sh b/ld/emulparams/elf64microblazeel.sh
4336new file mode 100644
4337index 0000000..9c7b0eb
4338--- /dev/null
4339+++ b/ld/emulparams/elf64microblazeel.sh
4340@@ -0,0 +1,23 @@
4341+SCRIPT_NAME=elfmicroblaze
4342+OUTPUT_FORMAT="elf64-microblazeel"
4343+#BIG_OUTPUT_FORMAT="elf64-microblaze"
4344+LITTLE_OUTPUT_FORMAT="elf64-microblazeel"
4345+#TEXT_START_ADDR=0
4346+NONPAGED_TEXT_START_ADDR=0x28
4347+ALIGNMENT=4
4348+MAXPAGESIZE=4
4349+ARCH=microblaze
4350+EMBEDDED=yes
4351+
4352+NOP=0x80000000
4353+
4354+# Hmmm, there's got to be a better way. This sets the stack to the
4355+# top of the simulator memory (2^19 bytes).
4356+#PAGE_SIZE=0x1000
4357+#DATA_ADDR=0x10000
4358+#OTHER_RELOCATING_SECTIONS='.stack 0x7000 : { _stack = .; *(.stack) }'
4359+#$@{RELOCATING+ PROVIDE (__stack = 0x7000);@}
4360+#OTHER_RELOCATING_SECTIONS='PROVIDE (_stack = _end + 0x1000);'
4361+
4362+TEMPLATE_NAME=elf32
4363+#GENERATE_SHLIB_SCRIPT=yes
4364diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
4365index 5101ceb..09757d1 100644
4366--- a/opcodes/microblaze-dis.c
4367+++ b/opcodes/microblaze-dis.c
4368@@ -33,6 +33,7 @@
4369 #define get_field_r1(instr) get_field (instr, RA_MASK, RA_LOW)
4370 #define get_field_r2(instr) get_field (instr, RB_MASK, RB_LOW)
4371 #define get_int_field_imm(instr) ((instr & IMM_MASK) >> IMM_LOW)
4372+#define get_int_field_imml(instr) ((instr & IMML_MASK) >> IMM_LOW)
4373 #define get_int_field_r1(instr) ((instr & RA_MASK) >> RA_LOW)
4374
4375
4376@@ -56,11 +57,20 @@ get_field_imm (long instr)
4377 }
4378
4379 static char *
4380-get_field_imm5 (long instr)
4381+get_field_imml (long instr)
4382 {
4383 char tmpstr[25];
4384
4385- sprintf (tmpstr, "%d", (short)((instr & IMM5_MASK) >> IMM_LOW));
4386+ sprintf (tmpstr, "%d", (short)((instr & IMML_MASK) >> IMM_LOW));
4387+ return (strdup (tmpstr));
4388+}
4389+
4390+static char *
4391+get_field_imms (long instr)
4392+{
4393+ char tmpstr[25];
4394+
4395+ sprintf (tmpstr, "%d", (short)((instr & IMM6_MASK) >> IMM_LOW));
4396 return (strdup (tmpstr));
4397 }
4398
4399@@ -74,14 +84,14 @@ get_field_imm5_mbar (long instr)
4400 }
4401
4402 static char *
4403-get_field_imm5width (long instr)
4404+get_field_immw (long instr)
4405 {
4406 char tmpstr[25];
4407
4408 if (instr & 0x00004000)
4409- sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW))); /* bsefi */
4410+ sprintf (tmpstr, "%d", (short)(((instr & IMM6_WIDTH_MASK) >> IMM_WIDTH_LOW))); /* bsefi */
4411 else
4412- sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW) - ((instr & IMM5_MASK) >> IMM_LOW) + 1)); /* bsifi */
4413+ sprintf (tmpstr, "%d", (short)(((instr & IMM6_WIDTH_MASK) >> IMM_WIDTH_LOW) - ((instr & IMM6_MASK) >> IMM_LOW) + 1)); /* bsifi */
4414 return (strdup (tmpstr));
4415 }
4416
4417@@ -286,9 +296,13 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
4418 }
4419 }
4420 break;
4421- case INST_TYPE_RD_R1_IMM5:
4422+ case INST_TYPE_RD_R1_IMML:
4423+ print_func (stream, "\t%s, %s, %s", get_field_rd (inst),
4424+ get_field_r1(inst), get_field_imm (inst));
4425+ /* TODO: Also print symbol */
4426+ case INST_TYPE_RD_R1_IMMS:
4427 print_func (stream, "\t%s, %s, %s", get_field_rd (inst),
4428- get_field_r1(inst), get_field_imm5 (inst));
4429+ get_field_r1(inst), get_field_imms (inst));
4430 break;
4431 case INST_TYPE_RD_RFSL:
4432 print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_rfsl (inst));
4433@@ -386,6 +400,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
4434 }
4435 }
4436 break;
4437+ case INST_TYPE_IMML:
4438+ print_func (stream, "\t%s", get_field_imml (inst));
4439+ /* TODO: Also print symbol */
4440+ break;
4441 case INST_TYPE_RD_R2:
4442 print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_r2 (inst));
4443 break;
4444@@ -409,9 +427,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
4445 case INST_TYPE_NONE:
4446 break;
4447 /* For bit field insns. */
4448- case INST_TYPE_RD_R1_IMM5_IMM5:
4449- print_func (stream, "\t%s, %s, %s, %s", get_field_rd (inst),get_field_r1(inst),get_field_imm5width (inst), get_field_imm5 (inst));
4450- break;
4451+ case INST_TYPE_RD_R1_IMMW_IMMS:
4452+ print_func (stream, "\t%s, %s, %s, %s", get_field_rd (inst), get_field_r1(inst),
4453+ get_field_immw (inst), get_field_imms (inst));
4454+ break;
4455 /* For tuqula instruction */
4456 case INST_TYPE_RD:
4457 print_func (stream, "\t%s", get_field_rd (inst));
4458diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
4459index 4bc400a..c88092d 100644
4460--- a/opcodes/microblaze-opc.h
4461+++ b/opcodes/microblaze-opc.h
4462@@ -40,7 +40,7 @@
4463 #define INST_TYPE_RD_SPECIAL 11
4464 #define INST_TYPE_R1 12
4465 /* New instn type for barrel shift imms. */
4466-#define INST_TYPE_RD_R1_IMM5 13
4467+#define INST_TYPE_RD_R1_IMMS 13
4468 #define INST_TYPE_RD_RFSL 14
4469 #define INST_TYPE_R1_RFSL 15
4470
4471@@ -60,7 +60,13 @@
4472 #define INST_TYPE_IMM5 20
4473
4474 /* For bsefi and bsifi */
4475-#define INST_TYPE_RD_R1_IMM5_IMM5 21
4476+#define INST_TYPE_RD_R1_IMMW_IMMS 21
4477+
4478+/* For 64-bit instructions */
4479+#define INST_TYPE_IMML 22
4480+#define INST_TYPE_RD_R1_IMML 23
4481+#define INST_TYPE_R1_IMML 24
4482+#define INST_TYPE_RD_R1_IMMW_IMMS 21
4483
4484 #define INST_TYPE_NONE 25
4485
4486@@ -91,13 +97,14 @@
4487 #define OPCODE_MASK_H24 0xFC1F07FF /* High 6, bits 20-16 and low 11 bits. */
4488 #define OPCODE_MASK_H124 0xFFFF07FF /* High 16, and low 11 bits. */
4489 #define OPCODE_MASK_H1234 0xFFFFFFFF /* All 32 bits. */
4490-#define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22. */
4491-#define OPCODE_MASK_H3B 0xFC00C600 /* High 6 bits and bits 16, 17, 21, 22. */
4492+#define OPCODE_MASK_H3 0xFC000700 /* High 6 bits and bits 21, 22, 23. */
4493+#define OPCODE_MASK_H3B 0xFC00E600 /* High 6 bits and bits 16, 17, 18, 21, 22. */
4494 #define OPCODE_MASK_H32 0xFC00FC00 /* High 6 bits and bit 16-21. */
4495-#define OPCODE_MASK_H32B 0xFC00C000 /* High 6 bits and bit 16, 17. */
4496+#define OPCODE_MASK_H32B 0xFC00E000 /* High 6 bits and bit 16, 17, 18. */
4497 #define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits. */
4498 #define OPCODE_MASK_H35B 0xFC0004FF /* High 6 bits and low 9 bits. */
4499 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
4500+#define OPCODE_MASK_H8 0xFF000000 /* High 8 bits only. */
4501
4502 /* New Mask for msrset, msrclr insns. */
4503 #define OPCODE_MASK_H23N 0xFC1F8000 /* High 6 and bits 11 - 16. */
4504@@ -107,7 +114,7 @@
4505 #define DELAY_SLOT 1
4506 #define NO_DELAY_SLOT 0
4507
4508-#define MAX_OPCODES 301
4509+#define MAX_OPCODES 412
4510
4511 struct op_code_struct
4512 {
4513@@ -125,6 +132,7 @@ struct op_code_struct
4514 /* More info about output format here. */
4515 } opcodes[MAX_OPCODES] =
4516 {
4517+ /* 32-bit instructions */
4518 {"add", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x00000000, OPCODE_MASK_H4, add, arithmetic_inst },
4519 {"rsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H4, rsub, arithmetic_inst },
4520 {"addc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x08000000, OPCODE_MASK_H4, addc, arithmetic_inst },
4521@@ -161,11 +169,11 @@ struct op_code_struct
4522 {"ncget", INST_TYPE_RD_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C006000, OPCODE_MASK_H32, ncget, anyware_inst },
4523 {"ncput", INST_TYPE_R1_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00E000, OPCODE_MASK_H32, ncput, anyware_inst },
4524 {"muli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x60000000, OPCODE_MASK_H, muli, mult_inst },
4525- {"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3, bslli, barrel_shift_inst },
4526- {"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3, bsrai, barrel_shift_inst },
4527- {"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3, bsrli, barrel_shift_inst },
4528- {"bsefi", INST_TYPE_RD_R1_IMM5_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64004000, OPCODE_MASK_H32B, bsefi, barrel_shift_inst },
4529- {"bsifi", INST_TYPE_RD_R1_IMM5_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64008000, OPCODE_MASK_H32B, bsifi, barrel_shift_inst },
4530+ {"bslli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3B, bslli, barrel_shift_inst },
4531+ {"bsrai", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3B, bsrai, barrel_shift_inst },
4532+ {"bsrli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3B, bsrli, barrel_shift_inst },
4533+ {"bsefi", INST_TYPE_RD_R1_IMMW_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64004000, OPCODE_MASK_H32B, bsefi, barrel_shift_inst },
4534+ {"bsifi", INST_TYPE_RD_R1_IMMW_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64008000, OPCODE_MASK_H32B, bsifi, barrel_shift_inst },
4535 {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst },
4536 {"and", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000000, OPCODE_MASK_H4, microblaze_and, logical_inst },
4537 {"xor", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000000, OPCODE_MASK_H4, microblaze_xor, logical_inst },
4538@@ -425,6 +433,129 @@ struct op_code_struct
4539 {"suspend", INST_TYPE_NONE, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBB020004, OPCODE_MASK_HN, invalid_inst, special_inst }, /* translates to mbar 24. */
4540 {"swapb", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E0, OPCODE_MASK_H4, swapb, arithmetic_inst },
4541 {"swaph", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E2, OPCODE_MASK_H4, swaph, arithmetic_inst },
4542+
4543+ /* 64-bit instructions */
4544+ {"addl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x00000100, OPCODE_MASK_H4, addl, arithmetic_inst },
4545+ {"rsubl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000100, OPCODE_MASK_H4, rsubl, arithmetic_inst },
4546+ {"addlc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x08000100, OPCODE_MASK_H4, addlc, arithmetic_inst },
4547+ {"rsublc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x0C000100, OPCODE_MASK_H4, rsublc, arithmetic_inst },
4548+ {"addlk", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x10000100, OPCODE_MASK_H4, addlk, arithmetic_inst },
4549+ {"rsublk", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000100, OPCODE_MASK_H4, rsublk, arithmetic_inst },
4550+ {"addlkc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x18000100, OPCODE_MASK_H4, addlkc, arithmetic_inst },
4551+ {"rsublkc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x1C000100, OPCODE_MASK_H4, rsublkc, arithmetic_inst },
4552+ {"cmpl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000101, OPCODE_MASK_H4, cmpl, arithmetic_inst },
4553+ {"cmplu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000103, OPCODE_MASK_H4, cmplu, arithmetic_inst },
4554+ {"addli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x20000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* Identical to 32-bit */
4555+ {"rsubli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x24000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* Identical to 32-bit */
4556+ {"addlic", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x28000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* Identical to 32-bit */
4557+ {"rsublic", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x2C000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* Identical to 32-bit */
4558+ {"addlik", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x30000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* Identical to 32-bit */
4559+ {"rsublik", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x34000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* Identical to 32-bit */
4560+ {"addlikc", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x38000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* Identical to 32-bit */
4561+ {"rsublikc",INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x3C000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* Identical to 32-bit */
4562+ {"mull", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x40000100, OPCODE_MASK_H4, mull, mult_inst },
4563+ {"bslll", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000500, OPCODE_MASK_H3, bslll, barrel_shift_inst },
4564+ {"bslra", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000300, OPCODE_MASK_H3, bslra, barrel_shift_inst },
4565+ {"bslrl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000100, OPCODE_MASK_H3, bslrl, barrel_shift_inst },
4566+ {"bsllli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64002400, OPCODE_MASK_H3B, bsllli, barrel_shift_inst },
4567+ {"bslrai", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64002200, OPCODE_MASK_H3B, bslrai, barrel_shift_inst },
4568+ {"bslrli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64002000, OPCODE_MASK_H3B, bslrli, barrel_shift_inst },
4569+ {"bslefi", INST_TYPE_RD_R1_IMMW_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64006000, OPCODE_MASK_H32B, bslefi, barrel_shift_inst },
4570+ {"bslifi", INST_TYPE_RD_R1_IMMW_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6400a000, OPCODE_MASK_H32B, bslifi, barrel_shift_inst },
4571+ {"orl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000100, OPCODE_MASK_H4, orl, logical_inst },
4572+ {"andl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000100, OPCODE_MASK_H4, andl, logical_inst },
4573+ {"xorl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000100, OPCODE_MASK_H4, xorl, logical_inst },
4574+ {"andnl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x8C000100, OPCODE_MASK_H4, andnl, logical_inst },
4575+ {"pcmplbf", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000500, OPCODE_MASK_H4, pcmplbf, logical_inst },
4576+ {"pcmpleq", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000500, OPCODE_MASK_H4, pcmpleq, logical_inst },
4577+ {"pcmplne", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x8C000500, OPCODE_MASK_H4, pcmplne, logical_inst },
4578+ {"srla", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000101, OPCODE_MASK_H34, srla, logical_inst },
4579+ {"srlc", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000121, OPCODE_MASK_H34, srlc, logical_inst },
4580+ {"srll", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000141, OPCODE_MASK_H34, srll, logical_inst },
4581+ {"sextl8", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000160, OPCODE_MASK_H34, sextl8, logical_inst },
4582+ {"sextl16", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000161, OPCODE_MASK_H34, sextl16, logical_inst },
4583+ {"sextl32", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000162, OPCODE_MASK_H34, sextl32, logical_inst },
4584+ {"brea", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98010000, OPCODE_MASK_H124, brea, branch_inst },
4585+ {"bread", INST_TYPE_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98110000, OPCODE_MASK_H124, bread, branch_inst },
4586+ {"breald", INST_TYPE_RD_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98150000, OPCODE_MASK_H24, breald, branch_inst },
4587+ {"beaeq", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D000000, OPCODE_MASK_H14, beaeq, branch_inst },
4588+ {"bealeq", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D000100, OPCODE_MASK_H14, bealeq, branch_inst },
4589+ {"beaeqd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F000000, OPCODE_MASK_H14, beaeqd, branch_inst },
4590+ {"bealeqd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F000100, OPCODE_MASK_H14, bealeqd, branch_inst },
4591+ {"beane", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D200000, OPCODE_MASK_H14, beane, branch_inst },
4592+ {"bealne", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D200100, OPCODE_MASK_H14, bealne, branch_inst },
4593+ {"beaned", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F200000, OPCODE_MASK_H14, beaned, branch_inst },
4594+ {"bealned", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F200100, OPCODE_MASK_H14, bealned, branch_inst },
4595+ {"bealt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D400000, OPCODE_MASK_H14, bealt, branch_inst },
4596+ {"beallt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D400100, OPCODE_MASK_H14, beallt, branch_inst },
4597+ {"bealtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F400000, OPCODE_MASK_H14, bealtd, branch_inst },
4598+ {"bealltd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F400100, OPCODE_MASK_H14, bealltd, branch_inst },
4599+ {"beale", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D600000, OPCODE_MASK_H14, beale, branch_inst },
4600+ {"bealle", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D600100, OPCODE_MASK_H14, bealle, branch_inst },
4601+ {"bealed", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F600000, OPCODE_MASK_H14, bealed, branch_inst },
4602+ {"bealled", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F600100, OPCODE_MASK_H14, bealled, branch_inst },
4603+ {"beagt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D800000, OPCODE_MASK_H14, beagt, branch_inst },
4604+ {"bealgt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D800100, OPCODE_MASK_H14, bealgt, branch_inst },
4605+ {"beagtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F800000, OPCODE_MASK_H14, beagtd, branch_inst },
4606+ {"bealgtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F800100, OPCODE_MASK_H14, bealgtd, branch_inst },
4607+ {"beage", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9DA00000, OPCODE_MASK_H14, beage, branch_inst },
4608+ {"bealge", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9DA00100, OPCODE_MASK_H14, bealge, branch_inst },
4609+ {"beaged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00000, OPCODE_MASK_H14, beaged, branch_inst },
4610+ {"bealged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00100, OPCODE_MASK_H14, bealged, branch_inst },
4611+ {"orli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA0000000, OPCODE_MASK_H, invalid_inst, logical_inst }, /* Identical to 32-bit */
4612+ {"andli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA4000000, OPCODE_MASK_H, invalid_inst, logical_inst }, /* Identical to 32-bit */
4613+ {"xorli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA8000000, OPCODE_MASK_H, invalid_inst, logical_inst }, /* Identical to 32-bit */
4614+ {"andnli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xAC000000, OPCODE_MASK_H, invalid_inst, logical_inst }, /* Identical to 32-bit */
4615+ {"imml", INST_TYPE_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB2000000, OPCODE_MASK_H8, imml, immediate_inst },
4616+ {"breai", INST_TYPE_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8010000, OPCODE_MASK_H12, breai, branch_inst },
4617+ {"breaid", INST_TYPE_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8110000, OPCODE_MASK_H12, breaid, branch_inst },
4618+ {"brealid", INST_TYPE_RD_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8150000, OPCODE_MASK_H2, brealid, branch_inst },
4619+ {"beaeqi", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD000000, OPCODE_MASK_H1, beaeqi, branch_inst },
4620+ {"bealeqi", INST_TYPE_R1_IMML, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD000000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to beaeqi */
4621+ {"beaeqid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF000000, OPCODE_MASK_H1, beaeqid, branch_inst },
4622+ {"bealeqid",INST_TYPE_R1_IMML, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF000000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to beaeqid */
4623+ {"beanei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD200000, OPCODE_MASK_H1, beanei, branch_inst },
4624+ {"bealnei", INST_TYPE_R1_IMML, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD200000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to beanei */
4625+ {"beaneid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF200000, OPCODE_MASK_H1, beaneid, branch_inst },
4626+ {"bealneid",INST_TYPE_R1_IMML, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF200000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to beaneid */
4627+ {"bealti", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD400000, OPCODE_MASK_H1, bealti, branch_inst },
4628+ {"beallti", INST_TYPE_R1_IMML, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD400000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to bealti */
4629+ {"bealtid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF400000, OPCODE_MASK_H1, bealtid, branch_inst },
4630+ {"bealltid",INST_TYPE_R1_IMML, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF400000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to bealtid */
4631+ {"bealei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD600000, OPCODE_MASK_H1, bealei, branch_inst },
4632+ {"beallei", INST_TYPE_R1_IMML, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD600000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to bealei */
4633+ {"bealeid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF600000, OPCODE_MASK_H1, bealeid, branch_inst },
4634+ {"bealleid",INST_TYPE_R1_IMML, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF600000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to bealeid */
4635+ {"beagti", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD800000, OPCODE_MASK_H1, beagti, branch_inst },
4636+ {"bealgti", INST_TYPE_R1_IMML, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD800000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to beagti */
4637+ {"beagtid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF800000, OPCODE_MASK_H1, beagtid, branch_inst },
4638+ {"bealgtid",INST_TYPE_R1_IMML, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF800000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to beagtid */
4639+ {"beagei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBDA00000, OPCODE_MASK_H1, beagei, branch_inst },
4640+ {"bealgei", INST_TYPE_R1_IMML, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBDA00000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to beagei */
4641+ {"beageid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBFA00000, OPCODE_MASK_H1, beageid, branch_inst },
4642+ {"bealgeid",INST_TYPE_R1_IMML, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBFA00000, OPCODE_MASK_H1, invalid_inst, branch_inst }, /* Identical to beageid */
4643+ {"ll", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000100, OPCODE_MASK_H4, ll, memory_load_inst },
4644+ {"llr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000300, OPCODE_MASK_H4, llr, memory_load_inst },
4645+ {"sl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000100, OPCODE_MASK_H4, sl, memory_store_inst },
4646+ {"slr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000300, OPCODE_MASK_H4, slr, memory_store_inst },
4647+ {"lli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, invalid_inst, memory_load_inst }, /* Identical to 32-bit */
4648+ {"sli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xF8000000, OPCODE_MASK_H, invalid_inst, memory_store_inst }, /* Identical to 32-bit */
4649+ {"lla", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x30000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* lla translates to addlik */
4650+ {"dadd", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000400, OPCODE_MASK_H4, dadd, arithmetic_inst },
4651+ {"drsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000480, OPCODE_MASK_H4, drsub, arithmetic_inst },
4652+ {"dmul", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000500, OPCODE_MASK_H4, dmul, arithmetic_inst },
4653+ {"ddiv", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000580, OPCODE_MASK_H4, ddiv, arithmetic_inst },
4654+ {"dcmp.lt", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000610, OPCODE_MASK_H4, dcmp_lt, arithmetic_inst },
4655+ {"dcmp.eq", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000620, OPCODE_MASK_H4, dcmp_eq, arithmetic_inst },
4656+ {"dcmp.le", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000630, OPCODE_MASK_H4, dcmp_le, arithmetic_inst },
4657+ {"dcmp.gt", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000640, OPCODE_MASK_H4, dcmp_gt, arithmetic_inst },
4658+ {"dcmp.ne", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000650, OPCODE_MASK_H4, dcmp_ne, arithmetic_inst },
4659+ {"dcmp.ge", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000660, OPCODE_MASK_H4, dcmp_ge, arithmetic_inst },
4660+ {"dcmp.un", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000600, OPCODE_MASK_H4, dcmp_un, arithmetic_inst },
4661+ {"dbl", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000680, OPCODE_MASK_H4, dbl, arithmetic_inst },
4662+ {"dlong", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000700, OPCODE_MASK_H4, dlong, arithmetic_inst },
4663+ {"dsqrt", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000780, OPCODE_MASK_H4, dsqrt, arithmetic_inst },
4664+
4665 {"", 0, 0, 0, 0, 0, 0, 0, 0},
4666 };
4667
4668@@ -445,8 +576,17 @@ char pvr_register_prefix[] = "rpvr";
4669 #define MIN_IMM5 ((int) 0x00000000)
4670 #define MAX_IMM5 ((int) 0x0000001f)
4671
4672+#define MIN_IMM6 ((int) 0x00000000)
4673+#define MAX_IMM6 ((int) 0x0000003f)
4674+
4675 #define MIN_IMM_WIDTH ((int) 0x00000001)
4676 #define MAX_IMM_WIDTH ((int) 0x00000020)
4677
4678+#define MIN_IMM6_WIDTH ((int) 0x00000001)
4679+#define MAX_IMM6_WIDTH ((int) 0x00000040)
4680+
4681+#define MIN_IMML ((long) 0xffffff8000000000L)
4682+#define MAX_IMML ((long) 0x0000007fffffffffL)
4683+
4684 #endif /* MICROBLAZE_OPC */
4685
4686diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
4687index b69e6a4..265cea8 100644
4688--- a/opcodes/microblaze-opcm.h
4689+++ b/opcodes/microblaze-opcm.h
4690@@ -25,6 +25,7 @@
4691
4692 enum microblaze_instr
4693 {
4694+ /* 32-bit instructions */
4695 add, rsub, addc, rsubc, addk, rsubk, addkc, rsubkc, clz, cmp, cmpu,
4696 addi, rsubi, addic, rsubic, addik, rsubik, addikc, rsubikc, mul,
4697 mulh, mulhu, mulhsu,swapb,swaph,
4698@@ -58,6 +59,18 @@ enum microblaze_instr
4699 aputd, taputd, caputd, tcaputd, naputd, tnaputd, ncaputd, tncaputd,
4700 eagetd, teagetd, ecagetd, tecagetd, neagetd, tneagetd, necagetd, tnecagetd,
4701 eaputd, teaputd, ecaputd, tecaputd, neaputd, tneaputd, necaputd, tnecaputd,
4702+
4703+ /* 64-bit instructions */
4704+ addl, rsubl, addlc, rsublc, addlk, rsublk, addlkc, rsublkc, cmpl, cmplu, mull,
4705+ bslll, bslra, bslrl, bsllli, bslrai, bslrli, bslefi, bslifi, orl, andl, xorl,
4706+ andnl, pcmplbf, pcmpleq, pcmplne, srla, srlc, srll, sextl8, sextl16, sextl32,
4707+ brea, bread, breald, beaeq, bealeq, beaeqd, bealeqd, beane, bealne, beaned,
4708+ bealned, bealt, beallt, bealtd, bealltd, beale, bealle, bealed, bealled, beagt,
4709+ bealgt, beagtd, bealgtd, beage, bealge, beaged, bealged, breai, breaid, brealid,
4710+ beaeqi, beaeqid, beanei, beaneid, bealti, bealtid, bealei, bealeid, beagti,
4711+ beagtid, beagei, beageid, imml, ll, llr, sl, slr,
4712+ dadd, drsub, dmul, ddiv, dcmp_lt, dcmp_eq, dcmp_le, dcmp_gt, dcmp_ne, dcmp_ge,
4713+ dcmp_un, dbl, dlong, dsqrt,
4714 invalid_inst
4715 };
4716
4717@@ -135,15 +148,18 @@ enum microblaze_instr_type
4718 #define RA_MASK 0x001F0000
4719 #define RB_MASK 0x0000F800
4720 #define IMM_MASK 0x0000FFFF
4721+#define IMML_MASK 0x00FFFFFF
4722
4723-/* Imm mask for barrel shifts. */
4724+/* Imm masks for barrel shifts. */
4725 #define IMM5_MASK 0x0000001F
4726+#define IMM6_MASK 0x0000003F
4727
4728 /* Imm mask for mbar. */
4729 #define IMM5_MBAR_MASK 0x03E00000
4730
4731-/* Imm mask for extract/insert width. */
4732+/* Imm masks for extract/insert width. */
4733 #define IMM5_WIDTH_MASK 0x000007C0
4734+#define IMM6_WIDTH_MASK 0x00000FC0
4735
4736 /* FSL imm mask for get, put instructions. */
4737 #define RFSL_MASK 0x000000F
4738--
47392.7.4
4740
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0016-MB-X-initial-commit.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0016-MB-X-initial-commit.patch
new file mode 100644
index 00000000..6239e214
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0016-MB-X-initial-commit.patch
@@ -0,0 +1,694 @@
1From 05240f6bdb5e3789efdc03b90c073b78785268e4 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Sun, 30 Sep 2018 16:31:26 +0530
4Subject: [PATCH 16/31] MB-X initial commit code cleanup is needed.
5
6Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
8---
9 bfd/bfd-in2.h | 10 +++
10 bfd/elf32-microblaze.c | 65 +++++++++++++++++--
11 bfd/elf64-microblaze.c | 61 +++++++++++++++++-
12 bfd/libbfd.h | 2 +
13 bfd/reloc.c | 12 ++++
14 gas/config/tc-microblaze.c | 152 +++++++++++++++++++++++++++++++++++++--------
15 include/elf/microblaze.h | 2 +
16 opcodes/microblaze-opc.h | 4 +-
17 opcodes/microblaze-opcm.h | 4 +-
18 9 files changed, 277 insertions(+), 35 deletions(-)
19
20diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
21index 5807f70..44cddc2 100644
22--- a/bfd/bfd-in2.h
23+++ b/bfd/bfd-in2.h
24@@ -5801,11 +5801,21 @@ done here - only used for relaxing */
25 BFD_RELOC_MICROBLAZE_64_NONE,
26
27 /* This is a 64 bit reloc that stores the 32 bit pc relative
28+ * +value in two words (with an imml instruction). No relocation is
29+ * +done here - only used for relaxing */
30+ BFD_RELOC_MICROBLAZE_64,
31+
32+/* This is a 64 bit reloc that stores the 32 bit pc relative
33 value in two words (with an imm instruction). The relocation is
34 PC-relative GOT offset */
35 BFD_RELOC_MICROBLAZE_64_GOTPC,
36
37 /* This is a 64 bit reloc that stores the 32 bit pc relative
38+value in two words (with an imml instruction). The relocation is
39+PC-relative GOT offset */
40+ BFD_RELOC_MICROBLAZE_64_GPC,
41+
42+/* This is a 64 bit reloc that stores the 32 bit pc relative
43 value in two words (with an imm instruction). The relocation is
44 GOT offset */
45 BFD_RELOC_MICROBLAZE_64_GOT,
46diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
47index 94fa3cf..b632dd1 100644
48--- a/bfd/elf32-microblaze.c
49+++ b/bfd/elf32-microblaze.c
50@@ -116,6 +116,20 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
51 0x0000ffff, /* Dest Mask. */
52 TRUE), /* PC relative offset? */
53
54+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */
55+ 0, /* Rightshift. */
56+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
57+ 16, /* Bitsize. */
58+ TRUE, /* PC_relative. */
59+ 0, /* Bitpos. */
60+ complain_overflow_dont, /* Complain on overflow. */
61+ bfd_elf_generic_reloc,/* Special Function. */
62+ "R_MICROBLAZE_IMML_64", /* Name. */
63+ FALSE, /* Partial Inplace. */
64+ 0, /* Source Mask. */
65+ 0x0000ffff, /* Dest Mask. */
66+ FALSE), /* PC relative offset? */
67+
68 /* A 64 bit relocation. Table entry not really used. */
69 HOWTO (R_MICROBLAZE_64, /* Type. */
70 0, /* Rightshift. */
71@@ -280,6 +294,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
72 0x0000ffff, /* Dest Mask. */
73 TRUE), /* PC relative offset? */
74
75+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
76+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */
77+ 0, /* Rightshift. */
78+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
79+ 16, /* Bitsize. */
80+ TRUE, /* PC_relative. */
81+ 0, /* Bitpos. */
82+ complain_overflow_dont, /* Complain on overflow. */
83+ bfd_elf_generic_reloc, /* Special Function. */
84+ "R_MICROBLAZE_GPC_64", /* Name. */
85+ FALSE, /* Partial Inplace. */
86+ 0, /* Source Mask. */
87+ 0x0000ffff, /* Dest Mask. */
88+ TRUE), /* PC relative offset? */
89+
90 /* A 64 bit GOT relocation. Table-entry not really used. */
91 HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
92 0, /* Rightshift. */
93@@ -619,9 +648,15 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
94 case BFD_RELOC_VTABLE_ENTRY:
95 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
96 break;
97+ case BFD_RELOC_MICROBLAZE_64:
98+ microblaze_reloc = R_MICROBLAZE_IMML_64;
99+ break;
100 case BFD_RELOC_MICROBLAZE_64_GOTPC:
101 microblaze_reloc = R_MICROBLAZE_GOTPC_64;
102 break;
103+ case BFD_RELOC_MICROBLAZE_64_GPC:
104+ microblaze_reloc = R_MICROBLAZE_GPC_64;
105+ break;
106 case BFD_RELOC_MICROBLAZE_64_GOT:
107 microblaze_reloc = R_MICROBLAZE_GOT_64;
108 break;
109@@ -1467,7 +1502,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
110 if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
111 {
112 relocation += addend;
113- if (r_type == R_MICROBLAZE_32)
114+ if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
115 bfd_put_32 (input_bfd, relocation, contents + offset);
116 else
117 {
118@@ -1933,6 +1968,28 @@ microblaze_elf_relax_section (bfd *abfd,
119 irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
120 }
121 break;
122+ case R_MICROBLAZE_IMML_64:
123+ {
124+ /* This was a PC-relative instruction that was
125+ completely resolved. */
126+ int sfix, efix;
127+ unsigned int val;
128+ bfd_vma target_address;
129+ target_address = irel->r_addend + irel->r_offset;
130+ sfix = calc_fixup (irel->r_offset, 0, sec);
131+ efix = calc_fixup (target_address, 0, sec);
132+
133+ /* Validate the in-band val. */
134+ val = bfd_get_32 (abfd, contents + irel->r_offset);
135+ if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
136+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
137+ }
138+ irel->r_addend -= (efix - sfix);
139+ /* Should use HOWTO. */
140+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
141+ irel->r_addend);
142+ }
143+ break;
144 case R_MICROBLAZE_NONE:
145 case R_MICROBLAZE_32_NONE:
146 {
147@@ -2037,9 +2094,9 @@ microblaze_elf_relax_section (bfd *abfd,
148 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
149 irelscan->r_addend);
150 }
151- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
152- {
153- isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
154+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)// || ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64)
155+ {
156+ isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
157
158 /* Look at the reloc only if the value has been resolved. */
159 if (isym->st_shndx == shndx
160diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
161index 0f43ae6..56a45f2 100644
162--- a/bfd/elf64-microblaze.c
163+++ b/bfd/elf64-microblaze.c
164@@ -117,6 +117,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
165 TRUE), /* PC relative offset? */
166
167 /* A 64 bit relocation. Table entry not really used. */
168+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */
169+ 0, /* Rightshift. */
170+ 4, /* Size (0 = byte, 1 = short, 2 = long). */
171+ 64, /* Bitsize. */
172+ TRUE, /* PC_relative. */
173+ 0, /* Bitpos. */
174+ complain_overflow_dont, /* Complain on overflow. */
175+ bfd_elf_generic_reloc,/* Special Function. */
176+ "R_MICROBLAZE_IMML_64", /* Name. */
177+ FALSE, /* Partial Inplace. */
178+ 0, /* Source Mask. */
179+ 0x0000ffff, /* Dest Mask. */
180+ TRUE), /* PC relative offset? */
181+
182+ /* A 64 bit relocation. Table entry not really used. */
183 HOWTO (R_MICROBLAZE_64, /* Type. */
184 0, /* Rightshift. */
185 2, /* Size (0 = byte, 1 = short, 2 = long). */
186@@ -265,6 +280,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
187 0x0000ffff, /* Dest Mask. */
188 TRUE), /* PC relative offset? */
189
190+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
191+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */
192+ 0, /* Rightshift. */
193+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
194+ 16, /* Bitsize. */
195+ TRUE, /* PC_relative. */
196+ 0, /* Bitpos. */
197+ complain_overflow_dont, /* Complain on overflow. */
198+ bfd_elf_generic_reloc, /* Special Function. */
199+ "R_MICROBLAZE_GPC_64", /* Name. */
200+ FALSE, /* Partial Inplace. */
201+ 0, /* Source Mask. */
202+ 0x0000ffff, /* Dest Mask. */
203+ TRUE), /* PC relative offset? */
204+
205 /* A 64 bit GOT relocation. Table-entry not really used. */
206 HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
207 0, /* Rightshift. */
208@@ -589,9 +619,15 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
209 case BFD_RELOC_VTABLE_ENTRY:
210 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
211 break;
212+ case BFD_RELOC_MICROBLAZE_64:
213+ microblaze_reloc = R_MICROBLAZE_IMML_64;
214+ break;
215 case BFD_RELOC_MICROBLAZE_64_GOTPC:
216 microblaze_reloc = R_MICROBLAZE_GOTPC_64;
217 break;
218+ case BFD_RELOC_MICROBLAZE_64_GPC:
219+ microblaze_reloc = R_MICROBLAZE_GPC_64;
220+ break;
221 case BFD_RELOC_MICROBLAZE_64_GOT:
222 microblaze_reloc = R_MICROBLAZE_GOT_64;
223 break;
224@@ -1161,6 +1197,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
225 break; /* Do nothing. */
226
227 case (int) R_MICROBLAZE_GOTPC_64:
228+ case (int) R_MICROBLAZE_GPC_64:
229 relocation = htab->sgotplt->output_section->vma
230 + htab->sgotplt->output_offset;
231 relocation -= (input_section->output_section->vma
232@@ -1431,7 +1468,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
233 if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
234 {
235 relocation += addend;
236- if (r_type == R_MICROBLAZE_32)
237+ if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
238 bfd_put_32 (input_bfd, relocation, contents + offset);
239 else
240 {
241@@ -1876,6 +1913,28 @@ microblaze_elf_relax_section (bfd *abfd,
242 irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
243 }
244 break;
245+ case R_MICROBLAZE_IMML_64:
246+ {
247+ /* This was a PC-relative instruction that was
248+ completely resolved. */
249+ int sfix, efix;
250+ unsigned int val;
251+ bfd_vma target_address;
252+ target_address = irel->r_addend + irel->r_offset;
253+ sfix = calc_fixup (irel->r_offset, 0, sec);
254+ efix = calc_fixup (target_address, 0, sec);
255+
256+ /* Validate the in-band val. */
257+ val = bfd_get_32 (abfd, contents + irel->r_offset);
258+ if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
259+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
260+ }
261+ irel->r_addend -= (efix - sfix);
262+ /* Should use HOWTO. */
263+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
264+ irel->r_addend);
265+ }
266+ break;
267 case R_MICROBLAZE_NONE:
268 case R_MICROBLAZE_32_NONE:
269 {
270diff --git a/bfd/libbfd.h b/bfd/libbfd.h
271index 261086c..d7892a6 100644
272--- a/bfd/libbfd.h
273+++ b/bfd/libbfd.h
274@@ -2864,7 +2864,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
275 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
276 "BFD_RELOC_MICROBLAZE_32_NONE",
277 "BFD_RELOC_MICROBLAZE_64_NONE",
278+ "BFD_RELOC_MICROBLAZE_64",
279 "BFD_RELOC_MICROBLAZE_64_GOTPC",
280+ "BFD_RELOC_MICROBLAZE_64_GPC",
281 "BFD_RELOC_MICROBLAZE_64_GOT",
282 "BFD_RELOC_MICROBLAZE_64_PLT",
283 "BFD_RELOC_MICROBLAZE_64_GOTOFF",
284diff --git a/bfd/reloc.c b/bfd/reloc.c
285index d89bc5d..60eac77 100644
286--- a/bfd/reloc.c
287+++ b/bfd/reloc.c
288@@ -6873,6 +6873,12 @@ ENUMDOC
289 ENUM
290 BFD_RELOC_MICROBLAZE_64_NONE
291 ENUMDOC
292+ This is a 32 bit reloc that stores the 32 bit pc relative
293+ value in two words (with an imml instruction). No relocation is
294+ done here - only used for relaxing
295+ENUM
296+ BFD_RELOC_MICROBLAZE_64
297+ENUMDOC
298 This is a 64 bit reloc that stores the 32 bit pc relative
299 value in two words (with an imm instruction). No relocation is
300 done here - only used for relaxing
301@@ -6880,6 +6886,12 @@ ENUM
302 BFD_RELOC_MICROBLAZE_64_GOTPC
303 ENUMDOC
304 This is a 64 bit reloc that stores the 32 bit pc relative
305+ value in two words (with an imml instruction). No relocation is
306+ done here - only used for relaxing
307+ENUM
308+ BFD_RELOC_MICROBLAZE_64_GPC
309+ENUMDOC
310+ This is a 64 bit reloc that stores the 32 bit pc relative
311 value in two words (with an imm instruction). The relocation is
312 PC-relative GOT offset
313 ENUM
314diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
315index eb7998f..680a794 100644
316--- a/gas/config/tc-microblaze.c
317+++ b/gas/config/tc-microblaze.c
318@@ -94,6 +94,7 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP";
319 #define TLSTPREL_OFFSET 16
320 #define TEXT_OFFSET 17
321 #define TEXT_PC_OFFSET 18
322+#define DEFINED_64_OFFSET 19
323
324 /* Initialize the relax table. */
325 const relax_typeS md_relax_table[] =
326@@ -117,6 +118,8 @@ const relax_typeS md_relax_table[] =
327 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 16: TLSTPREL_OFFSET. */
328 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 17: TEXT_OFFSET. */
329 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 18: TEXT_PC_OFFSET. */
330+// { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 16: TLSTPREL_OFFSET. */
331+ { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 } /* 17: DEFINED_64_OFFSET. */
332 };
333
334 static struct hash_control * opcode_hash_control; /* Opcode mnemonics. */
335@@ -396,7 +399,8 @@ const pseudo_typeS md_pseudo_table[] =
336 {"data32", cons, 4}, /* Same as word. */
337 {"ent", s_func, 0}, /* Treat ent as function entry point. */
338 {"end", microblaze_s_func, 1}, /* Treat end as function end point. */
339- {"gpword", s_rva, 4}, /* gpword label => store resolved label address in data section. */
340+ {"gpword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
341+ {"gpdword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
342 {"weakext", microblaze_s_weakext, 0},
343 {"rodata", microblaze_s_rdata, 0},
344 {"sdata2", microblaze_s_rdata, 1},
345@@ -405,6 +409,7 @@ const pseudo_typeS md_pseudo_table[] =
346 {"sbss", microblaze_s_bss, 1},
347 {"text", microblaze_s_text, 0},
348 {"word", cons, 4},
349+ {"dword", cons, 8},
350 {"frame", s_ignore, 0},
351 {"mask", s_ignore, 0}, /* Emitted by gcc. */
352 {NULL, NULL, 0}
353@@ -898,7 +903,7 @@ check_got (int * got_type, int * got_len)
354 extern bfd_reloc_code_real_type
355 parse_cons_expression_microblaze (expressionS *exp, int size)
356 {
357- if (size == 4)
358+ if (size == 4 || (microblaze_arch_size == 64 && size == 8))
359 {
360 /* Handle @GOTOFF et.al. */
361 char *save, *gotfree_copy;
362@@ -930,6 +935,7 @@ parse_cons_expression_microblaze (expressionS *exp, int size)
363
364 static const char * str_microblaze_ro_anchor = "RO";
365 static const char * str_microblaze_rw_anchor = "RW";
366+static const char * str_microblaze_64 = "64";
367
368 static bfd_boolean
369 check_spl_reg (unsigned * reg)
370@@ -1174,6 +1180,33 @@ md_assemble (char * str)
371 inst |= (immed << IMM_LOW) & IMM_MASK;
372 }
373 }
374+#if 0 //revisit
375+ else if (streq (name, "lli") || streq (name, "sli"))
376+ {
377+ temp = immed & 0xFFFFFFFFFFFF8000;
378+ if ((temp != 0) && (temp != 0xFFFFFFFFFFFF8000))
379+ {
380+ /* Needs an immediate inst. */
381+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
382+ if (opcode1 == NULL)
383+ {
384+ as_bad (_("unknown opcode \"%s\""), "imml");
385+ return;
386+ }
387+
388+ inst1 = opcode1->bit_sequence;
389+ inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
390+ output[0] = INST_BYTE0 (inst1);
391+ output[1] = INST_BYTE1 (inst1);
392+ output[2] = INST_BYTE2 (inst1);
393+ output[3] = INST_BYTE3 (inst1);
394+ output = frag_more (isize);
395+ }
396+ inst |= (reg1 << RD_LOW) & RD_MASK;
397+ inst |= (reg2 << RA_LOW) & RA_MASK;
398+ inst |= (immed << IMM_LOW) & IMM_MASK;
399+ }
400+#endif
401 else
402 {
403 temp = immed & 0xFFFF8000;
404@@ -1926,6 +1959,7 @@ md_assemble (char * str)
405 if (exp.X_op != O_constant)
406 {
407 char *opc = NULL;
408+ //char *opc = str_microblaze_64;
409 relax_substateT subtype;
410
411 if (exp.X_md != 0)
412@@ -1939,7 +1973,7 @@ md_assemble (char * str)
413 subtype, /* PC-relative or not. */
414 exp.X_add_symbol,
415 exp.X_add_number,
416- opc);
417+ (char *) opc);
418 immedl = 0L;
419 }
420 else
421@@ -1977,7 +2011,7 @@ md_assemble (char * str)
422 reg1 = 0;
423 }
424 if (strcmp (op_end, ""))
425- op_end = parse_imml (op_end + 1, & exp, MIN_IMM, MAX_IMM);
426+ op_end = parse_imml (op_end + 1, & exp, MIN_IMML, MAX_IMML);
427 else
428 as_fatal (_("Error in statement syntax"));
429
430@@ -1987,7 +2021,8 @@ md_assemble (char * str)
431
432 if (exp.X_op != O_constant)
433 {
434- char *opc = NULL;
435+ //char *opc = NULL;
436+ char *opc = str_microblaze_64;
437 relax_substateT subtype;
438
439 if (exp.X_md != 0)
440@@ -2001,14 +2036,13 @@ md_assemble (char * str)
441 subtype, /* PC-relative or not. */
442 exp.X_add_symbol,
443 exp.X_add_number,
444- opc);
445+ (char *) opc);
446 immedl = 0L;
447 }
448 else
449 {
450 output = frag_more (isize);
451 immedl = exp.X_add_number;
452-
453 opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
454 if (opcode1 == NULL)
455 {
456@@ -2187,13 +2221,23 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
457 fragP->fr_fix += INST_WORD_SIZE * 2;
458 fragP->fr_var = 0;
459 break;
460+ case DEFINED_64_OFFSET:
461+ if (fragP->fr_symbol == GOT_symbol)
462+ fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
463+ fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_GPC);
464+ else
465+ fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
466+ fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64);
467+ fragP->fr_fix += INST_WORD_SIZE * 2;
468+ fragP->fr_var = 0;
469+ break;
470 case DEFINED_ABS_SEGMENT:
471 if (fragP->fr_symbol == GOT_symbol)
472 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol,
473 fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_GOTPC);
474 else
475 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol,
476- fragP->fr_offset, FALSE, BFD_RELOC_64);
477+ fragP->fr_offset, TRUE, BFD_RELOC_64);
478 fragP->fr_fix += INST_WORD_SIZE * 2;
479 fragP->fr_var = 0;
480 break;
481@@ -2416,22 +2460,38 @@ md_apply_fix (fixS * fixP,
482 case BFD_RELOC_64_PCREL:
483 case BFD_RELOC_64:
484 case BFD_RELOC_MICROBLAZE_64_TEXTREL:
485+ case BFD_RELOC_MICROBLAZE_64:
486 /* Add an imm instruction. First save the current instruction. */
487 for (i = 0; i < INST_WORD_SIZE; i++)
488 buf[i + INST_WORD_SIZE] = buf[i];
489+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
490+ {
491+ /* Generate the imm instruction. */
492+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
493+ if (opcode1 == NULL)
494+ {
495+ as_bad (_("unknown opcode \"%s\""), "imml");
496+ return;
497+ }
498
499- /* Generate the imm instruction. */
500- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
501- if (opcode1 == NULL)
502- {
503- as_bad (_("unknown opcode \"%s\""), "imm");
504- return;
505- }
506-
507- inst1 = opcode1->bit_sequence;
508- if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
509- inst1 |= ((val & 0xFFFF0000) >> 16) & IMM_MASK;
510-
511+ inst1 = opcode1->bit_sequence;
512+ if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
513+ inst1 |= ((val & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
514+ }
515+ else
516+ {
517+ /* Generate the imm instruction. */
518+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
519+ if (opcode1 == NULL)
520+ {
521+ as_bad (_("unknown opcode \"%s\""), "imm");
522+ return;
523+ }
524+
525+ inst1 = opcode1->bit_sequence;
526+ if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
527+ inst1 |= ((val & 0xFFFF0000) >> 16) & IMM_MASK;
528+ }
529 buf[0] = INST_BYTE0 (inst1);
530 buf[1] = INST_BYTE1 (inst1);
531 buf[2] = INST_BYTE2 (inst1);
532@@ -2460,6 +2520,7 @@ md_apply_fix (fixS * fixP,
533 /* Fall through. */
534
535 case BFD_RELOC_MICROBLAZE_64_GOTPC:
536+ case BFD_RELOC_MICROBLAZE_64_GPC:
537 case BFD_RELOC_MICROBLAZE_64_GOT:
538 case BFD_RELOC_MICROBLAZE_64_PLT:
539 case BFD_RELOC_MICROBLAZE_64_GOTOFF:
540@@ -2467,12 +2528,16 @@ md_apply_fix (fixS * fixP,
541 /* Add an imm instruction. First save the current instruction. */
542 for (i = 0; i < INST_WORD_SIZE; i++)
543 buf[i + INST_WORD_SIZE] = buf[i];
544-
545- /* Generate the imm instruction. */
546- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
547+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
548+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
549+ else
550+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
551 if (opcode1 == NULL)
552 {
553- as_bad (_("unknown opcode \"%s\""), "imm");
554+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
555+ as_bad (_("unknown opcode \"%s\""), "imml");
556+ else
557+ as_bad (_("unknown opcode \"%s\""), "imm");
558 return;
559 }
560
561@@ -2496,6 +2561,8 @@ md_apply_fix (fixS * fixP,
562 moves code around due to relaxing. */
563 if (fixP->fx_r_type == BFD_RELOC_64_PCREL)
564 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
565+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
566+ fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
567 else if (fixP->fx_r_type == BFD_RELOC_32)
568 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_32_NONE;
569 else
570@@ -2539,6 +2606,32 @@ md_estimate_size_before_relax (fragS * fragP,
571 as_bad (_("Absolute PC-relative value in relaxation code. Assembler error....."));
572 abort ();
573 }
574+ else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type
575+ && !S_IS_WEAK (fragP->fr_symbol))
576+ {
577+ if (fragP->fr_opcode != NULL) {
578+ if(streq (fragP->fr_opcode, str_microblaze_64))
579+ {
580+ /* Used as an absolute value. */
581+ fragP->fr_subtype = DEFINED_64_OFFSET;
582+ /* Variable part does not change. */
583+ fragP->fr_var = INST_WORD_SIZE;
584+ }
585+ else
586+ {
587+ fragP->fr_subtype = DEFINED_PC_OFFSET;
588+ /* Don't know now whether we need an imm instruction. */
589+ fragP->fr_var = INST_WORD_SIZE;
590+ }
591+ }
592+ else
593+ {
594+ fragP->fr_subtype = DEFINED_PC_OFFSET;
595+ /* Don't know now whether we need an imm instruction. */
596+ fragP->fr_var = INST_WORD_SIZE;
597+ }
598+ }
599+ #if 0
600 else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type &&
601 !S_IS_WEAK (fragP->fr_symbol))
602 {
603@@ -2546,6 +2639,7 @@ md_estimate_size_before_relax (fragS * fragP,
604 /* Don't know now whether we need an imm instruction. */
605 fragP->fr_var = INST_WORD_SIZE;
606 }
607+#endif
608 else if (S_IS_DEFINED (fragP->fr_symbol)
609 && (((S_GET_SEGMENT (fragP->fr_symbol))->flags & SEC_CODE) == 0))
610 {
611@@ -2648,6 +2742,7 @@ md_estimate_size_before_relax (fragS * fragP,
612 case TLSLD_OFFSET:
613 case TLSTPREL_OFFSET:
614 case TLSDTPREL_OFFSET:
615+ case DEFINED_64_OFFSET:
616 fragP->fr_var = INST_WORD_SIZE*2;
617 break;
618 case DEFINED_RO_SEGMENT:
619@@ -2701,7 +2796,7 @@ md_pcrel_from_section (fixS * fixp, segT sec ATTRIBUTE_UNUSED)
620 else
621 {
622 /* The case where we are going to resolve things... */
623- if (fixp->fx_r_type == BFD_RELOC_64_PCREL)
624+ if (fixp->fx_r_type == BFD_RELOC_64_PCREL ||fixp->fx_r_type == BFD_RELOC_MICROBLAZE_64)
625 return fixp->fx_where + fixp->fx_frag->fr_address + INST_WORD_SIZE;
626 else
627 return fixp->fx_where + fixp->fx_frag->fr_address;
628@@ -2734,6 +2829,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
629 case BFD_RELOC_MICROBLAZE_32_RWSDA:
630 case BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM:
631 case BFD_RELOC_MICROBLAZE_64_GOTPC:
632+ case BFD_RELOC_MICROBLAZE_64_GPC:
633+ case BFD_RELOC_MICROBLAZE_64:
634 case BFD_RELOC_MICROBLAZE_64_GOT:
635 case BFD_RELOC_MICROBLAZE_64_PLT:
636 case BFD_RELOC_MICROBLAZE_64_GOTOFF:
637@@ -2876,7 +2973,10 @@ cons_fix_new_microblaze (fragS * frag,
638 r = BFD_RELOC_32;
639 break;
640 case 8:
641- r = BFD_RELOC_64;
642+ if (microblaze_arch_size == 64)
643+ r = BFD_RELOC_32;
644+ else
645+ r = BFD_RELOC_64;
646 break;
647 default:
648 as_bad (_("unsupported BFD relocation size %u"), size);
649diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h
650index 7bdba67..454e2b4 100644
651--- a/include/elf/microblaze.h
652+++ b/include/elf/microblaze.h
653@@ -62,6 +62,8 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type)
654 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_64, 31) /* TEXT Entry offset 64-bit. */
655 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_32_LO, 32) /* TEXT Entry offset 32-bit. */
656 RELOC_NUMBER (R_MICROBLAZE_32_NONE, 33)
657+ RELOC_NUMBER (R_MICROBLAZE_IMML_64, 34)
658+ RELOC_NUMBER (R_MICROBLAZE_GPC_64, 35) /* GOT entry offset. */
659
660 END_RELOC_NUMBERS (R_MICROBLAZE_max)
661
662diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
663index c88092d..8d43af0 100644
664--- a/opcodes/microblaze-opc.h
665+++ b/opcodes/microblaze-opc.h
666@@ -538,8 +538,8 @@ struct op_code_struct
667 {"llr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000300, OPCODE_MASK_H4, llr, memory_load_inst },
668 {"sl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000100, OPCODE_MASK_H4, sl, memory_store_inst },
669 {"slr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000300, OPCODE_MASK_H4, slr, memory_store_inst },
670- {"lli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, invalid_inst, memory_load_inst }, /* Identical to 32-bit */
671- {"sli", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xF8000000, OPCODE_MASK_H, invalid_inst, memory_store_inst }, /* Identical to 32-bit */
672+ {"lli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xEC000000, OPCODE_MASK_H, invalid_inst, memory_load_inst }, /* Identical to 32-bit */
673+ {"sli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xFC000000, OPCODE_MASK_H, invalid_inst, memory_store_inst }, /* Identical to 32-bit */
674 {"lla", INST_TYPE_RD_R1_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x30000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* lla translates to addlik */
675 {"dadd", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000400, OPCODE_MASK_H4, dadd, arithmetic_inst },
676 {"drsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000480, OPCODE_MASK_H4, drsub, arithmetic_inst },
677diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
678index 265cea8..abb5c9f 100644
679--- a/opcodes/microblaze-opcm.h
680+++ b/opcodes/microblaze-opcm.h
681@@ -40,8 +40,8 @@ enum microblaze_instr
682 imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid,
683 brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti,
684 bgtid, bgei, bgeid, lbu, lbuea, lbur, lhu, lhuea, lhur, lw, lwea, lwr, lwx,
685- sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi,
686- sbi, shi, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv,
687+ sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi, lli,
688+ sbi, shi, sli, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv,
689 fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, flt,
690 fint, fsqrt,
691 tget, tcget, tnget, tncget, tput, tcput, tnput, tncput,
692--
6932.7.4
694
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch
new file mode 100644
index 00000000..9cc96fae
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch
@@ -0,0 +1,38 @@
1From 7df271f0025a39dc7b9f21e122d69a6f81a44af2 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 11 Sep 2018 13:48:33 +0530
4Subject: [PATCH 17/31] [Patch,Microblaze] : negl instruction is overriding
5 rsubl,fixed it by changing the instruction order...
6
7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9---
10 opcodes/microblaze-opc.h | 4 ++--
11 1 file changed, 2 insertions(+), 2 deletions(-)
12
13diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
14index 8d43af0..2096269 100644
15--- a/opcodes/microblaze-opc.h
16+++ b/opcodes/microblaze-opc.h
17@@ -275,9 +275,7 @@ struct op_code_struct
18 {"la", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x30000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* la translates to addik. */
19 {"tuqula",INST_TYPE_RD, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x3000002A, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* tuqula rd translates to addik rd, r0, 42. */
20 {"not", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA800FFFF, OPCODE_MASK_H34, invalid_inst, logical_inst }, /* not translates to xori rd,ra,-1. */
21- {"neg", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* neg translates to rsub rd, ra, r0. */
22 {"rtb", INST_TYPE_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB6000004, OPCODE_MASK_H1, invalid_inst, return_inst }, /* rtb translates to rts rd, 4. */
23- {"sub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* sub translates to rsub rd, rb, ra. */
24 {"lmi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, invalid_inst, memory_load_inst },
25 {"smi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xF8000000, OPCODE_MASK_H, invalid_inst, memory_store_inst },
26 {"msrset",INST_TYPE_RD_IMM15, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x94100000, OPCODE_MASK_H23N, msrset, special_inst },
27@@ -555,6 +553,8 @@ struct op_code_struct
28 {"dbl", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000680, OPCODE_MASK_H4, dbl, arithmetic_inst },
29 {"dlong", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000700, OPCODE_MASK_H4, dlong, arithmetic_inst },
30 {"dsqrt", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000780, OPCODE_MASK_H4, dsqrt, arithmetic_inst },
31+ {"neg", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* neg translates to rsub rd, ra, r0. */
32+ {"sub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* sub translates to rsub rd, rb, ra. */
33
34 {"", 0, 0, 0, 0, 0, 0, 0, 0},
35 };
36--
372.7.4
38
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0018-Added-relocations-for-MB-X.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0018-Added-relocations-for-MB-X.patch
new file mode 100644
index 00000000..d401cdd3
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0018-Added-relocations-for-MB-X.patch
@@ -0,0 +1,350 @@
1From a1961dbfa4324335116f84494396ce9801688f18 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 11 Sep 2018 17:30:17 +0530
4Subject: [PATCH 18/31] Added relocations for MB-X
5
6Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
8---
9 bfd/bfd-in2.h | 11 ++++--
10 bfd/libbfd.h | 4 +--
11 bfd/reloc.c | 26 +++++++-------
12 gas/config/tc-microblaze.c | 90 ++++++++++++++++++++--------------------------
13 4 files changed, 62 insertions(+), 69 deletions(-)
14
15diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
16index 44cddc2..44e719b 100644
17--- a/bfd/bfd-in2.h
18+++ b/bfd/bfd-in2.h
19@@ -5796,16 +5796,21 @@ done here - only used for relaxing */
20 BFD_RELOC_MICROBLAZE_32_NONE,
21
22 /* This is a 64 bit reloc that stores the 32 bit pc relative
23- * +value in two words (with an imm instruction). No relocation is
24+ * +value in two words (with an imml instruction). No relocation is
25 * +done here - only used for relaxing */
26- BFD_RELOC_MICROBLAZE_64_NONE,
27+ BFD_RELOC_MICROBLAZE_64_PCREL,
28
29-/* This is a 64 bit reloc that stores the 32 bit pc relative
30+/* This is a 64 bit reloc that stores the 32 bit relative
31 * +value in two words (with an imml instruction). No relocation is
32 * +done here - only used for relaxing */
33 BFD_RELOC_MICROBLAZE_64,
34
35 /* This is a 64 bit reloc that stores the 32 bit pc relative
36+ * +value in two words (with an imm instruction). No relocation is
37+ * +done here - only used for relaxing */
38+ BFD_RELOC_MICROBLAZE_64_NONE,
39+
40+/* This is a 64 bit reloc that stores the 32 bit pc relative
41 value in two words (with an imm instruction). The relocation is
42 PC-relative GOT offset */
43 BFD_RELOC_MICROBLAZE_64_GOTPC,
44diff --git a/bfd/libbfd.h b/bfd/libbfd.h
45index d7892a6..bb8fb42 100644
46--- a/bfd/libbfd.h
47+++ b/bfd/libbfd.h
48@@ -2864,14 +2864,14 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
49 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
50 "BFD_RELOC_MICROBLAZE_32_NONE",
51 "BFD_RELOC_MICROBLAZE_64_NONE",
52- "BFD_RELOC_MICROBLAZE_64",
53 "BFD_RELOC_MICROBLAZE_64_GOTPC",
54- "BFD_RELOC_MICROBLAZE_64_GPC",
55 "BFD_RELOC_MICROBLAZE_64_GOT",
56 "BFD_RELOC_MICROBLAZE_64_PLT",
57 "BFD_RELOC_MICROBLAZE_64_GOTOFF",
58 "BFD_RELOC_MICROBLAZE_32_GOTOFF",
59 "BFD_RELOC_MICROBLAZE_COPY",
60+ "BFD_RELOC_MICROBLAZE_64",
61+ "BFD_RELOC_MICROBLAZE_64_PCREL",
62 "BFD_RELOC_MICROBLAZE_64_TLS",
63 "BFD_RELOC_MICROBLAZE_64_TLSGD",
64 "BFD_RELOC_MICROBLAZE_64_TLSLD",
65diff --git a/bfd/reloc.c b/bfd/reloc.c
66index 60eac77..2d73154 100644
67--- a/bfd/reloc.c
68+++ b/bfd/reloc.c
69@@ -6873,12 +6873,6 @@ ENUMDOC
70 ENUM
71 BFD_RELOC_MICROBLAZE_64_NONE
72 ENUMDOC
73- This is a 32 bit reloc that stores the 32 bit pc relative
74- value in two words (with an imml instruction). No relocation is
75- done here - only used for relaxing
76-ENUM
77- BFD_RELOC_MICROBLAZE_64
78-ENUMDOC
79 This is a 64 bit reloc that stores the 32 bit pc relative
80 value in two words (with an imm instruction). No relocation is
81 done here - only used for relaxing
82@@ -6886,12 +6880,6 @@ ENUM
83 BFD_RELOC_MICROBLAZE_64_GOTPC
84 ENUMDOC
85 This is a 64 bit reloc that stores the 32 bit pc relative
86- value in two words (with an imml instruction). No relocation is
87- done here - only used for relaxing
88-ENUM
89- BFD_RELOC_MICROBLAZE_64_GPC
90-ENUMDOC
91- This is a 64 bit reloc that stores the 32 bit pc relative
92 value in two words (with an imm instruction). The relocation is
93 PC-relative GOT offset
94 ENUM
95@@ -6975,6 +6963,20 @@ ENUMDOC
96 value in two words (with an imm instruction). The relocation is
97 relative offset from start of TEXT.
98
99+ This is a 64 bit reloc that stores 64-bit thread pointer relative offset
100+ to two words (uses imml instruction).
101+ENUM
102+BFD_RELOC_MICROBLAZE_64,
103+ENUMDOC
104+ This is a 64 bit reloc that stores the 64 bit pc relative
105+ value in two words (with an imml instruction). No relocation is
106+ done here - only used for relaxing
107+ENUM
108+BFD_RELOC_MICROBLAZE_64_PCREL,
109+ENUMDOC
110+ This is a 32 bit reloc that stores the 32 bit pc relative
111+ value in two words (with an imml instruction). No relocation is
112+ done here - only used for relaxing
113 ENUM
114 BFD_RELOC_AARCH64_RELOC_START
115 ENUMDOC
116diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
117index 680a794..663e1a6 100644
118--- a/gas/config/tc-microblaze.c
119+++ b/gas/config/tc-microblaze.c
120@@ -95,6 +95,7 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP";
121 #define TEXT_OFFSET 17
122 #define TEXT_PC_OFFSET 18
123 #define DEFINED_64_OFFSET 19
124+#define DEFINED_64_PC_OFFSET 20
125
126 /* Initialize the relax table. */
127 const relax_typeS md_relax_table[] =
128@@ -119,7 +120,8 @@ const relax_typeS md_relax_table[] =
129 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 17: TEXT_OFFSET. */
130 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 18: TEXT_PC_OFFSET. */
131 // { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 16: TLSTPREL_OFFSET. */
132- { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 } /* 17: DEFINED_64_OFFSET. */
133+ { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 } /* 19: DEFINED_64_OFFSET. */
134+ { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE*2, 0 } /* 20: DEFINED_64_PC_OFFSET. */
135 };
136
137 static struct hash_control * opcode_hash_control; /* Opcode mnemonics. */
138@@ -1180,33 +1182,6 @@ md_assemble (char * str)
139 inst |= (immed << IMM_LOW) & IMM_MASK;
140 }
141 }
142-#if 0 //revisit
143- else if (streq (name, "lli") || streq (name, "sli"))
144- {
145- temp = immed & 0xFFFFFFFFFFFF8000;
146- if ((temp != 0) && (temp != 0xFFFFFFFFFFFF8000))
147- {
148- /* Needs an immediate inst. */
149- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
150- if (opcode1 == NULL)
151- {
152- as_bad (_("unknown opcode \"%s\""), "imml");
153- return;
154- }
155-
156- inst1 = opcode1->bit_sequence;
157- inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
158- output[0] = INST_BYTE0 (inst1);
159- output[1] = INST_BYTE1 (inst1);
160- output[2] = INST_BYTE2 (inst1);
161- output[3] = INST_BYTE3 (inst1);
162- output = frag_more (isize);
163- }
164- inst |= (reg1 << RD_LOW) & RD_MASK;
165- inst |= (reg2 << RA_LOW) & RA_MASK;
166- inst |= (immed << IMM_LOW) & IMM_MASK;
167- }
168-#endif
169 else
170 {
171 temp = immed & 0xFFFF8000;
172@@ -1958,8 +1933,8 @@ md_assemble (char * str)
173
174 if (exp.X_op != O_constant)
175 {
176- char *opc = NULL;
177- //char *opc = str_microblaze_64;
178+ //char *opc = NULL;
179+ char *opc = str_microblaze_64;
180 relax_substateT subtype;
181
182 if (exp.X_md != 0)
183@@ -2221,13 +2196,19 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
184 fragP->fr_fix += INST_WORD_SIZE * 2;
185 fragP->fr_var = 0;
186 break;
187+ case DEFINED_64_PC_OFFSET:
188+ fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
189+ fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_PCREL);
190+ fragP->fr_fix += INST_WORD_SIZE * 2;
191+ fragP->fr_var = 0;
192+ break;
193 case DEFINED_64_OFFSET:
194 if (fragP->fr_symbol == GOT_symbol)
195 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
196- fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_GPC);
197+ fragP->fr_offset, FALSE, BFD_RELOC_MICROBLAZE_64_GPC);
198 else
199 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
200- fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64);
201+ fragP->fr_offset, FALSE, BFD_RELOC_MICROBLAZE_64);
202 fragP->fr_fix += INST_WORD_SIZE * 2;
203 fragP->fr_var = 0;
204 break;
205@@ -2237,7 +2218,7 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
206 fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_GOTPC);
207 else
208 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol,
209- fragP->fr_offset, TRUE, BFD_RELOC_64);
210+ fragP->fr_offset, FALSE, BFD_RELOC_64);
211 fragP->fr_fix += INST_WORD_SIZE * 2;
212 fragP->fr_var = 0;
213 break;
214@@ -2457,14 +2438,17 @@ md_apply_fix (fixS * fixP,
215 }
216 }
217 break;
218+
219 case BFD_RELOC_64_PCREL:
220 case BFD_RELOC_64:
221 case BFD_RELOC_MICROBLAZE_64_TEXTREL:
222 case BFD_RELOC_MICROBLAZE_64:
223+ case BFD_RELOC_MICROBLAZE_64_PCREL:
224 /* Add an imm instruction. First save the current instruction. */
225 for (i = 0; i < INST_WORD_SIZE; i++)
226 buf[i + INST_WORD_SIZE] = buf[i];
227- if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
228+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64
229+ || fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
230 {
231 /* Generate the imm instruction. */
232 opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
233@@ -2477,6 +2461,10 @@ md_apply_fix (fixS * fixP,
234 inst1 = opcode1->bit_sequence;
235 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
236 inst1 |= ((val & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
237+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
238+ fixP->fx_r_type = BFD_RELOC_64;
239+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
240+ fixP->fx_r_type = BFD_RELOC_64_PCREL;
241 }
242 else
243 {
244@@ -2487,7 +2475,7 @@ md_apply_fix (fixS * fixP,
245 as_bad (_("unknown opcode \"%s\""), "imm");
246 return;
247 }
248-
249+
250 inst1 = opcode1->bit_sequence;
251 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
252 inst1 |= ((val & 0xFFFF0000) >> 16) & IMM_MASK;
253@@ -2534,7 +2522,7 @@ md_apply_fix (fixS * fixP,
254 opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
255 if (opcode1 == NULL)
256 {
257- if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
258+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
259 as_bad (_("unknown opcode \"%s\""), "imml");
260 else
261 as_bad (_("unknown opcode \"%s\""), "imm");
262@@ -2561,8 +2549,6 @@ md_apply_fix (fixS * fixP,
263 moves code around due to relaxing. */
264 if (fixP->fx_r_type == BFD_RELOC_64_PCREL)
265 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
266- if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
267- fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
268 else if (fixP->fx_r_type == BFD_RELOC_32)
269 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_32_NONE;
270 else
271@@ -2613,33 +2599,24 @@ md_estimate_size_before_relax (fragS * fragP,
272 if(streq (fragP->fr_opcode, str_microblaze_64))
273 {
274 /* Used as an absolute value. */
275- fragP->fr_subtype = DEFINED_64_OFFSET;
276+ fragP->fr_subtype = DEFINED_64_PC_OFFSET;
277 /* Variable part does not change. */
278- fragP->fr_var = INST_WORD_SIZE;
279+ fragP->fr_var = INST_WORD_SIZE*2;
280 }
281 else
282 {
283 fragP->fr_subtype = DEFINED_PC_OFFSET;
284- /* Don't know now whether we need an imm instruction. */
285+ /* Don't know now whether we need an imm instruction. */
286 fragP->fr_var = INST_WORD_SIZE;
287 }
288 }
289 else
290 {
291 fragP->fr_subtype = DEFINED_PC_OFFSET;
292- /* Don't know now whether we need an imm instruction. */
293+ /* Don't know now whether we need an imm instruction. */
294 fragP->fr_var = INST_WORD_SIZE;
295 }
296 }
297- #if 0
298- else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type &&
299- !S_IS_WEAK (fragP->fr_symbol))
300- {
301- fragP->fr_subtype = DEFINED_PC_OFFSET;
302- /* Don't know now whether we need an imm instruction. */
303- fragP->fr_var = INST_WORD_SIZE;
304- }
305-#endif
306 else if (S_IS_DEFINED (fragP->fr_symbol)
307 && (((S_GET_SEGMENT (fragP->fr_symbol))->flags & SEC_CODE) == 0))
308 {
309@@ -2669,6 +2646,13 @@ md_estimate_size_before_relax (fragS * fragP,
310 /* Variable part does not change. */
311 fragP->fr_var = INST_WORD_SIZE*2;
312 }
313+ else if (streq (fragP->fr_opcode, str_microblaze_64))
314+ {
315+ /* Used as an absolute value. */
316+ fragP->fr_subtype = DEFINED_64_OFFSET;
317+ /* Variable part does not change. */
318+ fragP->fr_var = INST_WORD_SIZE;
319+ }
320 else if (streq (fragP->fr_opcode, str_microblaze_ro_anchor))
321 {
322 /* It is accessed using the small data read only anchor. */
323@@ -2743,6 +2727,7 @@ md_estimate_size_before_relax (fragS * fragP,
324 case TLSTPREL_OFFSET:
325 case TLSDTPREL_OFFSET:
326 case DEFINED_64_OFFSET:
327+ case DEFINED_64_PC_OFFSET:
328 fragP->fr_var = INST_WORD_SIZE*2;
329 break;
330 case DEFINED_RO_SEGMENT:
331@@ -2796,7 +2781,7 @@ md_pcrel_from_section (fixS * fixp, segT sec ATTRIBUTE_UNUSED)
332 else
333 {
334 /* The case where we are going to resolve things... */
335- if (fixp->fx_r_type == BFD_RELOC_64_PCREL ||fixp->fx_r_type == BFD_RELOC_MICROBLAZE_64)
336+ if (fixp->fx_r_type == BFD_RELOC_64_PCREL ||fixp->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
337 return fixp->fx_where + fixp->fx_frag->fr_address + INST_WORD_SIZE;
338 else
339 return fixp->fx_where + fixp->fx_frag->fr_address;
340@@ -2831,6 +2816,7 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
341 case BFD_RELOC_MICROBLAZE_64_GOTPC:
342 case BFD_RELOC_MICROBLAZE_64_GPC:
343 case BFD_RELOC_MICROBLAZE_64:
344+ case BFD_RELOC_MICROBLAZE_64_PCREL:
345 case BFD_RELOC_MICROBLAZE_64_GOT:
346 case BFD_RELOC_MICROBLAZE_64_PLT:
347 case BFD_RELOC_MICROBLAZE_64_GOTOFF:
348--
3492.7.4
350
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0019-Fixed-MB-x-relocation-issues.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0019-Fixed-MB-x-relocation-issues.patch
new file mode 100644
index 00000000..814672d2
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0019-Fixed-MB-x-relocation-issues.patch
@@ -0,0 +1,375 @@
1From b63b8ae83cc538808e06d84143df6b7150fb4037 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 28 Sep 2018 12:04:55 +0530
4Subject: [PATCH 19/31] -Fixed MB-x relocation issues -Added imml for required
5 MB-x instructions
6
7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9---
10 bfd/elf64-microblaze.c | 68 ++++++++++++++++----
11 gas/config/tc-microblaze.c | 152 ++++++++++++++++++++++++++++++++-------------
12 gas/tc.h | 2 +-
13 3 files changed, 167 insertions(+), 55 deletions(-)
14
15diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
16index 56a45f2..54a2461 100644
17--- a/bfd/elf64-microblaze.c
18+++ b/bfd/elf64-microblaze.c
19@@ -1476,8 +1476,17 @@ microblaze_elf_relocate_section (bfd *output_bfd,
20 relocation -= (input_section->output_section->vma
21 + input_section->output_offset
22 + offset + INST_WORD_SIZE);
23- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
24+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
25+ if (insn == 0xb2000000 || insn == 0xb2ffffff)
26+ {
27+ insn &= ~0x00ffffff;
28+ insn |= (relocation >> 16) & 0xffffff;
29+ bfd_put_32 (input_bfd, insn,
30 contents + offset + endian);
31+ }
32+ else
33+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
34+ contents + offset + endian);
35 bfd_put_16 (input_bfd, relocation & 0xffff,
36 contents + offset + endian + INST_WORD_SIZE);
37 }
38@@ -1567,11 +1576,28 @@ microblaze_elf_relocate_section (bfd *output_bfd,
39 else
40 {
41 if (r_type == R_MICROBLAZE_64_PCREL)
42- relocation -= (input_section->output_section->vma
43- + input_section->output_offset
44- + offset + INST_WORD_SIZE);
45- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
46+ {
47+ if (!input_section->output_section->vma &&
48+ !input_section->output_offset && !offset)
49+ relocation -= (input_section->output_section->vma
50+ + input_section->output_offset
51+ + offset);
52+ else
53+ relocation -= (input_section->output_section->vma
54+ + input_section->output_offset
55+ + offset + INST_WORD_SIZE);
56+ }
57+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
58+ if (insn == 0xb2000000 || insn == 0xb2ffffff)
59+ {
60+ insn &= ~0x00ffffff;
61+ insn |= (relocation >> 16) & 0xffffff;
62+ bfd_put_32 (input_bfd, insn,
63 contents + offset + endian);
64+ }
65+ else
66+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
67+ contents + offset + endian);
68 bfd_put_16 (input_bfd, relocation & 0xffff,
69 contents + offset + endian + INST_WORD_SIZE);
70 }
71@@ -1690,9 +1716,19 @@ static void
72 microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
73 {
74 unsigned long instr = bfd_get_32 (abfd, bfd_addr);
75- instr &= ~0x0000ffff;
76- instr |= (val & 0x0000ffff);
77- bfd_put_32 (abfd, instr, bfd_addr);
78+
79+ if (instr == 0xb2000000 || instr == 0xb2ffffff)
80+ {
81+ instr &= ~0x00ffffff;
82+ instr |= (val & 0xffffff);
83+ bfd_put_32 (abfd, instr, bfd_addr);
84+ }
85+ else
86+ {
87+ instr &= ~0x0000ffff;
88+ instr |= (val & 0x0000ffff);
89+ bfd_put_32 (abfd, instr, bfd_addr);
90+ }
91 }
92
93 /* Read-modify-write into the bfd, an immediate value into appropriate fields of
94@@ -1704,10 +1740,18 @@ microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
95 unsigned long instr_lo;
96
97 instr_hi = bfd_get_32 (abfd, bfd_addr);
98- instr_hi &= ~0x0000ffff;
99- instr_hi |= ((val >> 16) & 0x0000ffff);
100- bfd_put_32 (abfd, instr_hi, bfd_addr);
101-
102+ if (instr_hi == 0xb2000000 || instr_hi == 0xb2ffffff)
103+ {
104+ instr_hi &= ~0x00ffffff;
105+ instr_hi |= (val >> 16) & 0xffffff;
106+ bfd_put_32 (abfd, instr_hi,bfd_addr);
107+ }
108+ else
109+ {
110+ instr_hi &= ~0x0000ffff;
111+ instr_hi |= ((val >> 16) & 0x0000ffff);
112+ bfd_put_32 (abfd, instr_hi, bfd_addr);
113+ }
114 instr_lo = bfd_get_32 (abfd, bfd_addr + INST_WORD_SIZE);
115 instr_lo &= ~0x0000ffff;
116 instr_lo |= (val & 0x0000ffff);
117diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
118index 663e1a6..8d2980a 100644
119--- a/gas/config/tc-microblaze.c
120+++ b/gas/config/tc-microblaze.c
121@@ -392,7 +392,7 @@ microblaze_s_weakext (int ignore ATTRIBUTE_UNUSED)
122 Integer arg to pass to the function. */
123 /* If the pseudo-op is not found in this table, it searches in the obj-elf.c,
124 and then in the read.c table. */
125-const pseudo_typeS md_pseudo_table[] =
126+pseudo_typeS md_pseudo_table[] =
127 {
128 {"lcomm", microblaze_s_lcomm, 1},
129 {"data", microblaze_s_data, 0},
130@@ -401,7 +401,7 @@ const pseudo_typeS md_pseudo_table[] =
131 {"data32", cons, 4}, /* Same as word. */
132 {"ent", s_func, 0}, /* Treat ent as function entry point. */
133 {"end", microblaze_s_func, 1}, /* Treat end as function end point. */
134- {"gpword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
135+ {"gpword", s_rva, 4}, /* gpword label => store resolved label address in data section. */
136 {"gpdword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
137 {"weakext", microblaze_s_weakext, 0},
138 {"rodata", microblaze_s_rdata, 0},
139@@ -996,7 +996,7 @@ md_assemble (char * str)
140 unsigned reg2;
141 unsigned reg3;
142 unsigned isize;
143- unsigned int immed, immed2, temp;
144+ unsigned long immed, immed2, temp;
145 expressionS exp;
146 char name[20];
147 long immedl;
148@@ -1118,8 +1118,9 @@ md_assemble (char * str)
149 as_fatal (_("lmi pseudo instruction should not use a label in imm field"));
150 else if (streq (name, "smi"))
151 as_fatal (_("smi pseudo instruction should not use a label in imm field"));
152-
153- if (reg2 == REG_ROSDP)
154+ if(streq (name, "lli") || streq (name, "sli"))
155+ opc = str_microblaze_64;
156+ else if (reg2 == REG_ROSDP)
157 opc = str_microblaze_ro_anchor;
158 else if (reg2 == REG_RWSDP)
159 opc = str_microblaze_rw_anchor;
160@@ -1182,31 +1183,55 @@ md_assemble (char * str)
161 inst |= (immed << IMM_LOW) & IMM_MASK;
162 }
163 }
164- else
165- {
166- temp = immed & 0xFFFF8000;
167- if ((temp != 0) && (temp != 0xFFFF8000))
168- {
169+ else if (streq (name, "lli") || streq (name, "sli"))
170+ {
171+ temp = immed & 0xFFFFFF8000;
172+ if (temp != 0 && temp != 0xFFFFFF8000)
173+ {
174 /* Needs an immediate inst. */
175- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
176+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
177 if (opcode1 == NULL)
178 {
179- as_bad (_("unknown opcode \"%s\""), "imm");
180+ as_bad (_("unknown opcode \"%s\""), "imml");
181 return;
182 }
183-
184 inst1 = opcode1->bit_sequence;
185- inst1 |= ((immed & 0xFFFF0000) >> 16) & IMM_MASK;
186+ inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
187 output[0] = INST_BYTE0 (inst1);
188 output[1] = INST_BYTE1 (inst1);
189 output[2] = INST_BYTE2 (inst1);
190 output[3] = INST_BYTE3 (inst1);
191 output = frag_more (isize);
192- }
193- inst |= (reg1 << RD_LOW) & RD_MASK;
194- inst |= (reg2 << RA_LOW) & RA_MASK;
195- inst |= (immed << IMM_LOW) & IMM_MASK;
196- }
197+ }
198+ inst |= (reg1 << RD_LOW) & RD_MASK;
199+ inst |= (reg2 << RA_LOW) & RA_MASK;
200+ inst |= (immed << IMM_LOW) & IMM_MASK;
201+ }
202+ else
203+ {
204+ temp = immed & 0xFFFF8000;
205+ if ((temp != 0) && (temp != 0xFFFF8000))
206+ {
207+ /* Needs an immediate inst. */
208+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
209+ if (opcode1 == NULL)
210+ {
211+ as_bad (_("unknown opcode \"%s\""), "imm");
212+ return;
213+ }
214+
215+ inst1 = opcode1->bit_sequence;
216+ inst1 |= ((immed & 0xFFFF0000) >> 16) & IMM_MASK;
217+ output[0] = INST_BYTE0 (inst1);
218+ output[1] = INST_BYTE1 (inst1);
219+ output[2] = INST_BYTE2 (inst1);
220+ output[3] = INST_BYTE3 (inst1);
221+ output = frag_more (isize);
222+ }
223+ inst |= (reg1 << RD_LOW) & RD_MASK;
224+ inst |= (reg2 << RA_LOW) & RA_MASK;
225+ inst |= (immed << IMM_LOW) & IMM_MASK;
226+ }
227 break;
228
229 case INST_TYPE_RD_R1_IMMS:
230@@ -1832,12 +1857,20 @@ md_assemble (char * str)
231 case INST_TYPE_IMM:
232 if (streq (name, "imm"))
233 as_fatal (_("An IMM instruction should not be present in the .s file"));
234-
235- op_end = parse_imm (op_end + 1, & exp, MIN_IMM, MAX_IMM);
236+ if (microblaze_arch_size == 64)
237+ op_end = parse_imml (op_end + 1, & exp, MIN_IMML, MAX_IMML);
238+ else
239+ op_end = parse_imm (op_end + 1, & exp, MIN_IMM, MAX_IMM);
240
241 if (exp.X_op != O_constant)
242 {
243- char *opc = NULL;
244+ char *opc;
245+ if (microblaze_arch_size == 64 && (streq (name, "breai") ||
246+ streq (name, "breaid") ||
247+ streq (name, "brai") || streq (name, "braid")))
248+ opc = str_microblaze_64;
249+ else
250+ opc = NULL;
251 relax_substateT subtype;
252
253 if (exp.X_md != 0)
254@@ -1860,27 +1893,54 @@ md_assemble (char * str)
255 immed = exp.X_add_number;
256 }
257
258+ if (microblaze_arch_size == 64 && (streq (name, "breai") ||
259+ streq (name, "breaid") ||
260+ streq (name, "brai") || streq (name, "braid")))
261+ {
262+ temp = immed & 0xFFFFFF8000;
263+ if (temp != 0)
264+ {
265+ /* Needs an immediate inst. */
266+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
267+ if (opcode1 == NULL)
268+ {
269+ as_bad (_("unknown opcode \"%s\""), "imml");
270+ return;
271+ }
272
273- temp = immed & 0xFFFF8000;
274- if ((temp != 0) && (temp != 0xFFFF8000))
275- {
276- /* Needs an immediate inst. */
277- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
278- if (opcode1 == NULL)
279- {
280- as_bad (_("unknown opcode \"%s\""), "imm");
281- return;
282+ inst1 = opcode1->bit_sequence;
283+ inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
284+ output[0] = INST_BYTE0 (inst1);
285+ output[1] = INST_BYTE1 (inst1);
286+ output[2] = INST_BYTE2 (inst1);
287+ output[3] = INST_BYTE3 (inst1);
288+ output = frag_more (isize);
289 }
290+ inst |= (immed << IMM_LOW) & IMM_MASK;
291+ }
292+ else
293+ {
294+ temp = immed & 0xFFFF8000;
295+ if ((temp != 0) && (temp != 0xFFFF8000))
296+ {
297+ /* Needs an immediate inst. */
298+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
299+ if (opcode1 == NULL)
300+ {
301+ as_bad (_("unknown opcode \"%s\""), "imm");
302+ return;
303+ }
304
305- inst1 = opcode1->bit_sequence;
306- inst1 |= ((immed & 0xFFFF0000) >> 16) & IMM_MASK;
307- output[0] = INST_BYTE0 (inst1);
308- output[1] = INST_BYTE1 (inst1);
309- output[2] = INST_BYTE2 (inst1);
310- output[3] = INST_BYTE3 (inst1);
311- output = frag_more (isize);
312- }
313- inst |= (immed << IMM_LOW) & IMM_MASK;
314+ inst1 = opcode1->bit_sequence;
315+ inst1 |= ((immed & 0xFFFF0000) >> 16) & IMM_MASK;
316+ output[0] = INST_BYTE0 (inst1);
317+ output[1] = INST_BYTE1 (inst1);
318+ output[2] = INST_BYTE2 (inst1);
319+ output[3] = INST_BYTE3 (inst1);
320+ output = frag_more (isize);
321+ }
322+ inst |= (immed << IMM_LOW) & IMM_MASK;
323+ }
324 break;
325
326 case INST_TYPE_NONE:
327@@ -2460,7 +2520,7 @@ md_apply_fix (fixS * fixP,
328
329 inst1 = opcode1->bit_sequence;
330 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
331- inst1 |= ((val & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
332+ inst1 |= ((val & 0xFFFFFF0000L) >> 16) & IMML_MASK;
333 if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
334 fixP->fx_r_type = BFD_RELOC_64;
335 if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
336@@ -2628,7 +2688,14 @@ md_estimate_size_before_relax (fragS * fragP,
337 }
338 else
339 {
340- fragP->fr_subtype = UNDEFINED_PC_OFFSET;
341+ if (fragP->fr_opcode != NULL) {
342+ if (streq (fragP->fr_opcode, str_microblaze_64))
343+ fragP->fr_subtype = DEFINED_64_PC_OFFSET;
344+ else
345+ fragP->fr_subtype = UNDEFINED_PC_OFFSET;
346+ }
347+ else
348+ fragP->fr_subtype = UNDEFINED_PC_OFFSET;
349 fragP->fr_var = INST_WORD_SIZE*2;
350 }
351 break;
352@@ -2905,6 +2972,7 @@ md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
353 case OPTION_M64:
354 //if (arg != NULL && strcmp (arg, "64") == 0)
355 microblaze_arch_size = 64;
356+ md_pseudo_table[7].poc_val = 8;
357 break;
358 default:
359 return 0;
360diff --git a/gas/tc.h b/gas/tc.h
361index beddb48..96c7559 100644
362--- a/gas/tc.h
363+++ b/gas/tc.h
364@@ -22,7 +22,7 @@
365 /* In theory (mine, at least!) the machine dependent part of the assembler
366 should only have to include one file. This one. -- JF */
367
368-extern const pseudo_typeS md_pseudo_table[];
369+extern pseudo_typeS md_pseudo_table[];
370
371 const char * md_atof (int, char *, int *);
372 int md_parse_option (int, const char *);
373--
3742.7.4
375
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0020-Fixing-the-branch-related-issues.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0020-Fixing-the-branch-related-issues.patch
new file mode 100644
index 00000000..0fbb6362
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0020-Fixing-the-branch-related-issues.patch
@@ -0,0 +1,27 @@
1From fc9704bdb0c74f34a77346c0283f2e05440d68ec Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Sun, 30 Sep 2018 17:06:58 +0530
4Subject: [PATCH 20/31] Fixing the branch related issues
5
6Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
8---
9 bfd/elf64-microblaze.c | 2 +-
10 1 file changed, 1 insertion(+), 1 deletion(-)
11
12diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
13index 54a2461..e9b3cf3 100644
14--- a/bfd/elf64-microblaze.c
15+++ b/bfd/elf64-microblaze.c
16@@ -2532,7 +2532,7 @@ microblaze_elf_check_relocs (bfd * abfd,
17
18 /* PR15323, ref flags aren't set for references in the same
19 object. */
20- h->root.non_ir_ref = 1;
21+ h->root.non_ir_ref_regular = 1;
22 }
23
24 switch (r_type)
25--
262.7.4
27
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0021-Fixed-address-computation-issues-with-64bit-address.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0021-Fixed-address-computation-issues-with-64bit-address.patch
new file mode 100644
index 00000000..612f706d
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0021-Fixed-address-computation-issues-with-64bit-address.patch
@@ -0,0 +1,219 @@
1From 380ad65a2bdb42749c22783f53f4b2263721a2ca Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 9 Oct 2018 10:14:22 +0530
4Subject: [PATCH 21/31] - Fixed address computation issues with 64bit address -
5 Fixed imml dissassamble issue
6
7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9---
10 bfd/bfd-in2.h | 5 ++++
11 bfd/elf64-microblaze.c | 14 ++++-----
12 gas/config/tc-microblaze.c | 74 +++++++++++++++++++++++++++++++++++++++++-----
13 opcodes/microblaze-dis.c | 2 +-
14 4 files changed, 79 insertions(+), 16 deletions(-)
15
16diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
17index 44e719b..a35e51d 100644
18--- a/bfd/bfd-in2.h
19+++ b/bfd/bfd-in2.h
20@@ -5805,6 +5805,11 @@ done here - only used for relaxing */
21 * +done here - only used for relaxing */
22 BFD_RELOC_MICROBLAZE_64,
23
24+/* This is a 64 bit reloc that stores the 32 bit relative
25+ * +value in two words (with an imml instruction). No relocation is
26+ * +done here - only used for relaxing */
27+ BFD_RELOC_MICROBLAZE_EA64,
28+
29 /* This is a 64 bit reloc that stores the 32 bit pc relative
30 * +value in two words (with an imm instruction). No relocation is
31 * +done here - only used for relaxing */
32diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
33index e9b3cf3..40f10aa 100644
34--- a/bfd/elf64-microblaze.c
35+++ b/bfd/elf64-microblaze.c
36@@ -121,15 +121,15 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
37 0, /* Rightshift. */
38 4, /* Size (0 = byte, 1 = short, 2 = long). */
39 64, /* Bitsize. */
40- TRUE, /* PC_relative. */
41+ FALSE, /* PC_relative. */
42 0, /* Bitpos. */
43 complain_overflow_dont, /* Complain on overflow. */
44 bfd_elf_generic_reloc,/* Special Function. */
45 "R_MICROBLAZE_IMML_64", /* Name. */
46 FALSE, /* Partial Inplace. */
47 0, /* Source Mask. */
48- 0x0000ffff, /* Dest Mask. */
49- TRUE), /* PC relative offset? */
50+ 0xffffffffffffff, /* Dest Mask. */
51+ FALSE), /* PC relative offset? */
52
53 /* A 64 bit relocation. Table entry not really used. */
54 HOWTO (R_MICROBLAZE_64, /* Type. */
55@@ -585,9 +585,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
56 case BFD_RELOC_32:
57 microblaze_reloc = R_MICROBLAZE_32;
58 break;
59- /* RVA is treated the same as 32 */
60+ /* RVA is treated the same as 64 */
61 case BFD_RELOC_RVA:
62- microblaze_reloc = R_MICROBLAZE_32;
63+ microblaze_reloc = R_MICROBLAZE_IMML_64;
64 break;
65 case BFD_RELOC_32_PCREL:
66 microblaze_reloc = R_MICROBLAZE_32_PCREL;
67@@ -619,7 +619,7 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
68 case BFD_RELOC_VTABLE_ENTRY:
69 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
70 break;
71- case BFD_RELOC_MICROBLAZE_64:
72+ case BFD_RELOC_MICROBLAZE_EA64:
73 microblaze_reloc = R_MICROBLAZE_IMML_64;
74 break;
75 case BFD_RELOC_MICROBLAZE_64_GOTPC:
76@@ -1969,7 +1969,7 @@ microblaze_elf_relax_section (bfd *abfd,
77 efix = calc_fixup (target_address, 0, sec);
78
79 /* Validate the in-band val. */
80- val = bfd_get_32 (abfd, contents + irel->r_offset);
81+ val = bfd_get_64 (abfd, contents + irel->r_offset);
82 if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
83 fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
84 }
85diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
86index 8d2980a..7ff93a1 100644
87--- a/gas/config/tc-microblaze.c
88+++ b/gas/config/tc-microblaze.c
89@@ -402,7 +402,6 @@ pseudo_typeS md_pseudo_table[] =
90 {"ent", s_func, 0}, /* Treat ent as function entry point. */
91 {"end", microblaze_s_func, 1}, /* Treat end as function end point. */
92 {"gpword", s_rva, 4}, /* gpword label => store resolved label address in data section. */
93- {"gpdword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
94 {"weakext", microblaze_s_weakext, 0},
95 {"rodata", microblaze_s_rdata, 0},
96 {"sdata2", microblaze_s_rdata, 1},
97@@ -2482,15 +2481,71 @@ md_apply_fix (fixS * fixP,
98 /* Don't do anything if the symbol is not defined. */
99 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
100 {
101+ if ((fixP->fx_r_type == BFD_RELOC_RVA) && (microblaze_arch_size == 64))
102+ {
103+ if (target_big_endian)
104+ {
105+ buf[0] |= ((val >> 56) & 0xff);
106+ buf[1] |= ((val >> 48) & 0xff);
107+ buf[2] |= ((val >> 40) & 0xff);
108+ buf[3] |= ((val >> 32) & 0xff);
109+ buf[4] |= ((val >> 24) & 0xff);
110+ buf[5] |= ((val >> 16) & 0xff);
111+ buf[6] |= ((val >> 8) & 0xff);
112+ buf[7] |= (val & 0xff);
113+ }
114+ else
115+ {
116+ buf[7] |= ((val >> 56) & 0xff);
117+ buf[6] |= ((val >> 48) & 0xff);
118+ buf[5] |= ((val >> 40) & 0xff);
119+ buf[4] |= ((val >> 32) & 0xff);
120+ buf[3] |= ((val >> 24) & 0xff);
121+ buf[2] |= ((val >> 16) & 0xff);
122+ buf[1] |= ((val >> 8) & 0xff);
123+ buf[0] |= (val & 0xff);
124+ }
125+ }
126+ else {
127+ if (target_big_endian)
128+ {
129+ buf[0] |= ((val >> 24) & 0xff);
130+ buf[1] |= ((val >> 16) & 0xff);
131+ buf[2] |= ((val >> 8) & 0xff);
132+ buf[3] |= (val & 0xff);
133+ }
134+ else
135+ {
136+ buf[3] |= ((val >> 24) & 0xff);
137+ buf[2] |= ((val >> 16) & 0xff);
138+ buf[1] |= ((val >> 8) & 0xff);
139+ buf[0] |= (val & 0xff);
140+ }
141+ }
142+ }
143+ break;
144+
145+ case BFD_RELOC_MICROBLAZE_EA64:
146+ /* Don't do anything if the symbol is not defined. */
147+ if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
148+ {
149 if (target_big_endian)
150 {
151- buf[0] |= ((val >> 24) & 0xff);
152- buf[1] |= ((val >> 16) & 0xff);
153- buf[2] |= ((val >> 8) & 0xff);
154- buf[3] |= (val & 0xff);
155+ buf[0] |= ((val >> 56) & 0xff);
156+ buf[1] |= ((val >> 48) & 0xff);
157+ buf[2] |= ((val >> 40) & 0xff);
158+ buf[3] |= ((val >> 32) & 0xff);
159+ buf[4] |= ((val >> 24) & 0xff);
160+ buf[5] |= ((val >> 16) & 0xff);
161+ buf[6] |= ((val >> 8) & 0xff);
162+ buf[7] |= (val & 0xff);
163 }
164 else
165 {
166+ buf[7] |= ((val >> 56) & 0xff);
167+ buf[6] |= ((val >> 48) & 0xff);
168+ buf[5] |= ((val >> 40) & 0xff);
169+ buf[4] |= ((val >> 32) & 0xff);
170 buf[3] |= ((val >> 24) & 0xff);
171 buf[2] |= ((val >> 16) & 0xff);
172 buf[1] |= ((val >> 8) & 0xff);
173@@ -2611,6 +2666,8 @@ md_apply_fix (fixS * fixP,
174 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
175 else if (fixP->fx_r_type == BFD_RELOC_32)
176 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_32_NONE;
177+ else if(fixP->fx_r_type == BFD_RELOC_MICROBLAZE_EA64)
178+ fixP->fx_r_type = BFD_RELOC_MICROBLAZE_EA64;
179 else
180 fixP->fx_r_type = BFD_RELOC_NONE;
181 fixP->fx_addsy = section_symbol (absolute_section);
182@@ -2882,6 +2939,7 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
183 case BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM:
184 case BFD_RELOC_MICROBLAZE_64_GOTPC:
185 case BFD_RELOC_MICROBLAZE_64_GPC:
186+ case BFD_RELOC_MICROBLAZE_EA64:
187 case BFD_RELOC_MICROBLAZE_64:
188 case BFD_RELOC_MICROBLAZE_64_PCREL:
189 case BFD_RELOC_MICROBLAZE_64_GOT:
190@@ -3027,10 +3085,10 @@ cons_fix_new_microblaze (fragS * frag,
191 r = BFD_RELOC_32;
192 break;
193 case 8:
194- if (microblaze_arch_size == 64)
195+ /*if (microblaze_arch_size == 64)
196 r = BFD_RELOC_32;
197- else
198- r = BFD_RELOC_64;
199+ else*/
200+ r = BFD_RELOC_MICROBLAZE_EA64;
201 break;
202 default:
203 as_bad (_("unsupported BFD relocation size %u"), size);
204diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
205index 09757d1..69e11e6 100644
206--- a/opcodes/microblaze-dis.c
207+++ b/opcodes/microblaze-dis.c
208@@ -61,7 +61,7 @@ get_field_imml (long instr)
209 {
210 char tmpstr[25];
211
212- sprintf (tmpstr, "%d", (short)((instr & IMML_MASK) >> IMM_LOW));
213+ sprintf (tmpstr, "%d", (int)((instr & IMML_MASK) >> IMM_LOW));
214 return (strdup (tmpstr));
215 }
216
217--
2182.7.4
219
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0022-Adding-new-relocation-to-support-64bit-rodata.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0022-Adding-new-relocation-to-support-64bit-rodata.patch
new file mode 100644
index 00000000..4e54b0d3
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0022-Adding-new-relocation-to-support-64bit-rodata.patch
@@ -0,0 +1,168 @@
1From e2c399e62b6b0f1940e73024a8076c8787602b9c Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Sat, 13 Oct 2018 21:17:01 +0530
4Subject: [PATCH 22/31] Adding new relocation to support 64bit rodata
5
6Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
8---
9 bfd/elf64-microblaze.c | 11 +++++++++--
10 gas/config/tc-microblaze.c | 49 ++++++++++++++++++++++++++++++++++++++++++----
11 2 files changed, 54 insertions(+), 6 deletions(-)
12
13diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
14index 40f10aa..4d9b906 100644
15--- a/bfd/elf64-microblaze.c
16+++ b/bfd/elf64-microblaze.c
17@@ -1461,6 +1461,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
18 case (int) R_MICROBLAZE_64_PCREL :
19 case (int) R_MICROBLAZE_64:
20 case (int) R_MICROBLAZE_32:
21+ case (int) R_MICROBLAZE_IMML_64:
22 {
23 /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
24 from removed linkonce sections, or sections discarded by
25@@ -1470,6 +1471,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
26 relocation += addend;
27 if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
28 bfd_put_32 (input_bfd, relocation, contents + offset);
29+ else if (r_type == R_MICROBLAZE_IMML_64)
30+ bfd_put_64 (input_bfd, relocation, contents + offset);
31 else
32 {
33 if (r_type == R_MICROBLAZE_64_PCREL)
34@@ -1547,7 +1550,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
35 }
36 else
37 {
38- if (r_type == R_MICROBLAZE_32)
39+ if (r_type == R_MICROBLAZE_32 || r_type == R_MICROBLAZE_IMML_64)
40 {
41 outrel.r_info = ELF64_R_INFO (0, R_MICROBLAZE_REL);
42 outrel.r_addend = relocation + addend;
43@@ -1573,6 +1576,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
44 relocation += addend;
45 if (r_type == R_MICROBLAZE_32)
46 bfd_put_32 (input_bfd, relocation, contents + offset);
47+ else if (r_type == R_MICROBLAZE_IMML_64)
48+ bfd_put_64 (input_bfd, relocation, contents + offset + endian);
49 else
50 {
51 if (r_type == R_MICROBLAZE_64_PCREL)
52@@ -2085,7 +2090,8 @@ microblaze_elf_relax_section (bfd *abfd,
53 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
54 irelscan->r_addend);
55 }
56- if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
57+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32
58+ || ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64)
59 {
60 isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
61
62@@ -2591,6 +2597,7 @@ microblaze_elf_check_relocs (bfd * abfd,
63 case R_MICROBLAZE_64:
64 case R_MICROBLAZE_64_PCREL:
65 case R_MICROBLAZE_32:
66+ case R_MICROBLAZE_IMML_64:
67 {
68 if (h != NULL && !bfd_link_pic (info))
69 {
70diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
71index 7ff93a1..442f72c 100644
72--- a/gas/config/tc-microblaze.c
73+++ b/gas/config/tc-microblaze.c
74@@ -1119,6 +1119,13 @@ md_assemble (char * str)
75 as_fatal (_("smi pseudo instruction should not use a label in imm field"));
76 if(streq (name, "lli") || streq (name, "sli"))
77 opc = str_microblaze_64;
78+ else if ((microblaze_arch_size == 64) && ((streq (name, "lbui")
79+ || streq (name, "lhui") || streq (name, "lwi") || streq (name, "sbi")
80+ || streq (name, "shi") || streq (name, "swi"))))
81+ {
82+ opc = str_microblaze_64;
83+ subtype = opcode->inst_offset_type;
84+ }
85 else if (reg2 == REG_ROSDP)
86 opc = str_microblaze_ro_anchor;
87 else if (reg2 == REG_RWSDP)
88@@ -1182,7 +1189,10 @@ md_assemble (char * str)
89 inst |= (immed << IMM_LOW) & IMM_MASK;
90 }
91 }
92- else if (streq (name, "lli") || streq (name, "sli"))
93+ else if (streq (name, "lli") || streq (name, "sli") || ((microblaze_arch_size == 64)
94+ && ((streq (name, "lbui")) || streq (name, "lhui")
95+ || streq (name, "lwi") || streq (name, "sbi")
96+ || streq (name, "shi") || streq (name, "swi"))))
97 {
98 temp = immed & 0xFFFFFF8000;
99 if (temp != 0 && temp != 0xFFFFFF8000)
100@@ -1794,6 +1804,11 @@ md_assemble (char * str)
101
102 if (exp.X_md != 0)
103 subtype = get_imm_otype(exp.X_md);
104+ else if (streq (name, "brealid") || streq (name, "breaid") || streq (name, "breai"))
105+ {
106+ opc = str_microblaze_64;
107+ subtype = opcode->inst_offset_type;
108+ }
109 else
110 subtype = opcode->inst_offset_type;
111
112@@ -1811,6 +1826,31 @@ md_assemble (char * str)
113 output = frag_more (isize);
114 immed = exp.X_add_number;
115 }
116+ if (streq (name, "brealid") || streq (name, "breaid") || streq (name, "breai"))
117+ {
118+ temp = immed & 0xFFFFFF8000;
119+ if (temp != 0 && temp != 0xFFFFFF8000)
120+ {
121+ /* Needs an immediate inst. */
122+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
123+ if (opcode1 == NULL)
124+ {
125+ as_bad (_("unknown opcode \"%s\""), "imml");
126+ return;
127+ }
128+ inst1 = opcode1->bit_sequence;
129+ inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
130+ output[0] = INST_BYTE0 (inst1);
131+ output[1] = INST_BYTE1 (inst1);
132+ output[2] = INST_BYTE2 (inst1);
133+ output[3] = INST_BYTE3 (inst1);
134+ output = frag_more (isize);
135+ }
136+ inst |= (reg1 << RD_LOW) & RD_MASK;
137+ inst |= (immed << IMM_LOW) & IMM_MASK;
138+ }
139+ else
140+ {
141
142 temp = immed & 0xFFFF8000;
143 if ((temp != 0) && (temp != 0xFFFF8000))
144@@ -1834,6 +1874,7 @@ md_assemble (char * str)
145
146 inst |= (reg1 << RD_LOW) & RD_MASK;
147 inst |= (immed << IMM_LOW) & IMM_MASK;
148+ }
149 break;
150
151 case INST_TYPE_R2:
152@@ -3085,10 +3126,10 @@ cons_fix_new_microblaze (fragS * frag,
153 r = BFD_RELOC_32;
154 break;
155 case 8:
156- /*if (microblaze_arch_size == 64)
157- r = BFD_RELOC_32;
158- else*/
159+ if (microblaze_arch_size == 64)
160 r = BFD_RELOC_MICROBLAZE_EA64;
161+ else
162+ r = BFD_RELOC_64;
163 break;
164 default:
165 as_bad (_("unsupported BFD relocation size %u"), size);
166--
1672.7.4
168
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0023-fixing-the-.bss-relocation-issue.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0023-fixing-the-.bss-relocation-issue.patch
new file mode 100644
index 00000000..fc42ca58
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0023-fixing-the-.bss-relocation-issue.patch
@@ -0,0 +1,78 @@
1From 2a2298c9f32e96a71d6295e7ef52b37d834e5224 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Wed, 24 Oct 2018 12:34:37 +0530
4Subject: [PATCH 23/31] fixing the .bss relocation issue
5
6Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
8---
9 bfd/elf64-microblaze.c | 18 ++++++++++++------
10 1 file changed, 12 insertions(+), 6 deletions(-)
11
12diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
13index 4d9b906..184b7d5 100644
14--- a/bfd/elf64-microblaze.c
15+++ b/bfd/elf64-microblaze.c
16@@ -1480,7 +1480,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
17 + input_section->output_offset
18 + offset + INST_WORD_SIZE);
19 unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
20- if (insn == 0xb2000000 || insn == 0xb2ffffff)
21+ if ((insn & 0xff000000) == 0xb2000000)
22 {
23 insn &= ~0x00ffffff;
24 insn |= (relocation >> 16) & 0xffffff;
25@@ -1593,7 +1593,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
26 + offset + INST_WORD_SIZE);
27 }
28 unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
29- if (insn == 0xb2000000 || insn == 0xb2ffffff)
30+ if ((insn & 0xff000000) == 0xb2000000)
31 {
32 insn &= ~0x00ffffff;
33 insn |= (relocation >> 16) & 0xffffff;
34@@ -1722,7 +1722,7 @@ microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
35 {
36 unsigned long instr = bfd_get_32 (abfd, bfd_addr);
37
38- if (instr == 0xb2000000 || instr == 0xb2ffffff)
39+ if ((instr & 0xff000000) == 0xb2000000)
40 {
41 instr &= ~0x00ffffff;
42 instr |= (val & 0xffffff);
43@@ -1745,7 +1745,7 @@ microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
44 unsigned long instr_lo;
45
46 instr_hi = bfd_get_32 (abfd, bfd_addr);
47- if (instr_hi == 0xb2000000 || instr_hi == 0xb2ffffff)
48+ if ((instr_hi & 0xff000000) == 0xb2000000)
49 {
50 instr_hi &= ~0x00ffffff;
51 instr_hi |= (val >> 16) & 0xffffff;
52@@ -2238,7 +2238,10 @@ microblaze_elf_relax_section (bfd *abfd,
53 unsigned long instr_lo = bfd_get_32 (abfd, ocontents
54 + irelscan->r_offset
55 + INST_WORD_SIZE);
56- immediate = (instr_hi & 0x0000ffff) << 16;
57+ if ((instr_hi & 0xff000000) == 0xb2000000)
58+ immediate = (instr_hi & 0x00ffffff) << 24;
59+ else
60+ immediate = (instr_hi & 0x0000ffff) << 16;
61 immediate |= (instr_lo & 0x0000ffff);
62 offset = calc_fixup (irelscan->r_addend, 0, sec);
63 immediate -= offset;
64@@ -2282,7 +2285,10 @@ microblaze_elf_relax_section (bfd *abfd,
65 unsigned long instr_lo = bfd_get_32 (abfd, ocontents
66 + irelscan->r_offset
67 + INST_WORD_SIZE);
68- immediate = (instr_hi & 0x0000ffff) << 16;
69+ if ((instr_hi & 0xff000000) == 0xb2000000)
70+ immediate = (instr_hi & 0x00ffffff) << 24;
71+ else
72+ immediate = (instr_hi & 0x0000ffff) << 16;
73 immediate |= (instr_lo & 0x0000ffff);
74 target_address = immediate;
75 offset = calc_fixup (target_address, 0, sec);
76--
772.7.4
78
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch
new file mode 100644
index 00000000..5c327d2d
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch
@@ -0,0 +1,46 @@
1From 198f2ccd054613f39bbad49b3f0dbad23036b4fc Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Wed, 28 Nov 2018 14:00:29 +0530
4Subject: [PATCH 24/31] Fixed the bug in the R_MICROBLAZE_64_NONE relocation.
5 It was adjusting only lower 16bits.
6
7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9---
10 bfd/elf32-microblaze.c | 4 ++--
11 bfd/elf64-microblaze.c | 4 ++--
12 2 files changed, 4 insertions(+), 4 deletions(-)
13
14diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
15index b632dd1..ffb23d8 100644
16--- a/bfd/elf32-microblaze.c
17+++ b/bfd/elf32-microblaze.c
18@@ -2022,8 +2022,8 @@ microblaze_elf_relax_section (bfd *abfd,
19 sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
20 efix = calc_fixup (target_address, 0, sec);
21 irel->r_addend -= (efix - sfix);
22- microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
23- + INST_WORD_SIZE, irel->r_addend);
24+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
25+ irel->r_addend);
26 }
27 break;
28 }
29diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
30index 184b7d5..ef6a870 100644
31--- a/bfd/elf64-microblaze.c
32+++ b/bfd/elf64-microblaze.c
33@@ -2017,8 +2017,8 @@ microblaze_elf_relax_section (bfd *abfd,
34 sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
35 efix = calc_fixup (target_address, 0, sec);
36 irel->r_addend -= (efix - sfix);
37- microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
38- + INST_WORD_SIZE, irel->r_addend);
39+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
40+ irel->r_addend);
41 }
42 break;
43 }
44--
452.7.4
46
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch
new file mode 100644
index 00000000..f035a8da
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch
@@ -0,0 +1,70 @@
1From 597ab75895c106c673db0e7a2adfac2f2350c2ec Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Sun, 2 Dec 2018 14:49:14 +0530
4Subject: [PATCH 25/31] [Patch,MicroBlaze]: fixed Build issue which are due to
5 conflicts in patches.
6
7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9---
10 bfd/elf32-microblaze.c | 1 +
11 bfd/elf64-microblaze.c | 12 ++++++------
12 gas/config/tc-microblaze.c | 4 ++--
13 3 files changed, 9 insertions(+), 8 deletions(-)
14
15diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
16index ffb23d8..53924f6 100644
17--- a/bfd/elf32-microblaze.c
18+++ b/bfd/elf32-microblaze.c
19@@ -1996,6 +1996,7 @@ microblaze_elf_relax_section (bfd *abfd,
20 /* This was a PC-relative instruction that was
21 completely resolved. */
22 int sfix, efix;
23+ unsigned int val;
24 bfd_vma target_address;
25 target_address = irel->r_addend + irel->r_offset;
26 sfix = calc_fixup (irel->r_offset, 0, sec);
27diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
28index ef6a870..bed534e 100644
29--- a/bfd/elf64-microblaze.c
30+++ b/bfd/elf64-microblaze.c
31@@ -2854,14 +2854,14 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
32 /* If this is a weak symbol, and there is a real definition, the
33 processor independent code will have arranged for us to see the
34 real definition first, and we can just use the same value. */
35- if (h->u.weakdef != NULL)
36+ if (h->is_weakalias)
37 {
38- BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
39- || h->u.weakdef->root.type == bfd_link_hash_defweak);
40- h->root.u.def.section = h->u.weakdef->root.u.def.section;
41- h->root.u.def.value = h->u.weakdef->root.u.def.value;
42+ struct elf_link_hash_entry *def = weakdef (h);
43+ BFD_ASSERT (def->root.type == bfd_link_hash_defined);
44+ h->root.u.def.section = def->root.u.def.section;
45+ h->root.u.def.value = def->root.u.def.value;
46 return TRUE;
47- }
48+ }
49
50 /* This is a reference to a symbol defined by a dynamic object which
51 is not a function. */
52diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
53index 442f72c..edc7985 100644
54--- a/gas/config/tc-microblaze.c
55+++ b/gas/config/tc-microblaze.c
56@@ -118,9 +118,9 @@ const relax_typeS md_relax_table[] =
57 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 15: TLSGOTTPREL_OFFSET. */
58 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 16: TLSTPREL_OFFSET. */
59 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 17: TEXT_OFFSET. */
60- { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 18: TEXT_PC_OFFSET. */
61+ { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 18: TEXT_PC_OFFSET. */
62 // { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 16: TLSTPREL_OFFSET. */
63- { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 } /* 19: DEFINED_64_OFFSET. */
64+ { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 }, /* 19: DEFINED_64_OFFSET. */
65 { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE*2, 0 } /* 20: DEFINED_64_PC_OFFSET. */
66 };
67
68--
692.7.4
70
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch
new file mode 100644
index 00000000..a7ecec15
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch
@@ -0,0 +1,33 @@
1From c0be3d2a8f0ac0c1a2ba82253c9eea99071da0a9 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 26 Feb 2019 17:31:41 +0530
4Subject: [PATCH 26/31] [Patch,Microblaze] : changes of "PR22458, failure to
5 choose a matching ELF target" is causing "Multiple Prevailing definition
6 errors",added check for best_match elf.
7
8Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
9Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
10---
11 bfd/format.c | 5 +++++
12 1 file changed, 5 insertions(+)
13
14diff --git a/bfd/format.c b/bfd/format.c
15index c4afd97..4f7367d 100644
16--- a/bfd/format.c
17+++ b/bfd/format.c
18@@ -292,7 +292,12 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
19
20 /* Don't check the default target twice. */
21 if (*target == &binary_vec
22+#if !BFD_SUPPORTS_PLUGINS
23 || (!abfd->target_defaulted && *target == save_targ))
24+#else
25+ || (!abfd->target_defaulted && *target == save_targ)
26+ || (*target)->match_priority > best_match)
27+#endif
28 continue;
29
30 /* If we already tried a match, the bfd is modified and may
31--
322.7.4
33
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0027-Patch-Microblaze-PR22471-undefined-reference-to-link.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0027-Patch-Microblaze-PR22471-undefined-reference-to-link.patch
new file mode 100644
index 00000000..002b3794
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0027-Patch-Microblaze-PR22471-undefined-reference-to-link.patch
@@ -0,0 +1,363 @@
1From 059fc6d823a81602d951275ba99430550b84f8a3 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 26 Feb 2019 17:46:36 +0530
4Subject: [PATCH 27/31] [Patch,Microblaze] : "PR22471, undefined reference to
5 linker-defined symbols" is causing runtime loops.reverting for now.
6
7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9---
10 bfd/elflink.c | 7 +---
11 bfd/linker.c | 9 +----
12 ld/ldexp.c | 64 +++++++++++++++++++------------
13 ld/ldlang.c | 6 +--
14 ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d | 4 +-
15 ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got | 2 +-
16 ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d | 4 +-
17 ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got | 2 +-
18 ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d | 4 +-
19 ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got | 2 +-
20 10 files changed, 53 insertions(+), 51 deletions(-)
21
22diff --git a/bfd/elflink.c b/bfd/elflink.c
23index b316149..3860891 100644
24--- a/bfd/elflink.c
25+++ b/bfd/elflink.c
26@@ -1496,15 +1496,10 @@ _bfd_elf_merge_symbol (bfd *abfd,
27 treated as strong if the new symbol is from a dynamic library.
28 This reflects the way glibc's ld.so works.
29
30- Also allow a weak symbol to override a linker script symbol
31- defined by an early pass over the script. This is done so the
32- linker knows the symbol is defined in an object file, for the
33- DEFINED script function.
34-
35 Do this before setting *type_change_ok or *size_change_ok so that
36 we warn properly when dynamic library symbols are overridden. */
37
38- if (newdef && !newdyn && (olddyn || h->root.ldscript_def))
39+ if (newdef && !newdyn && olddyn)
40 newweak = FALSE;
41 if (olddef && newdyn)
42 oldweak = FALSE;
43diff --git a/bfd/linker.c b/bfd/linker.c
44index 6b4c8e5..8d51c2a 100644
45--- a/bfd/linker.c
46+++ b/bfd/linker.c
47@@ -1449,14 +1449,9 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
48 do
49 {
50 enum link_action action;
51- int prev;
52
53- prev = h->type;
54- /* Treat symbols defined by early linker script pass as undefined. */
55- if (h->ldscript_def)
56- prev = bfd_link_hash_undefined;
57 cycle = FALSE;
58- action = link_action[(int) row][prev];
59+ action = link_action[(int) row][(int) h->type];
60 switch (action)
61 {
62 case FAIL:
63@@ -1500,7 +1495,6 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
64 h->u.def.section = section;
65 h->u.def.value = value;
66 h->linker_def = 0;
67- h->ldscript_def = 0;
68
69 /* If we have been asked to, we act like collect2 and
70 identify all functions that might be global
71@@ -1600,7 +1594,6 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info,
72 else
73 h->u.c.p->section = section;
74 h->linker_def = 0;
75- h->ldscript_def = 0;
76 break;
77
78 case REF:
79diff --git a/ld/ldexp.c b/ld/ldexp.c
80index 6fa251e..d46a06f 100644
81--- a/ld/ldexp.c
82+++ b/ld/ldexp.c
83@@ -60,12 +60,15 @@ struct definedness_hash_entry
84 section statement, the section we'd like it relative to. */
85 asection *final_sec;
86
87- /* Low bits of iteration count. Symbols with matching iteration have
88- been defined in this pass over the script. */
89- unsigned int iteration : 8;
90-
91 /* Symbol was defined by an object file. */
92 unsigned int by_object : 1;
93+
94+ /* Symbols was defined by a script. */
95+ unsigned int by_script : 1;
96+
97+ /* Low bit of iteration count. Symbols with matching iteration have
98+ been defined in this pass over the script. */
99+ unsigned int iteration : 1;
100 };
101
102 static struct bfd_hash_table definedness_table;
103@@ -283,6 +286,7 @@ definedness_newfunc (struct bfd_hash_entry *entry,
104 einfo (_("%F%P: bfd_hash_allocate failed creating symbol %s\n"), name);
105
106 ret->by_object = 0;
107+ ret->by_script = 0;
108 ret->iteration = 0;
109 return &ret->root;
110 }
111@@ -316,7 +320,7 @@ update_definedness (const char *name, struct bfd_link_hash_entry *h)
112 /* If the symbol was already defined, and not by a script, then it
113 must be defined by an object file or by the linker target code. */
114 ret = TRUE;
115- if (!h->ldscript_def
116+ if (!defentry->by_script
117 && (h->type == bfd_link_hash_defined
118 || h->type == bfd_link_hash_defweak
119 || h->type == bfd_link_hash_common))
120@@ -328,6 +332,7 @@ update_definedness (const char *name, struct bfd_link_hash_entry *h)
121 ret = FALSE;
122 }
123
124+ defentry->by_script = 1;
125 defentry->iteration = lang_statement_iteration;
126 defentry->final_sec = bfd_abs_section_ptr;
127 if (expld.phase == lang_final_phase_enum
128@@ -681,9 +686,6 @@ fold_trinary (etree_type *tree)
129 static void
130 fold_name (etree_type *tree)
131 {
132- struct bfd_link_hash_entry *h;
133- struct definedness_hash_entry *def;
134-
135 memset (&expld.result, 0, sizeof (expld.result));
136
137 switch (tree->type.node_code)
138@@ -701,18 +703,23 @@ fold_name (etree_type *tree)
139 break;
140
141 case DEFINED:
142- h = bfd_wrapped_link_hash_lookup (link_info.output_bfd,
143- &link_info,
144- tree->name.name,
145- FALSE, FALSE, TRUE);
146- new_number (h != NULL
147- && (h->type == bfd_link_hash_defined
148- || h->type == bfd_link_hash_defweak
149- || h->type == bfd_link_hash_common)
150- && (!h->ldscript_def
151- || (def = symbol_defined (tree->name.name)) == NULL
152- || def->by_object
153- || def->iteration == (lang_statement_iteration & 255)));
154+ if (expld.phase != lang_first_phase_enum)
155+ {
156+ struct bfd_link_hash_entry *h;
157+ struct definedness_hash_entry *def;
158+
159+ h = bfd_wrapped_link_hash_lookup (link_info.output_bfd,
160+ &link_info,
161+ tree->name.name,
162+ FALSE, FALSE, TRUE);
163+ new_number (h != NULL
164+ && (h->type == bfd_link_hash_defined
165+ || h->type == bfd_link_hash_defweak
166+ || h->type == bfd_link_hash_common)
167+ && ((def = symbol_defined (tree->name.name)) == NULL
168+ || def->by_object
169+ || def->iteration == (lang_statement_iteration & 1)));
170+ }
171 break;
172
173 case NAME:
174@@ -721,6 +728,9 @@ fold_name (etree_type *tree)
175 {
176 /* Self-assignment is only allowed for absolute symbols
177 defined in a linker script. */
178+ struct bfd_link_hash_entry *h;
179+ struct definedness_hash_entry *def;
180+
181 h = bfd_wrapped_link_hash_lookup (link_info.output_bfd,
182 &link_info,
183 tree->name.name,
184@@ -730,13 +740,17 @@ fold_name (etree_type *tree)
185 || h->type == bfd_link_hash_defweak)
186 && h->u.def.section == bfd_abs_section_ptr
187 && (def = symbol_defined (tree->name.name)) != NULL
188- && def->iteration == (lang_statement_iteration & 255)))
189+ && def->iteration == (lang_statement_iteration & 1)))
190 expld.assign_name = NULL;
191 }
192- if (tree->name.name[0] == '.' && tree->name.name[1] == 0)
193+ if (expld.phase == lang_first_phase_enum)
194+ ;
195+ else if (tree->name.name[0] == '.' && tree->name.name[1] == 0)
196 new_rel_from_abs (expld.dot);
197 else
198 {
199+ struct bfd_link_hash_entry *h;
200+
201 h = bfd_wrapped_link_hash_lookup (link_info.output_bfd,
202 &link_info,
203 tree->name.name,
204@@ -751,7 +765,7 @@ fold_name (etree_type *tree)
205 output_section = h->u.def.section->output_section;
206 if (output_section == NULL)
207 {
208- if (expld.phase <= lang_mark_phase_enum)
209+ if (expld.phase == lang_mark_phase_enum)
210 new_rel (h->u.def.value, h->u.def.section);
211 else
212 einfo (_("%X%P:%pS: unresolvable symbol `%s'"
213@@ -943,12 +957,12 @@ is_sym_value (const etree_type *tree, bfd_vma val)
214 return (tree->type.node_class == etree_name
215 && tree->type.node_code == NAME
216 && (def = symbol_defined (tree->name.name)) != NULL
217- && def->iteration == (lang_statement_iteration & 255)
218+ && def->by_script
219+ && def->iteration == (lang_statement_iteration & 1)
220 && (h = bfd_wrapped_link_hash_lookup (link_info.output_bfd,
221 &link_info,
222 tree->name.name,
223 FALSE, FALSE, TRUE)) != NULL
224- && h->ldscript_def
225 && h->type == bfd_link_hash_defined
226 && h->u.def.section == bfd_abs_section_ptr
227 && h->u.def.value == val);
228diff --git a/ld/ldlang.c b/ld/ldlang.c
229index 350baf2..7e12480 100644
230--- a/ld/ldlang.c
231+++ b/ld/ldlang.c
232@@ -3360,7 +3360,9 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode)
233 #endif
234 break;
235 case lang_assignment_statement_enum:
236- if (s->assignment_statement.exp->type.node_class != etree_assert)
237+ if (s->assignment_statement.exp->type.node_class != etree_assert
238+ && s->assignment_statement.exp->assign.defsym)
239+ /* This is from a --defsym on the command line. */
240 exp_fold_tree_no_dot (s->assignment_statement.exp);
241 break;
242 default:
243@@ -7176,7 +7178,6 @@ lang_process (void)
244
245 /* Create a bfd for each input file. */
246 current_target = default_target;
247- lang_statement_iteration++;
248 open_input_bfds (statement_list.head, OPEN_BFD_NORMAL);
249
250 #ifdef ENABLE_PLUGINS
251@@ -7232,7 +7233,6 @@ lang_process (void)
252
253 /* Rescan archives in case new undefined symbols have appeared. */
254 files = file_chain;
255- lang_statement_iteration++;
256 open_input_bfds (statement_list.head, OPEN_BFD_RESCAN);
257 lang_list_remove_tail (&file_chain, &files);
258 while (files.head != NULL)
259diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
260index 17e42d0..011df6c 100644
261--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
262+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
263@@ -5,7 +5,7 @@ Disassembly of section .text:
264
265 .* <__start>:
266 .*: 3c1c0fc0 lui gp,0xfc0
267- .*: 279c7b80 addiu gp,gp,31616
268+ .*: 279c7c30 addiu gp,gp,31792
269 .*: 0399e021 addu gp,gp,t9
270 .*: 27bdfff0 addiu sp,sp,-16
271 .*: afbe0008 sw s8,8\(sp\)
272@@ -55,7 +55,7 @@ Disassembly of section .text:
273
274 .* <other>:
275 .*: 3c1c0fc0 lui gp,0xfc0
276- .*: 279c7ac0 addiu gp,gp,31424
277+ .*: 279c7b70 addiu gp,gp,31600
278 .*: 0399e021 addu gp,gp,t9
279 .*: 27bdfff0 addiu sp,sp,-16
280 .*: afbe0008 sw s8,8\(sp\)
281diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
282index 508fed2..1dbcab4 100644
283--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
284+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
285@@ -13,6 +13,6 @@ OFFSET TYPE VALUE
286
287
288 Contents of section .got:
289- 10000020 00000000 80000000 0040053c 00000000 .........@......
290+ 10000020 00000000 80000000 0040048c 00000000 .........@......
291 10000030 00000000 00000000 00000000 00000000 ................
292 10000040 00000000 00000001 00000000 ............
293diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
294index 17e42d0..011df6c 100644
295--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
296+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
297@@ -5,7 +5,7 @@ Disassembly of section .text:
298
299 .* <__start>:
300 .*: 3c1c0fc0 lui gp,0xfc0
301- .*: 279c7b80 addiu gp,gp,31616
302+ .*: 279c7c30 addiu gp,gp,31792
303 .*: 0399e021 addu gp,gp,t9
304 .*: 27bdfff0 addiu sp,sp,-16
305 .*: afbe0008 sw s8,8\(sp\)
306@@ -55,7 +55,7 @@ Disassembly of section .text:
307
308 .* <other>:
309 .*: 3c1c0fc0 lui gp,0xfc0
310- .*: 279c7ac0 addiu gp,gp,31424
311+ .*: 279c7b70 addiu gp,gp,31600
312 .*: 0399e021 addu gp,gp,t9
313 .*: 27bdfff0 addiu sp,sp,-16
314 .*: afbe0008 sw s8,8\(sp\)
315diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
316index 4a97099..fb50635 100644
317--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
318+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
319@@ -13,6 +13,6 @@ OFFSET TYPE VALUE
320
321
322 Contents of section .got:
323- 10000020 00000000 80000000 0040053c 00000000 .*
324+ 10000020 00000000 80000000 0040048c 00000000 .*
325 10000030 00000000 00000000 00000000 00000000 .*
326 10000040 00000000 00000001 00000000 .*
327diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
328index fb3750a..3828aca 100644
329--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
330+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
331@@ -5,7 +5,7 @@ Disassembly of section .text:
332
333 .* <other>:
334 .*: 3c1c0fc0 lui gp,0xfc0
335- .*: 279c7b80 addiu gp,gp,31616
336+ .*: 279c7c30 addiu gp,gp,31792
337 .*: 0399e021 addu gp,gp,t9
338 .*: 27bdfff0 addiu sp,sp,-16
339 .*: afbe0008 sw s8,8\(sp\)
340@@ -51,7 +51,7 @@ Disassembly of section .text:
341
342 .* <__start>:
343 .*: 3c1c0fc0 lui gp,0xfc0
344- .*: 279c7ad0 addiu gp,gp,31440
345+ .*: 279c7b80 addiu gp,gp,31616
346 .*: 0399e021 addu gp,gp,t9
347 .*: 27bdfff0 addiu sp,sp,-16
348 .*: afbe0008 sw s8,8\(sp\)
349diff --git a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
350index d96375c..4a97099 100644
351--- a/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
352+++ b/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
353@@ -13,6 +13,6 @@ OFFSET TYPE VALUE
354
355
356 Contents of section .got:
357- 10000020 00000000 80000000 004005ec 00000000 .*
358+ 10000020 00000000 80000000 0040053c 00000000 .*
359 10000030 00000000 00000000 00000000 00000000 .*
360 10000040 00000000 00000001 00000000 .*
361--
3622.7.4
363
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0028-Revert-ld-Remove-unused-expression-state.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0028-Revert-ld-Remove-unused-expression-state.patch
new file mode 100644
index 00000000..c574470e
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0028-Revert-ld-Remove-unused-expression-state.patch
@@ -0,0 +1,97 @@
1From a9bcbddf77662f8c12e83360809a697196a55281 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 27 Feb 2019 15:12:32 +0530
4Subject: [PATCH 28/31] Revert "ld: Remove unused expression state"
5
6This reverts commit 65f14869fd3fbee8ed4c4ca49de8aaa86dbc66cb.
7
8Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
9Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
10---
11 ld/ChangeLog | 9 ---------
12 ld/ldexp.c | 8 +++++---
13 ld/ldexp.h | 1 +
14 3 files changed, 6 insertions(+), 12 deletions(-)
15
16diff --git a/ld/ChangeLog b/ld/ChangeLog
17index 4827678..ce3d2d5 100644
18--- a/ld/ChangeLog
19+++ b/ld/ChangeLog
20@@ -2972,15 +2972,6 @@
21
22 2018-01-11 Andrew Burgess <andrew.burgess@embecosm.com>
23
24- * ldexp.h (union etree_union): Remove defsym field.
25- * ldexp.c (exp_assop): Remove defsym parameter, and use of defsym
26- parameter.
27- (exp_assign): Remove passing of defsym parameter.
28- (exp_defsym): Likewise.
29- (exp_provide): Likewise.
30-
31-2018-01-11 Andrew Burgess <andrew.burgess@embecosm.com>
32-
33 * ldexp.c (exp_fold_tree_1): Rework condition underwhich provide
34 nodes are ignored in the tree walk, and move the location at which
35 we change provide nodes into provided nodes.
36diff --git a/ld/ldexp.c b/ld/ldexp.c
37index d46a06f..a84bf63 100644
38--- a/ld/ldexp.c
39+++ b/ld/ldexp.c
40@@ -1355,6 +1355,7 @@ static etree_type *
41 exp_assop (const char *dst,
42 etree_type *src,
43 enum node_tree_enum class,
44+ bfd_boolean defsym,
45 bfd_boolean hidden)
46 {
47 etree_type *n;
48@@ -1366,6 +1367,7 @@ exp_assop (const char *dst,
49 n->assign.type.node_class = class;
50 n->assign.src = src;
51 n->assign.dst = dst;
52+ n->assign.defsym = defsym;
53 n->assign.hidden = hidden;
54 return n;
55 }
56@@ -1375,7 +1377,7 @@ exp_assop (const char *dst,
57 etree_type *
58 exp_assign (const char *dst, etree_type *src, bfd_boolean hidden)
59 {
60- return exp_assop (dst, src, etree_assign, hidden);
61+ return exp_assop (dst, src, etree_assign, FALSE, hidden);
62 }
63
64 /* Handle --defsym command-line option. */
65@@ -1383,7 +1385,7 @@ exp_assign (const char *dst, etree_type *src, bfd_boolean hidden)
66 etree_type *
67 exp_defsym (const char *dst, etree_type *src)
68 {
69- return exp_assop (dst, src, etree_assign, FALSE);
70+ return exp_assop (dst, src, etree_assign, TRUE, FALSE);
71 }
72
73 /* Handle PROVIDE. */
74@@ -1391,7 +1393,7 @@ exp_defsym (const char *dst, etree_type *src)
75 etree_type *
76 exp_provide (const char *dst, etree_type *src, bfd_boolean hidden)
77 {
78- return exp_assop (dst, src, etree_provide, hidden);
79+ return exp_assop (dst, src, etree_provide, FALSE, hidden);
80 }
81
82 /* Handle ASSERT. */
83diff --git a/ld/ldexp.h b/ld/ldexp.h
84index d58cacb..572b703 100644
85--- a/ld/ldexp.h
86+++ b/ld/ldexp.h
87@@ -66,6 +66,7 @@ typedef union etree_union {
88 node_type type;
89 const char *dst;
90 union etree_union *src;
91+ bfd_boolean defsym;
92 bfd_boolean hidden;
93 } assign;
94 struct {
95--
962.7.4
97
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0029-Patch-Microblaze-Binutils-security-check-is-causing-.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0029-Patch-Microblaze-Binutils-security-check-is-causing-.patch
new file mode 100644
index 00000000..dd7bf088
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0029-Patch-Microblaze-Binutils-security-check-is-causing-.patch
@@ -0,0 +1,35 @@
1From e267384901f94566300114b91fa251de43f7ec34 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 11 Mar 2019 14:23:58 +0530
4Subject: [PATCH 29/31] [Patch,Microblaze] : Binutils security check is causing
5 build error for windows builds.commenting for now.
6
7Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
8Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
9---
10 bfd/elf-attrs.c | 2 ++
11 1 file changed, 2 insertions(+)
12
13diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
14index 5c1b960..5285db2 100644
15--- a/bfd/elf-attrs.c
16+++ b/bfd/elf-attrs.c
17@@ -440,6 +440,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
18 /* PR 17512: file: 2844a11d. */
19 if (hdr->sh_size == 0)
20 return;
21+ #if 0
22 if (hdr->sh_size > bfd_get_file_size (abfd))
23 {
24 /* xgettext:c-format */
25@@ -448,6 +449,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
26 bfd_set_error (bfd_error_invalid_operation);
27 return;
28 }
29+ #endif
30
31 contents = (bfd_byte *) bfd_malloc (hdr->sh_size + 1);
32 if (!contents)
33--
342.7.4
35
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0030-fixing-the-long-long-long-mingw-toolchain-issue.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0030-fixing-the-long-long-long-mingw-toolchain-issue.patch
new file mode 100644
index 00000000..fea12b0b
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0030-fixing-the-long-long-long-mingw-toolchain-issue.patch
@@ -0,0 +1,59 @@
1From 0e918ef176cf14073abca83c61d3978f3fa2551e Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 29 Nov 2018 17:59:25 +0530
4Subject: [PATCH 30/31] fixing the long & long long mingw toolchain issue
5
6Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
7Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
8---
9 gas/config/tc-microblaze.c | 10 +++++-----
10 opcodes/microblaze-opc.h | 4 ++--
11 2 files changed, 7 insertions(+), 7 deletions(-)
12
13diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
14index edc7985..9db9a7f 100644
15--- a/gas/config/tc-microblaze.c
16+++ b/gas/config/tc-microblaze.c
17@@ -783,7 +783,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
18 }
19
20 static char *
21-parse_imml (char * s, expressionS * e, long min, long max)
22+parse_imml (char * s, expressionS * e, long long min, long long max)
23 {
24 char *new_pointer;
25 char *atp;
26@@ -834,11 +834,11 @@ parse_imml (char * s, expressionS * e, long min, long max)
27 ; /* An error message has already been emitted. */
28 else if ((e->X_op != O_constant && e->X_op != O_symbol) )
29 as_fatal (_("operand must be a constant or a label"));
30- else if ((e->X_op == O_constant) && ((long) e->X_add_number < min
31- || (long) e->X_add_number > max))
32+ else if ((e->X_op == O_constant) && ((long long) e->X_add_number < min
33+ || (long long) e->X_add_number > max))
34 {
35- as_fatal (_("operand must be absolute in range %ld..%ld, not %ld"),
36- min, max, (long) e->X_add_number);
37+ as_fatal (_("operand must be absolute in range %lld..%lld, not %lld"),
38+ min, max, (long long) e->X_add_number);
39 }
40
41 if (atp)
42diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
43index 2096269..7df80d4 100644
44--- a/opcodes/microblaze-opc.h
45+++ b/opcodes/microblaze-opc.h
46@@ -585,8 +585,8 @@ char pvr_register_prefix[] = "rpvr";
47 #define MIN_IMM6_WIDTH ((int) 0x00000001)
48 #define MAX_IMM6_WIDTH ((int) 0x00000040)
49
50-#define MIN_IMML ((long) 0xffffff8000000000L)
51-#define MAX_IMML ((long) 0x0000007fffffffffL)
52+#define MIN_IMML ((long long) 0xffffff8000000000L)
53+#define MAX_IMML ((long long) 0x0000007fffffffffL)
54
55 #endif /* MICROBLAZE_OPC */
56
57--
582.7.4
59
diff --git a/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0031-fixing-the-_STACK_SIZE-issue-with-the-flto-flag.patch b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0031-fixing-the-_STACK_SIZE-issue-with-the-flto-flag.patch
new file mode 100644
index 00000000..d47b59a9
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-microblaze/binutils/binutils-2.31/0031-fixing-the-_STACK_SIZE-issue-with-the-flto-flag.patch
@@ -0,0 +1,57 @@
1From 8c08e0dfcfcb6c56576b68f235b0006c4c67fafb Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Wed, 20 Mar 2019 11:42:07 +0530
4Subject: [PATCH 31/31] fixing the _STACK_SIZE issue with the flto flag
5
6Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
7---
8 ld/scripttempl/elfmicroblaze.sc | 12 ++++++------
9 1 file changed, 6 insertions(+), 6 deletions(-)
10
11diff --git a/ld/scripttempl/elfmicroblaze.sc b/ld/scripttempl/elfmicroblaze.sc
12index d8f7569..1316901 100644
13--- a/ld/scripttempl/elfmicroblaze.sc
14+++ b/ld/scripttempl/elfmicroblaze.sc
15@@ -63,9 +63,9 @@ ${RELOCATING+${LIB_SEARCH_DIRS}}
16
17 ${RELOCATING+ENTRY (${ENTRY})}
18
19-_TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50;
20-_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x0;
21-_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400;
22+_DEF_TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50;
23+_DEF_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x0;
24+_DEF_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400;
25
26 SECTIONS
27 {
28@@ -75,7 +75,7 @@ SECTIONS
29 .vectors.debug_sw_break 0x18 : { KEEP (*(.vectors.debug_sw_break)) } = 0
30 .vectors.hw_exception 0x20 : { KEEP (*(.vectors.hw_exception)) } = 0
31
32- ${RELOCATING+. = _TEXT_START_ADDR;}
33+ ${RELOCATING+. = _DEF_TEXT_START_ADDR;}
34
35 ${RELOCATING+ _ftext = .;}
36 .text : {
37@@ -208,7 +208,7 @@ SECTIONS
38 .heap : {
39 ${RELOCATING+ _heap = .;}
40 ${RELOCATING+ _heap_start = .;}
41- ${RELOCATING+ . += _HEAP_SIZE;}
42+ ${RELOCATING+ . += _DEF_HEAP_SIZE;}
43 ${RELOCATING+ _heap_end = .;}
44 }
45
46@@ -216,7 +216,7 @@ SECTIONS
47
48 .stack : {
49 ${RELOCATING+ _stack_end = .;}
50- ${RELOCATING+ . += _STACK_SIZE;}
51+ ${RELOCATING+ . += _DEF_STACK_SIZE;}
52 ${RELOCATING+ . = ALIGN(. != 0 ? 8 : 1);}
53 ${RELOCATING+ _stack = .;}
54 ${RELOCATING+ _end = .;}
55--
562.7.4
57