summaryrefslogtreecommitdiffstats
path: root/meta-microblaze
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@kernel.crashing.org>2020-06-28 20:40:30 -0500
committerMark Hatle <mark.hatle@kernel.crashing.org>2020-08-14 11:56:32 -0500
commit557ab11ff5be82548b5fd97e9c75b3e9b7524414 (patch)
tree6818f78a17f08a03df2d3f32c17049d618703e30 /meta-microblaze
parent86146f2e5b25e5ac198f1ccef73fa39e5f870c72 (diff)
downloadmeta-xilinx-557ab11ff5be82548b5fd97e9c75b3e9b7524414.tar.gz
Move microblaze specific items to new meta-microblaze layer
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
Diffstat (limited to 'meta-microblaze')
-rw-r--r--meta-microblaze/conf/layer.conf14
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils-cross-canadian_%.bbappend4
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils-cross_%.bbappend4
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils-microblaze.inc54
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch65
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0002-Add-mlittle-endian-and-mbig-endian-flags.patch64
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0003-Disable-the-warning-message-for-eh_frame_hdr.patch31
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0004-Fix-relaxation-of-assembler-resolved-references.patch74
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch247
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch39
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0007-Fix-bug-in-TLSTPREL-Relocation.patch33
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0008-Added-Address-extension-instructions.patch98
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0009-fixing-the-MAX_OPCODES-to-correct-value.patch25
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0010-Add-new-bit-field-instructions.patch230
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0011-fixing-the-imm-bug.patch27
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0012-Patch-Microblaze-fixed-bug-in-GCC-so-that-It-will-su.patch33
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0013-fixing-the-constant-range-check-issue.patch26
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch36
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0015-intial-commit-of-MB-64-bit.patch4738
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0016-MB-X-initial-commit.patch691
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch36
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0018-Added-relocations-for-MB-X.patch346
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0019-Fixed-MB-x-relocation-issues.patch373
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0020-Fixing-the-branch-related-issues.patch25
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0021-Fixed-address-computation-issues-with-64bit-address.patch220
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0022-Adding-new-relocation-to-support-64bit-rodata.patch166
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0023-fixing-the-.bss-relocation-issue.patch76
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch44
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch68
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch31
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0027-Revert-ld-Remove-unused-expression-state.patch76
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch33
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0029-fixing-the-long-long-long-mingw-toolchain-issue.patch57
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0030-Added-support-to-new-arithmetic-single-register-inst.patch359
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch551
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0032-Add-initial-port-of-linux-gdbserver.patch435
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0033-Initial-port-of-core-reading-support.patch388
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0034-Fix-debug-message-when-register-is-unavailable.patch40
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0035-revert-master-rebase-changes-to-gdbserver.patch31
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch33
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch32
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0038-Initial-support-for-native-gdb.patch511
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0039-Fixing-the-issues-related-to-GDB-7.12.patch309
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0040-Patch-microblaze-Adding-64-bit-MB-support.patch1168
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0041-patch-MicroBlaze-porting-GDB-for-linux.patch155
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch146
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch24
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch364
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0045-Fixed-bug-in-generation-of-IMML-instruction-for-the.patch86
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0046-Patch-MicroBlaze-m64-This-patch-will-remove-imml-0-a.patch38
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0047-Patch-MicroBlaze-commit-for-triggering-build-to-remo.patch25
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0048-Patch-MicroBlaze-Adding-more-description-to-the-imml.patch27
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0049-Patch-MicroBlaze-improper-address-mapping-of-PROVIDE.patch39
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils/0050-Fix-i386-md_pseudo_table.patch28
-rw-r--r--meta-microblaze/recipes-microblaze/binutils/binutils_%.bbappend4
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch35
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch31
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0003-LOCAL-Testsuite-explicitly-add-fivopts-for-tests-tha.patch119
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0004-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch35
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0005-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch35
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0005-Testsuite-explicitly-add-fivopts-for-tests-that-depe.patch118
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0006-Patch-testsuite-Update-MicroBlaze-strings-test.patch43
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0007-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch67
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0008-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch28
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0009-Patch-microblaze-Fix-atomic-side-effects.patch68
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0010-Patch-microblaze-Fix-atomic-boolean-return-value.patch40
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0011-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch33
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0012-Patch-microblaze-Added-ashrsi3_with_size_opt.patch48
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0013-Patch-microblaze-Fixed-missing-save-of-r18-in-fast_i.patch41
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0014-Patch-microblaze-Use-bralid-for-profiler-calls.patch26
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0015-Patch-microblaze-Disable-fivopts-by-default.patch42
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0016-Patch-microblaze-Removed-moddi3-routinue.patch160
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0017-Patch-microblaze-Add-INIT_PRIORITY-support.patch101
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0018-Patch-microblaze-Add-optimized-lshrsi3.patch81
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0019-Patch-microblaze-Modified-trap-instruction.patch29
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0020-Patch-microblaze-Reducing-Stack-space-for-arguments.patch206
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0021-Patch-microblaze-Add-cbranchsi4_reg.patch159
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0022-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch58
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0023-Patch-OPT-Update-heuristics-for-loop-invariant-for-a.patch47
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0024-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch63
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0025-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch72
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0026-Patch-microblaze-8-stage-pipeline-for-microblaze.patch193
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0027-Patch-rtl-Optimization-Better-register-pressure-esti.patch142
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0028-Patch-microblaze-Correct-the-const-high-double-immed.patch69
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0029-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch36
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0030-patch-microblaze-Fix-the-calculation-of-high-word-in.patch45
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0031-Patch-microblaze-Add-new-bit-field-instructions.patch120
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0032-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch247
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0033-Fixing-the-bug-in-the-bit-field-instruction.patch48
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0034-Patch-microblaze-Macros-used-in-Xilinx-internal-patc.patch32
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0035-Fixing-the-issue-with-the-builtin_alloc.patch44
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0036-Patch-Microblaze-reverting-the-cost-check-before-pro.patch49
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0037-Patch-Microblaze-update-in-constraints-for-bitfield-.patch80
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0038-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch38
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0039-Intial-commit-of-64-bit-Microblaze.patch804
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0040-Added-load-store-pattern-movdi-and-also-adding-missi.patch83
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0041-Intial-commit-for-64bit-MB-sources.patch2463
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0042-re-arrangement-of-the-compare-branches.patch268
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0043-Patch-Microblaze-previous-commit-broke-the-handling-.patch28
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0044-Patch-Microblaze-Support-of-multilibs-with-m64.patch73
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0045-Fixed-issues-like.patch70
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0046-Fixed-below-issues.patch307
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0047-Added-double-arith-instructions.patch135
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0048-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch37
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0049-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch256
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0050-extending-the-Dwarf-support-to-64bit-Microblaze.patch25
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0051-fixing-the-typo-errors-in-umodsi3-file.patch29
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0052-fixing-the-32bit-LTO-related-issue9-1014024.patch68
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0053-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch25
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0054-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch29
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0055-fixing-the-long-long-long-mingw-toolchain-issue.patch59
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0055-microblaze_linker_script_xilinx_ld.patch16
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0056-Fix-the-MB-64-bug-of-handling-QI-objects.patch47
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0056-fix-the-lto-wrapper-issue-on-windows.patch36
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0057-Fix-the-MB-64-bug-of-handling-QI-objects.patch47
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0057-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch87
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0058-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch87
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0058-Reverting-the-patch-as-kernel-boot-is-not-working-wi.patch51
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0059-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch466
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0059-Reverting-the-patch-as-kernel-boot-is-not-working-wi.patch51
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0060-Author-Nagaraju-nmekala-xilinx.com.patch479
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0060-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch466
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0061-Author-Nagaraju-nmekala-xilinx.com.patch479
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0061-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch41
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0062-Added-new-MB-64-single-register-arithmetic-instructi.patch107
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0062-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch41
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0063-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch44
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-10/0064-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch77
-rw-r--r--meta-microblaze/recipes-microblaze/gcc/gcc-source_10.%.bbappend69
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb-cross-canadian_%.bbappend4
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb-cross_%.bbappend4
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb-microblaze.inc47
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch65
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0003-Disable-the-warning-message-for-eh_frame_hdr.patch31
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0004-Fix-relaxation-of-assembler-resolved-references.patch61
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch207
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch39
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0007-Fix-bug-in-TLSTPREL-Relocation.patch33
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0008-Added-Address-extension-instructions.patch98
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0009-fixing-the-MAX_OPCODES-to-correct-value.patch25
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0010-Add-new-bit-field-instructions.patch139
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0011-fixing-the-imm-bug.patch27
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0015-intial-commit-of-MB-64-bit.patch4186
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0016-MB-X-initial-commit.patch355
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch36
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0018-Added-relocations-for-MB-X.patch113
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0019-Fixed-MB-x-relocation-issues.patch115
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0020-Fixing-the-branch-related-issues.patch25
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0021-Fixed-address-computation-issues-with-64bit-address.patch97
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0022-Adding-new-relocation-to-support-64bit-rodata.patch69
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0023-fixing-the-.bss-relocation-issue.patch76
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch44
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch51
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch31
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch33
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0029-fixing-the-long-long-long-mingw-toolchain-issue.patch27
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0030-Added-support-to-new-arithmetic-single-register-inst.patch166
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch28
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0032-Add-initial-port-of-linux-gdbserver.patch435
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0033-Initial-port-of-core-reading-support.patch388
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0034-Fix-debug-message-when-register-is-unavailable.patch40
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0035-revert-master-rebase-changes-to-gdbserver.patch31
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch33
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch32
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0038-Initial-support-for-native-gdb.patch511
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0039-Fixing-the-issues-related-to-GDB-7.12.patch309
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0040-Patch-microblaze-Adding-64-bit-MB-support.patch1110
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0041-patch-MicroBlaze-porting-GDB-for-linux.patch155
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch146
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch24
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb/0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch363
-rw-r--r--meta-microblaze/recipes-microblaze/gdb/gdb_%.bbappend4
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch91
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch25
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch28
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch304
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch25
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0006-MB-X-intial-commit.patch194
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch1137
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch102
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch227
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch87
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/files/0011-Removing-the-Assembly-implementation-of-64bit-string.patch332
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/libgloss_3.3.%.bbappend6
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/microblaze-newlib.inc15
-rw-r--r--meta-microblaze/recipes-microblaze/newlib/newlib_3.3.%.bbappend7
-rw-r--r--meta-microblaze/recipes-microblaze/qemu/qemu_%.bbappend2
187 files changed, 35650 insertions, 0 deletions
diff --git a/meta-microblaze/conf/layer.conf b/meta-microblaze/conf/layer.conf
new file mode 100644
index 00000000..e4e4d907
--- /dev/null
+++ b/meta-microblaze/conf/layer.conf
@@ -0,0 +1,14 @@
1# We have a conf and classes directory, add to BBPATH
2BBPATH .= ":${LAYERDIR}"
3
4# We have a packages directory, add to BBFILES
5BBFILES += "${LAYERDIR}/recipes-*/*/*.bb"
6BBFILES += "${LAYERDIR}/recipes-*/*/*.bbappend"
7
8BBFILE_COLLECTIONS += "xilinx-microblaze"
9BBFILE_PATTERN_xilinx-microblaze = "^${LAYERDIR}/"
10BBFILE_PRIORITY_xilinx-microblaze = "5"
11
12LAYERDEPENDS_xilinx-microblaze = "core"
13
14LAYERSERIES_COMPAT_xilinx-microblaze = "dunfell gatesgarth"
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils-cross-canadian_%.bbappend b/meta-microblaze/recipes-microblaze/binutils/binutils-cross-canadian_%.bbappend
new file mode 100644
index 00000000..e439cae7
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils-cross-canadian_%.bbappend
@@ -0,0 +1,4 @@
1MICROBLAZEPATCHES = ""
2MICROBLAZEPATCHES_microblaze = "binutils-microblaze.inc"
3
4require ${MICROBLAZEPATCHES}
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils-cross_%.bbappend b/meta-microblaze/recipes-microblaze/binutils/binutils-cross_%.bbappend
new file mode 100644
index 00000000..e439cae7
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils-cross_%.bbappend
@@ -0,0 +1,4 @@
1MICROBLAZEPATCHES = ""
2MICROBLAZEPATCHES_microblaze = "binutils-microblaze.inc"
3
4require ${MICROBLAZEPATCHES}
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils-microblaze.inc b/meta-microblaze/recipes-microblaze/binutils/binutils-microblaze.inc
new file mode 100644
index 00000000..ed6e75b2
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils-microblaze.inc
@@ -0,0 +1,54 @@
1FILESEXTRAPATHS_append := ":${THISDIR}/binutils"
2
3SRC_URI_append = " \
4 file://0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch \
5 file://0002-Add-mlittle-endian-and-mbig-endian-flags.patch \
6 file://0003-Disable-the-warning-message-for-eh_frame_hdr.patch \
7 file://0004-Fix-relaxation-of-assembler-resolved-references.patch \
8 file://0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch \
9 file://0006-upstream-change-to-garbage-collection-sweep-causes-m.patch \
10 file://0007-Fix-bug-in-TLSTPREL-Relocation.patch \
11 file://0008-Added-Address-extension-instructions.patch \
12 file://0009-fixing-the-MAX_OPCODES-to-correct-value.patch \
13 file://0010-Add-new-bit-field-instructions.patch \
14 file://0011-fixing-the-imm-bug.patch \
15 file://0012-Patch-Microblaze-fixed-bug-in-GCC-so-that-It-will-su.patch \
16 file://0013-fixing-the-constant-range-check-issue.patch \
17 file://0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch \
18 file://0015-intial-commit-of-MB-64-bit.patch \
19 file://0016-MB-X-initial-commit.patch \
20 file://0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch \
21 file://0018-Added-relocations-for-MB-X.patch \
22 file://0019-Fixed-MB-x-relocation-issues.patch \
23 file://0020-Fixing-the-branch-related-issues.patch \
24 file://0021-Fixed-address-computation-issues-with-64bit-address.patch \
25 file://0022-Adding-new-relocation-to-support-64bit-rodata.patch \
26 file://0023-fixing-the-.bss-relocation-issue.patch \
27 file://0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch \
28 file://0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch \
29 file://0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch \
30 file://0027-Revert-ld-Remove-unused-expression-state.patch \
31 file://0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch \
32 file://0029-fixing-the-long-long-long-mingw-toolchain-issue.patch \
33 file://0030-Added-support-to-new-arithmetic-single-register-inst.patch \
34 file://0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch \
35 file://0032-Add-initial-port-of-linux-gdbserver.patch \
36 file://0033-Initial-port-of-core-reading-support.patch \
37 file://0034-Fix-debug-message-when-register-is-unavailable.patch \
38 file://0035-revert-master-rebase-changes-to-gdbserver.patch \
39 file://0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch \
40 file://0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch \
41 file://0038-Initial-support-for-native-gdb.patch \
42 file://0039-Fixing-the-issues-related-to-GDB-7.12.patch \
43 file://0040-Patch-microblaze-Adding-64-bit-MB-support.patch \
44 file://0041-patch-MicroBlaze-porting-GDB-for-linux.patch \
45 file://0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch \
46 file://0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch \
47 file://0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch \
48 file://0045-Fixed-bug-in-generation-of-IMML-instruction-for-the.patch \
49 file://0046-Patch-MicroBlaze-m64-This-patch-will-remove-imml-0-a.patch \
50 file://0047-Patch-MicroBlaze-commit-for-triggering-build-to-remo.patch \
51 file://0048-Patch-MicroBlaze-Adding-more-description-to-the-imml.patch \
52 file://0049-Patch-MicroBlaze-improper-address-mapping-of-PROVIDE.patch \
53 file://0050-Fix-i386-md_pseudo_table.patch \
54 "
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch
new file mode 100644
index 00000000..e0de79fd
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch
@@ -0,0 +1,65 @@
1From 247ead894f7079a4ededf2b48a65ffa6e78e2222 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Wed, 8 May 2013 11:03:36 +1000
4Subject: [PATCH 01/43] Add wdc.ext.clear and wdc.ext.flush insns
5
6Added two new instructions, wdc.ext.clear and wdc.ext.flush,
7to enable MicroBlaze to flush an external cache, which is
8used with the new coherency support for multiprocessing.
9
10Signed-off-by:nagaraju <nmekala@xilix.com>
11Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
12---
13 opcodes/microblaze-opc.h | 5 ++++-
14 opcodes/microblaze-opcm.h | 4 ++--
15 2 files changed, 6 insertions(+), 3 deletions(-)
16
17diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
18index 62ee3c9a4d..865151f95b 100644
19--- a/opcodes/microblaze-opc.h
20+++ b/opcodes/microblaze-opc.h
21@@ -91,6 +91,7 @@
22 #define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22. */
23 #define OPCODE_MASK_H32 0xFC00FC00 /* High 6 bits and bit 16-21. */
24 #define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits. */
25+#define OPCODE_MASK_H35B 0xFC0004FF /* High 6 bits and low 9 bits. */
26 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
27
28 /* New Mask for msrset, msrclr insns. */
29@@ -101,7 +102,7 @@
30 #define DELAY_SLOT 1
31 #define NO_DELAY_SLOT 0
32
33-#define MAX_OPCODES 289
34+#define MAX_OPCODES 291
35
36 struct op_code_struct
37 {
38@@ -174,7 +175,9 @@ struct op_code_struct
39 {"wic", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000068, OPCODE_MASK_H34B, wic, special_inst },
40 {"wdc", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000064, OPCODE_MASK_H34B, wdc, special_inst },
41 {"wdc.clear", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000066, OPCODE_MASK_H34B, wdcclear, special_inst },
42+ {"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 },
43 {"wdc.flush", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000074, OPCODE_MASK_H34B, wdcflush, special_inst },
44+ {"wdc.ext.flush", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000476, OPCODE_MASK_H35B, wdcextflush, special_inst },
45 {"mts", INST_TYPE_SPECIAL_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MTS, 0x9400C000, OPCODE_MASK_H13S, mts, special_inst },
46 {"mfs", INST_TYPE_RD_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MFS, 0x94008000, OPCODE_MASK_H23S, mfs, special_inst },
47 {"br", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98000000, OPCODE_MASK_H124, br, branch_inst },
48diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
49index 5a2d3b0c8b..42f3dd3be5 100644
50--- a/opcodes/microblaze-opcm.h
51+++ b/opcodes/microblaze-opcm.h
52@@ -33,8 +33,8 @@ enum microblaze_instr
53 /* 'or/and/xor' are C++ keywords. */
54 microblaze_or, microblaze_and, microblaze_xor,
55 andn, pcmpbf, pcmpbc, pcmpeq, pcmpne, sra, src, srl, sext8, sext16,
56- wic, wdc, wdcclear, wdcflush, mts, mfs, mbar, br, brd,
57- brld, bra, brad, brald, microblaze_brk, beq, beqd, bne, bned, blt,
58+ wic, wdc, wdcclear, wdcextclear, wdcflush, wdcextflush, mts, mfs, mbar, br,
59+ brd, brld, bra, brad, brald, microblaze_brk, beq, beqd, bne, bned, blt,
60 bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni,
61 imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid,
62 brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti,
63--
642.17.1
65
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0002-Add-mlittle-endian-and-mbig-endian-flags.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0002-Add-mlittle-endian-and-mbig-endian-flags.patch
new file mode 100644
index 00000000..98e40c0e
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0002-Add-mlittle-endian-and-mbig-endian-flags.patch
@@ -0,0 +1,64 @@
1From 7163824e07ade3ad2dc24e888265d27e0bc87869 Mon Sep 17 00:00:00 2001
2From: nagaraju <nmekala@xilix.com>
3Date: Tue, 19 Mar 2013 17:18:23 +0530
4Subject: [PATCH 02/43] Add mlittle-endian and mbig-endian flags
5
6Added support in gas for mlittle-endian and mbig-endian flags
7as options.
8
9Updated show usage for MicroBlaze specific assembler options
10to include new entries.
11
12Signed-off-by:nagaraju <nmekala@xilix.com>
13Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
14---
15 gas/config/tc-microblaze.c | 9 +++++++++
16 1 file changed, 9 insertions(+)
17
18diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
19index ab90c6b20f..c92e9ce563 100644
20--- a/gas/config/tc-microblaze.c
21+++ b/gas/config/tc-microblaze.c
22@@ -37,6 +37,8 @@
23
24 #define OPTION_EB (OPTION_MD_BASE + 0)
25 #define OPTION_EL (OPTION_MD_BASE + 1)
26+#define OPTION_LITTLE (OPTION_MD_BASE + 2)
27+#define OPTION_BIG (OPTION_MD_BASE + 3)
28
29 void microblaze_generate_symbol (char *sym);
30 static bfd_boolean check_spl_reg (unsigned *);
31@@ -1845,6 +1847,8 @@ struct option md_longopts[] =
32 {
33 {"EB", no_argument, NULL, OPTION_EB},
34 {"EL", no_argument, NULL, OPTION_EL},
35+ {"mlittle-endian", no_argument, NULL, OPTION_LITTLE},
36+ {"mbig-endian", no_argument, NULL, OPTION_BIG},
37 { NULL, no_argument, NULL, 0}
38 };
39
40@@ -2498,9 +2502,11 @@ md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
41 switch (c)
42 {
43 case OPTION_EB:
44+ case OPTION_BIG:
45 target_big_endian = 1;
46 break;
47 case OPTION_EL:
48+ case OPTION_LITTLE:
49 target_big_endian = 0;
50 break;
51 default:
52@@ -2515,6 +2521,9 @@ md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
53 /* fprintf(stream, _("\
54 MicroBlaze options:\n\
55 -noSmall Data in the comm and data sections do not go into the small data section\n")); */
56+ fprintf (stream, _(" MicroBlaze specific assembler options:\n"));
57+ fprintf (stream, " -%-23s%s\n", "mbig-endian", N_("assemble for a big endian cpu"));
58+ fprintf (stream, " -%-23s%s\n", "mlittle-endian", N_("assemble for a little endian cpu"));
59 }
60
61
62--
632.17.1
64
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0003-Disable-the-warning-message-for-eh_frame_hdr.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0003-Disable-the-warning-message-for-eh_frame_hdr.patch
new file mode 100644
index 00000000..445f5dd8
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0003-Disable-the-warning-message-for-eh_frame_hdr.patch
@@ -0,0 +1,31 @@
1From 2b9eec7fdfae66c5500baef444559976d1b20e0b Mon Sep 17 00:00:00 2001
2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
3Date: Fri, 22 Jun 2012 01:20:20 +0200
4Subject: [PATCH 03/43] Disable the warning message for eh_frame_hdr
5
6Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
7---
8 bfd/elf-eh-frame.c | 3 +++
9 1 file changed, 3 insertions(+)
10
11diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
12index a13e81ebb8..1824ba6e5b 100644
13--- a/bfd/elf-eh-frame.c
14+++ b/bfd/elf-eh-frame.c
15@@ -1044,10 +1044,13 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
16 goto success;
17
18 free_no_table:
19+/* FIXME: Remove the microblaze specifics when relaxing gets fixed. */
20+if (bfd_get_arch(abfd) != bfd_arch_microblaze) {
21 _bfd_error_handler
22 /* xgettext:c-format */
23 (_("error in %pB(%pA); no .eh_frame_hdr table will be created"),
24 abfd, sec);
25+}
26 hdr_info->u.dwarf.table = FALSE;
27 if (sec_info)
28 free (sec_info);
29--
302.17.1
31
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0004-Fix-relaxation-of-assembler-resolved-references.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0004-Fix-relaxation-of-assembler-resolved-references.patch
new file mode 100644
index 00000000..d1b754c3
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0004-Fix-relaxation-of-assembler-resolved-references.patch
@@ -0,0 +1,74 @@
1From ababe1df64146c616455eb1af4cf8fd21eb6f42c Mon Sep 17 00:00:00 2001
2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
3Date: Tue, 14 Feb 2012 01:00:22 +0100
4Subject: [PATCH 04/43] Fix relaxation of assembler resolved references
5
6---
7 bfd/elf32-microblaze.c | 38 ++++++++++++++++++++++++++++++++++++++
8 gas/config/tc-microblaze.c | 1 +
9 2 files changed, 39 insertions(+)
10
11diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
12index e3c8027248..359484dd5e 100644
13--- a/bfd/elf32-microblaze.c
14+++ b/bfd/elf32-microblaze.c
15@@ -1973,6 +1973,44 @@ microblaze_elf_relax_section (bfd *abfd,
16 irelscanend = irelocs + o->reloc_count;
17 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
18 {
19+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
20+ {
21+ unsigned int val;
22+
23+ isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
24+
25+ /* This was a PC-relative instruction that was completely resolved. */
26+ if (ocontents == NULL)
27+ {
28+ if (elf_section_data (o)->this_hdr.contents != NULL)
29+ ocontents = elf_section_data (o)->this_hdr.contents;
30+ else
31+ {
32+ /* We always cache the section contents.
33+ Perhaps, if info->keep_memory is FALSE, we
34+ should free them, if we are permitted to. */
35+
36+ if (o->rawsize == 0)
37+ o->rawsize = o->size;
38+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
39+ if (ocontents == NULL)
40+ goto error_return;
41+ if (!bfd_get_section_contents (abfd, o, ocontents,
42+ (file_ptr) 0,
43+ o->rawsize))
44+ goto error_return;
45+ elf_section_data (o)->this_hdr.contents = ocontents;
46+ }
47+ }
48+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
49+ + isym->st_value, sec);
50+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
51+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
52+ irelscan->r_addend);
53+ }
54+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
55+ fprintf(stderr, "Unhandled NONE 64\n");
56+ }
57 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
58 {
59 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
60diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
61index c92e9ce563..3e728400b7 100644
62--- a/gas/config/tc-microblaze.c
63+++ b/gas/config/tc-microblaze.c
64@@ -2205,6 +2205,7 @@ md_apply_fix (fixS * fixP,
65 else
66 fixP->fx_r_type = BFD_RELOC_NONE;
67 fixP->fx_addsy = section_symbol (absolute_section);
68+ fixP->fx_done = 0;
69 }
70 return;
71 }
72--
732.17.1
74
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch
new file mode 100644
index 00000000..ac13e6e3
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch
@@ -0,0 +1,247 @@
1From e9837b5aec42b084c93868095b409f9a6a81b570 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 6 Feb 2017 15:53:08 +0530
4Subject: [PATCH 05/43] [LOCAL]: Fixup debug_loc sections after linker
5 relaxation Adds a new reloctype R_MICROBLAZE_32_NONE, used for passing reloc
6 info from the assembler to the linker when the linker manages to fully
7 resolve a local symbol reference.
8
9This is a workaround for design flaws in the assembler to
10linker interface with regards to linker relaxation.
11
12Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13Signed-off-by: Nagaraju Mekala <nmekala@xilinx.com>
14---
15 bfd/bfd-in2.h | 9 +++++--
16 bfd/elf32-microblaze.c | 53 ++++++++++++++++++++++++++++----------
17 bfd/libbfd.h | 1 +
18 bfd/reloc.c | 6 +++++
19 binutils/readelf.c | 4 +++
20 gas/config/tc-microblaze.c | 5 +++-
21 include/elf/microblaze.h | 2 ++
22 7 files changed, 64 insertions(+), 16 deletions(-)
23
24diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
25index e25da50aaf..721531886a 100644
26--- a/bfd/bfd-in2.h
27+++ b/bfd/bfd-in2.h
28@@ -5866,10 +5866,15 @@ value relative to the read-write small data area anchor */
29 expressions of the form "Symbol Op Symbol" */
30 BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM,
31
32-/* This is a 64 bit reloc that stores the 32 bit pc relative
33+/* This is a 32 bit reloc that stores the 32 bit pc relative
34 value in two words (with an imm instruction). No relocation is
35 done here - only used for relaxing */
36- BFD_RELOC_MICROBLAZE_64_NONE,
37+ BFD_RELOC_MICROBLAZE_32_NONE,
38+
39+/* This is a 64 bit reloc that stores the 32 bit pc relative
40+ * +value in two words (with an imm instruction). No relocation is
41+ * +done here - only used for relaxing */
42+ BFD_RELOC_MICROBLAZE_64_NONE,
43
44 /* This is a 64 bit reloc that stores the 32 bit pc relative
45 value in two words (with an imm instruction). The relocation is
46diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
47index 359484dd5e..1c69c269c7 100644
48--- a/bfd/elf32-microblaze.c
49+++ b/bfd/elf32-microblaze.c
50@@ -176,7 +176,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
51 0x0000ffff, /* Dest Mask. */
52 FALSE), /* PC relative offset? */
53
54- /* This reloc does nothing. Used for relaxation. */
55+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
56+ 0, /* Rightshift. */
57+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
58+ 32, /* Bitsize. */
59+ TRUE, /* PC_relative. */
60+ 0, /* Bitpos. */
61+ complain_overflow_bitfield, /* Complain on overflow. */
62+ NULL, /* Special Function. */
63+ "R_MICROBLAZE_32_NONE",/* Name. */
64+ FALSE, /* Partial Inplace. */
65+ 0, /* Source Mask. */
66+ 0, /* Dest Mask. */
67+ FALSE), /* PC relative offset? */
68+
69+ /* This reloc does nothing. Used for relaxation. */
70 HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
71 0, /* Rightshift. */
72 3, /* Size (0 = byte, 1 = short, 2 = long). */
73@@ -562,6 +576,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
74 case BFD_RELOC_NONE:
75 microblaze_reloc = R_MICROBLAZE_NONE;
76 break;
77+ case BFD_RELOC_MICROBLAZE_32_NONE:
78+ microblaze_reloc = R_MICROBLAZE_32_NONE;
79+ break;
80 case BFD_RELOC_MICROBLAZE_64_NONE:
81 microblaze_reloc = R_MICROBLAZE_64_NONE;
82 break;
83@@ -1918,6 +1935,7 @@ microblaze_elf_relax_section (bfd *abfd,
84 }
85 break;
86 case R_MICROBLAZE_NONE:
87+ case R_MICROBLAZE_32_NONE:
88 {
89 /* This was a PC-relative instruction that was
90 completely resolved. */
91@@ -1926,12 +1944,18 @@ microblaze_elf_relax_section (bfd *abfd,
92 target_address = irel->r_addend + irel->r_offset;
93 sfix = calc_fixup (irel->r_offset, 0, sec);
94 efix = calc_fixup (target_address, 0, sec);
95+
96+ /* Validate the in-band val. */
97+ val = bfd_get_32 (abfd, contents + irel->r_offset);
98+ if (val != irel->r_addend && ELF32_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
99+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
100+ }
101 irel->r_addend -= (efix - sfix);
102 /* Should use HOWTO. */
103 microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
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,
113 irelscanend = irelocs + o->reloc_count;
114 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
115 {
116- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
117+ if (1 && ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
118 {
119 unsigned int val;
120
121 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
122
123+ /* hax: We only do the following fixup for debug location lists. */
124+ if (strcmp(".debug_loc", o->name))
125+ continue;
126+
127 /* This was a PC-relative instruction that was completely resolved. */
128 if (ocontents == NULL)
129 {
130@@ -1999,18 +2027,17 @@ microblaze_elf_relax_section (bfd *abfd,
131 (file_ptr) 0,
132 o->rawsize))
133 goto error_return;
134- elf_section_data (o)->this_hdr.contents = ocontents;
135- }
136- }
137- irelscan->r_addend -= calc_fixup (irelscan->r_addend
138- + isym->st_value, sec);
139+ elf_section_data (o)->this_hdr.contents = ocontents;
140+ }
141+ }
142 val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
143+ if (val != irelscan->r_addend) {
144+ fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend);
145+ }
146+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
147 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
148 irelscan->r_addend);
149 }
150- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
151- fprintf(stderr, "Unhandled NONE 64\n");
152- }
153 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
154 {
155 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
156@@ -2070,7 +2097,7 @@ microblaze_elf_relax_section (bfd *abfd,
157 elf_section_data (o)->this_hdr.contents = ocontents;
158 }
159 }
160- irelscan->r_addend -= calc_fixup (irel->r_addend
161+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
162 + isym->st_value,
163 0,
164 sec);
165diff --git a/bfd/libbfd.h b/bfd/libbfd.h
166index 36284d71a9..feb9fada1e 100644
167--- a/bfd/libbfd.h
168+++ b/bfd/libbfd.h
169@@ -2901,6 +2901,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
170 "BFD_RELOC_MICROBLAZE_32_ROSDA",
171 "BFD_RELOC_MICROBLAZE_32_RWSDA",
172 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
173+ "BFD_RELOC_MICROBLAZE_32_NONE",
174 "BFD_RELOC_MICROBLAZE_64_NONE",
175 "BFD_RELOC_MICROBLAZE_64_GOTPC",
176 "BFD_RELOC_MICROBLAZE_64_GOT",
177diff --git a/bfd/reloc.c b/bfd/reloc.c
178index e6446a7809..87753ae4f0 100644
179--- a/bfd/reloc.c
180+++ b/bfd/reloc.c
181@@ -6795,6 +6795,12 @@ ENUM
182 ENUMDOC
183 This is a 32 bit reloc for the microblaze to handle
184 expressions of the form "Symbol Op Symbol"
185+ENUM
186+ BFD_RELOC_MICROBLAZE_32_NONE
187+ENUMDOC
188+ This is a 32 bit reloc that stores the 32 bit pc relative
189+ value in two words (with an imm instruction). No relocation is
190+ done here - only used for relaxing
191 ENUM
192 BFD_RELOC_MICROBLAZE_64_NONE
193 ENUMDOC
194diff --git a/binutils/readelf.c b/binutils/readelf.c
195index b13eb6a43b..da6252c128 100644
196--- a/binutils/readelf.c
197+++ b/binutils/readelf.c
198@@ -13019,6 +13019,10 @@ is_none_reloc (Filedata * filedata, unsigned int reloc_type)
199 || reloc_type == 32 /* R_AVR_DIFF32. */);
200 case EM_METAG:
201 return reloc_type == 3; /* R_METAG_NONE. */
202+ case EM_MICROBLAZE:
203+ return reloc_type == 30 /* R_MICROBLAZE_32_NONE. */
204+ || reloc_type == 0 /* R_MICROBLAZE_NONE. */
205+ || reloc_type == 9; /* R_MICROBLAZE_64_NONE. */
206 case EM_NDS32:
207 return (reloc_type == 0 /* R_XTENSA_NONE. */
208 || reloc_type == 204 /* R_NDS32_DIFF8. */
209diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
210index 3e728400b7..fa665b4e25 100644
211--- a/gas/config/tc-microblaze.c
212+++ b/gas/config/tc-microblaze.c
213@@ -2201,7 +2201,9 @@ md_apply_fix (fixS * fixP,
214 /* This fixup has been resolved. Create a reloc in case the linker
215 moves code around due to relaxing. */
216 if (fixP->fx_r_type == BFD_RELOC_64_PCREL)
217- fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
218+ fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
219+ else if (fixP->fx_r_type == BFD_RELOC_32)
220+ fixP->fx_r_type = BFD_RELOC_MICROBLAZE_32_NONE;
221 else
222 fixP->fx_r_type = BFD_RELOC_NONE;
223 fixP->fx_addsy = section_symbol (absolute_section);
224@@ -2426,6 +2428,7 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
225 switch (fixp->fx_r_type)
226 {
227 case BFD_RELOC_NONE:
228+ case BFD_RELOC_MICROBLAZE_32_NONE:
229 case BFD_RELOC_MICROBLAZE_64_NONE:
230 case BFD_RELOC_32:
231 case BFD_RELOC_MICROBLAZE_32_LO:
232diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h
233index 830b5ad446..6ee0966444 100644
234--- a/include/elf/microblaze.h
235+++ b/include/elf/microblaze.h
236@@ -61,6 +61,8 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type)
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. */
239 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_32_LO, 32) /* TEXT Entry offset 32-bit. */
240+ RELOC_NUMBER (R_MICROBLAZE_32_NONE, 33)
241+
242 END_RELOC_NUMBERS (R_MICROBLAZE_max)
243
244 /* Global base address names. */
245--
2462.17.1
247
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch
new file mode 100644
index 00000000..97d692c7
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch
@@ -0,0 +1,39 @@
1From 403d6e82742452be4e3f3010c8d9989f0a490c0b 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/43] 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>
21---
22 bfd/elflink.c | 1 -
23 1 file changed, 1 deletion(-)
24
25diff --git a/bfd/elflink.c b/bfd/elflink.c
26index e50c0e4b38..09d43e3ca5 100644
27--- a/bfd/elflink.c
28+++ b/bfd/elflink.c
29@@ -6187,7 +6187,6 @@ elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
30
31 inf = (struct elf_gc_sweep_symbol_info *) data;
32 (*inf->hide_symbol) (inf->info, h, TRUE);
33- h->def_regular = 0;
34 h->ref_regular = 0;
35 h->ref_regular_nonweak = 0;
36 }
37--
382.17.1
39
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0007-Fix-bug-in-TLSTPREL-Relocation.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0007-Fix-bug-in-TLSTPREL-Relocation.patch
new file mode 100644
index 00000000..49534b4e
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0007-Fix-bug-in-TLSTPREL-Relocation.patch
@@ -0,0 +1,33 @@
1From 072a8968c50b2ebd93e225a6b959916f9d60b493 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 15 Jun 2015 16:50:30 +0530
4Subject: [PATCH 07/43] Fix bug in TLSTPREL Relocation
5
6Fixed the problem related to the fixup/relocations TLSTPREL.
7When the fixup is applied the addend is not added at the correct offset
8of the instruction. The offset is hard coded considering its big endian
9and it fails for Little endian. This patch allows support for both
10big & little-endian compilers
11---
12 bfd/elf32-microblaze.c | 4 ++--
13 1 file changed, 2 insertions(+), 2 deletions(-)
14
15diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
16index 1c69c269c7..d19a6dca84 100644
17--- a/bfd/elf32-microblaze.c
18+++ b/bfd/elf32-microblaze.c
19@@ -1451,9 +1451,9 @@ microblaze_elf_relocate_section (bfd *output_bfd,
20 relocation += addend;
21 relocation -= dtprel_base(info);
22 bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
23- contents + offset + 2);
24+ contents + offset + endian);
25 bfd_put_16 (input_bfd, relocation & 0xffff,
26- contents + offset + 2 + INST_WORD_SIZE);
27+ contents + offset + endian + INST_WORD_SIZE);
28 break;
29 case (int) R_MICROBLAZE_TEXTREL_64:
30 case (int) R_MICROBLAZE_TEXTREL_32_LO:
31--
322.17.1
33
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0008-Added-Address-extension-instructions.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0008-Added-Address-extension-instructions.patch
new file mode 100644
index 00000000..51fcee90
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0008-Added-Address-extension-instructions.patch
@@ -0,0 +1,98 @@
1From 4674056da6bafa8168c0a680498b958f3a39be94 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 18 Jan 2016 12:28:21 +0530
4Subject: [PATCH 08/43] Added Address extension instructions
5
6This patch adds the support of new instructions which are required
7for supporting Address extension feature.
8
9Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
10
11ChangeLog:
12 2016-01-18 Nagaraju Mekala <nmekala@xilix.com>
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---
19 opcodes/microblaze-opc.h | 11 +++++++++++
20 opcodes/microblaze-opcm.h | 10 +++++-----
21 2 files changed, 16 insertions(+), 5 deletions(-)
22
23diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
24index 865151f95b..330f1040e7 100644
25--- a/opcodes/microblaze-opc.h
26+++ b/opcodes/microblaze-opc.h
27@@ -178,8 +178,11 @@ struct op_code_struct
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 },
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 },
30 {"wdc.ext.flush", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000476, OPCODE_MASK_H35B, wdcextflush, special_inst },
31+ {"wdc.clear.ea", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900000E6, OPCODE_MASK_H34B, wdcclearea, special_inst },
32 {"mts", INST_TYPE_SPECIAL_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MTS, 0x9400C000, OPCODE_MASK_H13S, mts, special_inst },
33+ {"mtse", INST_TYPE_SPECIAL_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MTS, 0x9500C000, OPCODE_MASK_H13S, mtse,special_inst },
34 {"mfs", INST_TYPE_RD_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MFS, 0x94008000, OPCODE_MASK_H23S, mfs, special_inst },
35+ {"mfse", INST_TYPE_RD_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MFS, 0x94088000, OPCODE_MASK_H23S, mfse, special_inst },
36 {"br", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98000000, OPCODE_MASK_H124, br, branch_inst },
37 {"brd", INST_TYPE_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98100000, OPCODE_MASK_H124, brd, branch_inst },
38 {"brld", INST_TYPE_RD_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98140000, OPCODE_MASK_H24, brld, branch_inst },
39@@ -229,18 +232,24 @@ struct op_code_struct
40 {"bgeid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBEA00000, OPCODE_MASK_H1, bgeid, branch_inst },
41 {"lbu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000000, OPCODE_MASK_H4, lbu, memory_load_inst },
42 {"lbur", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000200, OPCODE_MASK_H4, lbur, memory_load_inst },
43+ {"lbuea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000080, OPCODE_MASK_H4, lbuea, memory_load_inst },
44 {"lhu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC4000000, OPCODE_MASK_H4, lhu, memory_load_inst },
45 {"lhur", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC4000200, OPCODE_MASK_H4, lhur, memory_load_inst },
46+ {"lhuea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC4000080, OPCODE_MASK_H4, lhuea, memory_load_inst },
47 {"lw", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000000, OPCODE_MASK_H4, lw, memory_load_inst },
48 {"lwr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000200, OPCODE_MASK_H4, lwr, memory_load_inst },
49 {"lwx", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000400, OPCODE_MASK_H4, lwx, memory_load_inst },
50+ {"lwea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000080, OPCODE_MASK_H4, lwea, memory_load_inst },
51 {"sb", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD0000000, OPCODE_MASK_H4, sb, memory_store_inst },
52 {"sbr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD0000200, OPCODE_MASK_H4, sbr, memory_store_inst },
53+ {"sbea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD0000080, OPCODE_MASK_H4, sbea, memory_store_inst },
54 {"sh", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD4000000, OPCODE_MASK_H4, sh, memory_store_inst },
55 {"shr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD4000200, OPCODE_MASK_H4, shr, memory_store_inst },
56+ {"shea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD4000080, OPCODE_MASK_H4, shea, memory_store_inst },
57 {"sw", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000000, OPCODE_MASK_H4, sw, memory_store_inst },
58 {"swr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000200, OPCODE_MASK_H4, swr, memory_store_inst },
59 {"swx", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000400, OPCODE_MASK_H4, swx, memory_store_inst },
60+ {"swea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000080, OPCODE_MASK_H4, swea, memory_store_inst },
61 {"lbui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE0000000, OPCODE_MASK_H, lbui, memory_load_inst },
62 {"lhui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE4000000, OPCODE_MASK_H, lhui, memory_load_inst },
63 {"lwi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, lwi, memory_load_inst },
64@@ -405,6 +414,8 @@ struct op_code_struct
65 {"clz", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900000E0, OPCODE_MASK_H34, clz, special_inst },
66 {"mbar", INST_TYPE_IMM5, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8020004, OPCODE_MASK_HN, mbar, special_inst },
67 {"sleep", INST_TYPE_NONE, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBA020004, OPCODE_MASK_HN, invalid_inst, special_inst }, /* translates to mbar 16. */
68+ {"hibernate", INST_TYPE_NONE, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB9020004, OPCODE_MASK_HN, invalid_inst, special_inst }, /* translates to mbar 8. */
69+ {"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. */
70 {"swapb", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E0, OPCODE_MASK_H4, swapb, arithmetic_inst },
71 {"swaph", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E2, OPCODE_MASK_H4, swaph, arithmetic_inst },
72 {"", 0, 0, 0, 0, 0, 0, 0, 0},
73diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
74index 42f3dd3be5..1c39dbf50b 100644
75--- a/opcodes/microblaze-opcm.h
76+++ b/opcodes/microblaze-opcm.h
77@@ -33,13 +33,13 @@ enum microblaze_instr
78 /* 'or/and/xor' are C++ keywords. */
79 microblaze_or, microblaze_and, microblaze_xor,
80 andn, pcmpbf, pcmpbc, pcmpeq, pcmpne, sra, src, srl, sext8, sext16,
81- wic, wdc, wdcclear, wdcextclear, wdcflush, wdcextflush, mts, mfs, mbar, br,
82- brd, brld, bra, brad, brald, microblaze_brk, beq, beqd, bne, bned, blt,
83- bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni,
84+ wic, wdc, wdcclear, wdcextclear, wdcflush, wdcextflush, wdcclearea, mts, mtse,
85+ mfs, mfse, mbar, br, brd, brld, bra, brad, brald, microblaze_brk, beq, beqd,
86+ bne, bned, blt, bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni,
87 imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid,
88 brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti,
89- bgtid, bgei, bgeid, lbu, lbur, lhu, lhur, lw, lwr, lwx, sb, sbr, sh,
90- shr, sw, swr, swx, lbui, lhui, lwi,
91+ bgtid, bgei, bgeid, lbu, lbuea, lbur, lhu, lhuea, lhur, lw, lwea, lwr, lwx,
92+ sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi,
93 sbi, shi, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv,
94 fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, flt,
95 fint, fsqrt,
96--
972.17.1
98
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0009-fixing-the-MAX_OPCODES-to-correct-value.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0009-fixing-the-MAX_OPCODES-to-correct-value.patch
new file mode 100644
index 00000000..d93ccd20
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0009-fixing-the-MAX_OPCODES-to-correct-value.patch
@@ -0,0 +1,25 @@
1From 7651a2f7ab486e26981cb5e032bf578d0951ff4a 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/43] fixing the MAX_OPCODES to correct value
5
6---
7 opcodes/microblaze-opc.h | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-)
9
10diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
11index 330f1040e7..2a6b841232 100644
12--- a/opcodes/microblaze-opc.h
13+++ b/opcodes/microblaze-opc.h
14@@ -102,7 +102,7 @@
15 #define DELAY_SLOT 1
16 #define NO_DELAY_SLOT 0
17
18-#define MAX_OPCODES 291
19+#define MAX_OPCODES 299
20
21 struct op_code_struct
22 {
23--
242.17.1
25
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0010-Add-new-bit-field-instructions.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0010-Add-new-bit-field-instructions.patch
new file mode 100644
index 00000000..901c53e6
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0010-Add-new-bit-field-instructions.patch
@@ -0,0 +1,230 @@
1From 7e9e123337f2d441b213ea9d0be07e9049241f64 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 18 Jul 2016 12:24:28 +0530
4Subject: [PATCH 10/43] Add new bit-field instructions
5
6This patches adds new bsefi and bsifi instructions.
7BSEFI- The instruction shall extract a bit field from a
8register and place it right-adjusted in the destination register.
9The other bits in the destination register shall be set to zero
10BSIFI- The instruction shall insert a right-adjusted bit field
11from a register at another position in the destination register.
12The rest of the bits in the destination register shall be unchanged
13
14Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
15---
16 gas/config/tc-microblaze.c | 71 +++++++++++++++++++++++++++++++++++++-
17 opcodes/microblaze-dis.c | 16 +++++++++
18 opcodes/microblaze-opc.h | 12 ++++++-
19 opcodes/microblaze-opcm.h | 6 +++-
20 4 files changed, 102 insertions(+), 3 deletions(-)
21
22diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
23index fa665b4e25..71bb888ab8 100644
24--- a/gas/config/tc-microblaze.c
25+++ b/gas/config/tc-microblaze.c
26@@ -917,7 +917,7 @@ md_assemble (char * str)
27 unsigned reg2;
28 unsigned reg3;
29 unsigned isize;
30- unsigned int immed, temp;
31+ unsigned int immed, immed2, temp;
32 expressionS exp;
33 char name[20];
34
35@@ -1172,7 +1172,76 @@ md_assemble (char * str)
36 inst |= (reg2 << RA_LOW) & RA_MASK;
37 inst |= (immed << IMM_LOW) & IMM5_MASK;
38 break;
39+ case INST_TYPE_RD_R1_IMM5_IMM5:
40+ if (strcmp (op_end, ""))
41+ op_end = parse_reg (op_end + 1, &reg1); /* Get rd. */
42+ else
43+ {
44+ as_fatal (_("Error in statement syntax"));
45+ reg1 = 0;
46+ }
47+ if (strcmp (op_end, ""))
48+ op_end = parse_reg (op_end + 1, &reg2); /* Get r1. */
49+ else
50+ {
51+ as_fatal (_("Error in statement syntax"));
52+ reg2 = 0;
53+ }
54+
55+ /* Check for spl registers. */
56+ if (check_spl_reg (&reg1))
57+ as_fatal (_("Cannot use special register with this instruction"));
58+ if (check_spl_reg (&reg2))
59+ as_fatal (_("Cannot use special register with this instruction"));
60
61+ /* Width immediate value. */
62+ if (strcmp (op_end, ""))
63+ op_end = parse_imm (op_end + 1, &exp, MIN_IMM_WIDTH, MAX_IMM_WIDTH);
64+ else
65+ as_fatal (_("Error in statement syntax"));
66+ if (exp.X_op != O_constant)
67+ {
68+ as_warn (_("Symbol used as immediate width value for bit field instruction"));
69+ immed = 1;
70+ }
71+ else
72+ immed = exp.X_add_number;
73+ if (opcode->instr == bsefi && immed > 31)
74+ as_fatal (_("Width value must be less than 32"));
75+
76+ /* Shift immediate value. */
77+ if (strcmp (op_end, ""))
78+ op_end = parse_imm (op_end + 1, &exp, MIN_IMM, MAX_IMM);
79+ else
80+ as_fatal (_("Error in statement syntax"));
81+ if (exp.X_op != O_constant)
82+ {
83+ as_warn (_("Symbol used as immediate shift value for bit field instruction"));
84+ immed2 = 0;
85+ }
86+ else
87+ {
88+ output = frag_more (isize);
89+ immed2 = exp.X_add_number;
90+ }
91+ if (immed2 != (immed2 % 32))
92+ {
93+ as_warn (_("Shift value greater than 32. using <value %% 32>"));
94+ immed2 = immed2 % 32;
95+ }
96+
97+ /* Check combined value. */
98+ if (immed + immed2 > 32)
99+ as_fatal (_("Width value + shift value must not be greater than 32"));
100+
101+ inst |= (reg1 << RD_LOW) & RD_MASK;
102+ inst |= (reg2 << RA_LOW) & RA_MASK;
103+ if (opcode->instr == bsefi)
104+ inst |= (immed & IMM5_MASK) << IMM_WIDTH_LOW; /* bsefi */
105+ else
106+ inst |= ((immed + immed2 - 1) & IMM5_MASK) << IMM_WIDTH_LOW; /* bsifi */
107+ inst |= (immed2 << IMM_LOW) & IMM5_MASK;
108+ break;
109 case INST_TYPE_R1_R2:
110 if (strcmp (op_end, ""))
111 op_end = parse_reg (op_end + 1, &reg1); /* Get r1. */
112diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
113index f691740dfd..f8aaf27873 100644
114--- a/opcodes/microblaze-dis.c
115+++ b/opcodes/microblaze-dis.c
116@@ -73,6 +73,18 @@ get_field_imm5_mbar (long instr)
117 return(strdup(tmpstr));
118 }
119
120+static char *
121+get_field_imm5width (long instr)
122+{
123+ char tmpstr[25];
124+
125+ if (instr & 0x00004000)
126+ sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW))); /* bsefi */
127+ else
128+ sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW) - ((instr & IMM5_MASK) >> IMM_LOW) + 1)); /* bsifi */
129+ return (strdup (tmpstr));
130+}
131+
132 static char *
133 get_field_rfsl (long instr)
134 {
135@@ -396,6 +408,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
136 /* For mbar 16 or sleep insn. */
137 case INST_TYPE_NONE:
138 break;
139+ /* For bit field insns. */
140+ case INST_TYPE_RD_R1_IMM5_IMM5:
141+ print_func (stream, "\t%s, %s, %s, %s", get_field_rd (inst),get_field_r1(inst),get_field_imm5width (inst), get_field_imm5 (inst));
142+ break;
143 /* For tuqula instruction */
144 case INST_TYPE_RD:
145 print_func (stream, "\t%s", get_field_rd (inst));
146diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
147index 2a6b841232..ce8ac351b5 100644
148--- a/opcodes/microblaze-opc.h
149+++ b/opcodes/microblaze-opc.h
150@@ -59,6 +59,9 @@
151 /* For mbar. */
152 #define INST_TYPE_IMM5 20
153
154+/* For bsefi and bsifi */
155+#define INST_TYPE_RD_R1_IMM5_IMM5 21
156+
157 #define INST_TYPE_NONE 25
158
159
160@@ -89,7 +92,9 @@
161 #define OPCODE_MASK_H124 0xFFFF07FF /* High 16, and low 11 bits. */
162 #define OPCODE_MASK_H1234 0xFFFFFFFF /* All 32 bits. */
163 #define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22. */
164+#define OPCODE_MASK_H3B 0xFC00C600 /* High 6 bits and bits 16, 17, 21, 22. */
165 #define OPCODE_MASK_H32 0xFC00FC00 /* High 6 bits and bit 16-21. */
166+#define OPCODE_MASK_H32B 0xFC00C000 /* High 6 bits and bit 16, 17. */
167 #define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits. */
168 #define OPCODE_MASK_H35B 0xFC0004FF /* High 6 bits and low 9 bits. */
169 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
170@@ -102,7 +107,7 @@
171 #define DELAY_SLOT 1
172 #define NO_DELAY_SLOT 0
173
174-#define MAX_OPCODES 299
175+#define MAX_OPCODES 301
176
177 struct op_code_struct
178 {
179@@ -159,6 +164,8 @@ struct op_code_struct
180 {"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3, bslli, barrel_shift_inst },
181 {"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3, bsrai, barrel_shift_inst },
182 {"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3, bsrli, barrel_shift_inst },
183+ {"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 },
184+ {"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 },
185 {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst },
186 {"and", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000000, OPCODE_MASK_H4, microblaze_and, logical_inst },
187 {"xor", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000000, OPCODE_MASK_H4, microblaze_xor, logical_inst },
188@@ -438,5 +445,8 @@ char pvr_register_prefix[] = "rpvr";
189 #define MIN_IMM5 ((int) 0x00000000)
190 #define MAX_IMM5 ((int) 0x0000001f)
191
192+#define MIN_IMM_WIDTH ((int) 0x00000001)
193+#define MAX_IMM_WIDTH ((int) 0x00000020)
194+
195 #endif /* MICROBLAZE_OPC */
196
197diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
198index 1c39dbf50b..28662694cd 100644
199--- a/opcodes/microblaze-opcm.h
200+++ b/opcodes/microblaze-opcm.h
201@@ -29,7 +29,7 @@ enum microblaze_instr
202 addi, rsubi, addic, rsubic, addik, rsubik, addikc, rsubikc, mul,
203 mulh, mulhu, mulhsu,swapb,swaph,
204 idiv, idivu, bsll, bsra, bsrl, get, put, nget, nput, cget, cput,
205- ncget, ncput, muli, bslli, bsrai, bsrli, mului,
206+ ncget, ncput, muli, bslli, bsrai, bsrli, bsefi, bsifi, mului,
207 /* 'or/and/xor' are C++ keywords. */
208 microblaze_or, microblaze_and, microblaze_xor,
209 andn, pcmpbf, pcmpbc, pcmpeq, pcmpne, sra, src, srl, sext8, sext16,
210@@ -129,6 +129,7 @@ enum microblaze_instr_type
211 #define RB_LOW 11 /* Low bit for RB. */
212 #define IMM_LOW 0 /* Low bit for immediate. */
213 #define IMM_MBAR 21 /* low bit for mbar instruction. */
214+#define IMM_WIDTH_LOW 6 /* Low bit for immediate width */
215
216 #define RD_MASK 0x03E00000
217 #define RA_MASK 0x001F0000
218@@ -141,6 +142,9 @@ enum microblaze_instr_type
219 /* Imm mask for mbar. */
220 #define IMM5_MBAR_MASK 0x03E00000
221
222+/* Imm mask for extract/insert width. */
223+#define IMM5_WIDTH_MASK 0x000007C0
224+
225 /* FSL imm mask for get, put instructions. */
226 #define RFSL_MASK 0x000000F
227
228--
2292.17.1
230
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0011-fixing-the-imm-bug.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0011-fixing-the-imm-bug.patch
new file mode 100644
index 00000000..4c1b0c25
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0011-fixing-the-imm-bug.patch
@@ -0,0 +1,27 @@
1From 8b2e8fe916066bb1caa99abc67f8cde3ebd41c70 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 10 Jul 2017 16:07:28 +0530
4Subject: [PATCH 11/43] fixing the imm bug. with relax option imm -1 is also
5 getting removed this is corrected now.
6
7---
8 bfd/elf32-microblaze.c | 3 +--
9 1 file changed, 1 insertion(+), 2 deletions(-)
10
11diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
12index d19a6dca84..d001437b3f 100644
13--- a/bfd/elf32-microblaze.c
14+++ b/bfd/elf32-microblaze.c
15@@ -1869,8 +1869,7 @@ microblaze_elf_relax_section (bfd *abfd,
16 else
17 symval += irel->r_addend;
18
19- if ((symval & 0xffff8000) == 0
20- || (symval & 0xffff8000) == 0xffff8000)
21+ if ((symval & 0xffff8000) == 0)
22 {
23 /* We can delete this instruction. */
24 sec->relax[sec->relax_count].addr = irel->r_offset;
25--
262.17.1
27
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0012-Patch-Microblaze-fixed-bug-in-GCC-so-that-It-will-su.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0012-Patch-Microblaze-fixed-bug-in-GCC-so-that-It-will-su.patch
new file mode 100644
index 00000000..ad4db430
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0012-Patch-Microblaze-fixed-bug-in-GCC-so-that-It-will-su.patch
@@ -0,0 +1,33 @@
1From 2a7b66bbc0473c6cbe6653a48818962b5b411ef2 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Fri, 29 Sep 2017 18:00:23 +0530
4Subject: [PATCH 12/43] [Patch,Microblaze]: fixed bug in GCC so that It will
5 support .long 0U and .long 0u
6
7---
8 gas/expr.c | 9 +++++++++
9 1 file changed, 9 insertions(+)
10
11diff --git a/gas/expr.c b/gas/expr.c
12index ee85bda1cc..b502418b71 100644
13--- a/gas/expr.c
14+++ b/gas/expr.c
15@@ -810,6 +810,15 @@ operand (expressionS *expressionP, enum expr_mode mode)
16 break;
17 }
18 }
19+ if ((*input_line_pointer == 'U') || (*input_line_pointer == 'u'))
20+ {
21+ input_line_pointer--;
22+
23+ integer_constant ((NUMBERS_WITH_SUFFIX || flag_m68k_mri)
24+ ? 0 : 10,
25+ expressionP);
26+ break;
27+ }
28 c = *input_line_pointer;
29 switch (c)
30 {
31--
322.17.1
33
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0013-fixing-the-constant-range-check-issue.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0013-fixing-the-constant-range-check-issue.patch
new file mode 100644
index 00000000..323b7bde
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0013-fixing-the-constant-range-check-issue.patch
@@ -0,0 +1,26 @@
1From 59a9a1a913b7dfa424792c907001413c1ddd320c Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 16 Oct 2017 15:44:23 +0530
4Subject: [PATCH 13/43] fixing the constant range check issue sample error: not
5 in range ffffffff80000000..7fffffff, not ffffffff70000000
6
7---
8 gas/config/tc-microblaze.c | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
12index 71bb888ab8..16b10d00a9 100644
13--- a/gas/config/tc-microblaze.c
14+++ b/gas/config/tc-microblaze.c
15@@ -757,7 +757,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
16 if ((e->X_add_number >> 31) == 1)
17 e->X_add_number |= -((addressT) (1U << 31));
18
19- if (e->X_add_number < min || e->X_add_number > max)
20+ if ((int)e->X_add_number < min || (int)e->X_add_number > max)
21 {
22 as_fatal (_("operand must be absolute in range %lx..%lx, not %lx"),
23 (long) min, (long) max, (long) e->X_add_number);
24--
252.17.1
26
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch
new file mode 100644
index 00000000..1a3e0130
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0014-Patch-Microblaze-Compiler-will-give-error-messages-i.patch
@@ -0,0 +1,36 @@
1From 00b7561a868b08dab952b9b9f4a01118195aeb29 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/43] [Patch,Microblaze]: Compiler will give error messages
5 in more detail for mxl-gp-opt flag..
6
7---
8 ld/ldmain.c | 12 ++++++++++++
9 1 file changed, 12 insertions(+)
10
11diff --git a/ld/ldmain.c b/ld/ldmain.c
12index 77cdbd0dd2..517d85baef 100644
13--- a/ld/ldmain.c
14+++ b/ld/ldmain.c
15@@ -1446,6 +1446,18 @@ reloc_overflow (struct bfd_link_info *info,
16 break;
17 case bfd_link_hash_defined:
18 case bfd_link_hash_defweak:
19+
20+ if((strcmp(reloc_name,"R_MICROBLAZE_SRW32") == 0) && entry->type == bfd_link_hash_defined)
21+ {
22+ einfo (_(" relocation truncated to fit: don't enable small data pointer optimizations[mxl-gp-opt] if extern or multiple declarations used: "
23+ "%s against symbol `%T' defined in %A section in %B"),
24+ reloc_name, entry->root.string,
25+ entry->u.def.section,
26+ entry->u.def.section == bfd_abs_section_ptr
27+ ? info->output_bfd : entry->u.def.section->owner);
28+ break;
29+ }
30+
31 einfo (_(" relocation truncated to fit: "
32 "%s against symbol `%pT' defined in %pA section in %pB"),
33 reloc_name, entry->root.string,
34--
352.17.1
36
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0015-intial-commit-of-MB-64-bit.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0015-intial-commit-of-MB-64-bit.patch
new file mode 100644
index 00000000..d0f96eca
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0015-intial-commit-of-MB-64-bit.patch
@@ -0,0 +1,4738 @@
1From 9aeae734291f8aaeb449c1403561b71de1ea3bea 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/43] intial commit of MB 64-bit
5
6---
7 bfd/Makefile.am | 2 +
8 bfd/Makefile.in | 3 +
9 bfd/config.bfd | 4 +
10 bfd/configure | 2 +
11 bfd/configure.ac | 2 +
12 bfd/cpu-microblaze.c | 52 +-
13 bfd/elf64-microblaze.c | 3584 ++++++++++++++++++++++++++++
14 bfd/targets.c | 6 +
15 gas/config/tc-microblaze.c | 274 ++-
16 gas/config/tc-microblaze.h | 4 +-
17 include/elf/common.h | 1 +
18 ld/Makefile.am | 8 +
19 ld/Makefile.in | 10 +
20 ld/configure.tgt | 3 +
21 ld/emulparams/elf64microblaze.sh | 23 +
22 ld/emulparams/elf64microblazeel.sh | 23 +
23 opcodes/microblaze-dis.c | 39 +-
24 opcodes/microblaze-opc.h | 162 +-
25 opcodes/microblaze-opcm.h | 20 +-
26 19 files changed, 4181 insertions(+), 41 deletions(-)
27 create mode 100644 bfd/elf64-microblaze.c
28 create mode 100644 ld/emulparams/elf64microblaze.sh
29 create mode 100644 ld/emulparams/elf64microblazeel.sh
30
31diff --git a/bfd/Makefile.am b/bfd/Makefile.am
32index a9191555ad..c5fd250812 100644
33--- a/bfd/Makefile.am
34+++ b/bfd/Makefile.am
35@@ -570,6 +570,7 @@ BFD64_BACKENDS = \
36 elf64-riscv.lo \
37 elfxx-riscv.lo \
38 elf64-s390.lo \
39+ elf64-microblaze.lo \
40 elf64-sparc.lo \
41 elf64-tilegx.lo \
42 elf64-x86-64.lo \
43@@ -603,6 +604,7 @@ BFD64_BACKENDS_CFILES = \
44 elf64-nfp.c \
45 elf64-ppc.c \
46 elf64-s390.c \
47+ elf64-microblaze.c \
48 elf64-sparc.c \
49 elf64-tilegx.c \
50 elf64-x86-64.c \
51diff --git a/bfd/Makefile.in b/bfd/Makefile.in
52index 896df52042..fd457cba1e 100644
53--- a/bfd/Makefile.in
54+++ b/bfd/Makefile.in
55@@ -995,6 +995,7 @@ BFD64_BACKENDS = \
56 elf64-riscv.lo \
57 elfxx-riscv.lo \
58 elf64-s390.lo \
59+ elf64-microblaze.lo \
60 elf64-sparc.lo \
61 elf64-tilegx.lo \
62 elf64-x86-64.lo \
63@@ -1028,6 +1029,7 @@ BFD64_BACKENDS_CFILES = \
64 elf64-nfp.c \
65 elf64-ppc.c \
66 elf64-s390.c \
67+ elf64-microblaze.c \
68 elf64-sparc.c \
69 elf64-tilegx.c \
70 elf64-x86-64.c \
71@@ -1494,6 +1496,7 @@ distclean-compile:
72 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-ppc.Plo@am__quote@
73 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-riscv.Plo@am__quote@
74 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-s390.Plo@am__quote@
75+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-microblaze.Plo@am__quote@
76 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-sparc.Plo@am__quote@
77 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-tilegx.Plo@am__quote@
78 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-x86-64.Plo@am__quote@
79diff --git a/bfd/config.bfd b/bfd/config.bfd
80index 0e1ddb659c..93d210643d 100644
81--- a/bfd/config.bfd
82+++ b/bfd/config.bfd
83@@ -850,11 +850,15 @@ case "${targ}" in
84 microblazeel*-*)
85 targ_defvec=microblaze_elf32_le_vec
86 targ_selvecs=microblaze_elf32_vec
87+ targ64_selvecs=microblaze_elf64_vec
88+ targ64_selvecs=microblaze_elf64_le_vec
89 ;;
90
91 microblaze*-*)
92 targ_defvec=microblaze_elf32_vec
93 targ_selvecs=microblaze_elf32_le_vec
94+ targ64_selvecs=microblaze_elf64_vec
95+ targ64_selvecs=microblaze_elf64_le_vec
96 ;;
97
98 #ifdef BFD64
99diff --git a/bfd/configure b/bfd/configure
100index 04786696dc..d455abe7c5 100755
101--- a/bfd/configure
102+++ b/bfd/configure
103@@ -14847,6 +14847,8 @@ do
104 rx_elf32_linux_le_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;;
105 s390_elf32_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
106 s390_elf64_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
107+ microblaze_elf64_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
108+ microblaze_elf64_le_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
109 score_elf32_be_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
110 score_elf32_le_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
111 sh_coff_vec) tb="$tb coff-sh.lo $coff" ;;
112diff --git a/bfd/configure.ac b/bfd/configure.ac
113index eda38ea086..f01c3362fe 100644
114--- a/bfd/configure.ac
115+++ b/bfd/configure.ac
116@@ -615,6 +615,8 @@ do
117 rx_elf32_linux_le_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;;
118 s390_elf32_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
119 s390_elf64_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
120+ microblaze_elf64_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
121+ microblaze_elf64_le_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
122 score_elf32_be_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
123 score_elf32_le_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
124 sh_coff_vec) tb="$tb coff-sh.lo $coff" ;;
125diff --git a/bfd/cpu-microblaze.c b/bfd/cpu-microblaze.c
126index 9bc2eb3de9..c91ba46f75 100644
127--- a/bfd/cpu-microblaze.c
128+++ b/bfd/cpu-microblaze.c
129@@ -23,7 +23,24 @@
130 #include "bfd.h"
131 #include "libbfd.h"
132
133-const bfd_arch_info_type bfd_microblaze_arch =
134+const bfd_arch_info_type bfd_microblaze_arch[] =
135+{
136+#if BFD_DEFAULT_TARGET_SIZE == 64
137+{
138+ 64, /* 32 bits in a word. */
139+ 64, /* 32 bits in an address. */
140+ 8, /* 8 bits in a byte. */
141+ bfd_arch_microblaze, /* Architecture. */
142+ 0, /* Machine number - 0 for now. */
143+ "microblaze", /* Architecture name. */
144+ "MicroBlaze", /* Printable name. */
145+ 3, /* Section align power. */
146+ FALSE, /* Is this the default architecture ? */
147+ bfd_default_compatible, /* Architecture comparison function. */
148+ bfd_default_scan, /* String to architecture conversion. */
149+ bfd_arch_default_fill, /* Default fill. */
150+ &bfd_microblaze_arch[1] /* Next in list. */
151+},
152 {
153 32, /* 32 bits in a word. */
154 32, /* 32 bits in an address. */
155@@ -38,4 +55,37 @@ const bfd_arch_info_type bfd_microblaze_arch =
156 bfd_default_scan, /* String to architecture conversion. */
157 bfd_arch_default_fill, /* Default fill. */
158 NULL /* Next in list. */
159+}
160+#else
161+{
162+ 32, /* 32 bits in a word. */
163+ 32, /* 32 bits in an address. */
164+ 8, /* 8 bits in a byte. */
165+ bfd_arch_microblaze, /* Architecture. */
166+ 0, /* Machine number - 0 for now. */
167+ "microblaze", /* Architecture name. */
168+ "MicroBlaze", /* Printable name. */
169+ 3, /* Section align power. */
170+ TRUE, /* Is this the default architecture ? */
171+ bfd_default_compatible, /* Architecture comparison function. */
172+ bfd_default_scan, /* String to architecture conversion. */
173+ bfd_arch_default_fill, /* Default fill. */
174+ &bfd_microblaze_arch[1] /* Next in list. */
175+},
176+{
177+ 64, /* 32 bits in a word. */
178+ 64, /* 32 bits in an address. */
179+ 8, /* 8 bits in a byte. */
180+ bfd_arch_microblaze, /* Architecture. */
181+ 0, /* Machine number - 0 for now. */
182+ "microblaze", /* Architecture name. */
183+ "MicroBlaze", /* Printable name. */
184+ 3, /* Section align power. */
185+ FALSE, /* Is this the default architecture ? */
186+ bfd_default_compatible, /* Architecture comparison function. */
187+ bfd_default_scan, /* String to architecture conversion. */
188+ bfd_arch_default_fill, /* Default fill. */
189+ NULL /* Next in list. */
190+}
191+#endif
192 };
193diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
194new file mode 100644
195index 0000000000..0f43ae6ea8
196--- /dev/null
197+++ b/bfd/elf64-microblaze.c
198@@ -0,0 +1,3584 @@
199+/* Xilinx MicroBlaze-specific support for 32-bit ELF
200+
201+ Copyright (C) 2009-2016 Free Software Foundation, Inc.
202+
203+ This file is part of BFD, the Binary File Descriptor library.
204+
205+ This program is free software; you can redistribute it and/or modify
206+ it under the terms of the GNU General Public License as published by
207+ the Free Software Foundation; either version 3 of the License, or
208+ (at your option) any later version.
209+
210+ This program is distributed in the hope that it will be useful,
211+ but WITHOUT ANY WARRANTY; without even the implied warranty of
212+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
213+ GNU General Public License for more details.
214+
215+ You should have received a copy of the GNU General Public License
216+ along with this program; if not, write to the
217+ Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
218+ Boston, MA 02110-1301, USA. */
219+
220+
221+int dbg1 = 0;
222+
223+#include "sysdep.h"
224+#include "bfd.h"
225+#include "bfdlink.h"
226+#include "libbfd.h"
227+#include "elf-bfd.h"
228+#include "elf/microblaze.h"
229+#include <assert.h>
230+
231+#define USE_RELA /* Only USE_REL is actually significant, but this is
232+ here are a reminder... */
233+#define INST_WORD_SIZE 4
234+
235+static int ro_small_data_pointer = 0;
236+static int rw_small_data_pointer = 0;
237+
238+static reloc_howto_type * microblaze_elf_howto_table [(int) R_MICROBLAZE_max];
239+
240+static reloc_howto_type microblaze_elf_howto_raw[] =
241+{
242+ /* This reloc does nothing. */
243+ HOWTO (R_MICROBLAZE_NONE, /* Type. */
244+ 0, /* Rightshift. */
245+ 3, /* Size (0 = byte, 1 = short, 2 = long). */
246+ 0, /* Bitsize. */
247+ FALSE, /* PC_relative. */
248+ 0, /* Bitpos. */
249+ complain_overflow_dont, /* Complain on overflow. */
250+ NULL, /* Special Function. */
251+ "R_MICROBLAZE_NONE", /* Name. */
252+ FALSE, /* Partial Inplace. */
253+ 0, /* Source Mask. */
254+ 0, /* Dest Mask. */
255+ FALSE), /* PC relative offset? */
256+
257+ /* A standard 32 bit relocation. */
258+ HOWTO (R_MICROBLAZE_32, /* Type. */
259+ 0, /* Rightshift. */
260+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
261+ 32, /* Bitsize. */
262+ FALSE, /* PC_relative. */
263+ 0, /* Bitpos. */
264+ complain_overflow_bitfield, /* Complain on overflow. */
265+ bfd_elf_generic_reloc,/* Special Function. */
266+ "R_MICROBLAZE_32", /* Name. */
267+ FALSE, /* Partial Inplace. */
268+ 0, /* Source Mask. */
269+ 0xffffffff, /* Dest Mask. */
270+ FALSE), /* PC relative offset? */
271+
272+ /* A standard PCREL 32 bit relocation. */
273+ HOWTO (R_MICROBLAZE_32_PCREL,/* Type. */
274+ 0, /* Rightshift. */
275+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
276+ 32, /* Bitsize. */
277+ TRUE, /* PC_relative. */
278+ 0, /* Bitpos. */
279+ complain_overflow_bitfield, /* Complain on overflow. */
280+ bfd_elf_generic_reloc,/* Special Function. */
281+ "R_MICROBLAZE_32_PCREL", /* Name. */
282+ TRUE, /* Partial Inplace. */
283+ 0, /* Source Mask. */
284+ 0xffffffff, /* Dest Mask. */
285+ TRUE), /* PC relative offset? */
286+
287+ /* A 64 bit PCREL relocation. Table-entry not really used. */
288+ HOWTO (R_MICROBLAZE_64_PCREL,/* Type. */
289+ 0, /* Rightshift. */
290+ 4, /* Size (0 = byte, 1 = short, 2 = long). */
291+ 64, /* Bitsize. */
292+ TRUE, /* PC_relative. */
293+ 0, /* Bitpos. */
294+ complain_overflow_dont, /* Complain on overflow. */
295+ bfd_elf_generic_reloc,/* Special Function. */
296+ "R_MICROBLAZE_64_PCREL", /* Name. */
297+ FALSE, /* Partial Inplace. */
298+ 0, /* Source Mask. */
299+ 0x0000ffff, /* Dest Mask. */
300+ TRUE), /* PC relative offset? */
301+
302+ /* The low half of a PCREL 32 bit relocation. */
303+ HOWTO (R_MICROBLAZE_32_PCREL_LO, /* Type. */
304+ 0, /* Rightshift. */
305+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
306+ 16, /* Bitsize. */
307+ TRUE, /* PC_relative. */
308+ 0, /* Bitpos. */
309+ complain_overflow_signed, /* Complain on overflow. */
310+ bfd_elf_generic_reloc, /* Special Function. */
311+ "R_MICROBLAZE_32_PCREL_LO", /* Name. */
312+ FALSE, /* Partial Inplace. */
313+ 0, /* Source Mask. */
314+ 0x0000ffff, /* Dest Mask. */
315+ TRUE), /* PC relative offset? */
316+
317+ /* A 64 bit relocation. Table entry not really used. */
318+ HOWTO (R_MICROBLAZE_64, /* Type. */
319+ 0, /* Rightshift. */
320+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
321+ 16, /* Bitsize. */
322+ FALSE, /* PC_relative. */
323+ 0, /* Bitpos. */
324+ complain_overflow_dont, /* Complain on overflow. */
325+ bfd_elf_generic_reloc,/* Special Function. */
326+ "R_MICROBLAZE_64", /* Name. */
327+ FALSE, /* Partial Inplace. */
328+ 0, /* Source Mask. */
329+ 0x0000ffff, /* Dest Mask. */
330+ FALSE), /* PC relative offset? */
331+
332+ /* The low half of a 32 bit relocation. */
333+ HOWTO (R_MICROBLAZE_32_LO, /* Type. */
334+ 0, /* Rightshift. */
335+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
336+ 16, /* Bitsize. */
337+ FALSE, /* PC_relative. */
338+ 0, /* Bitpos. */
339+ complain_overflow_signed, /* Complain on overflow. */
340+ bfd_elf_generic_reloc,/* Special Function. */
341+ "R_MICROBLAZE_32_LO", /* Name. */
342+ FALSE, /* Partial Inplace. */
343+ 0, /* Source Mask. */
344+ 0x0000ffff, /* Dest Mask. */
345+ FALSE), /* PC relative offset? */
346+
347+ /* Read-only small data section relocation. */
348+ HOWTO (R_MICROBLAZE_SRO32, /* Type. */
349+ 0, /* Rightshift. */
350+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
351+ 16, /* Bitsize. */
352+ FALSE, /* PC_relative. */
353+ 0, /* Bitpos. */
354+ complain_overflow_bitfield, /* Complain on overflow. */
355+ bfd_elf_generic_reloc,/* Special Function. */
356+ "R_MICROBLAZE_SRO32", /* Name. */
357+ FALSE, /* Partial Inplace. */
358+ 0, /* Source Mask. */
359+ 0x0000ffff, /* Dest Mask. */
360+ FALSE), /* PC relative offset? */
361+
362+ /* Read-write small data area relocation. */
363+ HOWTO (R_MICROBLAZE_SRW32, /* Type. */
364+ 0, /* Rightshift. */
365+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
366+ 16, /* Bitsize. */
367+ FALSE, /* PC_relative. */
368+ 0, /* Bitpos. */
369+ complain_overflow_bitfield, /* Complain on overflow. */
370+ bfd_elf_generic_reloc,/* Special Function. */
371+ "R_MICROBLAZE_SRW32", /* Name. */
372+ FALSE, /* Partial Inplace. */
373+ 0, /* Source Mask. */
374+ 0x0000ffff, /* Dest Mask. */
375+ FALSE), /* PC relative offset? */
376+
377+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
378+ 0, /* Rightshift. */
379+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
380+ 32, /* Bitsize. */
381+ TRUE, /* PC_relative. */
382+ 0, /* Bitpos. */
383+ complain_overflow_bitfield, /* Complain on overflow. */
384+ NULL, /* Special Function. */
385+ "R_MICROBLAZE_32_NONE",/* Name. */
386+ FALSE, /* Partial Inplace. */
387+ 0, /* Source Mask. */
388+ 0, /* Dest Mask. */
389+ FALSE), /* PC relative offset? */
390+
391+ /* This reloc does nothing. Used for relaxation. */
392+ HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
393+ 0, /* Rightshift. */
394+ 3, /* Size (0 = byte, 1 = short, 2 = long). */
395+ 0, /* Bitsize. */
396+ TRUE, /* PC_relative. */
397+ 0, /* Bitpos. */
398+ complain_overflow_dont, /* Complain on overflow. */
399+ NULL, /* Special Function. */
400+ "R_MICROBLAZE_64_NONE",/* Name. */
401+ FALSE, /* Partial Inplace. */
402+ 0, /* Source Mask. */
403+ 0, /* Dest Mask. */
404+ FALSE), /* PC relative offset? */
405+
406+ /* Symbol Op Symbol relocation. */
407+ HOWTO (R_MICROBLAZE_32_SYM_OP_SYM, /* Type. */
408+ 0, /* Rightshift. */
409+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
410+ 32, /* Bitsize. */
411+ FALSE, /* PC_relative. */
412+ 0, /* Bitpos. */
413+ complain_overflow_bitfield, /* Complain on overflow. */
414+ bfd_elf_generic_reloc,/* Special Function. */
415+ "R_MICROBLAZE_32_SYM_OP_SYM", /* Name. */
416+ FALSE, /* Partial Inplace. */
417+ 0, /* Source Mask. */
418+ 0xffffffff, /* Dest Mask. */
419+ FALSE), /* PC relative offset? */
420+
421+ /* GNU extension to record C++ vtable hierarchy. */
422+ HOWTO (R_MICROBLAZE_GNU_VTINHERIT, /* Type. */
423+ 0, /* Rightshift. */
424+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
425+ 0, /* Bitsize. */
426+ FALSE, /* PC_relative. */
427+ 0, /* Bitpos. */
428+ complain_overflow_dont,/* Complain on overflow. */
429+ NULL, /* Special Function. */
430+ "R_MICROBLAZE_GNU_VTINHERIT", /* Name. */
431+ FALSE, /* Partial Inplace. */
432+ 0, /* Source Mask. */
433+ 0, /* Dest Mask. */
434+ FALSE), /* PC relative offset? */
435+
436+ /* GNU extension to record C++ vtable member usage. */
437+ HOWTO (R_MICROBLAZE_GNU_VTENTRY, /* Type. */
438+ 0, /* Rightshift. */
439+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
440+ 0, /* Bitsize. */
441+ FALSE, /* PC_relative. */
442+ 0, /* Bitpos. */
443+ complain_overflow_dont,/* Complain on overflow. */
444+ _bfd_elf_rel_vtable_reloc_fn, /* Special Function. */
445+ "R_MICROBLAZE_GNU_VTENTRY", /* Name. */
446+ FALSE, /* Partial Inplace. */
447+ 0, /* Source Mask. */
448+ 0, /* Dest Mask. */
449+ FALSE), /* PC relative offset? */
450+
451+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
452+ HOWTO (R_MICROBLAZE_GOTPC_64, /* Type. */
453+ 0, /* Rightshift. */
454+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
455+ 16, /* Bitsize. */
456+ TRUE, /* PC_relative. */
457+ 0, /* Bitpos. */
458+ complain_overflow_dont, /* Complain on overflow. */
459+ bfd_elf_generic_reloc, /* Special Function. */
460+ "R_MICROBLAZE_GOTPC_64", /* Name. */
461+ FALSE, /* Partial Inplace. */
462+ 0, /* Source Mask. */
463+ 0x0000ffff, /* Dest Mask. */
464+ TRUE), /* PC relative offset? */
465+
466+ /* A 64 bit GOT relocation. Table-entry not really used. */
467+ HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
468+ 0, /* Rightshift. */
469+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
470+ 16, /* Bitsize. */
471+ FALSE, /* PC_relative. */
472+ 0, /* Bitpos. */
473+ complain_overflow_dont, /* Complain on overflow. */
474+ bfd_elf_generic_reloc,/* Special Function. */
475+ "R_MICROBLAZE_GOT_64",/* Name. */
476+ FALSE, /* Partial Inplace. */
477+ 0, /* Source Mask. */
478+ 0x0000ffff, /* Dest Mask. */
479+ FALSE), /* PC relative offset? */
480+
481+ /* A 64 bit PLT relocation. Table-entry not really used. */
482+ HOWTO (R_MICROBLAZE_PLT_64, /* Type. */
483+ 0, /* Rightshift. */
484+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
485+ 16, /* Bitsize. */
486+ TRUE, /* PC_relative. */
487+ 0, /* Bitpos. */
488+ complain_overflow_dont, /* Complain on overflow. */
489+ bfd_elf_generic_reloc,/* Special Function. */
490+ "R_MICROBLAZE_PLT_64",/* Name. */
491+ FALSE, /* Partial Inplace. */
492+ 0, /* Source Mask. */
493+ 0x0000ffff, /* Dest Mask. */
494+ TRUE), /* PC relative offset? */
495+
496+ /* Table-entry not really used. */
497+ HOWTO (R_MICROBLAZE_REL, /* Type. */
498+ 0, /* Rightshift. */
499+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
500+ 16, /* Bitsize. */
501+ TRUE, /* PC_relative. */
502+ 0, /* Bitpos. */
503+ complain_overflow_dont, /* Complain on overflow. */
504+ bfd_elf_generic_reloc,/* Special Function. */
505+ "R_MICROBLAZE_REL", /* Name. */
506+ FALSE, /* Partial Inplace. */
507+ 0, /* Source Mask. */
508+ 0x0000ffff, /* Dest Mask. */
509+ TRUE), /* PC relative offset? */
510+
511+ /* Table-entry not really used. */
512+ HOWTO (R_MICROBLAZE_JUMP_SLOT,/* Type. */
513+ 0, /* Rightshift. */
514+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
515+ 16, /* Bitsize. */
516+ TRUE, /* PC_relative. */
517+ 0, /* Bitpos. */
518+ complain_overflow_dont, /* Complain on overflow. */
519+ bfd_elf_generic_reloc,/* Special Function. */
520+ "R_MICROBLAZE_JUMP_SLOT", /* Name. */
521+ FALSE, /* Partial Inplace. */
522+ 0, /* Source Mask. */
523+ 0x0000ffff, /* Dest Mask. */
524+ TRUE), /* PC relative offset? */
525+
526+ /* Table-entry not really used. */
527+ HOWTO (R_MICROBLAZE_GLOB_DAT,/* Type. */
528+ 0, /* Rightshift. */
529+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
530+ 16, /* Bitsize. */
531+ TRUE, /* PC_relative. */
532+ 0, /* Bitpos. */
533+ complain_overflow_dont, /* Complain on overflow. */
534+ bfd_elf_generic_reloc,/* Special Function. */
535+ "R_MICROBLAZE_GLOB_DAT", /* Name. */
536+ FALSE, /* Partial Inplace. */
537+ 0, /* Source Mask. */
538+ 0x0000ffff, /* Dest Mask. */
539+ TRUE), /* PC relative offset? */
540+
541+ /* A 64 bit GOT relative relocation. Table-entry not really used. */
542+ HOWTO (R_MICROBLAZE_GOTOFF_64, /* Type. */
543+ 0, /* Rightshift. */
544+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
545+ 16, /* Bitsize. */
546+ FALSE, /* PC_relative. */
547+ 0, /* Bitpos. */
548+ complain_overflow_dont, /* Complain on overflow. */
549+ bfd_elf_generic_reloc,/* Special Function. */
550+ "R_MICROBLAZE_GOTOFF_64", /* Name. */
551+ FALSE, /* Partial Inplace. */
552+ 0, /* Source Mask. */
553+ 0x0000ffff, /* Dest Mask. */
554+ FALSE), /* PC relative offset? */
555+
556+ /* A 32 bit GOT relative relocation. Table-entry not really used. */
557+ HOWTO (R_MICROBLAZE_GOTOFF_32, /* Type. */
558+ 0, /* Rightshift. */
559+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
560+ 16, /* Bitsize. */
561+ FALSE, /* PC_relative. */
562+ 0, /* Bitpos. */
563+ complain_overflow_dont, /* Complain on overflow. */
564+ bfd_elf_generic_reloc, /* Special Function. */
565+ "R_MICROBLAZE_GOTOFF_32", /* Name. */
566+ FALSE, /* Partial Inplace. */
567+ 0, /* Source Mask. */
568+ 0x0000ffff, /* Dest Mask. */
569+ FALSE), /* PC relative offset? */
570+
571+ /* COPY relocation. Table-entry not really used. */
572+ HOWTO (R_MICROBLAZE_COPY, /* Type. */
573+ 0, /* Rightshift. */
574+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
575+ 16, /* Bitsize. */
576+ FALSE, /* PC_relative. */
577+ 0, /* Bitpos. */
578+ complain_overflow_dont, /* Complain on overflow. */
579+ bfd_elf_generic_reloc,/* Special Function. */
580+ "R_MICROBLAZE_COPY", /* Name. */
581+ FALSE, /* Partial Inplace. */
582+ 0, /* Source Mask. */
583+ 0x0000ffff, /* Dest Mask. */
584+ FALSE), /* PC relative offset? */
585+
586+ /* Marker relocs for TLS. */
587+ HOWTO (R_MICROBLAZE_TLS,
588+ 0, /* rightshift */
589+ 2, /* size (0 = byte, 1 = short, 2 = long) */
590+ 32, /* bitsize */
591+ FALSE, /* pc_relative */
592+ 0, /* bitpos */
593+ complain_overflow_dont, /* complain_on_overflow */
594+ bfd_elf_generic_reloc, /* special_function */
595+ "R_MICROBLAZE_TLS", /* name */
596+ FALSE, /* partial_inplace */
597+ 0, /* src_mask */
598+ 0x0000ffff, /* dst_mask */
599+ FALSE), /* pcrel_offset */
600+
601+ HOWTO (R_MICROBLAZE_TLSGD,
602+ 0, /* rightshift */
603+ 2, /* size (0 = byte, 1 = short, 2 = long) */
604+ 32, /* bitsize */
605+ FALSE, /* pc_relative */
606+ 0, /* bitpos */
607+ complain_overflow_dont, /* complain_on_overflow */
608+ bfd_elf_generic_reloc, /* special_function */
609+ "R_MICROBLAZE_TLSGD", /* name */
610+ FALSE, /* partial_inplace */
611+ 0, /* src_mask */
612+ 0x0000ffff, /* dst_mask */
613+ FALSE), /* pcrel_offset */
614+
615+ HOWTO (R_MICROBLAZE_TLSLD,
616+ 0, /* rightshift */
617+ 2, /* size (0 = byte, 1 = short, 2 = long) */
618+ 32, /* bitsize */
619+ FALSE, /* pc_relative */
620+ 0, /* bitpos */
621+ complain_overflow_dont, /* complain_on_overflow */
622+ bfd_elf_generic_reloc, /* special_function */
623+ "R_MICROBLAZE_TLSLD", /* name */
624+ FALSE, /* partial_inplace */
625+ 0, /* src_mask */
626+ 0x0000ffff, /* dst_mask */
627+ FALSE), /* pcrel_offset */
628+
629+ /* Computes the load module index of the load module that contains the
630+ definition of its TLS sym. */
631+ HOWTO (R_MICROBLAZE_TLSDTPMOD32,
632+ 0, /* rightshift */
633+ 2, /* size (0 = byte, 1 = short, 2 = long) */
634+ 32, /* bitsize */
635+ FALSE, /* pc_relative */
636+ 0, /* bitpos */
637+ complain_overflow_dont, /* complain_on_overflow */
638+ bfd_elf_generic_reloc, /* special_function */
639+ "R_MICROBLAZE_TLSDTPMOD32", /* name */
640+ FALSE, /* partial_inplace */
641+ 0, /* src_mask */
642+ 0x0000ffff, /* dst_mask */
643+ FALSE), /* pcrel_offset */
644+
645+ /* Computes a dtv-relative displacement, the difference between the value
646+ of sym+add and the base address of the thread-local storage block that
647+ contains the definition of sym, minus 0x8000. Used for initializing GOT */
648+ HOWTO (R_MICROBLAZE_TLSDTPREL32,
649+ 0, /* rightshift */
650+ 2, /* size (0 = byte, 1 = short, 2 = long) */
651+ 32, /* bitsize */
652+ FALSE, /* pc_relative */
653+ 0, /* bitpos */
654+ complain_overflow_dont, /* complain_on_overflow */
655+ bfd_elf_generic_reloc, /* special_function */
656+ "R_MICROBLAZE_TLSDTPREL32", /* name */
657+ FALSE, /* partial_inplace */
658+ 0, /* src_mask */
659+ 0x0000ffff, /* dst_mask */
660+ FALSE), /* pcrel_offset */
661+
662+ /* Computes a dtv-relative displacement, the difference between the value
663+ of sym+add and the base address of the thread-local storage block that
664+ contains the definition of sym, minus 0x8000. */
665+ HOWTO (R_MICROBLAZE_TLSDTPREL64,
666+ 0, /* rightshift */
667+ 2, /* size (0 = byte, 1 = short, 2 = long) */
668+ 32, /* bitsize */
669+ FALSE, /* pc_relative */
670+ 0, /* bitpos */
671+ complain_overflow_dont, /* complain_on_overflow */
672+ bfd_elf_generic_reloc, /* special_function */
673+ "R_MICROBLAZE_TLSDTPREL64", /* name */
674+ FALSE, /* partial_inplace */
675+ 0, /* src_mask */
676+ 0x0000ffff, /* dst_mask */
677+ FALSE), /* pcrel_offset */
678+
679+ /* Computes a tp-relative displacement, the difference between the value of
680+ sym+add and the value of the thread pointer (r13). */
681+ HOWTO (R_MICROBLAZE_TLSGOTTPREL32,
682+ 0, /* rightshift */
683+ 2, /* size (0 = byte, 1 = short, 2 = long) */
684+ 32, /* bitsize */
685+ FALSE, /* pc_relative */
686+ 0, /* bitpos */
687+ complain_overflow_dont, /* complain_on_overflow */
688+ bfd_elf_generic_reloc, /* special_function */
689+ "R_MICROBLAZE_TLSGOTTPREL32", /* name */
690+ FALSE, /* partial_inplace */
691+ 0, /* src_mask */
692+ 0x0000ffff, /* dst_mask */
693+ FALSE), /* pcrel_offset */
694+
695+ /* Computes a tp-relative displacement, the difference between the value of
696+ sym+add and the value of the thread pointer (r13). */
697+ HOWTO (R_MICROBLAZE_TLSTPREL32,
698+ 0, /* rightshift */
699+ 2, /* size (0 = byte, 1 = short, 2 = long) */
700+ 32, /* bitsize */
701+ FALSE, /* pc_relative */
702+ 0, /* bitpos */
703+ complain_overflow_dont, /* complain_on_overflow */
704+ bfd_elf_generic_reloc, /* special_function */
705+ "R_MICROBLAZE_TLSTPREL32", /* name */
706+ FALSE, /* partial_inplace */
707+ 0, /* src_mask */
708+ 0x0000ffff, /* dst_mask */
709+ FALSE), /* pcrel_offset */
710+
711+};
712+
713+#ifndef NUM_ELEM
714+#define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0])
715+#endif
716+
717+/* Initialize the microblaze_elf_howto_table, so that linear accesses can be done. */
718+
719+static void
720+microblaze_elf_howto_init (void)
721+{
722+ unsigned int i;
723+
724+ for (i = NUM_ELEM (microblaze_elf_howto_raw); i--;)
725+ {
726+ unsigned int type;
727+
728+ type = microblaze_elf_howto_raw[i].type;
729+
730+ BFD_ASSERT (type < NUM_ELEM (microblaze_elf_howto_table));
731+
732+ microblaze_elf_howto_table [type] = & microblaze_elf_howto_raw [i];
733+ }
734+}
735+
736+static reloc_howto_type *
737+microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
738+ bfd_reloc_code_real_type code)
739+{
740+ enum elf_microblaze_reloc_type microblaze_reloc = R_MICROBLAZE_NONE;
741+
742+ switch (code)
743+ {
744+ case BFD_RELOC_NONE:
745+ microblaze_reloc = R_MICROBLAZE_NONE;
746+ break;
747+ case BFD_RELOC_MICROBLAZE_32_NONE:
748+ microblaze_reloc = R_MICROBLAZE_32_NONE;
749+ break;
750+ case BFD_RELOC_MICROBLAZE_64_NONE:
751+ microblaze_reloc = R_MICROBLAZE_64_NONE;
752+ break;
753+ case BFD_RELOC_32:
754+ microblaze_reloc = R_MICROBLAZE_32;
755+ break;
756+ /* RVA is treated the same as 32 */
757+ case BFD_RELOC_RVA:
758+ microblaze_reloc = R_MICROBLAZE_32;
759+ break;
760+ case BFD_RELOC_32_PCREL:
761+ microblaze_reloc = R_MICROBLAZE_32_PCREL;
762+ break;
763+ case BFD_RELOC_64_PCREL:
764+ microblaze_reloc = R_MICROBLAZE_64_PCREL;
765+ break;
766+ case BFD_RELOC_MICROBLAZE_32_LO_PCREL:
767+ microblaze_reloc = R_MICROBLAZE_32_PCREL_LO;
768+ break;
769+ case BFD_RELOC_64:
770+ microblaze_reloc = R_MICROBLAZE_64;
771+ break;
772+ case BFD_RELOC_MICROBLAZE_32_LO:
773+ microblaze_reloc = R_MICROBLAZE_32_LO;
774+ break;
775+ case BFD_RELOC_MICROBLAZE_32_ROSDA:
776+ microblaze_reloc = R_MICROBLAZE_SRO32;
777+ break;
778+ case BFD_RELOC_MICROBLAZE_32_RWSDA:
779+ microblaze_reloc = R_MICROBLAZE_SRW32;
780+ break;
781+ case BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM:
782+ microblaze_reloc = R_MICROBLAZE_32_SYM_OP_SYM;
783+ break;
784+ case BFD_RELOC_VTABLE_INHERIT:
785+ microblaze_reloc = R_MICROBLAZE_GNU_VTINHERIT;
786+ break;
787+ case BFD_RELOC_VTABLE_ENTRY:
788+ microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
789+ break;
790+ case BFD_RELOC_MICROBLAZE_64_GOTPC:
791+ microblaze_reloc = R_MICROBLAZE_GOTPC_64;
792+ break;
793+ case BFD_RELOC_MICROBLAZE_64_GOT:
794+ microblaze_reloc = R_MICROBLAZE_GOT_64;
795+ break;
796+ case BFD_RELOC_MICROBLAZE_64_PLT:
797+ microblaze_reloc = R_MICROBLAZE_PLT_64;
798+ break;
799+ case BFD_RELOC_MICROBLAZE_64_GOTOFF:
800+ microblaze_reloc = R_MICROBLAZE_GOTOFF_64;
801+ break;
802+ case BFD_RELOC_MICROBLAZE_32_GOTOFF:
803+ microblaze_reloc = R_MICROBLAZE_GOTOFF_32;
804+ break;
805+ case BFD_RELOC_MICROBLAZE_64_TLSGD:
806+ microblaze_reloc = R_MICROBLAZE_TLSGD;
807+ break;
808+ case BFD_RELOC_MICROBLAZE_64_TLSLD:
809+ microblaze_reloc = R_MICROBLAZE_TLSLD;
810+ break;
811+ case BFD_RELOC_MICROBLAZE_32_TLSDTPREL:
812+ microblaze_reloc = R_MICROBLAZE_TLSDTPREL32;
813+ break;
814+ case BFD_RELOC_MICROBLAZE_64_TLSDTPREL:
815+ microblaze_reloc = R_MICROBLAZE_TLSDTPREL64;
816+ break;
817+ case BFD_RELOC_MICROBLAZE_32_TLSDTPMOD:
818+ microblaze_reloc = R_MICROBLAZE_TLSDTPMOD32;
819+ break;
820+ case BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL:
821+ microblaze_reloc = R_MICROBLAZE_TLSGOTTPREL32;
822+ break;
823+ case BFD_RELOC_MICROBLAZE_64_TLSTPREL:
824+ microblaze_reloc = R_MICROBLAZE_TLSTPREL32;
825+ break;
826+ case BFD_RELOC_MICROBLAZE_COPY:
827+ microblaze_reloc = R_MICROBLAZE_COPY;
828+ break;
829+ default:
830+ return (reloc_howto_type *) NULL;
831+ }
832+
833+ if (!microblaze_elf_howto_table [R_MICROBLAZE_32])
834+ /* Initialize howto table if needed. */
835+ microblaze_elf_howto_init ();
836+
837+ return microblaze_elf_howto_table [(int) microblaze_reloc];
838+};
839+
840+static reloc_howto_type *
841+microblaze_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
842+ const char *r_name)
843+{
844+ unsigned int i;
845+
846+ for (i = 0; i < NUM_ELEM (microblaze_elf_howto_raw); i++)
847+ if (microblaze_elf_howto_raw[i].name != NULL
848+ && strcasecmp (microblaze_elf_howto_raw[i].name, r_name) == 0)
849+ return &microblaze_elf_howto_raw[i];
850+
851+ return NULL;
852+}
853+
854+/* Set the howto pointer for a RCE ELF reloc. */
855+
856+static void
857+microblaze_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
858+ arelent * cache_ptr,
859+ Elf_Internal_Rela * dst)
860+{
861+ unsigned int r_type;
862+
863+ if (!microblaze_elf_howto_table [R_MICROBLAZE_32])
864+ /* Initialize howto table if needed. */
865+ microblaze_elf_howto_init ();
866+
867+ r_type = ELF64_R_TYPE (dst->r_info);
868+ if (r_type >= R_MICROBLAZE_max)
869+ {
870+ (*_bfd_error_handler) (_("%B: unrecognised MicroBlaze reloc number: %d"),
871+ abfd, r_type);
872+ bfd_set_error (bfd_error_bad_value);
873+ r_type = R_MICROBLAZE_NONE;
874+ }
875+
876+ cache_ptr->howto = microblaze_elf_howto_table [r_type];
877+}
878+
879+/* Microblaze ELF local labels start with 'L.' or '$L', not '.L'. */
880+
881+static bfd_boolean
882+microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
883+{
884+ if (name[0] == 'L' && name[1] == '.')
885+ return TRUE;
886+
887+ if (name[0] == '$' && name[1] == 'L')
888+ return TRUE;
889+
890+ /* With gcc, the labels go back to starting with '.', so we accept
891+ the generic ELF local label syntax as well. */
892+ return _bfd_elf_is_local_label_name (abfd, name);
893+}
894+
895+/* The microblaze linker (like many others) needs to keep track of
896+ the number of relocs that it decides to copy as dynamic relocs in
897+ check_relocs for each symbol. This is so that it can later discard
898+ them if they are found to be unnecessary. We store the information
899+ in a field extending the regular ELF linker hash table. */
900+
901+struct elf64_mb_dyn_relocs
902+{
903+ struct elf64_mb_dyn_relocs *next;
904+
905+ /* The input section of the reloc. */
906+ asection *sec;
907+
908+ /* Total number of relocs copied for the input section. */
909+ bfd_size_type count;
910+
911+ /* Number of pc-relative relocs copied for the input section. */
912+ bfd_size_type pc_count;
913+};
914+
915+/* ELF linker hash entry. */
916+
917+struct elf64_mb_link_hash_entry
918+{
919+ struct elf_link_hash_entry elf;
920+
921+ /* Track dynamic relocs copied for this symbol. */
922+ struct elf64_mb_dyn_relocs *dyn_relocs;
923+
924+ /* TLS Reference Types for the symbol; Updated by check_relocs */
925+#define TLS_GD 1 /* GD reloc. */
926+#define TLS_LD 2 /* LD reloc. */
927+#define TLS_TPREL 4 /* TPREL reloc, => IE. */
928+#define TLS_DTPREL 8 /* DTPREL reloc, => LD. */
929+#define TLS_TLS 16 /* Any TLS reloc. */
930+ unsigned char tls_mask;
931+
932+};
933+
934+#define IS_TLS_GD(x) (x == (TLS_TLS | TLS_GD))
935+#define IS_TLS_LD(x) (x == (TLS_TLS | TLS_LD))
936+#define IS_TLS_DTPREL(x) (x == (TLS_TLS | TLS_DTPREL))
937+#define IS_TLS_NONE(x) (x == 0)
938+
939+#define elf64_mb_hash_entry(ent) ((struct elf64_mb_link_hash_entry *)(ent))
940+
941+/* ELF linker hash table. */
942+
943+struct elf64_mb_link_hash_table
944+{
945+ struct elf_link_hash_table elf;
946+
947+ /* Short-cuts to get to dynamic linker sections. */
948+ asection *sgot;
949+ asection *sgotplt;
950+ asection *srelgot;
951+ asection *splt;
952+ asection *srelplt;
953+ asection *sdynbss;
954+ asection *srelbss;
955+
956+ /* Small local sym to section mapping cache. */
957+ struct sym_cache sym_sec;
958+
959+ /* TLS Local Dynamic GOT Entry */
960+ union {
961+ bfd_signed_vma refcount;
962+ bfd_vma offset;
963+ } tlsld_got;
964+};
965+
966+/* Nonzero if this section has TLS related relocations. */
967+#define has_tls_reloc sec_flg0
968+
969+/* Get the ELF linker hash table from a link_info structure. */
970+
971+#define elf64_mb_hash_table(p) \
972+ (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
973+ == MICROBLAZE_ELF_DATA ? ((struct elf64_mb_link_hash_table *) ((p)->hash)) : NULL)
974+
975+/* Create an entry in a microblaze ELF linker hash table. */
976+
977+static struct bfd_hash_entry *
978+link_hash_newfunc (struct bfd_hash_entry *entry,
979+ struct bfd_hash_table *table,
980+ const char *string)
981+{
982+ /* Allocate the structure if it has not already been allocated by a
983+ subclass. */
984+ if (entry == NULL)
985+ {
986+ entry = bfd_hash_allocate (table,
987+ sizeof (struct elf64_mb_link_hash_entry));
988+ if (entry == NULL)
989+ return entry;
990+ }
991+
992+ /* Call the allocation method of the superclass. */
993+ entry = _bfd_elf_link_hash_newfunc (entry, table, string);
994+ if (entry != NULL)
995+ {
996+ struct elf64_mb_link_hash_entry *eh;
997+
998+ eh = (struct elf64_mb_link_hash_entry *) entry;
999+ eh->dyn_relocs = NULL;
1000+ eh->tls_mask = 0;
1001+ }
1002+
1003+ return entry;
1004+}
1005+
1006+/* Create a mb ELF linker hash table. */
1007+
1008+static struct bfd_link_hash_table *
1009+microblaze_elf_link_hash_table_create (bfd *abfd)
1010+{
1011+ struct elf64_mb_link_hash_table *ret;
1012+ bfd_size_type amt = sizeof (struct elf64_mb_link_hash_table);
1013+
1014+ ret = (struct elf64_mb_link_hash_table *) bfd_zmalloc (amt);
1015+ if (ret == NULL)
1016+ return NULL;
1017+
1018+ if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
1019+ sizeof (struct elf64_mb_link_hash_entry),
1020+ MICROBLAZE_ELF_DATA))
1021+ {
1022+ free (ret);
1023+ return NULL;
1024+ }
1025+
1026+ return &ret->elf.root;
1027+}
1028+
1029+/* Set the values of the small data pointers. */
1030+
1031+static void
1032+microblaze_elf_final_sdp (struct bfd_link_info *info)
1033+{
1034+ struct bfd_link_hash_entry *h;
1035+
1036+ h = bfd_link_hash_lookup (info->hash, RO_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE);
1037+ if (h != (struct bfd_link_hash_entry *) NULL
1038+ && h->type == bfd_link_hash_defined)
1039+ ro_small_data_pointer = (h->u.def.value
1040+ + h->u.def.section->output_section->vma
1041+ + h->u.def.section->output_offset);
1042+
1043+ h = bfd_link_hash_lookup (info->hash, RW_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE);
1044+ if (h != (struct bfd_link_hash_entry *) NULL
1045+ && h->type == bfd_link_hash_defined)
1046+ rw_small_data_pointer = (h->u.def.value
1047+ + h->u.def.section->output_section->vma
1048+ + h->u.def.section->output_offset);
1049+}
1050+
1051+static bfd_vma
1052+dtprel_base (struct bfd_link_info *info)
1053+{
1054+ /* If tls_sec is NULL, we should have signalled an error already. */
1055+ if (elf_hash_table (info)->tls_sec == NULL)
1056+ return 0;
1057+ return elf_hash_table (info)->tls_sec->vma;
1058+}
1059+
1060+/* The size of the thread control block. */
1061+#define TCB_SIZE 8
1062+
1063+/* Output a simple dynamic relocation into SRELOC. */
1064+
1065+static void
1066+microblaze_elf_output_dynamic_relocation (bfd *output_bfd,
1067+ asection *sreloc,
1068+ unsigned long reloc_index,
1069+ unsigned long indx,
1070+ int r_type,
1071+ bfd_vma offset,
1072+ bfd_vma addend)
1073+{
1074+
1075+ Elf_Internal_Rela rel;
1076+
1077+ rel.r_info = ELF64_R_INFO (indx, r_type);
1078+ rel.r_offset = offset;
1079+ rel.r_addend = addend;
1080+
1081+ bfd_elf64_swap_reloca_out (output_bfd, &rel,
1082+ (sreloc->contents + reloc_index * sizeof (Elf64_External_Rela)));
1083+}
1084+
1085+/* This code is taken from elf64-m32r.c
1086+ There is some attempt to make this function usable for many architectures,
1087+ both USE_REL and USE_RELA ['twould be nice if such a critter existed],
1088+ if only to serve as a learning tool.
1089+
1090+ The RELOCATE_SECTION function is called by the new ELF backend linker
1091+ to handle the relocations for a section.
1092+
1093+ The relocs are always passed as Rela structures; if the section
1094+ actually uses Rel structures, the r_addend field will always be
1095+ zero.
1096+
1097+ This function is responsible for adjust the section contents as
1098+ necessary, and (if using Rela relocs and generating a
1099+ relocatable output file) adjusting the reloc addend as
1100+ necessary.
1101+
1102+ This function does not have to worry about setting the reloc
1103+ address or the reloc symbol index.
1104+
1105+ LOCAL_SYMS is a pointer to the swapped in local symbols.
1106+
1107+ LOCAL_SECTIONS is an array giving the section in the input file
1108+ corresponding to the st_shndx field of each local symbol.
1109+
1110+ The global hash table entry for the global symbols can be found
1111+ via elf_sym_hashes (input_bfd).
1112+
1113+ When generating relocatable output, this function must handle
1114+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is
1115+ going to be the section symbol corresponding to the output
1116+ section, which means that the addend must be adjusted
1117+ accordingly. */
1118+
1119+static bfd_boolean
1120+microblaze_elf_relocate_section (bfd *output_bfd,
1121+ struct bfd_link_info *info,
1122+ bfd *input_bfd,
1123+ asection *input_section,
1124+ bfd_byte *contents,
1125+ Elf_Internal_Rela *relocs,
1126+ Elf_Internal_Sym *local_syms,
1127+ asection **local_sections)
1128+{
1129+ struct elf64_mb_link_hash_table *htab;
1130+ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1131+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
1132+ Elf_Internal_Rela *rel, *relend;
1133+ int endian = (bfd_little_endian (output_bfd)) ? 0 : 2;
1134+ /* Assume success. */
1135+ bfd_boolean ret = TRUE;
1136+ asection *sreloc;
1137+ bfd_vma *local_got_offsets;
1138+ unsigned int tls_type;
1139+
1140+ if (!microblaze_elf_howto_table[R_MICROBLAZE_max-1])
1141+ microblaze_elf_howto_init ();
1142+
1143+ htab = elf64_mb_hash_table (info);
1144+ if (htab == NULL)
1145+ return FALSE;
1146+
1147+ local_got_offsets = elf_local_got_offsets (input_bfd);
1148+
1149+ sreloc = elf_section_data (input_section)->sreloc;
1150+
1151+ rel = relocs;
1152+ relend = relocs + input_section->reloc_count;
1153+ for (; rel < relend; rel++)
1154+ {
1155+ int r_type;
1156+ reloc_howto_type *howto;
1157+ unsigned long r_symndx;
1158+ bfd_vma addend = rel->r_addend;
1159+ bfd_vma offset = rel->r_offset;
1160+ struct elf_link_hash_entry *h;
1161+ Elf_Internal_Sym *sym;
1162+ asection *sec;
1163+ const char *sym_name;
1164+ bfd_reloc_status_type r = bfd_reloc_ok;
1165+ const char *errmsg = NULL;
1166+ bfd_boolean unresolved_reloc = FALSE;
1167+
1168+ h = NULL;
1169+ r_type = ELF64_R_TYPE (rel->r_info);
1170+ tls_type = 0;
1171+
1172+ if (r_type < 0 || r_type >= (int) R_MICROBLAZE_max)
1173+ {
1174+ (*_bfd_error_handler) (_("%s: unknown relocation type %d"),
1175+ bfd_get_filename (input_bfd), (int) r_type);
1176+ bfd_set_error (bfd_error_bad_value);
1177+ ret = FALSE;
1178+ continue;
1179+ }
1180+
1181+ howto = microblaze_elf_howto_table[r_type];
1182+ r_symndx = ELF64_R_SYM (rel->r_info);
1183+
1184+ if (bfd_link_relocatable (info))
1185+ {
1186+ /* This is a relocatable link. We don't have to change
1187+ anything, unless the reloc is against a section symbol,
1188+ in which case we have to adjust according to where the
1189+ section symbol winds up in the output section. */
1190+ sec = NULL;
1191+ if (r_symndx >= symtab_hdr->sh_info)
1192+ /* External symbol. */
1193+ continue;
1194+
1195+ /* Local symbol. */
1196+ sym = local_syms + r_symndx;
1197+ sym_name = "<local symbol>";
1198+ /* STT_SECTION: symbol is associated with a section. */
1199+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
1200+ /* Symbol isn't associated with a section. Nothing to do. */
1201+ continue;
1202+
1203+ sec = local_sections[r_symndx];
1204+ addend += sec->output_offset + sym->st_value;
1205+#ifndef USE_REL
1206+ /* This can't be done for USE_REL because it doesn't mean anything
1207+ and elf_link_input_bfd asserts this stays zero. */
1208+ /* rel->r_addend = addend; */
1209+#endif
1210+
1211+#ifndef USE_REL
1212+ /* Addends are stored with relocs. We're done. */
1213+ continue;
1214+#else /* USE_REL */
1215+ /* If partial_inplace, we need to store any additional addend
1216+ back in the section. */
1217+ if (!howto->partial_inplace)
1218+ continue;
1219+ /* ??? Here is a nice place to call a special_function like handler. */
1220+ r = _bfd_relocate_contents (howto, input_bfd, addend,
1221+ contents + offset);
1222+#endif /* USE_REL */
1223+ }
1224+ else
1225+ {
1226+ bfd_vma relocation;
1227+
1228+ /* This is a final link. */
1229+ sym = NULL;
1230+ sec = NULL;
1231+ unresolved_reloc = FALSE;
1232+
1233+ if (r_symndx < symtab_hdr->sh_info)
1234+ {
1235+ /* Local symbol. */
1236+ sym = local_syms + r_symndx;
1237+ sec = local_sections[r_symndx];
1238+ if (sec == 0)
1239+ continue;
1240+ sym_name = "<local symbol>";
1241+ relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
1242+ /* r_addend may have changed if the reference section was
1243+ a merge section. */
1244+ addend = rel->r_addend;
1245+ }
1246+ else
1247+ {
1248+ /* External symbol. */
1249+ bfd_boolean warned ATTRIBUTE_UNUSED;
1250+ bfd_boolean ignored ATTRIBUTE_UNUSED;
1251+
1252+ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
1253+ r_symndx, symtab_hdr, sym_hashes,
1254+ h, sec, relocation,
1255+ unresolved_reloc, warned, ignored);
1256+ sym_name = h->root.root.string;
1257+ }
1258+
1259+ /* Sanity check the address. */
1260+ if (offset > bfd_get_section_limit (input_bfd, input_section))
1261+ {
1262+ r = bfd_reloc_outofrange;
1263+ goto check_reloc;
1264+ }
1265+
1266+ switch ((int) r_type)
1267+ {
1268+ case (int) R_MICROBLAZE_SRO32 :
1269+ {
1270+ const char *name;
1271+
1272+ /* Only relocate if the symbol is defined. */
1273+ if (sec)
1274+ {
1275+ name = bfd_get_section_name (sec->owner, sec);
1276+
1277+ if (strcmp (name, ".sdata2") == 0
1278+ || strcmp (name, ".sbss2") == 0)
1279+ {
1280+ if (ro_small_data_pointer == 0)
1281+ microblaze_elf_final_sdp (info);
1282+ if (ro_small_data_pointer == 0)
1283+ {
1284+ ret = FALSE;
1285+ r = bfd_reloc_undefined;
1286+ goto check_reloc;
1287+ }
1288+
1289+ /* At this point `relocation' contains the object's
1290+ address. */
1291+ relocation -= ro_small_data_pointer;
1292+ /* Now it contains the offset from _SDA2_BASE_. */
1293+ r = _bfd_final_link_relocate (howto, input_bfd,
1294+ input_section,
1295+ contents, offset,
1296+ relocation, addend);
1297+ }
1298+ else
1299+ {
1300+ (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
1301+ bfd_get_filename (input_bfd),
1302+ sym_name,
1303+ microblaze_elf_howto_table[(int) r_type]->name,
1304+ bfd_get_section_name (sec->owner, sec));
1305+ /*bfd_set_error (bfd_error_bad_value); ??? why? */
1306+ ret = FALSE;
1307+ continue;
1308+ }
1309+ }
1310+ }
1311+ break;
1312+
1313+ case (int) R_MICROBLAZE_SRW32 :
1314+ {
1315+ const char *name;
1316+
1317+ /* Only relocate if the symbol is defined. */
1318+ if (sec)
1319+ {
1320+ name = bfd_get_section_name (sec->owner, sec);
1321+
1322+ if (strcmp (name, ".sdata") == 0
1323+ || strcmp (name, ".sbss") == 0)
1324+ {
1325+ if (rw_small_data_pointer == 0)
1326+ microblaze_elf_final_sdp (info);
1327+ if (rw_small_data_pointer == 0)
1328+ {
1329+ ret = FALSE;
1330+ r = bfd_reloc_undefined;
1331+ goto check_reloc;
1332+ }
1333+
1334+ /* At this point `relocation' contains the object's
1335+ address. */
1336+ relocation -= rw_small_data_pointer;
1337+ /* Now it contains the offset from _SDA_BASE_. */
1338+ r = _bfd_final_link_relocate (howto, input_bfd,
1339+ input_section,
1340+ contents, offset,
1341+ relocation, addend);
1342+ }
1343+ else
1344+ {
1345+ (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
1346+ bfd_get_filename (input_bfd),
1347+ sym_name,
1348+ microblaze_elf_howto_table[(int) r_type]->name,
1349+ bfd_get_section_name (sec->owner, sec));
1350+ /*bfd_set_error (bfd_error_bad_value); ??? why? */
1351+ ret = FALSE;
1352+ continue;
1353+ }
1354+ }
1355+ }
1356+ break;
1357+
1358+ case (int) R_MICROBLAZE_32_SYM_OP_SYM:
1359+ break; /* Do nothing. */
1360+
1361+ case (int) R_MICROBLAZE_GOTPC_64:
1362+ relocation = htab->sgotplt->output_section->vma
1363+ + htab->sgotplt->output_offset;
1364+ relocation -= (input_section->output_section->vma
1365+ + input_section->output_offset
1366+ + offset + INST_WORD_SIZE);
1367+ relocation += addend;
1368+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1369+ contents + offset + endian);
1370+ bfd_put_16 (input_bfd, relocation & 0xffff,
1371+ contents + offset + endian + INST_WORD_SIZE);
1372+ break;
1373+
1374+ case (int) R_MICROBLAZE_PLT_64:
1375+ {
1376+ bfd_vma immediate;
1377+ if (htab->splt != NULL && h != NULL
1378+ && h->plt.offset != (bfd_vma) -1)
1379+ {
1380+ relocation = (htab->splt->output_section->vma
1381+ + htab->splt->output_offset
1382+ + h->plt.offset);
1383+ unresolved_reloc = FALSE;
1384+ immediate = relocation - (input_section->output_section->vma
1385+ + input_section->output_offset
1386+ + offset + INST_WORD_SIZE);
1387+ bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff,
1388+ contents + offset + endian);
1389+ bfd_put_16 (input_bfd, immediate & 0xffff,
1390+ contents + offset + endian + INST_WORD_SIZE);
1391+ }
1392+ else
1393+ {
1394+ relocation -= (input_section->output_section->vma
1395+ + input_section->output_offset
1396+ + offset + INST_WORD_SIZE);
1397+ immediate = relocation;
1398+ bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff,
1399+ contents + offset + endian);
1400+ bfd_put_16 (input_bfd, immediate & 0xffff,
1401+ contents + offset + endian + INST_WORD_SIZE);
1402+ }
1403+ break;
1404+ }
1405+
1406+ case (int) R_MICROBLAZE_TLSGD:
1407+ tls_type = (TLS_TLS | TLS_GD);
1408+ goto dogot;
1409+ case (int) R_MICROBLAZE_TLSLD:
1410+ tls_type = (TLS_TLS | TLS_LD);
1411+ dogot:
1412+ case (int) R_MICROBLAZE_GOT_64:
1413+ {
1414+ bfd_vma *offp;
1415+ bfd_vma off, off2;
1416+ unsigned long indx;
1417+ bfd_vma static_value;
1418+
1419+ bfd_boolean need_relocs = FALSE;
1420+ if (htab->sgot == NULL)
1421+ abort ();
1422+
1423+ indx = 0;
1424+ offp = NULL;
1425+
1426+ /* 1. Identify GOT Offset;
1427+ 2. Compute Static Values
1428+ 3. Process Module Id, Process Offset
1429+ 4. Fixup Relocation with GOT offset value. */
1430+
1431+ /* 1. Determine GOT Offset to use : TLS_LD, global, local */
1432+ if (IS_TLS_LD (tls_type))
1433+ offp = &htab->tlsld_got.offset;
1434+ else if (h != NULL)
1435+ {
1436+ if (htab->sgotplt != NULL && h->got.offset != (bfd_vma) -1)
1437+ offp = &h->got.offset;
1438+ else
1439+ abort ();
1440+ }
1441+ else
1442+ {
1443+ if (local_got_offsets == NULL)
1444+ abort ();
1445+ offp = &local_got_offsets[r_symndx];
1446+ }
1447+
1448+ if (!offp)
1449+ abort ();
1450+
1451+ off = (*offp) & ~1;
1452+ off2 = off;
1453+
1454+ if (IS_TLS_LD(tls_type) || IS_TLS_GD(tls_type))
1455+ off2 = off + 4;
1456+
1457+ /* Symbol index to use for relocs */
1458+ if (h != NULL)
1459+ {
1460+ bfd_boolean dyn =
1461+ elf_hash_table (info)->dynamic_sections_created;
1462+
1463+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
1464+ bfd_link_pic (info),
1465+ h)
1466+ && (!bfd_link_pic (info)
1467+ || !SYMBOL_REFERENCES_LOCAL (info, h)))
1468+ indx = h->dynindx;
1469+ }
1470+
1471+ /* Need to generate relocs ? */
1472+ if ((bfd_link_pic (info) || indx != 0)
1473+ && (h == NULL
1474+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
1475+ || h->root.type != bfd_link_hash_undefweak))
1476+ need_relocs = TRUE;
1477+
1478+ /* 2. Compute/Emit Static value of r-expression */
1479+ static_value = relocation + addend;
1480+
1481+ /* 3. Process module-id and offset */
1482+ if (! ((*offp) & 1) )
1483+ {
1484+ bfd_vma got_offset;
1485+
1486+ got_offset = (htab->sgot->output_section->vma
1487+ + htab->sgot->output_offset
1488+ + off);
1489+
1490+ /* Process module-id */
1491+ if (IS_TLS_LD(tls_type))
1492+ {
1493+ if (! bfd_link_pic (info))
1494+ {
1495+ bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
1496+ }
1497+ else
1498+ {
1499+ microblaze_elf_output_dynamic_relocation (output_bfd,
1500+ htab->srelgot, htab->srelgot->reloc_count++,
1501+ /* symindex= */ 0, R_MICROBLAZE_TLSDTPMOD32,
1502+ got_offset, 0);
1503+ }
1504+ }
1505+ else if (IS_TLS_GD(tls_type))
1506+ {
1507+ if (! need_relocs)
1508+ {
1509+ bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
1510+ }
1511+ else
1512+ {
1513+ microblaze_elf_output_dynamic_relocation (output_bfd,
1514+ htab->srelgot,
1515+ htab->srelgot->reloc_count++,
1516+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPMOD32,
1517+ got_offset, indx ? 0 : static_value);
1518+ }
1519+ }
1520+
1521+ /* Process Offset */
1522+ if (htab->srelgot == NULL)
1523+ abort ();
1524+
1525+ got_offset = (htab->sgot->output_section->vma
1526+ + htab->sgot->output_offset
1527+ + off2);
1528+ if (IS_TLS_LD(tls_type))
1529+ {
1530+ /* For LD, offset should be 0 */
1531+ *offp |= 1;
1532+ bfd_put_32 (output_bfd, 0, htab->sgot->contents + off2);
1533+ }
1534+ else if (IS_TLS_GD(tls_type))
1535+ {
1536+ *offp |= 1;
1537+ static_value -= dtprel_base(info);
1538+ if (need_relocs)
1539+ {
1540+ microblaze_elf_output_dynamic_relocation (output_bfd,
1541+ htab->srelgot, htab->srelgot->reloc_count++,
1542+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPREL32,
1543+ got_offset, indx ? 0 : static_value);
1544+ }
1545+ else
1546+ {
1547+ bfd_put_32 (output_bfd, static_value,
1548+ htab->sgot->contents + off2);
1549+ }
1550+ }
1551+ else
1552+ {
1553+ bfd_put_32 (output_bfd, static_value,
1554+ htab->sgot->contents + off2);
1555+
1556+ /* Relocs for dyn symbols generated by
1557+ finish_dynamic_symbols */
1558+ if (bfd_link_pic (info) && h == NULL)
1559+ {
1560+ *offp |= 1;
1561+ microblaze_elf_output_dynamic_relocation (output_bfd,
1562+ htab->srelgot, htab->srelgot->reloc_count++,
1563+ /* symindex= */ indx, R_MICROBLAZE_REL,
1564+ got_offset, static_value);
1565+ }
1566+ }
1567+ }
1568+
1569+ /* 4. Fixup Relocation with GOT offset value
1570+ Compute relative address of GOT entry for applying
1571+ the current relocation */
1572+ relocation = htab->sgot->output_section->vma
1573+ + htab->sgot->output_offset
1574+ + off
1575+ - htab->sgotplt->output_section->vma
1576+ - htab->sgotplt->output_offset;
1577+
1578+ /* Apply Current Relocation */
1579+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1580+ contents + offset + endian);
1581+ bfd_put_16 (input_bfd, relocation & 0xffff,
1582+ contents + offset + endian + INST_WORD_SIZE);
1583+
1584+ unresolved_reloc = FALSE;
1585+ break;
1586+ }
1587+
1588+ case (int) R_MICROBLAZE_GOTOFF_64:
1589+ {
1590+ bfd_vma immediate;
1591+ unsigned short lo, high;
1592+ relocation += addend;
1593+ relocation -= htab->sgotplt->output_section->vma
1594+ + htab->sgotplt->output_offset;
1595+ /* Write this value into correct location. */
1596+ immediate = relocation;
1597+ lo = immediate & 0x0000ffff;
1598+ high = (immediate >> 16) & 0x0000ffff;
1599+ bfd_put_16 (input_bfd, high, contents + offset + endian);
1600+ bfd_put_16 (input_bfd, lo, contents + offset + INST_WORD_SIZE + endian);
1601+ break;
1602+ }
1603+
1604+ case (int) R_MICROBLAZE_GOTOFF_32:
1605+ {
1606+ relocation += addend;
1607+ relocation -= htab->sgotplt->output_section->vma
1608+ + htab->sgotplt->output_offset;
1609+ /* Write this value into correct location. */
1610+ bfd_put_32 (input_bfd, relocation, contents + offset);
1611+ break;
1612+ }
1613+
1614+ case (int) R_MICROBLAZE_TLSDTPREL64:
1615+ relocation += addend;
1616+ relocation -= dtprel_base(info);
1617+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1618+ contents + offset + endian);
1619+ bfd_put_16 (input_bfd, relocation & 0xffff,
1620+ contents + offset + endian + INST_WORD_SIZE);
1621+ break;
1622+ case (int) R_MICROBLAZE_64_PCREL :
1623+ case (int) R_MICROBLAZE_64:
1624+ case (int) R_MICROBLAZE_32:
1625+ {
1626+ /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
1627+ from removed linkonce sections, or sections discarded by
1628+ a linker script. */
1629+ if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
1630+ {
1631+ relocation += addend;
1632+ if (r_type == R_MICROBLAZE_32)
1633+ bfd_put_32 (input_bfd, relocation, contents + offset);
1634+ else
1635+ {
1636+ if (r_type == R_MICROBLAZE_64_PCREL)
1637+ relocation -= (input_section->output_section->vma
1638+ + input_section->output_offset
1639+ + offset + INST_WORD_SIZE);
1640+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1641+ contents + offset + endian);
1642+ bfd_put_16 (input_bfd, relocation & 0xffff,
1643+ contents + offset + endian + INST_WORD_SIZE);
1644+ }
1645+ break;
1646+ }
1647+
1648+ if ((bfd_link_pic (info)
1649+ && (h == NULL
1650+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
1651+ || h->root.type != bfd_link_hash_undefweak)
1652+ && (!howto->pc_relative
1653+ || (h != NULL
1654+ && h->dynindx != -1
1655+ && (!info->symbolic
1656+ || !h->def_regular))))
1657+ || (!bfd_link_pic (info)
1658+ && h != NULL
1659+ && h->dynindx != -1
1660+ && !h->non_got_ref
1661+ && ((h->def_dynamic
1662+ && !h->def_regular)
1663+ || h->root.type == bfd_link_hash_undefweak
1664+ || h->root.type == bfd_link_hash_undefined)))
1665+ {
1666+ Elf_Internal_Rela outrel;
1667+ bfd_byte *loc;
1668+ bfd_boolean skip;
1669+
1670+ /* When generating a shared object, these relocations
1671+ are copied into the output file to be resolved at run
1672+ time. */
1673+
1674+ BFD_ASSERT (sreloc != NULL);
1675+
1676+ skip = FALSE;
1677+
1678+ outrel.r_offset =
1679+ _bfd_elf_section_offset (output_bfd, info, input_section,
1680+ rel->r_offset);
1681+ if (outrel.r_offset == (bfd_vma) -1)
1682+ skip = TRUE;
1683+ else if (outrel.r_offset == (bfd_vma) -2)
1684+ skip = TRUE;
1685+ outrel.r_offset += (input_section->output_section->vma
1686+ + input_section->output_offset);
1687+
1688+ if (skip)
1689+ memset (&outrel, 0, sizeof outrel);
1690+ /* h->dynindx may be -1 if the symbol was marked to
1691+ become local. */
1692+ else if (h != NULL
1693+ && ((! info->symbolic && h->dynindx != -1)
1694+ || !h->def_regular))
1695+ {
1696+ BFD_ASSERT (h->dynindx != -1);
1697+ outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
1698+ outrel.r_addend = addend;
1699+ }
1700+ else
1701+ {
1702+ if (r_type == R_MICROBLAZE_32)
1703+ {
1704+ outrel.r_info = ELF64_R_INFO (0, R_MICROBLAZE_REL);
1705+ outrel.r_addend = relocation + addend;
1706+ }
1707+ else
1708+ {
1709+ BFD_FAIL ();
1710+ (*_bfd_error_handler)
1711+ (_("%B: probably compiled without -fPIC?"),
1712+ input_bfd);
1713+ bfd_set_error (bfd_error_bad_value);
1714+ return FALSE;
1715+ }
1716+ }
1717+
1718+ loc = sreloc->contents;
1719+ loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
1720+ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
1721+ break;
1722+ }
1723+ else
1724+ {
1725+ relocation += addend;
1726+ if (r_type == R_MICROBLAZE_32)
1727+ bfd_put_32 (input_bfd, relocation, contents + offset);
1728+ else
1729+ {
1730+ if (r_type == R_MICROBLAZE_64_PCREL)
1731+ relocation -= (input_section->output_section->vma
1732+ + input_section->output_offset
1733+ + offset + INST_WORD_SIZE);
1734+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1735+ contents + offset + endian);
1736+ bfd_put_16 (input_bfd, relocation & 0xffff,
1737+ contents + offset + endian + INST_WORD_SIZE);
1738+ }
1739+ break;
1740+ }
1741+ }
1742+
1743+ default :
1744+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
1745+ contents, offset,
1746+ relocation, addend);
1747+ break;
1748+ }
1749+ }
1750+
1751+ check_reloc:
1752+
1753+ if (r != bfd_reloc_ok)
1754+ {
1755+ /* FIXME: This should be generic enough to go in a utility. */
1756+ const char *name;
1757+
1758+ if (h != NULL)
1759+ name = h->root.root.string;
1760+ else
1761+ {
1762+ name = (bfd_elf_string_from_elf_section
1763+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
1764+ if (name == NULL || *name == '\0')
1765+ name = bfd_section_name (input_bfd, sec);
1766+ }
1767+
1768+ if (errmsg != NULL)
1769+ goto common_error;
1770+
1771+ switch (r)
1772+ {
1773+ case bfd_reloc_overflow:
1774+ (*info->callbacks->reloc_overflow)
1775+ (info, (h ? &h->root : NULL), name, howto->name,
1776+ (bfd_vma) 0, input_bfd, input_section, offset);
1777+ break;
1778+
1779+ case bfd_reloc_undefined:
1780+ (*info->callbacks->undefined_symbol)
1781+ (info, name, input_bfd, input_section, offset, TRUE);
1782+ break;
1783+
1784+ case bfd_reloc_outofrange:
1785+ errmsg = _("internal error: out of range error");
1786+ goto common_error;
1787+
1788+ case bfd_reloc_notsupported:
1789+ errmsg = _("internal error: unsupported relocation error");
1790+ goto common_error;
1791+
1792+ case bfd_reloc_dangerous:
1793+ errmsg = _("internal error: dangerous error");
1794+ goto common_error;
1795+
1796+ default:
1797+ errmsg = _("internal error: unknown error");
1798+ /* Fall through. */
1799+ common_error:
1800+ (*info->callbacks->warning) (info, errmsg, name, input_bfd,
1801+ input_section, offset);
1802+ break;
1803+ }
1804+ }
1805+ }
1806+
1807+ return ret;
1808+}
1809+
1810+/* Merge backend specific data from an object file to the output
1811+ object file when linking.
1812+
1813+ Note: We only use this hook to catch endian mismatches. */
1814+static bfd_boolean
1815+microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
1816+{
1817+ /* Check if we have the same endianess. */
1818+ if (! _bfd_generic_verify_endian_match (ibfd, obfd))
1819+ return FALSE;
1820+
1821+ return TRUE;
1822+}
1823+
1824+
1825+/* Calculate fixup value for reference. */
1826+
1827+static int
1828+calc_fixup (bfd_vma start, bfd_vma size, asection *sec)
1829+{
1830+ bfd_vma end = start + size;
1831+ int i, fixup = 0;
1832+
1833+ if (sec == NULL || sec->relax == NULL)
1834+ return 0;
1835+
1836+ /* Look for addr in relax table, total fixup value. */
1837+ for (i = 0; i < sec->relax_count; i++)
1838+ {
1839+ if (end <= sec->relax[i].addr)
1840+ break;
1841+ if ((end != start) && (start > sec->relax[i].addr))
1842+ continue;
1843+ fixup += sec->relax[i].size;
1844+ }
1845+ return fixup;
1846+}
1847+
1848+/* Read-modify-write into the bfd, an immediate value into appropriate fields of
1849+ a 32-bit instruction. */
1850+static void
1851+microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
1852+{
1853+ unsigned long instr = bfd_get_32 (abfd, bfd_addr);
1854+ instr &= ~0x0000ffff;
1855+ instr |= (val & 0x0000ffff);
1856+ bfd_put_32 (abfd, instr, bfd_addr);
1857+}
1858+
1859+/* Read-modify-write into the bfd, an immediate value into appropriate fields of
1860+ two consecutive 32-bit instructions. */
1861+static void
1862+microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
1863+{
1864+ unsigned long instr_hi;
1865+ unsigned long instr_lo;
1866+
1867+ instr_hi = bfd_get_32 (abfd, bfd_addr);
1868+ instr_hi &= ~0x0000ffff;
1869+ instr_hi |= ((val >> 16) & 0x0000ffff);
1870+ bfd_put_32 (abfd, instr_hi, bfd_addr);
1871+
1872+ instr_lo = bfd_get_32 (abfd, bfd_addr + INST_WORD_SIZE);
1873+ instr_lo &= ~0x0000ffff;
1874+ instr_lo |= (val & 0x0000ffff);
1875+ bfd_put_32 (abfd, instr_lo, bfd_addr + INST_WORD_SIZE);
1876+}
1877+
1878+static bfd_boolean
1879+microblaze_elf_relax_section (bfd *abfd,
1880+ asection *sec,
1881+ struct bfd_link_info *link_info,
1882+ bfd_boolean *again)
1883+{
1884+ Elf_Internal_Shdr *symtab_hdr;
1885+ Elf_Internal_Rela *internal_relocs;
1886+ Elf_Internal_Rela *free_relocs = NULL;
1887+ Elf_Internal_Rela *irel, *irelend;
1888+ bfd_byte *contents = NULL;
1889+ bfd_byte *free_contents = NULL;
1890+ int rel_count;
1891+ unsigned int shndx;
1892+ int i, sym_index;
1893+ asection *o;
1894+ struct elf_link_hash_entry *sym_hash;
1895+ Elf_Internal_Sym *isymbuf, *isymend;
1896+ Elf_Internal_Sym *isym;
1897+ int symcount;
1898+ int offset;
1899+ bfd_vma src, dest;
1900+
1901+ /* We only do this once per section. We may be able to delete some code
1902+ by running multiple passes, but it is not worth it. */
1903+ *again = FALSE;
1904+
1905+ /* Only do this for a text section. */
1906+ if (bfd_link_relocatable (link_info)
1907+ || (sec->flags & SEC_RELOC) == 0
1908+ || (sec->reloc_count == 0)
1909+ || (sec->flags & SEC_CODE) == 0)
1910+ return TRUE;
1911+
1912+ BFD_ASSERT ((sec->size > 0) || (sec->rawsize > 0));
1913+
1914+ /* If this is the first time we have been called for this section,
1915+ initialize the cooked size. */
1916+ if (sec->size == 0)
1917+ sec->size = sec->rawsize;
1918+
1919+ /* Get symbols for this section. */
1920+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1921+ isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
1922+ symcount = symtab_hdr->sh_size / sizeof (Elf64_External_Sym);
1923+ if (isymbuf == NULL)
1924+ isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr, symcount,
1925+ 0, NULL, NULL, NULL);
1926+ BFD_ASSERT (isymbuf != NULL);
1927+
1928+ internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, link_info->keep_memory);
1929+ if (internal_relocs == NULL)
1930+ goto error_return;
1931+ if (! link_info->keep_memory)
1932+ free_relocs = internal_relocs;
1933+
1934+ sec->relax = (struct relax_table *) bfd_malloc ((sec->reloc_count + 1)
1935+ * sizeof (struct relax_table));
1936+ if (sec->relax == NULL)
1937+ goto error_return;
1938+ sec->relax_count = 0;
1939+
1940+ irelend = internal_relocs + sec->reloc_count;
1941+ rel_count = 0;
1942+ for (irel = internal_relocs; irel < irelend; irel++, rel_count++)
1943+ {
1944+ bfd_vma symval;
1945+ if ((ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64_PCREL)
1946+ && (ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64 ))
1947+ continue; /* Can't delete this reloc. */
1948+
1949+ /* Get the section contents. */
1950+ if (contents == NULL)
1951+ {
1952+ if (elf_section_data (sec)->this_hdr.contents != NULL)
1953+ contents = elf_section_data (sec)->this_hdr.contents;
1954+ else
1955+ {
1956+ contents = (bfd_byte *) bfd_malloc (sec->size);
1957+ if (contents == NULL)
1958+ goto error_return;
1959+ free_contents = contents;
1960+
1961+ if (!bfd_get_section_contents (abfd, sec, contents,
1962+ (file_ptr) 0, sec->size))
1963+ goto error_return;
1964+ elf_section_data (sec)->this_hdr.contents = contents;
1965+ }
1966+ }
1967+
1968+ /* Get the value of the symbol referred to by the reloc. */
1969+ if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
1970+ {
1971+ /* A local symbol. */
1972+ asection *sym_sec;
1973+
1974+ isym = isymbuf + ELF64_R_SYM (irel->r_info);
1975+ if (isym->st_shndx == SHN_UNDEF)
1976+ sym_sec = bfd_und_section_ptr;
1977+ else if (isym->st_shndx == SHN_ABS)
1978+ sym_sec = bfd_abs_section_ptr;
1979+ else if (isym->st_shndx == SHN_COMMON)
1980+ sym_sec = bfd_com_section_ptr;
1981+ else
1982+ sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
1983+
1984+ symval = _bfd_elf_rela_local_sym (abfd, isym, &sym_sec, irel);
1985+ }
1986+ else
1987+ {
1988+ unsigned long indx;
1989+ struct elf_link_hash_entry *h;
1990+
1991+ indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
1992+ h = elf_sym_hashes (abfd)[indx];
1993+ BFD_ASSERT (h != NULL);
1994+
1995+ if (h->root.type != bfd_link_hash_defined
1996+ && h->root.type != bfd_link_hash_defweak)
1997+ /* This appears to be a reference to an undefined
1998+ symbol. Just ignore it--it will be caught by the
1999+ regular reloc processing. */
2000+ continue;
2001+
2002+ symval = (h->root.u.def.value
2003+ + h->root.u.def.section->output_section->vma
2004+ + h->root.u.def.section->output_offset);
2005+ }
2006+
2007+ /* If this is a PC-relative reloc, subtract the instr offset from
2008+ the symbol value. */
2009+ if (ELF64_R_TYPE (irel->r_info) == (int) R_MICROBLAZE_64_PCREL)
2010+ {
2011+ symval = symval + irel->r_addend
2012+ - (irel->r_offset
2013+ + sec->output_section->vma
2014+ + sec->output_offset);
2015+ }
2016+ else
2017+ symval += irel->r_addend;
2018+
2019+ if ((symval & 0xffff8000) == 0)
2020+ {
2021+ /* We can delete this instruction. */
2022+ sec->relax[sec->relax_count].addr = irel->r_offset;
2023+ sec->relax[sec->relax_count].size = INST_WORD_SIZE;
2024+ sec->relax_count++;
2025+
2026+ /* Rewrite relocation type. */
2027+ switch ((enum elf_microblaze_reloc_type) ELF64_R_TYPE (irel->r_info))
2028+ {
2029+ case R_MICROBLAZE_64_PCREL:
2030+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
2031+ (int) R_MICROBLAZE_32_PCREL_LO);
2032+ break;
2033+ case R_MICROBLAZE_64:
2034+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
2035+ (int) R_MICROBLAZE_32_LO);
2036+ break;
2037+ default:
2038+ /* Cannot happen. */
2039+ BFD_ASSERT (FALSE);
2040+ }
2041+ }
2042+ } /* Loop through all relocations. */
2043+
2044+ /* Loop through the relocs again, and see if anything needs to change. */
2045+ if (sec->relax_count > 0)
2046+ {
2047+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
2048+ rel_count = 0;
2049+ sec->relax[sec->relax_count].addr = sec->size;
2050+
2051+ for (irel = internal_relocs; irel < irelend; irel++, rel_count++)
2052+ {
2053+ bfd_vma nraddr;
2054+
2055+ /* Get the new reloc address. */
2056+ nraddr = irel->r_offset - calc_fixup (irel->r_offset, 0, sec);
2057+ switch ((enum elf_microblaze_reloc_type) ELF64_R_TYPE (irel->r_info))
2058+ {
2059+ default:
2060+ break;
2061+ case R_MICROBLAZE_64_PCREL:
2062+ break;
2063+ case R_MICROBLAZE_64:
2064+ case R_MICROBLAZE_32_LO:
2065+ /* If this reloc is against a symbol defined in this
2066+ section, we must check the addend to see it will put the value in
2067+ range to be adjusted, and hence must be changed. */
2068+ if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
2069+ {
2070+ isym = isymbuf + ELF64_R_SYM (irel->r_info);
2071+ /* Only handle relocs against .text. */
2072+ if (isym->st_shndx == shndx
2073+ && ELF64_ST_TYPE (isym->st_info) == STT_SECTION)
2074+ irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
2075+ }
2076+ break;
2077+ case R_MICROBLAZE_NONE:
2078+ case R_MICROBLAZE_32_NONE:
2079+ {
2080+ /* This was a PC-relative instruction that was
2081+ completely resolved. */
2082+ int sfix, efix;
2083+ unsigned int val;
2084+ bfd_vma target_address;
2085+ target_address = irel->r_addend + irel->r_offset;
2086+ sfix = calc_fixup (irel->r_offset, 0, sec);
2087+ efix = calc_fixup (target_address, 0, sec);
2088+
2089+ /* Validate the in-band val. */
2090+ val = bfd_get_32 (abfd, contents + irel->r_offset);
2091+ if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
2092+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
2093+ }
2094+ irel->r_addend -= (efix - sfix);
2095+ /* Should use HOWTO. */
2096+ microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
2097+ irel->r_addend);
2098+ }
2099+ break;
2100+ case R_MICROBLAZE_64_NONE:
2101+ {
2102+ /* This was a PC-relative 64-bit instruction that was
2103+ completely resolved. */
2104+ int sfix, efix;
2105+ bfd_vma target_address;
2106+ target_address = irel->r_addend + irel->r_offset + INST_WORD_SIZE;
2107+ sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
2108+ efix = calc_fixup (target_address, 0, sec);
2109+ irel->r_addend -= (efix - sfix);
2110+ microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
2111+ + INST_WORD_SIZE, irel->r_addend);
2112+ }
2113+ break;
2114+ }
2115+ irel->r_offset = nraddr;
2116+ } /* Change all relocs in this section. */
2117+
2118+ /* Look through all other sections. */
2119+ for (o = abfd->sections; o != NULL; o = o->next)
2120+ {
2121+ Elf_Internal_Rela *irelocs;
2122+ Elf_Internal_Rela *irelscan, *irelscanend;
2123+ bfd_byte *ocontents;
2124+
2125+ if (o == sec
2126+ || (o->flags & SEC_RELOC) == 0
2127+ || o->reloc_count == 0)
2128+ continue;
2129+
2130+ /* We always cache the relocs. Perhaps, if info->keep_memory is
2131+ FALSE, we should free them, if we are permitted to. */
2132+
2133+ irelocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, TRUE);
2134+ if (irelocs == NULL)
2135+ goto error_return;
2136+
2137+ ocontents = NULL;
2138+ irelscanend = irelocs + o->reloc_count;
2139+ for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
2140+ {
2141+ if (1 && ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
2142+ {
2143+ unsigned int val;
2144+
2145+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2146+
2147+ /* hax: We only do the following fixup for debug location lists. */
2148+ if (strcmp(".debug_loc", o->name))
2149+ continue;
2150+
2151+ /* This was a PC-relative instruction that was completely resolved. */
2152+ if (ocontents == NULL)
2153+ {
2154+ if (elf_section_data (o)->this_hdr.contents != NULL)
2155+ ocontents = elf_section_data (o)->this_hdr.contents;
2156+ else
2157+ {
2158+ /* We always cache the section contents.
2159+ Perhaps, if info->keep_memory is FALSE, we
2160+ should free them, if we are permitted to. */
2161+
2162+ if (o->rawsize == 0)
2163+ o->rawsize = o->size;
2164+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2165+ if (ocontents == NULL)
2166+ goto error_return;
2167+ if (!bfd_get_section_contents (abfd, o, ocontents,
2168+ (file_ptr) 0,
2169+ o->rawsize))
2170+ goto error_return;
2171+ elf_section_data (o)->this_hdr.contents = ocontents;
2172+ }
2173+ }
2174+
2175+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
2176+ if (val != irelscan->r_addend) {
2177+ fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend);
2178+ }
2179+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
2180+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
2181+ irelscan->r_addend);
2182+ }
2183+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
2184+ {
2185+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2186+
2187+ /* Look at the reloc only if the value has been resolved. */
2188+ if (isym->st_shndx == shndx
2189+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2190+ {
2191+ if (ocontents == NULL)
2192+ {
2193+ if (elf_section_data (o)->this_hdr.contents != NULL)
2194+ ocontents = elf_section_data (o)->this_hdr.contents;
2195+ else
2196+ {
2197+ /* We always cache the section contents.
2198+ Perhaps, if info->keep_memory is FALSE, we
2199+ should free them, if we are permitted to. */
2200+ if (o->rawsize == 0)
2201+ o->rawsize = o->size;
2202+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2203+ if (ocontents == NULL)
2204+ goto error_return;
2205+ if (!bfd_get_section_contents (abfd, o, ocontents,
2206+ (file_ptr) 0,
2207+ o->rawsize))
2208+ goto error_return;
2209+ elf_section_data (o)->this_hdr.contents = ocontents;
2210+ }
2211+
2212+ }
2213+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
2214+ }
2215+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_SYM_OP_SYM)
2216+ {
2217+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2218+
2219+ /* Look at the reloc only if the value has been resolved. */
2220+ if (ocontents == NULL)
2221+ {
2222+ if (elf_section_data (o)->this_hdr.contents != NULL)
2223+ ocontents = elf_section_data (o)->this_hdr.contents;
2224+ else
2225+ {
2226+ /* We always cache the section contents.
2227+ Perhaps, if info->keep_memory is FALSE, we
2228+ should free them, if we are permitted to. */
2229+
2230+ if (o->rawsize == 0)
2231+ o->rawsize = o->size;
2232+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2233+ if (ocontents == NULL)
2234+ goto error_return;
2235+ if (!bfd_get_section_contents (abfd, o, ocontents,
2236+ (file_ptr) 0,
2237+ o->rawsize))
2238+ goto error_return;
2239+ elf_section_data (o)->this_hdr.contents = ocontents;
2240+ }
2241+ }
2242+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
2243+ + isym->st_value,
2244+ 0,
2245+ sec);
2246+ }
2247+ }
2248+ else if ((ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_PCREL_LO)
2249+ || (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_LO))
2250+ {
2251+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2252+
2253+ /* Look at the reloc only if the value has been resolved. */
2254+ if (isym->st_shndx == shndx
2255+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2256+ {
2257+ bfd_vma immediate;
2258+ bfd_vma target_address;
2259+
2260+ if (ocontents == NULL)
2261+ {
2262+ if (elf_section_data (o)->this_hdr.contents != NULL)
2263+ ocontents = elf_section_data (o)->this_hdr.contents;
2264+ else
2265+ {
2266+ /* We always cache the section contents.
2267+ Perhaps, if info->keep_memory is FALSE, we
2268+ should free them, if we are permitted to. */
2269+ if (o->rawsize == 0)
2270+ o->rawsize = o->size;
2271+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2272+ if (ocontents == NULL)
2273+ goto error_return;
2274+ if (!bfd_get_section_contents (abfd, o, ocontents,
2275+ (file_ptr) 0,
2276+ o->rawsize))
2277+ goto error_return;
2278+ elf_section_data (o)->this_hdr.contents = ocontents;
2279+ }
2280+ }
2281+
2282+ unsigned long instr = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
2283+ immediate = instr & 0x0000ffff;
2284+ target_address = immediate;
2285+ offset = calc_fixup (target_address, 0, sec);
2286+ immediate -= offset;
2287+ irelscan->r_addend -= offset;
2288+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
2289+ irelscan->r_addend);
2290+ }
2291+ }
2292+
2293+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64)
2294+ {
2295+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2296+
2297+ /* Look at the reloc only if the value has been resolved. */
2298+ if (isym->st_shndx == shndx
2299+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2300+ {
2301+ bfd_vma immediate;
2302+
2303+ if (ocontents == NULL)
2304+ {
2305+ if (elf_section_data (o)->this_hdr.contents != NULL)
2306+ ocontents = elf_section_data (o)->this_hdr.contents;
2307+ else
2308+ {
2309+ /* We always cache the section contents.
2310+ Perhaps, if info->keep_memory is FALSE, we
2311+ should free them, if we are permitted to. */
2312+
2313+ if (o->rawsize == 0)
2314+ o->rawsize = o->size;
2315+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2316+ if (ocontents == NULL)
2317+ goto error_return;
2318+ if (!bfd_get_section_contents (abfd, o, ocontents,
2319+ (file_ptr) 0,
2320+ o->rawsize))
2321+ goto error_return;
2322+ elf_section_data (o)->this_hdr.contents = ocontents;
2323+ }
2324+ }
2325+ unsigned long instr_hi = bfd_get_32 (abfd, ocontents
2326+ + irelscan->r_offset);
2327+ unsigned long instr_lo = bfd_get_32 (abfd, ocontents
2328+ + irelscan->r_offset
2329+ + INST_WORD_SIZE);
2330+ immediate = (instr_hi & 0x0000ffff) << 16;
2331+ immediate |= (instr_lo & 0x0000ffff);
2332+ offset = calc_fixup (irelscan->r_addend, 0, sec);
2333+ immediate -= offset;
2334+ irelscan->r_addend -= offset;
2335+ }
2336+ }
2337+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_PCREL)
2338+ {
2339+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2340+
2341+ /* Look at the reloc only if the value has been resolved. */
2342+ if (isym->st_shndx == shndx
2343+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2344+ {
2345+ bfd_vma immediate;
2346+ bfd_vma target_address;
2347+
2348+ if (ocontents == NULL)
2349+ {
2350+ if (elf_section_data (o)->this_hdr.contents != NULL)
2351+ ocontents = elf_section_data (o)->this_hdr.contents;
2352+ else
2353+ {
2354+ /* We always cache the section contents.
2355+ Perhaps, if info->keep_memory is FALSE, we
2356+ should free them, if we are permitted to. */
2357+ if (o->rawsize == 0)
2358+ o->rawsize = o->size;
2359+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2360+ if (ocontents == NULL)
2361+ goto error_return;
2362+ if (!bfd_get_section_contents (abfd, o, ocontents,
2363+ (file_ptr) 0,
2364+ o->rawsize))
2365+ goto error_return;
2366+ elf_section_data (o)->this_hdr.contents = ocontents;
2367+ }
2368+ }
2369+ unsigned long instr_hi = bfd_get_32 (abfd, ocontents
2370+ + irelscan->r_offset);
2371+ unsigned long instr_lo = bfd_get_32 (abfd, ocontents
2372+ + irelscan->r_offset
2373+ + INST_WORD_SIZE);
2374+ immediate = (instr_hi & 0x0000ffff) << 16;
2375+ immediate |= (instr_lo & 0x0000ffff);
2376+ target_address = immediate;
2377+ offset = calc_fixup (target_address, 0, sec);
2378+ immediate -= offset;
2379+ irelscan->r_addend -= offset;
2380+ microblaze_bfd_write_imm_value_64 (abfd, ocontents
2381+ + irelscan->r_offset, immediate);
2382+ }
2383+ }
2384+ }
2385+ }
2386+
2387+ /* Adjust the local symbols defined in this section. */
2388+ isymend = isymbuf + symtab_hdr->sh_info;
2389+ for (isym = isymbuf; isym < isymend; isym++)
2390+ {
2391+ if (isym->st_shndx == shndx)
2392+ {
2393+ isym->st_value -= calc_fixup (isym->st_value, 0, sec);
2394+ if (isym->st_size)
2395+ isym->st_size -= calc_fixup (isym->st_value, isym->st_size, sec);
2396+ }
2397+ }
2398+
2399+ /* Now adjust the global symbols defined in this section. */
2400+ isym = isymbuf + symtab_hdr->sh_info;
2401+ symcount = (symtab_hdr->sh_size / sizeof (Elf64_External_Sym)) - symtab_hdr->sh_info;
2402+ for (sym_index = 0; sym_index < symcount; sym_index++)
2403+ {
2404+ sym_hash = elf_sym_hashes (abfd)[sym_index];
2405+ if ((sym_hash->root.type == bfd_link_hash_defined
2406+ || sym_hash->root.type == bfd_link_hash_defweak)
2407+ && sym_hash->root.u.def.section == sec)
2408+ {
2409+ sym_hash->root.u.def.value -= calc_fixup (sym_hash->root.u.def.value,
2410+ 0, sec);
2411+ if (sym_hash->size)
2412+ sym_hash->size -= calc_fixup (sym_hash->root.u.def.value,
2413+ sym_hash->size, sec);
2414+ }
2415+ }
2416+
2417+ /* Physically move the code and change the cooked size. */
2418+ dest = sec->relax[0].addr;
2419+ for (i = 0; i < sec->relax_count; i++)
2420+ {
2421+ int len;
2422+ src = sec->relax[i].addr + sec->relax[i].size;
2423+ len = sec->relax[i+1].addr - sec->relax[i].addr - sec->relax[i].size;
2424+
2425+ memmove (contents + dest, contents + src, len);
2426+ sec->size -= sec->relax[i].size;
2427+ dest += len;
2428+ }
2429+
2430+ elf_section_data (sec)->relocs = internal_relocs;
2431+ free_relocs = NULL;
2432+
2433+ elf_section_data (sec)->this_hdr.contents = contents;
2434+ free_contents = NULL;
2435+
2436+ symtab_hdr->contents = (bfd_byte *) isymbuf;
2437+ }
2438+
2439+ if (free_relocs != NULL)
2440+ {
2441+ free (free_relocs);
2442+ free_relocs = NULL;
2443+ }
2444+
2445+ if (free_contents != NULL)
2446+ {
2447+ if (!link_info->keep_memory)
2448+ free (free_contents);
2449+ else
2450+ /* Cache the section contents for elf_link_input_bfd. */
2451+ elf_section_data (sec)->this_hdr.contents = contents;
2452+ free_contents = NULL;
2453+ }
2454+
2455+ if (sec->relax_count == 0)
2456+ {
2457+ *again = FALSE;
2458+ free (sec->relax);
2459+ sec->relax = NULL;
2460+ }
2461+ else
2462+ *again = TRUE;
2463+ return TRUE;
2464+
2465+ error_return:
2466+ if (free_relocs != NULL)
2467+ free (free_relocs);
2468+ if (free_contents != NULL)
2469+ free (free_contents);
2470+ if (sec->relax != NULL)
2471+ {
2472+ free (sec->relax);
2473+ sec->relax = NULL;
2474+ sec->relax_count = 0;
2475+ }
2476+ return FALSE;
2477+}
2478+
2479+/* Return the section that should be marked against GC for a given
2480+ relocation. */
2481+
2482+static asection *
2483+microblaze_elf_gc_mark_hook (asection *sec,
2484+ struct bfd_link_info * info,
2485+ Elf_Internal_Rela * rel,
2486+ struct elf_link_hash_entry * h,
2487+ Elf_Internal_Sym * sym)
2488+{
2489+ if (h != NULL)
2490+ switch (ELF64_R_TYPE (rel->r_info))
2491+ {
2492+ case R_MICROBLAZE_GNU_VTINHERIT:
2493+ case R_MICROBLAZE_GNU_VTENTRY:
2494+ return NULL;
2495+ }
2496+
2497+ return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
2498+}
2499+
2500+/* Update the got entry reference counts for the section being removed. */
2501+
2502+static bfd_boolean
2503+microblaze_elf_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED,
2504+ struct bfd_link_info * info ATTRIBUTE_UNUSED,
2505+ asection * sec ATTRIBUTE_UNUSED,
2506+ const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
2507+{
2508+ return TRUE;
2509+}
2510+
2511+/* PIC support. */
2512+
2513+#define PLT_ENTRY_SIZE 16
2514+
2515+#define PLT_ENTRY_WORD_0 0xb0000000 /* "imm 0". */
2516+#define PLT_ENTRY_WORD_1 0xe9940000 /* "lwi r12,r20,0" - relocated to lwi r12,r20,func@GOT. */
2517+#define PLT_ENTRY_WORD_1_NOPIC 0xe9800000 /* "lwi r12,r0,0" - non-PIC object. */
2518+#define PLT_ENTRY_WORD_2 0x98186000 /* "brad r12". */
2519+#define PLT_ENTRY_WORD_3 0x80000000 /* "nop". */
2520+
2521+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
2522+ shortcuts to them in our hash table. */
2523+
2524+static bfd_boolean
2525+create_got_section (bfd *dynobj, struct bfd_link_info *info)
2526+{
2527+ struct elf64_mb_link_hash_table *htab;
2528+
2529+ if (! _bfd_elf_create_got_section (dynobj, info))
2530+ return FALSE;
2531+ htab = elf64_mb_hash_table (info);
2532+ if (htab == NULL)
2533+ return FALSE;
2534+
2535+ htab->sgot = bfd_get_linker_section (dynobj, ".got");
2536+ htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
2537+ if (!htab->sgot || !htab->sgotplt)
2538+ return FALSE;
2539+
2540+ if ((htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got")) == NULL)
2541+ htab->srelgot = bfd_make_section_anyway (dynobj, ".rela.got");
2542+ if (htab->srelgot == NULL
2543+ || ! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC
2544+ | SEC_LOAD
2545+ | SEC_HAS_CONTENTS
2546+ | SEC_IN_MEMORY
2547+ | SEC_LINKER_CREATED
2548+ | SEC_READONLY)
2549+ || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
2550+ return FALSE;
2551+ return TRUE;
2552+}
2553+
2554+static bfd_boolean
2555+update_local_sym_info (bfd *abfd,
2556+ Elf_Internal_Shdr *symtab_hdr,
2557+ unsigned long r_symndx,
2558+ unsigned int tls_type)
2559+{
2560+ bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd);
2561+ unsigned char *local_got_tls_masks;
2562+
2563+ if (local_got_refcounts == NULL)
2564+ {
2565+ bfd_size_type size = symtab_hdr->sh_info;
2566+
2567+ size *= (sizeof (*local_got_refcounts) + sizeof (*local_got_tls_masks));
2568+ local_got_refcounts = bfd_zalloc (abfd, size);
2569+ if (local_got_refcounts == NULL)
2570+ return FALSE;
2571+ elf_local_got_refcounts (abfd) = local_got_refcounts;
2572+ }
2573+
2574+ local_got_tls_masks =
2575+ (unsigned char *) (local_got_refcounts + symtab_hdr->sh_info);
2576+ local_got_tls_masks[r_symndx] |= tls_type;
2577+ local_got_refcounts[r_symndx] += 1;
2578+
2579+ return TRUE;
2580+}
2581+/* Look through the relocs for a section during the first phase. */
2582+
2583+static bfd_boolean
2584+microblaze_elf_check_relocs (bfd * abfd,
2585+ struct bfd_link_info * info,
2586+ asection * sec,
2587+ const Elf_Internal_Rela * relocs)
2588+{
2589+ Elf_Internal_Shdr * symtab_hdr;
2590+ struct elf_link_hash_entry ** sym_hashes;
2591+ struct elf_link_hash_entry ** sym_hashes_end;
2592+ const Elf_Internal_Rela * rel;
2593+ const Elf_Internal_Rela * rel_end;
2594+ struct elf64_mb_link_hash_table *htab;
2595+ asection *sreloc = NULL;
2596+
2597+ if (bfd_link_relocatable (info))
2598+ return TRUE;
2599+
2600+ htab = elf64_mb_hash_table (info);
2601+ if (htab == NULL)
2602+ return FALSE;
2603+
2604+ symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
2605+ sym_hashes = elf_sym_hashes (abfd);
2606+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size / sizeof (Elf64_External_Sym);
2607+ if (!elf_bad_symtab (abfd))
2608+ sym_hashes_end -= symtab_hdr->sh_info;
2609+
2610+ rel_end = relocs + sec->reloc_count;
2611+
2612+ for (rel = relocs; rel < rel_end; rel++)
2613+ {
2614+ unsigned int r_type;
2615+ struct elf_link_hash_entry * h;
2616+ unsigned long r_symndx;
2617+ unsigned char tls_type = 0;
2618+
2619+ r_symndx = ELF64_R_SYM (rel->r_info);
2620+ r_type = ELF64_R_TYPE (rel->r_info);
2621+
2622+ if (r_symndx < symtab_hdr->sh_info)
2623+ h = NULL;
2624+ else
2625+ {
2626+ h = sym_hashes [r_symndx - symtab_hdr->sh_info];
2627+
2628+ /* PR15323, ref flags aren't set for references in the same
2629+ object. */
2630+ h->root.non_ir_ref = 1;
2631+ }
2632+
2633+ switch (r_type)
2634+ {
2635+ /* This relocation describes the C++ object vtable hierarchy.
2636+ Reconstruct it for later use during GC. */
2637+ case R_MICROBLAZE_GNU_VTINHERIT:
2638+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
2639+ return FALSE;
2640+ break;
2641+
2642+ /* This relocation describes which C++ vtable entries are actually
2643+ used. Record for later use during GC. */
2644+ case R_MICROBLAZE_GNU_VTENTRY:
2645+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
2646+ return FALSE;
2647+ break;
2648+
2649+ /* This relocation requires .plt entry. */
2650+ case R_MICROBLAZE_PLT_64:
2651+ if (h != NULL)
2652+ {
2653+ h->needs_plt = 1;
2654+ h->plt.refcount += 1;
2655+ }
2656+ break;
2657+
2658+ /* This relocation requires .got entry. */
2659+ case R_MICROBLAZE_TLSGD:
2660+ tls_type |= (TLS_TLS | TLS_GD);
2661+ goto dogottls;
2662+ case R_MICROBLAZE_TLSLD:
2663+ tls_type |= (TLS_TLS | TLS_LD);
2664+ dogottls:
2665+ sec->has_tls_reloc = 1;
2666+ case R_MICROBLAZE_GOT_64:
2667+ if (htab->sgot == NULL)
2668+ {
2669+ if (htab->elf.dynobj == NULL)
2670+ htab->elf.dynobj = abfd;
2671+ if (!create_got_section (htab->elf.dynobj, info))
2672+ return FALSE;
2673+ }
2674+ if (h != NULL)
2675+ {
2676+ h->got.refcount += 1;
2677+ elf64_mb_hash_entry (h)->tls_mask |= tls_type;
2678+ }
2679+ else
2680+ {
2681+ if (! update_local_sym_info(abfd, symtab_hdr, r_symndx, tls_type) )
2682+ return FALSE;
2683+ }
2684+ break;
2685+
2686+ case R_MICROBLAZE_64:
2687+ case R_MICROBLAZE_64_PCREL:
2688+ case R_MICROBLAZE_32:
2689+ {
2690+ if (h != NULL && !bfd_link_pic (info))
2691+ {
2692+ /* we may need a copy reloc. */
2693+ h->non_got_ref = 1;
2694+
2695+ /* we may also need a .plt entry. */
2696+ h->plt.refcount += 1;
2697+ if (ELF64_R_TYPE (rel->r_info) != R_MICROBLAZE_64_PCREL)
2698+ h->pointer_equality_needed = 1;
2699+ }
2700+
2701+
2702+ /* If we are creating a shared library, and this is a reloc
2703+ against a global symbol, or a non PC relative reloc
2704+ against a local symbol, then we need to copy the reloc
2705+ into the shared library. However, if we are linking with
2706+ -Bsymbolic, we do not need to copy a reloc against a
2707+ global symbol which is defined in an object we are
2708+ including in the link (i.e., DEF_REGULAR is set). At
2709+ this point we have not seen all the input files, so it is
2710+ possible that DEF_REGULAR is not set now but will be set
2711+ later (it is never cleared). In case of a weak definition,
2712+ DEF_REGULAR may be cleared later by a strong definition in
2713+ a shared library. We account for that possibility below by
2714+ storing information in the relocs_copied field of the hash
2715+ table entry. A similar situation occurs when creating
2716+ shared libraries and symbol visibility changes render the
2717+ symbol local.
2718+
2719+ If on the other hand, we are creating an executable, we
2720+ may need to keep relocations for symbols satisfied by a
2721+ dynamic library if we manage to avoid copy relocs for the
2722+ symbol. */
2723+
2724+ if ((bfd_link_pic (info)
2725+ && (sec->flags & SEC_ALLOC) != 0
2726+ && (r_type != R_MICROBLAZE_64_PCREL
2727+ || (h != NULL
2728+ && (! info->symbolic
2729+ || h->root.type == bfd_link_hash_defweak
2730+ || !h->def_regular))))
2731+ || (!bfd_link_pic (info)
2732+ && (sec->flags & SEC_ALLOC) != 0
2733+ && h != NULL
2734+ && (h->root.type == bfd_link_hash_defweak
2735+ || !h->def_regular)))
2736+ {
2737+ struct elf64_mb_dyn_relocs *p;
2738+ struct elf64_mb_dyn_relocs **head;
2739+
2740+ /* When creating a shared object, we must copy these
2741+ relocs into the output file. We create a reloc
2742+ section in dynobj and make room for the reloc. */
2743+
2744+ if (sreloc == NULL)
2745+ {
2746+ bfd *dynobj;
2747+
2748+ if (htab->elf.dynobj == NULL)
2749+ htab->elf.dynobj = abfd;
2750+ dynobj = htab->elf.dynobj;
2751+
2752+ sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj,
2753+ 2, abfd, 1);
2754+ if (sreloc == NULL)
2755+ return FALSE;
2756+ }
2757+
2758+ /* If this is a global symbol, we count the number of
2759+ relocations we need for this symbol. */
2760+ if (h != NULL)
2761+ head = &((struct elf64_mb_link_hash_entry *) h)->dyn_relocs;
2762+ else
2763+ {
2764+ /* Track dynamic relocs needed for local syms too.
2765+ We really need local syms available to do this
2766+ easily. Oh well. */
2767+
2768+ asection *s;
2769+ Elf_Internal_Sym *isym;
2770+ void *vpp;
2771+
2772+ isym = bfd_sym_from_r_symndx (&htab->sym_sec,
2773+ abfd, r_symndx);
2774+ if (isym == NULL)
2775+ return FALSE;
2776+
2777+ s = bfd_section_from_elf_index (abfd, isym->st_shndx);
2778+ if (s == NULL)
2779+ return FALSE;
2780+
2781+ vpp = &elf_section_data (s)->local_dynrel;
2782+ head = (struct elf64_mb_dyn_relocs **) vpp;
2783+ }
2784+
2785+ p = *head;
2786+ if (p == NULL || p->sec != sec)
2787+ {
2788+ bfd_size_type amt = sizeof *p;
2789+ p = ((struct elf64_mb_dyn_relocs *)
2790+ bfd_alloc (htab->elf.dynobj, amt));
2791+ if (p == NULL)
2792+ return FALSE;
2793+ p->next = *head;
2794+ *head = p;
2795+ p->sec = sec;
2796+ p->count = 0;
2797+ p->pc_count = 0;
2798+ }
2799+
2800+ p->count += 1;
2801+ if (r_type == R_MICROBLAZE_64_PCREL)
2802+ p->pc_count += 1;
2803+ }
2804+ }
2805+ break;
2806+ }
2807+ }
2808+
2809+ return TRUE;
2810+}
2811+
2812+static bfd_boolean
2813+microblaze_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
2814+{
2815+ struct elf64_mb_link_hash_table *htab;
2816+
2817+ htab = elf64_mb_hash_table (info);
2818+ if (htab == NULL)
2819+ return FALSE;
2820+
2821+ if (!htab->sgot && !create_got_section (dynobj, info))
2822+ return FALSE;
2823+
2824+ if (!_bfd_elf_create_dynamic_sections (dynobj, info))
2825+ return FALSE;
2826+
2827+ htab->splt = bfd_get_linker_section (dynobj, ".plt");
2828+ htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
2829+ htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
2830+ if (!bfd_link_pic (info))
2831+ htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
2832+
2833+ if (!htab->splt || !htab->srelplt || !htab->sdynbss
2834+ || (!bfd_link_pic (info) && !htab->srelbss))
2835+ abort ();
2836+
2837+ return TRUE;
2838+}
2839+
2840+/* Copy the extra info we tack onto an elf_link_hash_entry. */
2841+
2842+static void
2843+microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info,
2844+ struct elf_link_hash_entry *dir,
2845+ struct elf_link_hash_entry *ind)
2846+{
2847+ struct elf64_mb_link_hash_entry *edir, *eind;
2848+
2849+ edir = (struct elf64_mb_link_hash_entry *) dir;
2850+ eind = (struct elf64_mb_link_hash_entry *) ind;
2851+
2852+ if (eind->dyn_relocs != NULL)
2853+ {
2854+ if (edir->dyn_relocs != NULL)
2855+ {
2856+ struct elf64_mb_dyn_relocs **pp;
2857+ struct elf64_mb_dyn_relocs *p;
2858+
2859+ if (ind->root.type == bfd_link_hash_indirect)
2860+ abort ();
2861+
2862+ /* Add reloc counts against the weak sym to the strong sym
2863+ list. Merge any entries against the same section. */
2864+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
2865+ {
2866+ struct elf64_mb_dyn_relocs *q;
2867+
2868+ for (q = edir->dyn_relocs; q != NULL; q = q->next)
2869+ if (q->sec == p->sec)
2870+ {
2871+ q->pc_count += p->pc_count;
2872+ q->count += p->count;
2873+ *pp = p->next;
2874+ break;
2875+ }
2876+ if (q == NULL)
2877+ pp = &p->next;
2878+ }
2879+ *pp = edir->dyn_relocs;
2880+ }
2881+
2882+ edir->dyn_relocs = eind->dyn_relocs;
2883+ eind->dyn_relocs = NULL;
2884+ }
2885+
2886+ edir->tls_mask |= eind->tls_mask;
2887+
2888+ _bfd_elf_link_hash_copy_indirect (info, dir, ind);
2889+}
2890+
2891+static bfd_boolean
2892+microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
2893+ struct elf_link_hash_entry *h)
2894+{
2895+ struct elf64_mb_link_hash_table *htab;
2896+ struct elf64_mb_link_hash_entry * eh;
2897+ struct elf64_mb_dyn_relocs *p;
2898+ asection *sdynbss, *s;
2899+ unsigned int power_of_two;
2900+ bfd *dynobj;
2901+
2902+ htab = elf64_mb_hash_table (info);
2903+ if (htab == NULL)
2904+ return FALSE;
2905+
2906+ /* If this is a function, put it in the procedure linkage table. We
2907+ will fill in the contents of the procedure linkage table later,
2908+ when we know the address of the .got section. */
2909+ if (h->type == STT_FUNC
2910+ || h->needs_plt)
2911+ {
2912+ if (h->plt.refcount <= 0
2913+ || SYMBOL_CALLS_LOCAL (info, h)
2914+ || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
2915+ && h->root.type == bfd_link_hash_undefweak))
2916+ {
2917+ /* This case can occur if we saw a PLT reloc in an input
2918+ file, but the symbol was never referred to by a dynamic
2919+ object, or if all references were garbage collected. In
2920+ such a case, we don't actually need to build a procedure
2921+ linkage table, and we can just do a PC32 reloc instead. */
2922+ h->plt.offset = (bfd_vma) -1;
2923+ h->needs_plt = 0;
2924+ }
2925+
2926+ return TRUE;
2927+ }
2928+ else
2929+ /* It's possible that we incorrectly decided a .plt reloc was
2930+ needed for an R_MICROBLAZE_64_PCREL reloc to a non-function sym in
2931+ check_relocs. We can't decide accurately between function and
2932+ non-function syms in check-relocs; Objects loaded later in
2933+ the link may change h->type. So fix it now. */
2934+ h->plt.offset = (bfd_vma) -1;
2935+
2936+ /* If this is a weak symbol, and there is a real definition, the
2937+ processor independent code will have arranged for us to see the
2938+ real definition first, and we can just use the same value. */
2939+ if (h->u.weakdef != NULL)
2940+ {
2941+ BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
2942+ || h->u.weakdef->root.type == bfd_link_hash_defweak);
2943+ h->root.u.def.section = h->u.weakdef->root.u.def.section;
2944+ h->root.u.def.value = h->u.weakdef->root.u.def.value;
2945+ return TRUE;
2946+ }
2947+
2948+ /* This is a reference to a symbol defined by a dynamic object which
2949+ is not a function. */
2950+
2951+ /* If we are creating a shared library, we must presume that the
2952+ only references to the symbol are via the global offset table.
2953+ For such cases we need not do anything here; the relocations will
2954+ be handled correctly by relocate_section. */
2955+ if (bfd_link_pic (info))
2956+ return TRUE;
2957+
2958+ /* If there are no references to this symbol that do not use the
2959+ GOT, we don't need to generate a copy reloc. */
2960+ if (!h->non_got_ref)
2961+ return TRUE;
2962+
2963+ /* If -z nocopyreloc was given, we won't generate them either. */
2964+ if (info->nocopyreloc)
2965+ {
2966+ h->non_got_ref = 0;
2967+ return TRUE;
2968+ }
2969+
2970+ eh = (struct elf64_mb_link_hash_entry *) h;
2971+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
2972+ {
2973+ s = p->sec->output_section;
2974+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
2975+ break;
2976+ }
2977+
2978+ /* If we didn't find any dynamic relocs in read-only sections, then
2979+ we'll be keeping the dynamic relocs and avoiding the copy reloc. */
2980+ if (p == NULL)
2981+ {
2982+ h->non_got_ref = 0;
2983+ return TRUE;
2984+ }
2985+
2986+ /* We must allocate the symbol in our .dynbss section, which will
2987+ become part of the .bss section of the executable. There will be
2988+ an entry for this symbol in the .dynsym section. The dynamic
2989+ object will contain position independent code, so all references
2990+ from the dynamic object to this symbol will go through the global
2991+ offset table. The dynamic linker will use the .dynsym entry to
2992+ determine the address it must put in the global offset table, so
2993+ both the dynamic object and the regular object will refer to the
2994+ same memory location for the variable. */
2995+
2996+ /* We must generate a R_MICROBLAZE_COPY reloc to tell the dynamic linker
2997+ to copy the initial value out of the dynamic object and into the
2998+ runtime process image. */
2999+ dynobj = elf_hash_table (info)->dynobj;
3000+ BFD_ASSERT (dynobj != NULL);
3001+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
3002+ {
3003+ htab->srelbss->size += sizeof (Elf64_External_Rela);
3004+ h->needs_copy = 1;
3005+ }
3006+
3007+ /* We need to figure out the alignment required for this symbol. I
3008+ have no idea how ELF linkers handle this. */
3009+ power_of_two = bfd_log2 (h->size);
3010+ if (power_of_two > 3)
3011+ power_of_two = 3;
3012+
3013+ sdynbss = htab->sdynbss;
3014+ /* Apply the required alignment. */
3015+ sdynbss->size = BFD_ALIGN (sdynbss->size, (bfd_size_type) (1 << power_of_two));
3016+ if (power_of_two > bfd_get_section_alignment (dynobj, sdynbss))
3017+ {
3018+ if (! bfd_set_section_alignment (dynobj, sdynbss, power_of_two))
3019+ return FALSE;
3020+ }
3021+
3022+ /* Define the symbol as being at this point in the section. */
3023+ h->root.u.def.section = sdynbss;
3024+ h->root.u.def.value = sdynbss->size;
3025+
3026+ /* Increment the section size to make room for the symbol. */
3027+ sdynbss->size += h->size;
3028+ return TRUE;
3029+}
3030+
3031+/* Allocate space in .plt, .got and associated reloc sections for
3032+ dynamic relocs. */
3033+
3034+static bfd_boolean
3035+allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
3036+{
3037+ struct bfd_link_info *info;
3038+ struct elf64_mb_link_hash_table *htab;
3039+ struct elf64_mb_link_hash_entry *eh;
3040+ struct elf64_mb_dyn_relocs *p;
3041+
3042+ if (h->root.type == bfd_link_hash_indirect)
3043+ return TRUE;
3044+
3045+ info = (struct bfd_link_info *) dat;
3046+ htab = elf64_mb_hash_table (info);
3047+ if (htab == NULL)
3048+ return FALSE;
3049+
3050+ if (htab->elf.dynamic_sections_created
3051+ && h->plt.refcount > 0)
3052+ {
3053+ /* Make sure this symbol is output as a dynamic symbol.
3054+ Undefined weak syms won't yet be marked as dynamic. */
3055+ if (h->dynindx == -1
3056+ && !h->forced_local)
3057+ {
3058+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3059+ return FALSE;
3060+ }
3061+
3062+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
3063+ {
3064+ asection *s = htab->splt;
3065+
3066+ /* The first entry in .plt is reserved. */
3067+ if (s->size == 0)
3068+ s->size = PLT_ENTRY_SIZE;
3069+
3070+ h->plt.offset = s->size;
3071+
3072+ /* If this symbol is not defined in a regular file, and we are
3073+ not generating a shared library, then set the symbol to this
3074+ location in the .plt. This is required to make function
3075+ pointers compare as equal between the normal executable and
3076+ the shared library. */
3077+ if (! bfd_link_pic (info)
3078+ && !h->def_regular)
3079+ {
3080+ h->root.u.def.section = s;
3081+ h->root.u.def.value = h->plt.offset;
3082+ }
3083+
3084+ /* Make room for this entry. */
3085+ s->size += PLT_ENTRY_SIZE;
3086+
3087+ /* We also need to make an entry in the .got.plt section, which
3088+ will be placed in the .got section by the linker script. */
3089+ htab->sgotplt->size += 4;
3090+
3091+ /* We also need to make an entry in the .rel.plt section. */
3092+ htab->srelplt->size += sizeof (Elf64_External_Rela);
3093+ }
3094+ else
3095+ {
3096+ h->plt.offset = (bfd_vma) -1;
3097+ h->needs_plt = 0;
3098+ }
3099+ }
3100+ else
3101+ {
3102+ h->plt.offset = (bfd_vma) -1;
3103+ h->needs_plt = 0;
3104+ }
3105+
3106+ eh = (struct elf64_mb_link_hash_entry *) h;
3107+ if (h->got.refcount > 0)
3108+ {
3109+ unsigned int need;
3110+ asection *s;
3111+
3112+ /* Make sure this symbol is output as a dynamic symbol.
3113+ Undefined weak syms won't yet be marked as dynamic. */
3114+ if (h->dynindx == -1
3115+ && !h->forced_local)
3116+ {
3117+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3118+ return FALSE;
3119+ }
3120+
3121+ need = 0;
3122+ if ((eh->tls_mask & TLS_TLS) != 0)
3123+ {
3124+ /* Handle TLS Symbol */
3125+ if ((eh->tls_mask & TLS_LD) != 0)
3126+ {
3127+ if (!eh->elf.def_dynamic)
3128+ /* We'll just use htab->tlsld_got.offset. This should
3129+ always be the case. It's a little odd if we have
3130+ a local dynamic reloc against a non-local symbol. */
3131+ htab->tlsld_got.refcount += 1;
3132+ else
3133+ need += 8;
3134+ }
3135+ if ((eh->tls_mask & TLS_GD) != 0)
3136+ need += 8;
3137+ }
3138+ else
3139+ {
3140+ /* Regular (non-TLS) symbol */
3141+ need += 4;
3142+ }
3143+ if (need == 0)
3144+ {
3145+ h->got.offset = (bfd_vma) -1;
3146+ }
3147+ else
3148+ {
3149+ s = htab->sgot;
3150+ h->got.offset = s->size;
3151+ s->size += need;
3152+ htab->srelgot->size += need * (sizeof (Elf64_External_Rela) / 4);
3153+ }
3154+ }
3155+ else
3156+ h->got.offset = (bfd_vma) -1;
3157+
3158+ if (eh->dyn_relocs == NULL)
3159+ return TRUE;
3160+
3161+ /* In the shared -Bsymbolic case, discard space allocated for
3162+ dynamic pc-relative relocs against symbols which turn out to be
3163+ defined in regular objects. For the normal shared case, discard
3164+ space for pc-relative relocs that have become local due to symbol
3165+ visibility changes. */
3166+
3167+ if (bfd_link_pic (info))
3168+ {
3169+ if (h->def_regular
3170+ && (h->forced_local
3171+ || info->symbolic))
3172+ {
3173+ struct elf64_mb_dyn_relocs **pp;
3174+
3175+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
3176+ {
3177+ p->count -= p->pc_count;
3178+ p->pc_count = 0;
3179+ if (p->count == 0)
3180+ *pp = p->next;
3181+ else
3182+ pp = &p->next;
3183+ }
3184+ }
3185+ }
3186+ else
3187+ {
3188+ /* For the non-shared case, discard space for relocs against
3189+ symbols which turn out to need copy relocs or are not
3190+ dynamic. */
3191+
3192+ if (!h->non_got_ref
3193+ && ((h->def_dynamic
3194+ && !h->def_regular)
3195+ || (htab->elf.dynamic_sections_created
3196+ && (h->root.type == bfd_link_hash_undefweak
3197+ || h->root.type == bfd_link_hash_undefined))))
3198+ {
3199+ /* Make sure this symbol is output as a dynamic symbol.
3200+ Undefined weak syms won't yet be marked as dynamic. */
3201+ if (h->dynindx == -1
3202+ && !h->forced_local)
3203+ {
3204+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3205+ return FALSE;
3206+ }
3207+
3208+ /* If that succeeded, we know we'll be keeping all the
3209+ relocs. */
3210+ if (h->dynindx != -1)
3211+ goto keep;
3212+ }
3213+
3214+ eh->dyn_relocs = NULL;
3215+
3216+ keep: ;
3217+ }
3218+
3219+ /* Finally, allocate space. */
3220+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
3221+ {
3222+ asection *sreloc = elf_section_data (p->sec)->sreloc;
3223+ sreloc->size += p->count * sizeof (Elf64_External_Rela);
3224+ }
3225+
3226+ return TRUE;
3227+}
3228+
3229+/* Set the sizes of the dynamic sections. */
3230+
3231+static bfd_boolean
3232+microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
3233+ struct bfd_link_info *info)
3234+{
3235+ struct elf64_mb_link_hash_table *htab;
3236+ bfd *dynobj;
3237+ asection *s;
3238+ bfd *ibfd;
3239+
3240+ htab = elf64_mb_hash_table (info);
3241+ if (htab == NULL)
3242+ return FALSE;
3243+
3244+ dynobj = htab->elf.dynobj;
3245+ BFD_ASSERT (dynobj != NULL);
3246+
3247+ /* Set up .got offsets for local syms, and space for local dynamic
3248+ relocs. */
3249+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
3250+ {
3251+ bfd_signed_vma *local_got;
3252+ bfd_signed_vma *end_local_got;
3253+ bfd_size_type locsymcount;
3254+ Elf_Internal_Shdr *symtab_hdr;
3255+ unsigned char *lgot_masks;
3256+ asection *srel;
3257+
3258+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
3259+ continue;
3260+
3261+ for (s = ibfd->sections; s != NULL; s = s->next)
3262+ {
3263+ struct elf64_mb_dyn_relocs *p;
3264+
3265+ for (p = ((struct elf64_mb_dyn_relocs *)
3266+ elf_section_data (s)->local_dynrel);
3267+ p != NULL;
3268+ p = p->next)
3269+ {
3270+ if (!bfd_is_abs_section (p->sec)
3271+ && bfd_is_abs_section (p->sec->output_section))
3272+ {
3273+ /* Input section has been discarded, either because
3274+ it is a copy of a linkonce section or due to
3275+ linker script /DISCARD/, so we'll be discarding
3276+ the relocs too. */
3277+ }
3278+ else if (p->count != 0)
3279+ {
3280+ srel = elf_section_data (p->sec)->sreloc;
3281+ srel->size += p->count * sizeof (Elf64_External_Rela);
3282+ if ((p->sec->output_section->flags & SEC_READONLY) != 0)
3283+ info->flags |= DF_TEXTREL;
3284+ }
3285+ }
3286+ }
3287+
3288+ local_got = elf_local_got_refcounts (ibfd);
3289+ if (!local_got)
3290+ continue;
3291+
3292+ symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
3293+ locsymcount = symtab_hdr->sh_info;
3294+ end_local_got = local_got + locsymcount;
3295+ lgot_masks = (unsigned char *) end_local_got;
3296+ s = htab->sgot;
3297+ srel = htab->srelgot;
3298+
3299+ for (; local_got < end_local_got; ++local_got, ++lgot_masks)
3300+ {
3301+ if (*local_got > 0)
3302+ {
3303+ unsigned int need = 0;
3304+ if ((*lgot_masks & TLS_TLS) != 0)
3305+ {
3306+ if ((*lgot_masks & TLS_GD) != 0)
3307+ need += 8;
3308+ if ((*lgot_masks & TLS_LD) != 0)
3309+ htab->tlsld_got.refcount += 1;
3310+ }
3311+ else
3312+ need += 4;
3313+
3314+ if (need == 0)
3315+ {
3316+ *local_got = (bfd_vma) -1;
3317+ }
3318+ else
3319+ {
3320+ *local_got = s->size;
3321+ s->size += need;
3322+ if (bfd_link_pic (info))
3323+ srel->size += need * (sizeof (Elf64_External_Rela) / 4);
3324+ }
3325+ }
3326+ else
3327+ *local_got = (bfd_vma) -1;
3328+ }
3329+ }
3330+
3331+ /* Allocate global sym .plt and .got entries, and space for global
3332+ sym dynamic relocs. */
3333+ elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info);
3334+
3335+ if (htab->tlsld_got.refcount > 0)
3336+ {
3337+ htab->tlsld_got.offset = htab->sgot->size;
3338+ htab->sgot->size += 8;
3339+ if (bfd_link_pic (info))
3340+ htab->srelgot->size += sizeof (Elf64_External_Rela);
3341+ }
3342+ else
3343+ htab->tlsld_got.offset = (bfd_vma) -1;
3344+
3345+ if (elf_hash_table (info)->dynamic_sections_created)
3346+ {
3347+ /* Make space for the trailing nop in .plt. */
3348+ if (htab->splt->size > 0)
3349+ htab->splt->size += 4;
3350+ }
3351+
3352+ /* The check_relocs and adjust_dynamic_symbol entry points have
3353+ determined the sizes of the various dynamic sections. Allocate
3354+ memory for them. */
3355+ for (s = dynobj->sections; s != NULL; s = s->next)
3356+ {
3357+ const char *name;
3358+ bfd_boolean strip = FALSE;
3359+
3360+ if ((s->flags & SEC_LINKER_CREATED) == 0)
3361+ continue;
3362+
3363+ /* It's OK to base decisions on the section name, because none
3364+ of the dynobj section names depend upon the input files. */
3365+ name = bfd_get_section_name (dynobj, s);
3366+
3367+ if (strncmp (name, ".rela", 5) == 0)
3368+ {
3369+ if (s->size == 0)
3370+ {
3371+ /* If we don't need this section, strip it from the
3372+ output file. This is to handle .rela.bss and
3373+ .rela.plt. We must create it in
3374+ create_dynamic_sections, because it must be created
3375+ before the linker maps input sections to output
3376+ sections. The linker does that before
3377+ adjust_dynamic_symbol is called, and it is that
3378+ function which decides whether anything needs to go
3379+ into these sections. */
3380+ strip = TRUE;
3381+ }
3382+ else
3383+ {
3384+ /* We use the reloc_count field as a counter if we need
3385+ to copy relocs into the output file. */
3386+ s->reloc_count = 0;
3387+ }
3388+ }
3389+ else if (s != htab->splt && s != htab->sgot && s != htab->sgotplt)
3390+ {
3391+ /* It's not one of our sections, so don't allocate space. */
3392+ continue;
3393+ }
3394+
3395+ if (strip)
3396+ {
3397+ s->flags |= SEC_EXCLUDE;
3398+ continue;
3399+ }
3400+
3401+ /* Allocate memory for the section contents. */
3402+ /* FIXME: This should be a call to bfd_alloc not bfd_zalloc.
3403+ Unused entries should be reclaimed before the section's contents
3404+ are written out, but at the moment this does not happen. Thus in
3405+ order to prevent writing out garbage, we initialise the section's
3406+ contents to zero. */
3407+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
3408+ if (s->contents == NULL && s->size != 0)
3409+ return FALSE;
3410+ }
3411+
3412+ if (elf_hash_table (info)->dynamic_sections_created)
3413+ {
3414+ /* Add some entries to the .dynamic section. We fill in the
3415+ values later, in microblaze_elf_finish_dynamic_sections, but we
3416+ must add the entries now so that we get the correct size for
3417+ the .dynamic section. The DT_DEBUG entry is filled in by the
3418+ dynamic linker and used by the debugger. */
3419+#define add_dynamic_entry(TAG, VAL) \
3420+ _bfd_elf_add_dynamic_entry (info, TAG, VAL)
3421+
3422+ if (bfd_link_executable (info))
3423+ {
3424+ if (!add_dynamic_entry (DT_DEBUG, 0))
3425+ return FALSE;
3426+ }
3427+
3428+ if (!add_dynamic_entry (DT_RELA, 0)
3429+ || !add_dynamic_entry (DT_RELASZ, 0)
3430+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
3431+ return FALSE;
3432+
3433+ if (htab->splt->size != 0)
3434+ {
3435+ if (!add_dynamic_entry (DT_PLTGOT, 0)
3436+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
3437+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
3438+ || !add_dynamic_entry (DT_JMPREL, 0)
3439+ || !add_dynamic_entry (DT_BIND_NOW, 1))
3440+ return FALSE;
3441+ }
3442+
3443+ if (info->flags & DF_TEXTREL)
3444+ {
3445+ if (!add_dynamic_entry (DT_TEXTREL, 0))
3446+ return FALSE;
3447+ }
3448+ }
3449+#undef add_dynamic_entry
3450+ return TRUE;
3451+}
3452+
3453+/* Finish up dynamic symbol handling. We set the contents of various
3454+ dynamic sections here. */
3455+
3456+static bfd_boolean
3457+microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
3458+ struct bfd_link_info *info,
3459+ struct elf_link_hash_entry *h,
3460+ Elf_Internal_Sym *sym)
3461+{
3462+ struct elf64_mb_link_hash_table *htab;
3463+ struct elf64_mb_link_hash_entry *eh = elf64_mb_hash_entry(h);
3464+
3465+ htab = elf64_mb_hash_table (info);
3466+ if (htab == NULL)
3467+ return FALSE;
3468+
3469+ if (h->plt.offset != (bfd_vma) -1)
3470+ {
3471+ asection *splt;
3472+ asection *srela;
3473+ asection *sgotplt;
3474+ Elf_Internal_Rela rela;
3475+ bfd_byte *loc;
3476+ bfd_vma plt_index;
3477+ bfd_vma got_offset;
3478+ bfd_vma got_addr;
3479+
3480+ /* This symbol has an entry in the procedure linkage table. Set
3481+ it up. */
3482+ BFD_ASSERT (h->dynindx != -1);
3483+
3484+ splt = htab->splt;
3485+ srela = htab->srelplt;
3486+ sgotplt = htab->sgotplt;
3487+ BFD_ASSERT (splt != NULL && srela != NULL && sgotplt != NULL);
3488+
3489+ plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; /* first entry reserved. */
3490+ got_offset = (plt_index + 3) * 4; /* 3 reserved ??? */
3491+ got_addr = got_offset;
3492+
3493+ /* For non-PIC objects we need absolute address of the GOT entry. */
3494+ if (!bfd_link_pic (info))
3495+ got_addr += htab->sgotplt->output_section->vma + sgotplt->output_offset;
3496+
3497+ /* Fill in the entry in the procedure linkage table. */
3498+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_0 + ((got_addr >> 16) & 0xffff),
3499+ splt->contents + h->plt.offset);
3500+ if (bfd_link_pic (info))
3501+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_1 + (got_addr & 0xffff),
3502+ splt->contents + h->plt.offset + 4);
3503+ else
3504+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_1_NOPIC + (got_addr & 0xffff),
3505+ splt->contents + h->plt.offset + 4);
3506+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD_2,
3507+ splt->contents + h->plt.offset + 8);
3508+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD_3,
3509+ splt->contents + h->plt.offset + 12);
3510+
3511+ /* Any additions to the .got section??? */
3512+ /* bfd_put_32 (output_bfd,
3513+ splt->output_section->vma + splt->output_offset + h->plt.offset + 4,
3514+ sgotplt->contents + got_offset); */
3515+
3516+ /* Fill in the entry in the .rela.plt section. */
3517+ rela.r_offset = (sgotplt->output_section->vma
3518+ + sgotplt->output_offset
3519+ + got_offset);
3520+ rela.r_info = ELF64_R_INFO (h->dynindx, R_MICROBLAZE_JUMP_SLOT);
3521+ rela.r_addend = 0;
3522+ loc = srela->contents;
3523+ loc += plt_index * sizeof (Elf64_External_Rela);
3524+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
3525+
3526+ if (!h->def_regular)
3527+ {
3528+ /* Mark the symbol as undefined, rather than as defined in
3529+ the .plt section. Zero the value. */
3530+ sym->st_shndx = SHN_UNDEF;
3531+ sym->st_value = 0;
3532+ }
3533+ }
3534+
3535+ /* h->got.refcount to be checked ? */
3536+ if (h->got.offset != (bfd_vma) -1 &&
3537+ ! ((h->got.offset & 1) ||
3538+ IS_TLS_LD(eh->tls_mask) || IS_TLS_GD(eh->tls_mask)))
3539+ {
3540+ asection *sgot;
3541+ asection *srela;
3542+ bfd_vma offset;
3543+
3544+ /* This symbol has an entry in the global offset table. Set it
3545+ up. */
3546+
3547+ sgot = htab->sgot;
3548+ srela = htab->srelgot;
3549+ BFD_ASSERT (sgot != NULL && srela != NULL);
3550+
3551+ offset = (sgot->output_section->vma + sgot->output_offset
3552+ + (h->got.offset &~ (bfd_vma) 1));
3553+
3554+ /* If this is a -Bsymbolic link, and the symbol is defined
3555+ locally, we just want to emit a RELATIVE reloc. Likewise if
3556+ the symbol was forced to be local because of a version file.
3557+ The entry in the global offset table will already have been
3558+ initialized in the relocate_section function. */
3559+ if (bfd_link_pic (info)
3560+ && ((info->symbolic && h->def_regular)
3561+ || h->dynindx == -1))
3562+ {
3563+ asection *sec = h->root.u.def.section;
3564+ microblaze_elf_output_dynamic_relocation (output_bfd,
3565+ srela, srela->reloc_count++,
3566+ /* symindex= */ 0,
3567+ R_MICROBLAZE_REL, offset,
3568+ h->root.u.def.value
3569+ + sec->output_section->vma
3570+ + sec->output_offset);
3571+ }
3572+ else
3573+ {
3574+ microblaze_elf_output_dynamic_relocation (output_bfd,
3575+ srela, srela->reloc_count++,
3576+ h->dynindx,
3577+ R_MICROBLAZE_GLOB_DAT,
3578+ offset, 0);
3579+ }
3580+
3581+ bfd_put_32 (output_bfd, (bfd_vma) 0,
3582+ sgot->contents + (h->got.offset &~ (bfd_vma) 1));
3583+ }
3584+
3585+ if (h->needs_copy)
3586+ {
3587+ asection *s;
3588+ Elf_Internal_Rela rela;
3589+ bfd_byte *loc;
3590+
3591+ /* This symbols needs a copy reloc. Set it up. */
3592+
3593+ BFD_ASSERT (h->dynindx != -1);
3594+
3595+ s = bfd_get_linker_section (htab->elf.dynobj, ".rela.bss");
3596+ BFD_ASSERT (s != NULL);
3597+
3598+ rela.r_offset = (h->root.u.def.value
3599+ + h->root.u.def.section->output_section->vma
3600+ + h->root.u.def.section->output_offset);
3601+ rela.r_info = ELF64_R_INFO (h->dynindx, R_MICROBLAZE_COPY);
3602+ rela.r_addend = 0;
3603+ loc = s->contents + s->reloc_count++ * sizeof (Elf64_External_Rela);
3604+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
3605+ }
3606+
3607+ /* Mark some specially defined symbols as absolute. */
3608+ if (h == htab->elf.hdynamic
3609+ || h == htab->elf.hgot
3610+ || h == htab->elf.hplt)
3611+ sym->st_shndx = SHN_ABS;
3612+
3613+ return TRUE;
3614+}
3615+
3616+
3617+/* Finish up the dynamic sections. */
3618+
3619+static bfd_boolean
3620+microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
3621+ struct bfd_link_info *info)
3622+{
3623+ bfd *dynobj;
3624+ asection *sdyn, *sgot;
3625+ struct elf64_mb_link_hash_table *htab;
3626+
3627+ htab = elf64_mb_hash_table (info);
3628+ if (htab == NULL)
3629+ return FALSE;
3630+
3631+ dynobj = htab->elf.dynobj;
3632+
3633+ sdyn = bfd_get_linker_section (dynobj, ".dynamic");
3634+
3635+ if (htab->elf.dynamic_sections_created)
3636+ {
3637+ asection *splt;
3638+ Elf64_External_Dyn *dyncon, *dynconend;
3639+
3640+ splt = bfd_get_linker_section (dynobj, ".plt");
3641+ BFD_ASSERT (splt != NULL && sdyn != NULL);
3642+
3643+ dyncon = (Elf64_External_Dyn *) sdyn->contents;
3644+ dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
3645+ for (; dyncon < dynconend; dyncon++)
3646+ {
3647+ Elf_Internal_Dyn dyn;
3648+ const char *name;
3649+ bfd_boolean size;
3650+
3651+ bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
3652+
3653+ switch (dyn.d_tag)
3654+ {
3655+ case DT_PLTGOT: name = ".got.plt"; size = FALSE; break;
3656+ case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break;
3657+ case DT_JMPREL: name = ".rela.plt"; size = FALSE; break;
3658+ case DT_RELA: name = ".rela.dyn"; size = FALSE; break;
3659+ case DT_RELASZ: name = ".rela.dyn"; size = TRUE; break;
3660+ default: name = NULL; size = FALSE; break;
3661+ }
3662+
3663+ if (name != NULL)
3664+ {
3665+ asection *s;
3666+
3667+ s = bfd_get_section_by_name (output_bfd, name);
3668+ if (s == NULL)
3669+ dyn.d_un.d_val = 0;
3670+ else
3671+ {
3672+ if (! size)
3673+ dyn.d_un.d_ptr = s->vma;
3674+ else
3675+ dyn.d_un.d_val = s->size;
3676+ }
3677+ bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
3678+ }
3679+ }
3680+
3681+ /* Clear the first entry in the procedure linkage table,
3682+ and put a nop in the last four bytes. */
3683+ if (splt->size > 0)
3684+ {
3685+ memset (splt->contents, 0, PLT_ENTRY_SIZE);
3686+ bfd_put_32 (output_bfd, (bfd_vma) 0x80000000 /* nop. */,
3687+ splt->contents + splt->size - 4);
3688+ }
3689+
3690+ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
3691+ }
3692+
3693+ /* Set the first entry in the global offset table to the address of
3694+ the dynamic section. */
3695+ sgot = bfd_get_linker_section (dynobj, ".got.plt");
3696+ if (sgot && sgot->size > 0)
3697+ {
3698+ if (sdyn == NULL)
3699+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
3700+ else
3701+ bfd_put_32 (output_bfd,
3702+ sdyn->output_section->vma + sdyn->output_offset,
3703+ sgot->contents);
3704+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
3705+ }
3706+
3707+ if (htab->sgot && htab->sgot->size > 0)
3708+ elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4;
3709+
3710+ return TRUE;
3711+}
3712+
3713+/* Hook called by the linker routine which adds symbols from an object
3714+ file. We use it to put .comm items in .sbss, and not .bss. */
3715+
3716+static bfd_boolean
3717+microblaze_elf_add_symbol_hook (bfd *abfd,
3718+ struct bfd_link_info *info,
3719+ Elf_Internal_Sym *sym,
3720+ const char **namep ATTRIBUTE_UNUSED,
3721+ flagword *flagsp ATTRIBUTE_UNUSED,
3722+ asection **secp,
3723+ bfd_vma *valp)
3724+{
3725+ if (sym->st_shndx == SHN_COMMON
3726+ && !bfd_link_relocatable (info)
3727+ && sym->st_size <= elf_gp_size (abfd))
3728+ {
3729+ /* Common symbols less than or equal to -G nn bytes are automatically
3730+ put into .sbss. */
3731+ *secp = bfd_make_section_old_way (abfd, ".sbss");
3732+ if (*secp == NULL
3733+ || ! bfd_set_section_flags (abfd, *secp, SEC_IS_COMMON))
3734+ return FALSE;
3735+
3736+ *valp = sym->st_size;
3737+ }
3738+
3739+ return TRUE;
3740+}
3741+
3742+#define TARGET_LITTLE_SYM microblaze_elf64_le_vec
3743+#define TARGET_LITTLE_NAME "elf64-microblazeel"
3744+
3745+#define TARGET_BIG_SYM microblaze_elf64_vec
3746+#define TARGET_BIG_NAME "elf64-microblaze"
3747+
3748+#define ELF_ARCH bfd_arch_microblaze
3749+#define ELF_TARGET_ID MICROBLAZE_ELF_DATA
3750+#define ELF_MACHINE_CODE EM_MICROBLAZE
3751+#define ELF_MACHINE_ALT1 EM_MICROBLAZE_OLD
3752+#define ELF_MAXPAGESIZE 0x1000
3753+#define elf_info_to_howto microblaze_elf_info_to_howto
3754+#define elf_info_to_howto_rel NULL
3755+
3756+#define bfd_elf64_bfd_reloc_type_lookup microblaze_elf_reloc_type_lookup
3757+#define bfd_elf64_bfd_is_local_label_name microblaze_elf_is_local_label_name
3758+#define elf_backend_relocate_section microblaze_elf_relocate_section
3759+#define bfd_elf64_bfd_relax_section microblaze_elf_relax_section
3760+#define bfd_elf64_bfd_merge_private_bfd_data microblaze_elf_merge_private_bfd_data
3761+#define bfd_elf64_bfd_reloc_name_lookup microblaze_elf_reloc_name_lookup
3762+
3763+#define elf_backend_gc_mark_hook microblaze_elf_gc_mark_hook
3764+#define elf_backend_gc_sweep_hook microblaze_elf_gc_sweep_hook
3765+#define elf_backend_check_relocs microblaze_elf_check_relocs
3766+#define elf_backend_copy_indirect_symbol microblaze_elf_copy_indirect_symbol
3767+#define bfd_elf64_bfd_link_hash_table_create microblaze_elf_link_hash_table_create
3768+#define elf_backend_can_gc_sections 1
3769+#define elf_backend_can_refcount 1
3770+#define elf_backend_want_got_plt 1
3771+#define elf_backend_plt_readonly 1
3772+#define elf_backend_got_header_size 12
3773+#define elf_backend_rela_normal 1
3774+
3775+#define elf_backend_adjust_dynamic_symbol microblaze_elf_adjust_dynamic_symbol
3776+#define elf_backend_create_dynamic_sections microblaze_elf_create_dynamic_sections
3777+#define elf_backend_finish_dynamic_sections microblaze_elf_finish_dynamic_sections
3778+#define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
3779+#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
3780+#define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
3781+
3782+#include "elf64-target.h"
3783diff --git a/bfd/targets.c b/bfd/targets.c
3784index 158168cb3b..ef567a30c8 100644
3785--- a/bfd/targets.c
3786+++ b/bfd/targets.c
3787@@ -706,6 +706,8 @@ extern const bfd_target mep_elf32_le_vec;
3788 extern const bfd_target metag_elf32_vec;
3789 extern const bfd_target microblaze_elf32_vec;
3790 extern const bfd_target microblaze_elf32_le_vec;
3791+extern const bfd_target microblaze_elf64_vec;
3792+extern const bfd_target microblaze_elf64_le_vec;
3793 extern const bfd_target mips_ecoff_be_vec;
3794 extern const bfd_target mips_ecoff_le_vec;
3795 extern const bfd_target mips_ecoff_bele_vec;
3796@@ -1073,6 +1075,10 @@ static const bfd_target * const _bfd_target_vector[] =
3797
3798 &metag_elf32_vec,
3799
3800+#ifdef BFD64
3801+ &microblaze_elf64_vec,
3802+ &microblaze_elf64_le_vec,
3803+#endif
3804 &microblaze_elf32_vec,
3805
3806 &mips_ecoff_be_vec,
3807diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
3808index 16b10d00a9..c79434785a 100644
3809--- a/gas/config/tc-microblaze.c
3810+++ b/gas/config/tc-microblaze.c
3811@@ -35,10 +35,13 @@
3812 #define streq(a,b) (strcmp (a, b) == 0)
3813 #endif
3814
3815+static int microblaze_arch_size = 0;
3816+
3817 #define OPTION_EB (OPTION_MD_BASE + 0)
3818 #define OPTION_EL (OPTION_MD_BASE + 1)
3819 #define OPTION_LITTLE (OPTION_MD_BASE + 2)
3820 #define OPTION_BIG (OPTION_MD_BASE + 3)
3821+#define OPTION_M64 (OPTION_MD_BASE + 4)
3822
3823 void microblaze_generate_symbol (char *sym);
3824 static bfd_boolean check_spl_reg (unsigned *);
3825@@ -773,6 +776,74 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
3826 return new_pointer;
3827 }
3828
3829+ static char *
3830+parse_imml (char * s, expressionS * e, long min, long max)
3831+{
3832+ char *new_pointer;
3833+ char *atp;
3834+ int itype, ilen;
3835+
3836+ ilen = 0;
3837+
3838+ /* Find the start of "@GOT" or "@PLT" suffix (if any) */
3839+ for (atp = s; *atp != '@'; atp++)
3840+ if (is_end_of_line[(unsigned char) *atp])
3841+ break;
3842+
3843+ if (*atp == '@')
3844+ {
3845+ itype = match_imm (atp + 1, &ilen);
3846+ if (itype != 0)
3847+ {
3848+ *atp = 0;
3849+ e->X_md = itype;
3850+ }
3851+ else
3852+ {
3853+ atp = NULL;
3854+ e->X_md = 0;
3855+ ilen = 0;
3856+ }
3857+ *atp = 0;
3858+ }
3859+ else
3860+ {
3861+ atp = NULL;
3862+ e->X_md = 0;
3863+ }
3864+
3865+ if (atp && !GOT_symbol)
3866+ {
3867+ GOT_symbol = symbol_find_or_make (GOT_SYMBOL_NAME);
3868+ }
3869+
3870+ new_pointer = parse_exp (s, e);
3871+
3872+ if (!GOT_symbol && ! strncmp (s, GOT_SYMBOL_NAME, 20))
3873+ {
3874+ GOT_symbol = symbol_find_or_make (GOT_SYMBOL_NAME);
3875+ }
3876+
3877+ if (e->X_op == O_absent)
3878+ ; /* An error message has already been emitted. */
3879+ else if ((e->X_op != O_constant && e->X_op != O_symbol) )
3880+ as_fatal (_("operand must be a constant or a label"));
3881+ else if ((e->X_op == O_constant) && ((long) e->X_add_number < min
3882+ || (long) e->X_add_number > max))
3883+ {
3884+ as_fatal (_("operand must be absolute in range %ld..%ld, not %ld"),
3885+ min, max, (long) e->X_add_number);
3886+ }
3887+
3888+ if (atp)
3889+ {
3890+ *atp = '@'; /* restore back (needed?) */
3891+ if (new_pointer >= atp)
3892+ new_pointer += ilen + 1; /* sizeof (imm_suffix) + 1 for '@' */
3893+ }
3894+ return new_pointer;
3895+}
3896+
3897 static char *
3898 check_got (int * got_type, int * got_len)
3899 {
3900@@ -920,6 +991,7 @@ md_assemble (char * str)
3901 unsigned int immed, immed2, temp;
3902 expressionS exp;
3903 char name[20];
3904+ long immedl;
3905
3906 /* Drop leading whitespace. */
3907 while (ISSPACE (* str))
3908@@ -1129,7 +1201,7 @@ md_assemble (char * str)
3909 }
3910 break;
3911
3912- case INST_TYPE_RD_R1_IMM5:
3913+ case INST_TYPE_RD_R1_IMMS:
3914 if (strcmp (op_end, ""))
3915 op_end = parse_reg (op_end + 1, &reg1); /* Get rd. */
3916 else
3917@@ -1163,16 +1235,22 @@ md_assemble (char * str)
3918 immed = exp.X_add_number;
3919 }
3920
3921- if (immed != (immed % 32))
3922+ if ((immed != (immed % 32)) &&
3923+ (opcode->instr == bslli || opcode->instr == bsrai || opcode->instr == bsrli))
3924 {
3925 as_warn (_("Shift value > 32. using <value %% 32>"));
3926 immed = immed % 32;
3927 }
3928+ else if (immed != (immed % 64))
3929+ {
3930+ as_warn (_("Shift value > 64. using <value %% 64>"));
3931+ immed = immed % 64;
3932+ }
3933 inst |= (reg1 << RD_LOW) & RD_MASK;
3934 inst |= (reg2 << RA_LOW) & RA_MASK;
3935- inst |= (immed << IMM_LOW) & IMM5_MASK;
3936+ inst |= (immed << IMM_LOW) & IMM6_MASK;
3937 break;
3938- case INST_TYPE_RD_R1_IMM5_IMM5:
3939+ case INST_TYPE_RD_R1_IMMW_IMMS:
3940 if (strcmp (op_end, ""))
3941 op_end = parse_reg (op_end + 1, &reg1); /* Get rd. */
3942 else
3943@@ -1196,7 +1274,7 @@ md_assemble (char * str)
3944
3945 /* Width immediate value. */
3946 if (strcmp (op_end, ""))
3947- op_end = parse_imm (op_end + 1, &exp, MIN_IMM_WIDTH, MAX_IMM_WIDTH);
3948+ op_end = parse_imm (op_end + 1, &exp, MIN_IMM, MAX_IMM);
3949 else
3950 as_fatal (_("Error in statement syntax"));
3951 if (exp.X_op != O_constant)
3952@@ -1208,6 +1286,8 @@ md_assemble (char * str)
3953 immed = exp.X_add_number;
3954 if (opcode->instr == bsefi && immed > 31)
3955 as_fatal (_("Width value must be less than 32"));
3956+ else if (opcode->instr == bslefi && immed > 63)
3957+ as_fatal (_("Width value must be less than 64"));
3958
3959 /* Shift immediate value. */
3960 if (strcmp (op_end, ""))
3961@@ -1215,32 +1295,40 @@ md_assemble (char * str)
3962 else
3963 as_fatal (_("Error in statement syntax"));
3964 if (exp.X_op != O_constant)
3965- {
3966+ {
3967 as_warn (_("Symbol used as immediate shift value for bit field instruction"));
3968 immed2 = 0;
3969 }
3970 else
3971- {
3972+ {
3973 output = frag_more (isize);
3974 immed2 = exp.X_add_number;
3975- }
3976- if (immed2 != (immed2 % 32))
3977- {
3978- as_warn (_("Shift value greater than 32. using <value %% 32>"));
3979+ }
3980+ if ((immed2 != (immed2 % 32)) && (opcode->instr == bsefi || opcode->instr == bsifi))
3981+ {
3982+
3983+ as_warn (_("Shift value greater than 32. using <value %% 32>"));
3984 immed2 = immed2 % 32;
3985 }
3986+ else if (immed2 != (immed2 % 64))
3987+ {
3988+ as_warn (_("Shift value greater than 64. using <value %% 64>"));
3989+ immed2 = immed2 % 64;
3990+ }
3991
3992 /* Check combined value. */
3993- if (immed + immed2 > 32)
3994+ if ((immed + immed2 > 32) && (opcode->instr == bsefi || opcode->instr == bsifi))
3995 as_fatal (_("Width value + shift value must not be greater than 32"));
3996
3997+ else if (immed + immed2 > 64)
3998+ as_fatal (_("Width value + shift value must not be greater than 64"));
3999 inst |= (reg1 << RD_LOW) & RD_MASK;
4000 inst |= (reg2 << RA_LOW) & RA_MASK;
4001- if (opcode->instr == bsefi)
4002- inst |= (immed & IMM5_MASK) << IMM_WIDTH_LOW; /* bsefi */
4003+ if (opcode->instr == bsefi || opcode->instr == bslefi)
4004+ inst |= (immed & IMM6_MASK) << IMM_WIDTH_LOW; /* bsefi or bslefi */
4005 else
4006- inst |= ((immed + immed2 - 1) & IMM5_MASK) << IMM_WIDTH_LOW; /* bsifi */
4007- inst |= (immed2 << IMM_LOW) & IMM5_MASK;
4008+ inst |= ((immed + immed2 - 1) & IMM6_MASK) << IMM_WIDTH_LOW; /* bsifi or bslifi */
4009+ inst |= (immed2 << IMM_LOW) & IMM6_MASK;
4010 break;
4011 case INST_TYPE_R1_R2:
4012 if (strcmp (op_end, ""))
4013@@ -1808,6 +1896,142 @@ md_assemble (char * str)
4014 }
4015 inst |= (immed << IMM_MBAR);
4016 break;
4017+ /* For 64-bit instructions */
4018+ case INST_TYPE_RD_R1_IMML:
4019+ if (strcmp (op_end, ""))
4020+ op_end = parse_reg (op_end + 1, &reg1); /* Get rd. */
4021+ else
4022+ {
4023+ as_fatal (_("Error in statement syntax"));
4024+ reg1 = 0;
4025+ }
4026+ if (strcmp (op_end, ""))
4027+ op_end = parse_reg (op_end + 1, &reg2); /* Get r1. */
4028+ else
4029+ {
4030+ as_fatal (_("Error in statement syntax"));
4031+ reg2 = 0;
4032+ }
4033+ if (strcmp (op_end, ""))
4034+ op_end = parse_imml (op_end + 1, & exp, MIN_IMML, MAX_IMML);
4035+ else
4036+ as_fatal (_("Error in statement syntax"));
4037+
4038+ /* Check for spl registers. */
4039+ if (check_spl_reg (& reg1))
4040+ as_fatal (_("Cannot use special register with this instruction"));
4041+ if (check_spl_reg (& reg2))
4042+ as_fatal (_("Cannot use special register with this instruction"));
4043+
4044+ if (exp.X_op != O_constant)
4045+ {
4046+ char *opc = NULL;
4047+ relax_substateT subtype;
4048+
4049+ if (exp.X_md != 0)
4050+ subtype = get_imm_otype(exp.X_md);
4051+ else
4052+ subtype = opcode->inst_offset_type;
4053+
4054+ output = frag_var (rs_machine_dependent,
4055+ isize * 2, /* maxm of 2 words. */
4056+ isize * 2, /* minm of 2 words. */
4057+ subtype, /* PC-relative or not. */
4058+ exp.X_add_symbol,
4059+ exp.X_add_number,
4060+ opc);
4061+ immedl = 0L;
4062+ }
4063+ else
4064+ {
4065+ output = frag_more (isize);
4066+ immedl = exp.X_add_number;
4067+
4068+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
4069+ if (opcode1 == NULL)
4070+ {
4071+ as_bad (_("unknown opcode \"%s\""), "imml");
4072+ return;
4073+ }
4074+
4075+ inst1 = opcode1->bit_sequence;
4076+ inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
4077+ output[0] = INST_BYTE0 (inst1);
4078+ output[1] = INST_BYTE1 (inst1);
4079+ output[2] = INST_BYTE2 (inst1);
4080+ output[3] = INST_BYTE3 (inst1);
4081+ output = frag_more (isize);
4082+ }
4083+
4084+ inst |= (reg1 << RD_LOW) & RD_MASK;
4085+ inst |= (reg2 << RA_LOW) & RA_MASK;
4086+ inst |= (immedl << IMM_LOW) & IMM_MASK;
4087+ break;
4088+
4089+ case INST_TYPE_R1_IMML:
4090+ if (strcmp (op_end, ""))
4091+ op_end = parse_reg (op_end + 1, &reg1); /* Get r1. */
4092+ else
4093+ {
4094+ as_fatal (_("Error in statement syntax"));
4095+ reg1 = 0;
4096+ }
4097+ if (strcmp (op_end, ""))
4098+ op_end = parse_imml (op_end + 1, & exp, MIN_IMM, MAX_IMM);
4099+ else
4100+ as_fatal (_("Error in statement syntax"));
4101+
4102+ /* Check for spl registers. */
4103+ if (check_spl_reg (&reg1))
4104+ as_fatal (_("Cannot use special register with this instruction"));
4105+
4106+ if (exp.X_op != O_constant)
4107+ {
4108+ char *opc = NULL;
4109+ relax_substateT subtype;
4110+
4111+ if (exp.X_md != 0)
4112+ subtype = get_imm_otype(exp.X_md);
4113+ else
4114+ subtype = opcode->inst_offset_type;
4115+
4116+ output = frag_var (rs_machine_dependent,
4117+ isize * 2, /* maxm of 2 words. */
4118+ isize * 2, /* minm of 2 words. */
4119+ subtype, /* PC-relative or not. */
4120+ exp.X_add_symbol,
4121+ exp.X_add_number,
4122+ opc);
4123+ immedl = 0L;
4124+ }
4125+ else
4126+ {
4127+ output = frag_more (isize);
4128+ immedl = exp.X_add_number;
4129+
4130+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
4131+ if (opcode1 == NULL)
4132+ {
4133+ as_bad (_("unknown opcode \"%s\""), "imml");
4134+ return;
4135+ }
4136+
4137+ inst1 = opcode1->bit_sequence;
4138+ inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
4139+ output[0] = INST_BYTE0 (inst1);
4140+ output[1] = INST_BYTE1 (inst1);
4141+ output[2] = INST_BYTE2 (inst1);
4142+ output[3] = INST_BYTE3 (inst1);
4143+ output = frag_more (isize);
4144+ }
4145+
4146+ inst |= (reg1 << RA_LOW) & RA_MASK;
4147+ inst |= (immedl << IMM_LOW) & IMM_MASK;
4148+ break;
4149+
4150+ case INST_TYPE_IMML:
4151+ as_fatal (_("An IMML instruction should not be present in the .s file"));
4152+ break;
4153
4154 default:
4155 as_fatal (_("unimplemented opcode \"%s\""), name);
4156@@ -1918,6 +2142,7 @@ struct option md_longopts[] =
4157 {"EL", no_argument, NULL, OPTION_EL},
4158 {"mlittle-endian", no_argument, NULL, OPTION_LITTLE},
4159 {"mbig-endian", no_argument, NULL, OPTION_BIG},
4160+ {"m64", no_argument, NULL, OPTION_M64},
4161 { NULL, no_argument, NULL, 0}
4162 };
4163
4164@@ -2569,6 +2794,18 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
4165 return rel;
4166 }
4167
4168+/* Called by TARGET_FORMAT. */
4169+const char *
4170+microblaze_target_format (void)
4171+{
4172+
4173+ if (microblaze_arch_size == 64)
4174+ return "elf64-microblazeel";
4175+ else
4176+ return target_big_endian ? "elf32-microblaze" : "elf32-microblazeel";
4177+}
4178+
4179+
4180 int
4181 md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
4182 {
4183@@ -2582,6 +2819,10 @@ md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
4184 case OPTION_LITTLE:
4185 target_big_endian = 0;
4186 break;
4187+ case OPTION_M64:
4188+ //if (arg != NULL && strcmp (arg, "64") == 0)
4189+ microblaze_arch_size = 64;
4190+ break;
4191 default:
4192 return 0;
4193 }
4194@@ -2597,6 +2838,7 @@ md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
4195 fprintf (stream, _(" MicroBlaze specific assembler options:\n"));
4196 fprintf (stream, " -%-23s%s\n", "mbig-endian", N_("assemble for a big endian cpu"));
4197 fprintf (stream, " -%-23s%s\n", "mlittle-endian", N_("assemble for a little endian cpu"));
4198+ fprintf (stream, " -%-23s%s\n", "m64", N_("generate 64-bit elf"));
4199 }
4200
4201
4202diff --git a/gas/config/tc-microblaze.h b/gas/config/tc-microblaze.h
4203index ca9dbb861f..9d38d2ced5 100644
4204--- a/gas/config/tc-microblaze.h
4205+++ b/gas/config/tc-microblaze.h
4206@@ -78,7 +78,9 @@ extern const struct relax_type md_relax_table[];
4207
4208 #ifdef OBJ_ELF
4209
4210-#define TARGET_FORMAT (target_big_endian ? "elf32-microblaze" : "elf32-microblazeel")
4211+#define TARGET_FORMAT microblaze_target_format()
4212+extern const char *microblaze_target_format (void);
4213+//#define TARGET_FORMAT (target_big_endian ? "elf32-microblaze" : "elf32-microblazeel")
4214
4215 #define ELF_TC_SPECIAL_SECTIONS \
4216 { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
4217diff --git a/include/elf/common.h b/include/elf/common.h
4218index 996acf9703..2f1e5be366 100644
4219--- a/include/elf/common.h
4220+++ b/include/elf/common.h
4221@@ -339,6 +339,7 @@
4222 #define EM_RISCV 243 /* RISC-V */
4223 #define EM_LANAI 244 /* Lanai 32-bit processor. */
4224 #define EM_BPF 247 /* Linux BPF – in-kernel virtual machine. */
4225+#define EM_MB_64 248 /* Xilinx MicroBlaze 32-bit RISC soft processor core */
4226 #define EM_NFP 250 /* Netronome Flow Processor. */
4227 #define EM_CSKY 252 /* C-SKY processor family. */
4228
4229diff --git a/ld/Makefile.am b/ld/Makefile.am
4230index c2c798b4fe..b272f537e4 100644
4231--- a/ld/Makefile.am
4232+++ b/ld/Makefile.am
4233@@ -422,6 +422,8 @@ ALL_64_EMULATION_SOURCES = \
4234 eelf32ltsmipn32.c \
4235 eelf32ltsmipn32_fbsd.c \
4236 eelf32mipswindiss.c \
4237+ eelf64microblazeel.c \
4238+ eelf64microblaze.c \
4239 eelf64_aix.c \
4240 eelf64_ia64.c \
4241 eelf64_ia64_fbsd.c \
4242@@ -1702,6 +1704,12 @@ eelf32_x86_64_nacl.c: $(srcdir)/emulparams/elf32_x86_64_nacl.sh \
4243 $(srcdir)/emulparams/elf_nacl.sh \
4244 $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
4245
4246+eelf64microblazeel.c: $(srcdir)/emulparams/elf64microblazeel.sh \
4247+ $(ELF_DEPS) $(srcdir)/scripttempl/elfmicroblaze.sc ${GEN_DEPENDS}
4248+
4249+eelf64microblaze.c: $(srcdir)/emulparams/elf64microblaze.sh \
4250+ $(ELF_DEPS) $(srcdir)/scripttempl/elfmicroblaze.sc ${GEN_DEPENDS}
4251+
4252 eelf64_aix.c: $(srcdir)/emulparams/elf64_aix.sh \
4253 $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
4254
4255diff --git a/ld/Makefile.in b/ld/Makefile.in
4256index fc687fc516..1a530ad729 100644
4257--- a/ld/Makefile.in
4258+++ b/ld/Makefile.in
4259@@ -907,6 +907,8 @@ ALL_64_EMULATION_SOURCES = \
4260 eelf32ltsmipn32.c \
4261 eelf32ltsmipn32_fbsd.c \
4262 eelf32mipswindiss.c \
4263+ eelf64microblazeel.c \
4264+ eelf64microblaze.c \
4265 eelf64_aix.c \
4266 eelf64_ia64.c \
4267 eelf64_ia64_fbsd.c \
4268@@ -1355,6 +1357,8 @@ distclean-compile:
4269 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32xc16xs.Po@am__quote@
4270 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32xstormy16.Po@am__quote@
4271 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32xtensa.Po@am__quote@
4272+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64microblazeel.Po@am__quote@
4273+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64microblaze.Po@am__quote@
4274 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64_aix.Po@am__quote@
4275 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64_ia64.Po@am__quote@
4276 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64_ia64_fbsd.Po@am__quote@
4277@@ -3306,6 +3310,12 @@ eelf32_x86_64_nacl.c: $(srcdir)/emulparams/elf32_x86_64_nacl.sh \
4278 $(srcdir)/emulparams/elf_nacl.sh \
4279 $(ELF_X86_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
4280
4281+eelf64microblazeel.c: $(srcdir)/emulparams/elf64microblazeel.sh \
4282+ $(ELF_DEPS) $(srcdir)/scripttempl/elfmicroblaze.sc ${GEN_DEPENDS}
4283+
4284+eelf64microblaze.c: $(srcdir)/emulparams/elf64microblaze.sh \
4285+ $(ELF_DEPS) $(srcdir)/scripttempl/elfmicroblaze.sc ${GEN_DEPENDS}
4286+
4287 eelf64_aix.c: $(srcdir)/emulparams/elf64_aix.sh \
4288 $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
4289
4290diff --git a/ld/configure.tgt b/ld/configure.tgt
4291index beba17ef51..5109799f2b 100644
4292--- a/ld/configure.tgt
4293+++ b/ld/configure.tgt
4294@@ -423,6 +423,9 @@ microblaze*-linux*) targ_emul="elf32mb_linux"
4295 microblazeel*) targ_emul=elf32microblazeel
4296 targ_extra_emuls=elf32microblaze
4297 ;;
4298+microblazeel64*) targ_emul=elf64microblazeel
4299+ targ_extra_emuls=elf64microblaze
4300+ ;;
4301 microblaze*) targ_emul=elf32microblaze
4302 targ_extra_emuls=elf32microblazeel
4303 ;;
4304diff --git a/ld/emulparams/elf64microblaze.sh b/ld/emulparams/elf64microblaze.sh
4305new file mode 100644
4306index 0000000000..9c7b0eb708
4307--- /dev/null
4308+++ b/ld/emulparams/elf64microblaze.sh
4309@@ -0,0 +1,23 @@
4310+SCRIPT_NAME=elfmicroblaze
4311+OUTPUT_FORMAT="elf64-microblazeel"
4312+#BIG_OUTPUT_FORMAT="elf64-microblaze"
4313+LITTLE_OUTPUT_FORMAT="elf64-microblazeel"
4314+#TEXT_START_ADDR=0
4315+NONPAGED_TEXT_START_ADDR=0x28
4316+ALIGNMENT=4
4317+MAXPAGESIZE=4
4318+ARCH=microblaze
4319+EMBEDDED=yes
4320+
4321+NOP=0x80000000
4322+
4323+# Hmmm, there's got to be a better way. This sets the stack to the
4324+# top of the simulator memory (2^19 bytes).
4325+#PAGE_SIZE=0x1000
4326+#DATA_ADDR=0x10000
4327+#OTHER_RELOCATING_SECTIONS='.stack 0x7000 : { _stack = .; *(.stack) }'
4328+#$@{RELOCATING+ PROVIDE (__stack = 0x7000);@}
4329+#OTHER_RELOCATING_SECTIONS='PROVIDE (_stack = _end + 0x1000);'
4330+
4331+TEMPLATE_NAME=elf32
4332+#GENERATE_SHLIB_SCRIPT=yes
4333diff --git a/ld/emulparams/elf64microblazeel.sh b/ld/emulparams/elf64microblazeel.sh
4334new file mode 100644
4335index 0000000000..9c7b0eb708
4336--- /dev/null
4337+++ b/ld/emulparams/elf64microblazeel.sh
4338@@ -0,0 +1,23 @@
4339+SCRIPT_NAME=elfmicroblaze
4340+OUTPUT_FORMAT="elf64-microblazeel"
4341+#BIG_OUTPUT_FORMAT="elf64-microblaze"
4342+LITTLE_OUTPUT_FORMAT="elf64-microblazeel"
4343+#TEXT_START_ADDR=0
4344+NONPAGED_TEXT_START_ADDR=0x28
4345+ALIGNMENT=4
4346+MAXPAGESIZE=4
4347+ARCH=microblaze
4348+EMBEDDED=yes
4349+
4350+NOP=0x80000000
4351+
4352+# Hmmm, there's got to be a better way. This sets the stack to the
4353+# top of the simulator memory (2^19 bytes).
4354+#PAGE_SIZE=0x1000
4355+#DATA_ADDR=0x10000
4356+#OTHER_RELOCATING_SECTIONS='.stack 0x7000 : { _stack = .; *(.stack) }'
4357+#$@{RELOCATING+ PROVIDE (__stack = 0x7000);@}
4358+#OTHER_RELOCATING_SECTIONS='PROVIDE (_stack = _end + 0x1000);'
4359+
4360+TEMPLATE_NAME=elf32
4361+#GENERATE_SHLIB_SCRIPT=yes
4362diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
4363index f8aaf27873..20ea6a885a 100644
4364--- a/opcodes/microblaze-dis.c
4365+++ b/opcodes/microblaze-dis.c
4366@@ -33,6 +33,7 @@
4367 #define get_field_r1(instr) get_field (instr, RA_MASK, RA_LOW)
4368 #define get_field_r2(instr) get_field (instr, RB_MASK, RB_LOW)
4369 #define get_int_field_imm(instr) ((instr & IMM_MASK) >> IMM_LOW)
4370+#define get_int_field_imml(instr) ((instr & IMML_MASK) >> IMM_LOW)
4371 #define get_int_field_r1(instr) ((instr & RA_MASK) >> RA_LOW)
4372
4373
4374@@ -56,11 +57,20 @@ get_field_imm (long instr)
4375 }
4376
4377 static char *
4378-get_field_imm5 (long instr)
4379+get_field_imml (long instr)
4380 {
4381 char tmpstr[25];
4382
4383- sprintf (tmpstr, "%d", (short)((instr & IMM5_MASK) >> IMM_LOW));
4384+ sprintf (tmpstr, "%d", (short)((instr & IMML_MASK) >> IMM_LOW));
4385+ return (strdup (tmpstr));
4386+}
4387+
4388+static char *
4389+get_field_imms (long instr)
4390+{
4391+ char tmpstr[25];
4392+
4393+ sprintf (tmpstr, "%d", (short)((instr & IMM6_MASK) >> IMM_LOW));
4394 return (strdup (tmpstr));
4395 }
4396
4397@@ -74,14 +84,14 @@ get_field_imm5_mbar (long instr)
4398 }
4399
4400 static char *
4401-get_field_imm5width (long instr)
4402+get_field_immw (long instr)
4403 {
4404 char tmpstr[25];
4405
4406 if (instr & 0x00004000)
4407- sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW))); /* bsefi */
4408+ sprintf (tmpstr, "%d", (short)(((instr & IMM6_WIDTH_MASK) >> IMM_WIDTH_LOW))); /* bsefi */
4409 else
4410- sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW) - ((instr & IMM5_MASK) >> IMM_LOW) + 1)); /* bsifi */
4411+ sprintf (tmpstr, "%d", (short)(((instr & IMM6_WIDTH_MASK) >> IMM_WIDTH_LOW) - ((instr & IMM6_MASK) >> IMM_LOW) + 1)); /* bsifi */
4412 return (strdup (tmpstr));
4413 }
4414
4415@@ -286,9 +296,13 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
4416 }
4417 }
4418 break;
4419- case INST_TYPE_RD_R1_IMM5:
4420+ case INST_TYPE_RD_R1_IMML:
4421+ print_func (stream, "\t%s, %s, %s", get_field_rd (inst),
4422+ get_field_r1(inst), get_field_imm (inst));
4423+ /* TODO: Also print symbol */
4424+ case INST_TYPE_RD_R1_IMMS:
4425 print_func (stream, "\t%s, %s, %s", get_field_rd (inst),
4426- get_field_r1(inst), get_field_imm5 (inst));
4427+ get_field_r1(inst), get_field_imms (inst));
4428 break;
4429 case INST_TYPE_RD_RFSL:
4430 print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_rfsl (inst));
4431@@ -386,6 +400,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
4432 }
4433 }
4434 break;
4435+ case INST_TYPE_IMML:
4436+ print_func (stream, "\t%s", get_field_imml (inst));
4437+ /* TODO: Also print symbol */
4438+ break;
4439 case INST_TYPE_RD_R2:
4440 print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_r2 (inst));
4441 break;
4442@@ -409,9 +427,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
4443 case INST_TYPE_NONE:
4444 break;
4445 /* For bit field insns. */
4446- case INST_TYPE_RD_R1_IMM5_IMM5:
4447- print_func (stream, "\t%s, %s, %s, %s", get_field_rd (inst),get_field_r1(inst),get_field_imm5width (inst), get_field_imm5 (inst));
4448- break;
4449+ case INST_TYPE_RD_R1_IMMW_IMMS:
4450+ print_func (stream, "\t%s, %s, %s, %s", get_field_rd (inst), get_field_r1(inst),
4451+ get_field_immw (inst), get_field_imms (inst));
4452+ break;
4453 /* For tuqula instruction */
4454 case INST_TYPE_RD:
4455 print_func (stream, "\t%s", get_field_rd (inst));
4456diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
4457index ce8ac351b5..985834b8df 100644
4458--- a/opcodes/microblaze-opc.h
4459+++ b/opcodes/microblaze-opc.h
4460@@ -40,7 +40,7 @@
4461 #define INST_TYPE_RD_SPECIAL 11
4462 #define INST_TYPE_R1 12
4463 /* New instn type for barrel shift imms. */
4464-#define INST_TYPE_RD_R1_IMM5 13
4465+#define INST_TYPE_RD_R1_IMMS 13
4466 #define INST_TYPE_RD_RFSL 14
4467 #define INST_TYPE_R1_RFSL 15
4468
4469@@ -60,7 +60,13 @@
4470 #define INST_TYPE_IMM5 20
4471
4472 /* For bsefi and bsifi */
4473-#define INST_TYPE_RD_R1_IMM5_IMM5 21
4474+#define INST_TYPE_RD_R1_IMMW_IMMS 21
4475+
4476+/* For 64-bit instructions */
4477+#define INST_TYPE_IMML 22
4478+#define INST_TYPE_RD_R1_IMML 23
4479+#define INST_TYPE_R1_IMML 24
4480+#define INST_TYPE_RD_R1_IMMW_IMMS 21
4481
4482 #define INST_TYPE_NONE 25
4483
4484@@ -91,13 +97,14 @@
4485 #define OPCODE_MASK_H24 0xFC1F07FF /* High 6, bits 20-16 and low 11 bits. */
4486 #define OPCODE_MASK_H124 0xFFFF07FF /* High 16, and low 11 bits. */
4487 #define OPCODE_MASK_H1234 0xFFFFFFFF /* All 32 bits. */
4488-#define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22. */
4489-#define OPCODE_MASK_H3B 0xFC00C600 /* High 6 bits and bits 16, 17, 21, 22. */
4490+#define OPCODE_MASK_H3 0xFC000700 /* High 6 bits and bits 21, 22, 23. */
4491+#define OPCODE_MASK_H3B 0xFC00E600 /* High 6 bits and bits 16, 17, 18, 21, 22. */
4492 #define OPCODE_MASK_H32 0xFC00FC00 /* High 6 bits and bit 16-21. */
4493-#define OPCODE_MASK_H32B 0xFC00C000 /* High 6 bits and bit 16, 17. */
4494+#define OPCODE_MASK_H32B 0xFC00E000 /* High 6 bits and bit 16, 17, 18. */
4495 #define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits. */
4496 #define OPCODE_MASK_H35B 0xFC0004FF /* High 6 bits and low 9 bits. */
4497 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
4498+#define OPCODE_MASK_H8 0xFF000000 /* High 8 bits only. */
4499
4500 /* New Mask for msrset, msrclr insns. */
4501 #define OPCODE_MASK_H23N 0xFC1F8000 /* High 6 and bits 11 - 16. */
4502@@ -107,7 +114,7 @@
4503 #define DELAY_SLOT 1
4504 #define NO_DELAY_SLOT 0
4505
4506-#define MAX_OPCODES 301
4507+#define MAX_OPCODES 412
4508
4509 struct op_code_struct
4510 {
4511@@ -125,6 +132,7 @@ struct op_code_struct
4512 /* More info about output format here. */
4513 } opcodes[MAX_OPCODES] =
4514 {
4515+ /* 32-bit instructions */
4516 {"add", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x00000000, OPCODE_MASK_H4, add, arithmetic_inst },
4517 {"rsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H4, rsub, arithmetic_inst },
4518 {"addc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x08000000, OPCODE_MASK_H4, addc, arithmetic_inst },
4519@@ -161,11 +169,11 @@ struct op_code_struct
4520 {"ncget", INST_TYPE_RD_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C006000, OPCODE_MASK_H32, ncget, anyware_inst },
4521 {"ncput", INST_TYPE_R1_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00E000, OPCODE_MASK_H32, ncput, anyware_inst },
4522 {"muli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x60000000, OPCODE_MASK_H, muli, mult_inst },
4523- {"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3, bslli, barrel_shift_inst },
4524- {"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3, bsrai, barrel_shift_inst },
4525- {"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3, bsrli, barrel_shift_inst },
4526- {"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 },
4527- {"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 },
4528+ {"bslli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3B, bslli, barrel_shift_inst },
4529+ {"bsrai", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3B, bsrai, barrel_shift_inst },
4530+ {"bsrli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3B, bsrli, barrel_shift_inst },
4531+ {"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 },
4532+ {"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 },
4533 {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst },
4534 {"and", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000000, OPCODE_MASK_H4, microblaze_and, logical_inst },
4535 {"xor", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000000, OPCODE_MASK_H4, microblaze_xor, logical_inst },
4536@@ -425,6 +433,129 @@ struct op_code_struct
4537 {"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. */
4538 {"swapb", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E0, OPCODE_MASK_H4, swapb, arithmetic_inst },
4539 {"swaph", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E2, OPCODE_MASK_H4, swaph, arithmetic_inst },
4540+
4541+ /* 64-bit instructions */
4542+ {"addl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x00000100, OPCODE_MASK_H4, addl, arithmetic_inst },
4543+ {"rsubl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000100, OPCODE_MASK_H4, rsubl, arithmetic_inst },
4544+ {"addlc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x08000100, OPCODE_MASK_H4, addlc, arithmetic_inst },
4545+ {"rsublc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x0C000100, OPCODE_MASK_H4, rsublc, arithmetic_inst },
4546+ {"addlk", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x10000100, OPCODE_MASK_H4, addlk, arithmetic_inst },
4547+ {"rsublk", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000100, OPCODE_MASK_H4, rsublk, arithmetic_inst },
4548+ {"addlkc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x18000100, OPCODE_MASK_H4, addlkc, arithmetic_inst },
4549+ {"rsublkc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x1C000100, OPCODE_MASK_H4, rsublkc, arithmetic_inst },
4550+ {"cmpl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000101, OPCODE_MASK_H4, cmpl, arithmetic_inst },
4551+ {"cmplu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000103, OPCODE_MASK_H4, cmplu, arithmetic_inst },
4552+ {"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 */
4553+ {"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 */
4554+ {"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 */
4555+ {"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 */
4556+ {"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 */
4557+ {"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 */
4558+ {"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 */
4559+ {"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 */
4560+ {"mull", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x40000100, OPCODE_MASK_H4, mull, mult_inst },
4561+ {"bslll", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000500, OPCODE_MASK_H3, bslll, barrel_shift_inst },
4562+ {"bslra", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000300, OPCODE_MASK_H3, bslra, barrel_shift_inst },
4563+ {"bslrl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000100, OPCODE_MASK_H3, bslrl, barrel_shift_inst },
4564+ {"bsllli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64002400, OPCODE_MASK_H3B, bsllli, barrel_shift_inst },
4565+ {"bslrai", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64002200, OPCODE_MASK_H3B, bslrai, barrel_shift_inst },
4566+ {"bslrli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64002000, OPCODE_MASK_H3B, bslrli, barrel_shift_inst },
4567+ {"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 },
4568+ {"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 },
4569+ {"orl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000100, OPCODE_MASK_H4, orl, logical_inst },
4570+ {"andl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000100, OPCODE_MASK_H4, andl, logical_inst },
4571+ {"xorl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000100, OPCODE_MASK_H4, xorl, logical_inst },
4572+ {"andnl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x8C000100, OPCODE_MASK_H4, andnl, logical_inst },
4573+ {"pcmplbf", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000500, OPCODE_MASK_H4, pcmplbf, logical_inst },
4574+ {"pcmpleq", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000500, OPCODE_MASK_H4, pcmpleq, logical_inst },
4575+ {"pcmplne", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x8C000500, OPCODE_MASK_H4, pcmplne, logical_inst },
4576+ {"srla", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000101, OPCODE_MASK_H34, srla, logical_inst },
4577+ {"srlc", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000121, OPCODE_MASK_H34, srlc, logical_inst },
4578+ {"srll", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000141, OPCODE_MASK_H34, srll, logical_inst },
4579+ {"sextl8", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000160, OPCODE_MASK_H34, sextl8, logical_inst },
4580+ {"sextl16", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000161, OPCODE_MASK_H34, sextl16, logical_inst },
4581+ {"sextl32", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000162, OPCODE_MASK_H34, sextl32, logical_inst },
4582+ {"brea", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98010000, OPCODE_MASK_H124, brea, branch_inst },
4583+ {"bread", INST_TYPE_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98110000, OPCODE_MASK_H124, bread, branch_inst },
4584+ {"breald", INST_TYPE_RD_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98150000, OPCODE_MASK_H24, breald, branch_inst },
4585+ {"beaeq", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D000000, OPCODE_MASK_H14, beaeq, branch_inst },
4586+ {"bealeq", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D000100, OPCODE_MASK_H14, bealeq, branch_inst },
4587+ {"beaeqd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F000000, OPCODE_MASK_H14, beaeqd, branch_inst },
4588+ {"bealeqd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F000100, OPCODE_MASK_H14, bealeqd, branch_inst },
4589+ {"beane", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D200000, OPCODE_MASK_H14, beane, branch_inst },
4590+ {"bealne", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D200100, OPCODE_MASK_H14, bealne, branch_inst },
4591+ {"beaned", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F200000, OPCODE_MASK_H14, beaned, branch_inst },
4592+ {"bealned", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F200100, OPCODE_MASK_H14, bealned, branch_inst },
4593+ {"bealt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D400000, OPCODE_MASK_H14, bealt, branch_inst },
4594+ {"beallt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D400100, OPCODE_MASK_H14, beallt, branch_inst },
4595+ {"bealtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F400000, OPCODE_MASK_H14, bealtd, branch_inst },
4596+ {"bealltd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F400100, OPCODE_MASK_H14, bealltd, branch_inst },
4597+ {"beale", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D600000, OPCODE_MASK_H14, beale, branch_inst },
4598+ {"bealle", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D600100, OPCODE_MASK_H14, bealle, branch_inst },
4599+ {"bealed", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F600000, OPCODE_MASK_H14, bealed, branch_inst },
4600+ {"bealled", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F600100, OPCODE_MASK_H14, bealled, branch_inst },
4601+ {"beagt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D800000, OPCODE_MASK_H14, beagt, branch_inst },
4602+ {"bealgt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D800100, OPCODE_MASK_H14, bealgt, branch_inst },
4603+ {"beagtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F800000, OPCODE_MASK_H14, beagtd, branch_inst },
4604+ {"bealgtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F800100, OPCODE_MASK_H14, bealgtd, branch_inst },
4605+ {"beage", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9DA00000, OPCODE_MASK_H14, beage, branch_inst },
4606+ {"bealge", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9DA00100, OPCODE_MASK_H14, bealge, branch_inst },
4607+ {"beaged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00000, OPCODE_MASK_H14, beaged, branch_inst },
4608+ {"bealged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00100, OPCODE_MASK_H14, bealged, branch_inst },
4609+ {"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 */
4610+ {"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 */
4611+ {"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 */
4612+ {"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 */
4613+ {"imml", INST_TYPE_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB2000000, OPCODE_MASK_H8, imml, immediate_inst },
4614+ {"breai", INST_TYPE_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8010000, OPCODE_MASK_H12, breai, branch_inst },
4615+ {"breaid", INST_TYPE_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8110000, OPCODE_MASK_H12, breaid, branch_inst },
4616+ {"brealid", INST_TYPE_RD_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8150000, OPCODE_MASK_H2, brealid, branch_inst },
4617+ {"beaeqi", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD000000, OPCODE_MASK_H1, beaeqi, branch_inst },
4618+ {"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 */
4619+ {"beaeqid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF000000, OPCODE_MASK_H1, beaeqid, branch_inst },
4620+ {"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 */
4621+ {"beanei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD200000, OPCODE_MASK_H1, beanei, branch_inst },
4622+ {"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 */
4623+ {"beaneid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF200000, OPCODE_MASK_H1, beaneid, branch_inst },
4624+ {"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 */
4625+ {"bealti", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD400000, OPCODE_MASK_H1, bealti, branch_inst },
4626+ {"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 */
4627+ {"bealtid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF400000, OPCODE_MASK_H1, bealtid, branch_inst },
4628+ {"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 */
4629+ {"bealei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD600000, OPCODE_MASK_H1, bealei, branch_inst },
4630+ {"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 */
4631+ {"bealeid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF600000, OPCODE_MASK_H1, bealeid, branch_inst },
4632+ {"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 */
4633+ {"beagti", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD800000, OPCODE_MASK_H1, beagti, branch_inst },
4634+ {"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 */
4635+ {"beagtid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF800000, OPCODE_MASK_H1, beagtid, branch_inst },
4636+ {"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 */
4637+ {"beagei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBDA00000, OPCODE_MASK_H1, beagei, branch_inst },
4638+ {"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 */
4639+ {"beageid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBFA00000, OPCODE_MASK_H1, beageid, branch_inst },
4640+ {"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 */
4641+ {"ll", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000100, OPCODE_MASK_H4, ll, memory_load_inst },
4642+ {"llr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000300, OPCODE_MASK_H4, llr, memory_load_inst },
4643+ {"sl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000100, OPCODE_MASK_H4, sl, memory_store_inst },
4644+ {"slr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000300, OPCODE_MASK_H4, slr, memory_store_inst },
4645+ {"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 */
4646+ {"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 */
4647+ {"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 */
4648+ {"dadd", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000400, OPCODE_MASK_H4, dadd, arithmetic_inst },
4649+ {"drsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000480, OPCODE_MASK_H4, drsub, arithmetic_inst },
4650+ {"dmul", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000500, OPCODE_MASK_H4, dmul, arithmetic_inst },
4651+ {"ddiv", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000580, OPCODE_MASK_H4, ddiv, arithmetic_inst },
4652+ {"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 },
4653+ {"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 },
4654+ {"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 },
4655+ {"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 },
4656+ {"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 },
4657+ {"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 },
4658+ {"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 },
4659+ {"dbl", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000680, OPCODE_MASK_H4, dbl, arithmetic_inst },
4660+ {"dlong", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000700, OPCODE_MASK_H4, dlong, arithmetic_inst },
4661+ {"dsqrt", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000780, OPCODE_MASK_H4, dsqrt, arithmetic_inst },
4662+
4663 {"", 0, 0, 0, 0, 0, 0, 0, 0},
4664 };
4665
4666@@ -445,8 +576,17 @@ char pvr_register_prefix[] = "rpvr";
4667 #define MIN_IMM5 ((int) 0x00000000)
4668 #define MAX_IMM5 ((int) 0x0000001f)
4669
4670+#define MIN_IMM6 ((int) 0x00000000)
4671+#define MAX_IMM6 ((int) 0x0000003f)
4672+
4673 #define MIN_IMM_WIDTH ((int) 0x00000001)
4674 #define MAX_IMM_WIDTH ((int) 0x00000020)
4675
4676+#define MIN_IMM6_WIDTH ((int) 0x00000001)
4677+#define MAX_IMM6_WIDTH ((int) 0x00000040)
4678+
4679+#define MIN_IMML ((long) 0xffffff8000000000L)
4680+#define MAX_IMML ((long) 0x0000007fffffffffL)
4681+
4682 #endif /* MICROBLAZE_OPC */
4683
4684diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
4685index 28662694cd..076dbcd0b3 100644
4686--- a/opcodes/microblaze-opcm.h
4687+++ b/opcodes/microblaze-opcm.h
4688@@ -25,6 +25,7 @@
4689
4690 enum microblaze_instr
4691 {
4692+ /* 32-bit instructions */
4693 add, rsub, addc, rsubc, addk, rsubk, addkc, rsubkc, clz, cmp, cmpu,
4694 addi, rsubi, addic, rsubic, addik, rsubik, addikc, rsubikc, mul,
4695 mulh, mulhu, mulhsu,swapb,swaph,
4696@@ -58,6 +59,18 @@ enum microblaze_instr
4697 aputd, taputd, caputd, tcaputd, naputd, tnaputd, ncaputd, tncaputd,
4698 eagetd, teagetd, ecagetd, tecagetd, neagetd, tneagetd, necagetd, tnecagetd,
4699 eaputd, teaputd, ecaputd, tecaputd, neaputd, tneaputd, necaputd, tnecaputd,
4700+
4701+ /* 64-bit instructions */
4702+ addl, rsubl, addlc, rsublc, addlk, rsublk, addlkc, rsublkc, cmpl, cmplu, mull,
4703+ bslll, bslra, bslrl, bsllli, bslrai, bslrli, bslefi, bslifi, orl, andl, xorl,
4704+ andnl, pcmplbf, pcmpleq, pcmplne, srla, srlc, srll, sextl8, sextl16, sextl32,
4705+ brea, bread, breald, beaeq, bealeq, beaeqd, bealeqd, beane, bealne, beaned,
4706+ bealned, bealt, beallt, bealtd, bealltd, beale, bealle, bealed, bealled, beagt,
4707+ bealgt, beagtd, bealgtd, beage, bealge, beaged, bealged, breai, breaid, brealid,
4708+ beaeqi, beaeqid, beanei, beaneid, bealti, bealtid, bealei, bealeid, beagti,
4709+ beagtid, beagei, beageid, imml, ll, llr, sl, slr,
4710+ dadd, drsub, dmul, ddiv, dcmp_lt, dcmp_eq, dcmp_le, dcmp_gt, dcmp_ne, dcmp_ge,
4711+ dcmp_un, dbl, dlong, dsqrt,
4712 invalid_inst
4713 };
4714
4715@@ -135,15 +148,18 @@ enum microblaze_instr_type
4716 #define RA_MASK 0x001F0000
4717 #define RB_MASK 0x0000F800
4718 #define IMM_MASK 0x0000FFFF
4719+#define IMML_MASK 0x00FFFFFF
4720
4721-/* Imm mask for barrel shifts. */
4722+/* Imm masks for barrel shifts. */
4723 #define IMM5_MASK 0x0000001F
4724+#define IMM6_MASK 0x0000003F
4725
4726 /* Imm mask for mbar. */
4727 #define IMM5_MBAR_MASK 0x03E00000
4728
4729-/* Imm mask for extract/insert width. */
4730+/* Imm masks for extract/insert width. */
4731 #define IMM5_WIDTH_MASK 0x000007C0
4732+#define IMM6_WIDTH_MASK 0x00000FC0
4733
4734 /* FSL imm mask for get, put instructions. */
4735 #define RFSL_MASK 0x000000F
4736--
47372.17.1
4738
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0016-MB-X-initial-commit.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0016-MB-X-initial-commit.patch
new file mode 100644
index 00000000..0c3da95a
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0016-MB-X-initial-commit.patch
@@ -0,0 +1,691 @@
1From bcd4263219c9756b9c1c1df64c6fef1311057fac 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/43] MB-X initial commit code cleanup is needed.
5
6---
7 bfd/bfd-in2.h | 10 +++
8 bfd/elf32-microblaze.c | 65 +++++++++++++++-
9 bfd/elf64-microblaze.c | 61 ++++++++++++++-
10 bfd/libbfd.h | 2 +
11 bfd/reloc.c | 12 +++
12 gas/config/tc-microblaze.c | 152 ++++++++++++++++++++++++++++++-------
13 include/elf/microblaze.h | 2 +
14 opcodes/microblaze-opc.h | 4 +-
15 opcodes/microblaze-opcm.h | 4 +-
16 9 files changed, 277 insertions(+), 35 deletions(-)
17
18diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
19index 721531886a..4f777059d8 100644
20--- a/bfd/bfd-in2.h
21+++ b/bfd/bfd-in2.h
22@@ -5876,11 +5876,21 @@ done here - only used for relaxing */
23 * +done here - only used for relaxing */
24 BFD_RELOC_MICROBLAZE_64_NONE,
25
26+/* This is a 64 bit reloc that stores the 32 bit pc relative
27+ * +value in two words (with an imml instruction). No relocation is
28+ * +done here - only used for relaxing */
29+ BFD_RELOC_MICROBLAZE_64,
30+
31 /* This is a 64 bit reloc that stores the 32 bit pc relative
32 value in two words (with an imm instruction). The relocation is
33 PC-relative GOT offset */
34 BFD_RELOC_MICROBLAZE_64_GOTPC,
35
36+/* This is a 64 bit reloc that stores the 32 bit pc relative
37+value in two words (with an imml instruction). The relocation is
38+PC-relative GOT offset */
39+ BFD_RELOC_MICROBLAZE_64_GPC,
40+
41 /* This is a 64 bit reloc that stores the 32 bit pc relative
42 value in two words (with an imm instruction). The relocation is
43 GOT offset */
44diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
45index d001437b3f..035e71f311 100644
46--- a/bfd/elf32-microblaze.c
47+++ b/bfd/elf32-microblaze.c
48@@ -116,6 +116,20 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
49 0x0000ffff, /* Dest Mask. */
50 TRUE), /* PC relative offset? */
51
52+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */
53+ 0, /* Rightshift. */
54+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
55+ 16, /* Bitsize. */
56+ TRUE, /* PC_relative. */
57+ 0, /* Bitpos. */
58+ complain_overflow_dont, /* Complain on overflow. */
59+ bfd_elf_generic_reloc,/* Special Function. */
60+ "R_MICROBLAZE_IMML_64", /* Name. */
61+ FALSE, /* Partial Inplace. */
62+ 0, /* Source Mask. */
63+ 0x0000ffff, /* Dest Mask. */
64+ FALSE), /* PC relative offset? */
65+
66 /* A 64 bit relocation. Table entry not really used. */
67 HOWTO (R_MICROBLAZE_64, /* Type. */
68 0, /* Rightshift. */
69@@ -280,6 +294,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
70 0x0000ffff, /* Dest Mask. */
71 TRUE), /* PC relative offset? */
72
73+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
74+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */
75+ 0, /* Rightshift. */
76+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
77+ 16, /* Bitsize. */
78+ TRUE, /* PC_relative. */
79+ 0, /* Bitpos. */
80+ complain_overflow_dont, /* Complain on overflow. */
81+ bfd_elf_generic_reloc, /* Special Function. */
82+ "R_MICROBLAZE_GPC_64", /* Name. */
83+ FALSE, /* Partial Inplace. */
84+ 0, /* Source Mask. */
85+ 0x0000ffff, /* Dest Mask. */
86+ TRUE), /* PC relative offset? */
87+
88 /* A 64 bit GOT relocation. Table-entry not really used. */
89 HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
90 0, /* Rightshift. */
91@@ -619,9 +648,15 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
92 case BFD_RELOC_VTABLE_ENTRY:
93 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
94 break;
95+ case BFD_RELOC_MICROBLAZE_64:
96+ microblaze_reloc = R_MICROBLAZE_IMML_64;
97+ break;
98 case BFD_RELOC_MICROBLAZE_64_GOTPC:
99 microblaze_reloc = R_MICROBLAZE_GOTPC_64;
100 break;
101+ case BFD_RELOC_MICROBLAZE_64_GPC:
102+ microblaze_reloc = R_MICROBLAZE_GPC_64;
103+ break;
104 case BFD_RELOC_MICROBLAZE_64_GOT:
105 microblaze_reloc = R_MICROBLAZE_GOT_64;
106 break;
107@@ -1467,7 +1502,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
108 if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
109 {
110 relocation += addend;
111- if (r_type == R_MICROBLAZE_32)
112+ if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
113 bfd_put_32 (input_bfd, relocation, contents + offset);
114 else
115 {
116@@ -1933,6 +1968,28 @@ microblaze_elf_relax_section (bfd *abfd,
117 irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
118 }
119 break;
120+ case R_MICROBLAZE_IMML_64:
121+ {
122+ /* This was a PC-relative instruction that was
123+ completely resolved. */
124+ int sfix, efix;
125+ unsigned int val;
126+ bfd_vma target_address;
127+ target_address = irel->r_addend + irel->r_offset;
128+ sfix = calc_fixup (irel->r_offset, 0, sec);
129+ efix = calc_fixup (target_address, 0, sec);
130+
131+ /* Validate the in-band val. */
132+ val = bfd_get_32 (abfd, contents + irel->r_offset);
133+ if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
134+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
135+ }
136+ irel->r_addend -= (efix - sfix);
137+ /* Should use HOWTO. */
138+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
139+ irel->r_addend);
140+ }
141+ break;
142 case R_MICROBLAZE_NONE:
143 case R_MICROBLAZE_32_NONE:
144 {
145@@ -2037,9 +2094,9 @@ microblaze_elf_relax_section (bfd *abfd,
146 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
147 irelscan->r_addend);
148 }
149- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
150- {
151- isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
152+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)// || ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64)
153+ {
154+ isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
155
156 /* Look at the reloc only if the value has been resolved. */
157 if (isym->st_shndx == shndx
158diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
159index 0f43ae6ea8..56a45f2a05 100644
160--- a/bfd/elf64-microblaze.c
161+++ b/bfd/elf64-microblaze.c
162@@ -116,6 +116,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
163 0x0000ffff, /* Dest Mask. */
164 TRUE), /* PC relative offset? */
165
166+ /* A 64 bit relocation. Table entry not really used. */
167+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */
168+ 0, /* Rightshift. */
169+ 4, /* Size (0 = byte, 1 = short, 2 = long). */
170+ 64, /* Bitsize. */
171+ TRUE, /* PC_relative. */
172+ 0, /* Bitpos. */
173+ complain_overflow_dont, /* Complain on overflow. */
174+ bfd_elf_generic_reloc,/* Special Function. */
175+ "R_MICROBLAZE_IMML_64", /* Name. */
176+ FALSE, /* Partial Inplace. */
177+ 0, /* Source Mask. */
178+ 0x0000ffff, /* Dest Mask. */
179+ TRUE), /* PC relative offset? */
180+
181 /* A 64 bit relocation. Table entry not really used. */
182 HOWTO (R_MICROBLAZE_64, /* Type. */
183 0, /* Rightshift. */
184@@ -265,6 +280,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
185 0x0000ffff, /* Dest Mask. */
186 TRUE), /* PC relative offset? */
187
188+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
189+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */
190+ 0, /* Rightshift. */
191+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
192+ 16, /* Bitsize. */
193+ TRUE, /* PC_relative. */
194+ 0, /* Bitpos. */
195+ complain_overflow_dont, /* Complain on overflow. */
196+ bfd_elf_generic_reloc, /* Special Function. */
197+ "R_MICROBLAZE_GPC_64", /* Name. */
198+ FALSE, /* Partial Inplace. */
199+ 0, /* Source Mask. */
200+ 0x0000ffff, /* Dest Mask. */
201+ TRUE), /* PC relative offset? */
202+
203 /* A 64 bit GOT relocation. Table-entry not really used. */
204 HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
205 0, /* Rightshift. */
206@@ -589,9 +619,15 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
207 case BFD_RELOC_VTABLE_ENTRY:
208 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
209 break;
210+ case BFD_RELOC_MICROBLAZE_64:
211+ microblaze_reloc = R_MICROBLAZE_IMML_64;
212+ break;
213 case BFD_RELOC_MICROBLAZE_64_GOTPC:
214 microblaze_reloc = R_MICROBLAZE_GOTPC_64;
215 break;
216+ case BFD_RELOC_MICROBLAZE_64_GPC:
217+ microblaze_reloc = R_MICROBLAZE_GPC_64;
218+ break;
219 case BFD_RELOC_MICROBLAZE_64_GOT:
220 microblaze_reloc = R_MICROBLAZE_GOT_64;
221 break;
222@@ -1161,6 +1197,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
223 break; /* Do nothing. */
224
225 case (int) R_MICROBLAZE_GOTPC_64:
226+ case (int) R_MICROBLAZE_GPC_64:
227 relocation = htab->sgotplt->output_section->vma
228 + htab->sgotplt->output_offset;
229 relocation -= (input_section->output_section->vma
230@@ -1431,7 +1468,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
231 if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
232 {
233 relocation += addend;
234- if (r_type == R_MICROBLAZE_32)
235+ if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
236 bfd_put_32 (input_bfd, relocation, contents + offset);
237 else
238 {
239@@ -1876,6 +1913,28 @@ microblaze_elf_relax_section (bfd *abfd,
240 irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
241 }
242 break;
243+ case R_MICROBLAZE_IMML_64:
244+ {
245+ /* This was a PC-relative instruction that was
246+ completely resolved. */
247+ int sfix, efix;
248+ unsigned int val;
249+ bfd_vma target_address;
250+ target_address = irel->r_addend + irel->r_offset;
251+ sfix = calc_fixup (irel->r_offset, 0, sec);
252+ efix = calc_fixup (target_address, 0, sec);
253+
254+ /* Validate the in-band val. */
255+ val = bfd_get_32 (abfd, contents + irel->r_offset);
256+ if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
257+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
258+ }
259+ irel->r_addend -= (efix - sfix);
260+ /* Should use HOWTO. */
261+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
262+ irel->r_addend);
263+ }
264+ break;
265 case R_MICROBLAZE_NONE:
266 case R_MICROBLAZE_32_NONE:
267 {
268diff --git a/bfd/libbfd.h b/bfd/libbfd.h
269index feb9fada1e..450653f2d8 100644
270--- a/bfd/libbfd.h
271+++ b/bfd/libbfd.h
272@@ -2903,7 +2903,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
273 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
274 "BFD_RELOC_MICROBLAZE_32_NONE",
275 "BFD_RELOC_MICROBLAZE_64_NONE",
276+ "BFD_RELOC_MICROBLAZE_64",
277 "BFD_RELOC_MICROBLAZE_64_GOTPC",
278+ "BFD_RELOC_MICROBLAZE_64_GPC",
279 "BFD_RELOC_MICROBLAZE_64_GOT",
280 "BFD_RELOC_MICROBLAZE_64_PLT",
281 "BFD_RELOC_MICROBLAZE_64_GOTOFF",
282diff --git a/bfd/reloc.c b/bfd/reloc.c
283index 87753ae4f0..ccf29f54cf 100644
284--- a/bfd/reloc.c
285+++ b/bfd/reloc.c
286@@ -6803,12 +6803,24 @@ ENUMDOC
287 done here - only used for relaxing
288 ENUM
289 BFD_RELOC_MICROBLAZE_64_NONE
290+ENUMDOC
291+ This is a 32 bit reloc that stores the 32 bit pc relative
292+ value in two words (with an imml instruction). No relocation is
293+ done here - only used for relaxing
294+ENUM
295+ BFD_RELOC_MICROBLAZE_64
296 ENUMDOC
297 This is a 64 bit reloc that stores the 32 bit pc relative
298 value in two words (with an imm instruction). No relocation is
299 done here - only used for relaxing
300 ENUM
301 BFD_RELOC_MICROBLAZE_64_GOTPC
302+ENUMDOC
303+ This is a 64 bit reloc that stores the 32 bit pc relative
304+ value in two words (with an imml instruction). No relocation is
305+ done here - only used for relaxing
306+ENUM
307+ BFD_RELOC_MICROBLAZE_64_GPC
308 ENUMDOC
309 This is a 64 bit reloc that stores the 32 bit pc relative
310 value in two words (with an imm instruction). The relocation is
311diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
312index c79434785a..3f90b7c892 100644
313--- a/gas/config/tc-microblaze.c
314+++ b/gas/config/tc-microblaze.c
315@@ -94,6 +94,7 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP";
316 #define TLSTPREL_OFFSET 16
317 #define TEXT_OFFSET 17
318 #define TEXT_PC_OFFSET 18
319+#define DEFINED_64_OFFSET 19
320
321 /* Initialize the relax table. */
322 const relax_typeS md_relax_table[] =
323@@ -117,6 +118,8 @@ const relax_typeS md_relax_table[] =
324 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 16: TLSTPREL_OFFSET. */
325 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 17: TEXT_OFFSET. */
326 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 18: TEXT_PC_OFFSET. */
327+// { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 16: TLSTPREL_OFFSET. */
328+ { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 } /* 17: DEFINED_64_OFFSET. */
329 };
330
331 static struct hash_control * opcode_hash_control; /* Opcode mnemonics. */
332@@ -396,7 +399,8 @@ const pseudo_typeS md_pseudo_table[] =
333 {"data32", cons, 4}, /* Same as word. */
334 {"ent", s_func, 0}, /* Treat ent as function entry point. */
335 {"end", microblaze_s_func, 1}, /* Treat end as function end point. */
336- {"gpword", s_rva, 4}, /* gpword label => store resolved label address in data section. */
337+ {"gpword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
338+ {"gpdword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
339 {"weakext", microblaze_s_weakext, 0},
340 {"rodata", microblaze_s_rdata, 0},
341 {"sdata2", microblaze_s_rdata, 1},
342@@ -405,6 +409,7 @@ const pseudo_typeS md_pseudo_table[] =
343 {"sbss", microblaze_s_bss, 1},
344 {"text", microblaze_s_text, 0},
345 {"word", cons, 4},
346+ {"dword", cons, 8},
347 {"frame", s_ignore, 0},
348 {"mask", s_ignore, 0}, /* Emitted by gcc. */
349 {NULL, NULL, 0}
350@@ -898,7 +903,7 @@ check_got (int * got_type, int * got_len)
351 extern bfd_reloc_code_real_type
352 parse_cons_expression_microblaze (expressionS *exp, int size)
353 {
354- if (size == 4)
355+ if (size == 4 || (microblaze_arch_size == 64 && size == 8))
356 {
357 /* Handle @GOTOFF et.al. */
358 char *save, *gotfree_copy;
359@@ -930,6 +935,7 @@ parse_cons_expression_microblaze (expressionS *exp, int size)
360
361 static const char * str_microblaze_ro_anchor = "RO";
362 static const char * str_microblaze_rw_anchor = "RW";
363+static const char * str_microblaze_64 = "64";
364
365 static bfd_boolean
366 check_spl_reg (unsigned * reg)
367@@ -1174,6 +1180,33 @@ md_assemble (char * str)
368 inst |= (immed << IMM_LOW) & IMM_MASK;
369 }
370 }
371+#if 0 //revisit
372+ else if (streq (name, "lli") || streq (name, "sli"))
373+ {
374+ temp = immed & 0xFFFFFFFFFFFF8000;
375+ if ((temp != 0) && (temp != 0xFFFFFFFFFFFF8000))
376+ {
377+ /* Needs an immediate inst. */
378+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
379+ if (opcode1 == NULL)
380+ {
381+ as_bad (_("unknown opcode \"%s\""), "imml");
382+ return;
383+ }
384+
385+ inst1 = opcode1->bit_sequence;
386+ inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
387+ output[0] = INST_BYTE0 (inst1);
388+ output[1] = INST_BYTE1 (inst1);
389+ output[2] = INST_BYTE2 (inst1);
390+ output[3] = INST_BYTE3 (inst1);
391+ output = frag_more (isize);
392+ }
393+ inst |= (reg1 << RD_LOW) & RD_MASK;
394+ inst |= (reg2 << RA_LOW) & RA_MASK;
395+ inst |= (immed << IMM_LOW) & IMM_MASK;
396+ }
397+#endif
398 else
399 {
400 temp = immed & 0xFFFF8000;
401@@ -1926,6 +1959,7 @@ md_assemble (char * str)
402 if (exp.X_op != O_constant)
403 {
404 char *opc = NULL;
405+ //char *opc = str_microblaze_64;
406 relax_substateT subtype;
407
408 if (exp.X_md != 0)
409@@ -1939,7 +1973,7 @@ md_assemble (char * str)
410 subtype, /* PC-relative or not. */
411 exp.X_add_symbol,
412 exp.X_add_number,
413- opc);
414+ (char *) opc);
415 immedl = 0L;
416 }
417 else
418@@ -1977,7 +2011,7 @@ md_assemble (char * str)
419 reg1 = 0;
420 }
421 if (strcmp (op_end, ""))
422- op_end = parse_imml (op_end + 1, & exp, MIN_IMM, MAX_IMM);
423+ op_end = parse_imml (op_end + 1, & exp, MIN_IMML, MAX_IMML);
424 else
425 as_fatal (_("Error in statement syntax"));
426
427@@ -1987,7 +2021,8 @@ md_assemble (char * str)
428
429 if (exp.X_op != O_constant)
430 {
431- char *opc = NULL;
432+ //char *opc = NULL;
433+ char *opc = str_microblaze_64;
434 relax_substateT subtype;
435
436 if (exp.X_md != 0)
437@@ -2001,14 +2036,13 @@ md_assemble (char * str)
438 subtype, /* PC-relative or not. */
439 exp.X_add_symbol,
440 exp.X_add_number,
441- opc);
442+ (char *) opc);
443 immedl = 0L;
444 }
445 else
446 {
447 output = frag_more (isize);
448 immedl = exp.X_add_number;
449-
450 opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
451 if (opcode1 == NULL)
452 {
453@@ -2187,13 +2221,23 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
454 fragP->fr_fix += INST_WORD_SIZE * 2;
455 fragP->fr_var = 0;
456 break;
457+ case DEFINED_64_OFFSET:
458+ if (fragP->fr_symbol == GOT_symbol)
459+ fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
460+ fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_GPC);
461+ else
462+ fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
463+ fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64);
464+ fragP->fr_fix += INST_WORD_SIZE * 2;
465+ fragP->fr_var = 0;
466+ break;
467 case DEFINED_ABS_SEGMENT:
468 if (fragP->fr_symbol == GOT_symbol)
469 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol,
470 fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_GOTPC);
471 else
472 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol,
473- fragP->fr_offset, FALSE, BFD_RELOC_64);
474+ fragP->fr_offset, TRUE, BFD_RELOC_64);
475 fragP->fr_fix += INST_WORD_SIZE * 2;
476 fragP->fr_var = 0;
477 break;
478@@ -2416,22 +2460,38 @@ md_apply_fix (fixS * fixP,
479 case BFD_RELOC_64_PCREL:
480 case BFD_RELOC_64:
481 case BFD_RELOC_MICROBLAZE_64_TEXTREL:
482+ case BFD_RELOC_MICROBLAZE_64:
483 /* Add an imm instruction. First save the current instruction. */
484 for (i = 0; i < INST_WORD_SIZE; i++)
485 buf[i + INST_WORD_SIZE] = buf[i];
486+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
487+ {
488+ /* Generate the imm instruction. */
489+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
490+ if (opcode1 == NULL)
491+ {
492+ as_bad (_("unknown opcode \"%s\""), "imml");
493+ return;
494+ }
495
496- /* Generate the imm instruction. */
497- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
498- if (opcode1 == NULL)
499- {
500- as_bad (_("unknown opcode \"%s\""), "imm");
501- return;
502- }
503-
504- inst1 = opcode1->bit_sequence;
505- if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
506- inst1 |= ((val & 0xFFFF0000) >> 16) & IMM_MASK;
507-
508+ inst1 = opcode1->bit_sequence;
509+ if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
510+ inst1 |= ((val & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
511+ }
512+ else
513+ {
514+ /* Generate the imm instruction. */
515+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
516+ if (opcode1 == NULL)
517+ {
518+ as_bad (_("unknown opcode \"%s\""), "imm");
519+ return;
520+ }
521+
522+ inst1 = opcode1->bit_sequence;
523+ if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
524+ inst1 |= ((val & 0xFFFF0000) >> 16) & IMM_MASK;
525+ }
526 buf[0] = INST_BYTE0 (inst1);
527 buf[1] = INST_BYTE1 (inst1);
528 buf[2] = INST_BYTE2 (inst1);
529@@ -2460,6 +2520,7 @@ md_apply_fix (fixS * fixP,
530 /* Fall through. */
531
532 case BFD_RELOC_MICROBLAZE_64_GOTPC:
533+ case BFD_RELOC_MICROBLAZE_64_GPC:
534 case BFD_RELOC_MICROBLAZE_64_GOT:
535 case BFD_RELOC_MICROBLAZE_64_PLT:
536 case BFD_RELOC_MICROBLAZE_64_GOTOFF:
537@@ -2467,12 +2528,16 @@ md_apply_fix (fixS * fixP,
538 /* Add an imm instruction. First save the current instruction. */
539 for (i = 0; i < INST_WORD_SIZE; i++)
540 buf[i + INST_WORD_SIZE] = buf[i];
541-
542- /* Generate the imm instruction. */
543- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
544+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
545+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
546+ else
547+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
548 if (opcode1 == NULL)
549 {
550- as_bad (_("unknown opcode \"%s\""), "imm");
551+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
552+ as_bad (_("unknown opcode \"%s\""), "imml");
553+ else
554+ as_bad (_("unknown opcode \"%s\""), "imm");
555 return;
556 }
557
558@@ -2496,6 +2561,8 @@ md_apply_fix (fixS * fixP,
559 moves code around due to relaxing. */
560 if (fixP->fx_r_type == BFD_RELOC_64_PCREL)
561 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
562+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
563+ fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
564 else if (fixP->fx_r_type == BFD_RELOC_32)
565 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_32_NONE;
566 else
567@@ -2539,6 +2606,32 @@ md_estimate_size_before_relax (fragS * fragP,
568 as_bad (_("Absolute PC-relative value in relaxation code. Assembler error....."));
569 abort ();
570 }
571+ else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type
572+ && !S_IS_WEAK (fragP->fr_symbol))
573+ {
574+ if (fragP->fr_opcode != NULL) {
575+ if(streq (fragP->fr_opcode, str_microblaze_64))
576+ {
577+ /* Used as an absolute value. */
578+ fragP->fr_subtype = DEFINED_64_OFFSET;
579+ /* Variable part does not change. */
580+ fragP->fr_var = INST_WORD_SIZE;
581+ }
582+ else
583+ {
584+ fragP->fr_subtype = DEFINED_PC_OFFSET;
585+ /* Don't know now whether we need an imm instruction. */
586+ fragP->fr_var = INST_WORD_SIZE;
587+ }
588+ }
589+ else
590+ {
591+ fragP->fr_subtype = DEFINED_PC_OFFSET;
592+ /* Don't know now whether we need an imm instruction. */
593+ fragP->fr_var = INST_WORD_SIZE;
594+ }
595+ }
596+ #if 0
597 else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type &&
598 !S_IS_WEAK (fragP->fr_symbol))
599 {
600@@ -2546,6 +2639,7 @@ md_estimate_size_before_relax (fragS * fragP,
601 /* Don't know now whether we need an imm instruction. */
602 fragP->fr_var = INST_WORD_SIZE;
603 }
604+#endif
605 else if (S_IS_DEFINED (fragP->fr_symbol)
606 && (((S_GET_SEGMENT (fragP->fr_symbol))->flags & SEC_CODE) == 0))
607 {
608@@ -2648,6 +2742,7 @@ md_estimate_size_before_relax (fragS * fragP,
609 case TLSLD_OFFSET:
610 case TLSTPREL_OFFSET:
611 case TLSDTPREL_OFFSET:
612+ case DEFINED_64_OFFSET:
613 fragP->fr_var = INST_WORD_SIZE*2;
614 break;
615 case DEFINED_RO_SEGMENT:
616@@ -2701,7 +2796,7 @@ md_pcrel_from_section (fixS * fixp, segT sec ATTRIBUTE_UNUSED)
617 else
618 {
619 /* The case where we are going to resolve things... */
620- if (fixp->fx_r_type == BFD_RELOC_64_PCREL)
621+ if (fixp->fx_r_type == BFD_RELOC_64_PCREL ||fixp->fx_r_type == BFD_RELOC_MICROBLAZE_64)
622 return fixp->fx_where + fixp->fx_frag->fr_address + INST_WORD_SIZE;
623 else
624 return fixp->fx_where + fixp->fx_frag->fr_address;
625@@ -2734,6 +2829,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
626 case BFD_RELOC_MICROBLAZE_32_RWSDA:
627 case BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM:
628 case BFD_RELOC_MICROBLAZE_64_GOTPC:
629+ case BFD_RELOC_MICROBLAZE_64_GPC:
630+ case BFD_RELOC_MICROBLAZE_64:
631 case BFD_RELOC_MICROBLAZE_64_GOT:
632 case BFD_RELOC_MICROBLAZE_64_PLT:
633 case BFD_RELOC_MICROBLAZE_64_GOTOFF:
634@@ -2876,7 +2973,10 @@ cons_fix_new_microblaze (fragS * frag,
635 r = BFD_RELOC_32;
636 break;
637 case 8:
638- r = BFD_RELOC_64;
639+ if (microblaze_arch_size == 64)
640+ r = BFD_RELOC_32;
641+ else
642+ r = BFD_RELOC_64;
643 break;
644 default:
645 as_bad (_("unsupported BFD relocation size %u"), size);
646diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h
647index 6ee0966444..16b2736577 100644
648--- a/include/elf/microblaze.h
649+++ b/include/elf/microblaze.h
650@@ -62,6 +62,8 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type)
651 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_64, 31) /* TEXT Entry offset 64-bit. */
652 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_32_LO, 32) /* TEXT Entry offset 32-bit. */
653 RELOC_NUMBER (R_MICROBLAZE_32_NONE, 33)
654+ RELOC_NUMBER (R_MICROBLAZE_IMML_64, 34)
655+ RELOC_NUMBER (R_MICROBLAZE_GPC_64, 35) /* GOT entry offset. */
656
657 END_RELOC_NUMBERS (R_MICROBLAZE_max)
658
659diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
660index 985834b8df..9b6264b61c 100644
661--- a/opcodes/microblaze-opc.h
662+++ b/opcodes/microblaze-opc.h
663@@ -538,8 +538,8 @@ struct op_code_struct
664 {"llr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000300, OPCODE_MASK_H4, llr, memory_load_inst },
665 {"sl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000100, OPCODE_MASK_H4, sl, memory_store_inst },
666 {"slr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000300, OPCODE_MASK_H4, slr, memory_store_inst },
667- {"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 */
668- {"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 */
669+ {"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 */
670+ {"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 */
671 {"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 */
672 {"dadd", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000400, OPCODE_MASK_H4, dadd, arithmetic_inst },
673 {"drsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000480, OPCODE_MASK_H4, drsub, arithmetic_inst },
674diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
675index 076dbcd0b3..5f2e190d23 100644
676--- a/opcodes/microblaze-opcm.h
677+++ b/opcodes/microblaze-opcm.h
678@@ -40,8 +40,8 @@ enum microblaze_instr
679 imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid,
680 brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti,
681 bgtid, bgei, bgeid, lbu, lbuea, lbur, lhu, lhuea, lhur, lw, lwea, lwr, lwx,
682- sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi,
683- sbi, shi, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv,
684+ sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi, lli,
685+ sbi, shi, sli, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv,
686 fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, flt,
687 fint, fsqrt,
688 tget, tcget, tnget, tncget, tput, tcput, tnput, tncput,
689--
6902.17.1
691
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch
new file mode 100644
index 00000000..a6428534
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch
@@ -0,0 +1,36 @@
1From 7f6533a7c442b8966f30bbe7f0e872b1ef6a0d3f 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/43] [Patch,Microblaze] : negl instruction is overriding
5 rsubl,fixed it by changing the instruction order...
6
7---
8 opcodes/microblaze-opc.h | 4 ++--
9 1 file changed, 2 insertions(+), 2 deletions(-)
10
11diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
12index 9b6264b61c..824afc0ab0 100644
13--- a/opcodes/microblaze-opc.h
14+++ b/opcodes/microblaze-opc.h
15@@ -275,9 +275,7 @@ struct op_code_struct
16 {"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. */
17 {"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. */
18 {"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. */
19- {"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. */
20 {"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. */
21- {"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. */
22 {"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 },
23 {"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 },
24 {"msrset",INST_TYPE_RD_IMM15, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x94100000, OPCODE_MASK_H23N, msrset, special_inst },
25@@ -555,6 +553,8 @@ struct op_code_struct
26 {"dbl", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000680, OPCODE_MASK_H4, dbl, arithmetic_inst },
27 {"dlong", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000700, OPCODE_MASK_H4, dlong, arithmetic_inst },
28 {"dsqrt", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000780, OPCODE_MASK_H4, dsqrt, arithmetic_inst },
29+ {"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. */
30+ {"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. */
31
32 {"", 0, 0, 0, 0, 0, 0, 0, 0},
33 };
34--
352.17.1
36
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0018-Added-relocations-for-MB-X.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0018-Added-relocations-for-MB-X.patch
new file mode 100644
index 00000000..99c5f62a
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0018-Added-relocations-for-MB-X.patch
@@ -0,0 +1,346 @@
1From 6d241a6865abf8196ba0cfa2aed7e847df087b6e 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/43] Added relocations for MB-X
5
6---
7 bfd/bfd-in2.h | 11 +++--
8 bfd/libbfd.h | 4 +-
9 bfd/reloc.c | 26 ++++++-----
10 gas/config/tc-microblaze.c | 90 ++++++++++++++++----------------------
11 4 files changed, 62 insertions(+), 69 deletions(-)
12
13diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
14index 4f777059d8..de46e78902 100644
15--- a/bfd/bfd-in2.h
16+++ b/bfd/bfd-in2.h
17@@ -5872,15 +5872,20 @@ done here - only used for relaxing */
18 BFD_RELOC_MICROBLAZE_32_NONE,
19
20 /* This is a 64 bit reloc that stores the 32 bit pc relative
21- * +value in two words (with an imm instruction). No relocation is
22+ * +value in two words (with an imml instruction). No relocation is
23 * +done here - only used for relaxing */
24- BFD_RELOC_MICROBLAZE_64_NONE,
25+ BFD_RELOC_MICROBLAZE_64_PCREL,
26
27-/* This is a 64 bit reloc that stores the 32 bit pc relative
28+/* This is a 64 bit reloc that stores the 32 bit relative
29 * +value in two words (with an imml instruction). No relocation is
30 * +done here - only used for relaxing */
31 BFD_RELOC_MICROBLAZE_64,
32
33+/* This is a 64 bit reloc that stores the 32 bit pc relative
34+ * +value in two words (with an imm instruction). No relocation is
35+ * +done here - only used for relaxing */
36+ BFD_RELOC_MICROBLAZE_64_NONE,
37+
38 /* This is a 64 bit reloc that stores the 32 bit pc relative
39 value in two words (with an imm instruction). The relocation is
40 PC-relative GOT offset */
41diff --git a/bfd/libbfd.h b/bfd/libbfd.h
42index 450653f2d8..d87a183d5e 100644
43--- a/bfd/libbfd.h
44+++ b/bfd/libbfd.h
45@@ -2903,14 +2903,14 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
46 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
47 "BFD_RELOC_MICROBLAZE_32_NONE",
48 "BFD_RELOC_MICROBLAZE_64_NONE",
49- "BFD_RELOC_MICROBLAZE_64",
50 "BFD_RELOC_MICROBLAZE_64_GOTPC",
51- "BFD_RELOC_MICROBLAZE_64_GPC",
52 "BFD_RELOC_MICROBLAZE_64_GOT",
53 "BFD_RELOC_MICROBLAZE_64_PLT",
54 "BFD_RELOC_MICROBLAZE_64_GOTOFF",
55 "BFD_RELOC_MICROBLAZE_32_GOTOFF",
56 "BFD_RELOC_MICROBLAZE_COPY",
57+ "BFD_RELOC_MICROBLAZE_64",
58+ "BFD_RELOC_MICROBLAZE_64_PCREL",
59 "BFD_RELOC_MICROBLAZE_64_TLS",
60 "BFD_RELOC_MICROBLAZE_64_TLSGD",
61 "BFD_RELOC_MICROBLAZE_64_TLSLD",
62diff --git a/bfd/reloc.c b/bfd/reloc.c
63index ccf29f54cf..861f2d48c0 100644
64--- a/bfd/reloc.c
65+++ b/bfd/reloc.c
66@@ -6803,24 +6803,12 @@ ENUMDOC
67 done here - only used for relaxing
68 ENUM
69 BFD_RELOC_MICROBLAZE_64_NONE
70-ENUMDOC
71- This is a 32 bit reloc that stores the 32 bit pc relative
72- value in two words (with an imml instruction). No relocation is
73- done here - only used for relaxing
74-ENUM
75- BFD_RELOC_MICROBLAZE_64
76 ENUMDOC
77 This is a 64 bit reloc that stores the 32 bit pc relative
78 value in two words (with an imm instruction). No relocation is
79 done here - only used for relaxing
80 ENUM
81 BFD_RELOC_MICROBLAZE_64_GOTPC
82-ENUMDOC
83- This is a 64 bit reloc that stores the 32 bit pc relative
84- value in two words (with an imml instruction). No relocation is
85- done here - only used for relaxing
86-ENUM
87- BFD_RELOC_MICROBLAZE_64_GPC
88 ENUMDOC
89 This is a 64 bit reloc that stores the 32 bit pc relative
90 value in two words (with an imm instruction). The relocation is
91@@ -6906,6 +6894,20 @@ ENUMDOC
92 value in two words (with an imm instruction). The relocation is
93 relative offset from start of TEXT.
94
95+ This is a 64 bit reloc that stores 64-bit thread pointer relative offset
96+ to two words (uses imml instruction).
97+ENUM
98+BFD_RELOC_MICROBLAZE_64,
99+ENUMDOC
100+ This is a 64 bit reloc that stores the 64 bit pc relative
101+ value in two words (with an imml instruction). No relocation is
102+ done here - only used for relaxing
103+ENUM
104+BFD_RELOC_MICROBLAZE_64_PCREL,
105+ENUMDOC
106+ This is a 32 bit reloc that stores the 32 bit pc relative
107+ value in two words (with an imml instruction). No relocation is
108+ done here - only used for relaxing
109 ENUM
110 BFD_RELOC_AARCH64_RELOC_START
111 ENUMDOC
112diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
113index 3f90b7c892..587a4d56ec 100644
114--- a/gas/config/tc-microblaze.c
115+++ b/gas/config/tc-microblaze.c
116@@ -95,6 +95,7 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP";
117 #define TEXT_OFFSET 17
118 #define TEXT_PC_OFFSET 18
119 #define DEFINED_64_OFFSET 19
120+#define DEFINED_64_PC_OFFSET 20
121
122 /* Initialize the relax table. */
123 const relax_typeS md_relax_table[] =
124@@ -119,7 +120,8 @@ const relax_typeS md_relax_table[] =
125 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 17: TEXT_OFFSET. */
126 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 18: TEXT_PC_OFFSET. */
127 // { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 16: TLSTPREL_OFFSET. */
128- { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 } /* 17: DEFINED_64_OFFSET. */
129+ { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 } /* 19: DEFINED_64_OFFSET. */
130+ { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE*2, 0 } /* 20: DEFINED_64_PC_OFFSET. */
131 };
132
133 static struct hash_control * opcode_hash_control; /* Opcode mnemonics. */
134@@ -1180,33 +1182,6 @@ md_assemble (char * str)
135 inst |= (immed << IMM_LOW) & IMM_MASK;
136 }
137 }
138-#if 0 //revisit
139- else if (streq (name, "lli") || streq (name, "sli"))
140- {
141- temp = immed & 0xFFFFFFFFFFFF8000;
142- if ((temp != 0) && (temp != 0xFFFFFFFFFFFF8000))
143- {
144- /* Needs an immediate inst. */
145- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
146- if (opcode1 == NULL)
147- {
148- as_bad (_("unknown opcode \"%s\""), "imml");
149- return;
150- }
151-
152- inst1 = opcode1->bit_sequence;
153- inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
154- output[0] = INST_BYTE0 (inst1);
155- output[1] = INST_BYTE1 (inst1);
156- output[2] = INST_BYTE2 (inst1);
157- output[3] = INST_BYTE3 (inst1);
158- output = frag_more (isize);
159- }
160- inst |= (reg1 << RD_LOW) & RD_MASK;
161- inst |= (reg2 << RA_LOW) & RA_MASK;
162- inst |= (immed << IMM_LOW) & IMM_MASK;
163- }
164-#endif
165 else
166 {
167 temp = immed & 0xFFFF8000;
168@@ -1958,8 +1933,8 @@ md_assemble (char * str)
169
170 if (exp.X_op != O_constant)
171 {
172- char *opc = NULL;
173- //char *opc = str_microblaze_64;
174+ //char *opc = NULL;
175+ char *opc = str_microblaze_64;
176 relax_substateT subtype;
177
178 if (exp.X_md != 0)
179@@ -2221,13 +2196,19 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
180 fragP->fr_fix += INST_WORD_SIZE * 2;
181 fragP->fr_var = 0;
182 break;
183+ case DEFINED_64_PC_OFFSET:
184+ fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
185+ fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_PCREL);
186+ fragP->fr_fix += INST_WORD_SIZE * 2;
187+ fragP->fr_var = 0;
188+ break;
189 case DEFINED_64_OFFSET:
190 if (fragP->fr_symbol == GOT_symbol)
191 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
192- fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_GPC);
193+ fragP->fr_offset, FALSE, BFD_RELOC_MICROBLAZE_64_GPC);
194 else
195 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE, fragP->fr_symbol,
196- fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64);
197+ fragP->fr_offset, FALSE, BFD_RELOC_MICROBLAZE_64);
198 fragP->fr_fix += INST_WORD_SIZE * 2;
199 fragP->fr_var = 0;
200 break;
201@@ -2237,7 +2218,7 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
202 fragP->fr_offset, TRUE, BFD_RELOC_MICROBLAZE_64_GOTPC);
203 else
204 fix_new (fragP, fragP->fr_fix, INST_WORD_SIZE * 2, fragP->fr_symbol,
205- fragP->fr_offset, TRUE, BFD_RELOC_64);
206+ fragP->fr_offset, FALSE, BFD_RELOC_64);
207 fragP->fr_fix += INST_WORD_SIZE * 2;
208 fragP->fr_var = 0;
209 break;
210@@ -2457,14 +2438,17 @@ md_apply_fix (fixS * fixP,
211 }
212 }
213 break;
214+
215 case BFD_RELOC_64_PCREL:
216 case BFD_RELOC_64:
217 case BFD_RELOC_MICROBLAZE_64_TEXTREL:
218 case BFD_RELOC_MICROBLAZE_64:
219+ case BFD_RELOC_MICROBLAZE_64_PCREL:
220 /* Add an imm instruction. First save the current instruction. */
221 for (i = 0; i < INST_WORD_SIZE; i++)
222 buf[i + INST_WORD_SIZE] = buf[i];
223- if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
224+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64
225+ || fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
226 {
227 /* Generate the imm instruction. */
228 opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
229@@ -2477,6 +2461,10 @@ md_apply_fix (fixS * fixP,
230 inst1 = opcode1->bit_sequence;
231 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
232 inst1 |= ((val & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
233+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
234+ fixP->fx_r_type = BFD_RELOC_64;
235+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
236+ fixP->fx_r_type = BFD_RELOC_64_PCREL;
237 }
238 else
239 {
240@@ -2487,7 +2475,7 @@ md_apply_fix (fixS * fixP,
241 as_bad (_("unknown opcode \"%s\""), "imm");
242 return;
243 }
244-
245+
246 inst1 = opcode1->bit_sequence;
247 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
248 inst1 |= ((val & 0xFFFF0000) >> 16) & IMM_MASK;
249@@ -2534,7 +2522,7 @@ md_apply_fix (fixS * fixP,
250 opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
251 if (opcode1 == NULL)
252 {
253- if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
254+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
255 as_bad (_("unknown opcode \"%s\""), "imml");
256 else
257 as_bad (_("unknown opcode \"%s\""), "imm");
258@@ -2561,8 +2549,6 @@ md_apply_fix (fixS * fixP,
259 moves code around due to relaxing. */
260 if (fixP->fx_r_type == BFD_RELOC_64_PCREL)
261 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
262- if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
263- fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
264 else if (fixP->fx_r_type == BFD_RELOC_32)
265 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_32_NONE;
266 else
267@@ -2613,33 +2599,24 @@ md_estimate_size_before_relax (fragS * fragP,
268 if(streq (fragP->fr_opcode, str_microblaze_64))
269 {
270 /* Used as an absolute value. */
271- fragP->fr_subtype = DEFINED_64_OFFSET;
272+ fragP->fr_subtype = DEFINED_64_PC_OFFSET;
273 /* Variable part does not change. */
274- fragP->fr_var = INST_WORD_SIZE;
275+ fragP->fr_var = INST_WORD_SIZE*2;
276 }
277 else
278 {
279 fragP->fr_subtype = DEFINED_PC_OFFSET;
280- /* Don't know now whether we need an imm instruction. */
281+ /* Don't know now whether we need an imm instruction. */
282 fragP->fr_var = INST_WORD_SIZE;
283 }
284 }
285 else
286 {
287 fragP->fr_subtype = DEFINED_PC_OFFSET;
288- /* Don't know now whether we need an imm instruction. */
289+ /* Don't know now whether we need an imm instruction. */
290 fragP->fr_var = INST_WORD_SIZE;
291 }
292 }
293- #if 0
294- else if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type &&
295- !S_IS_WEAK (fragP->fr_symbol))
296- {
297- fragP->fr_subtype = DEFINED_PC_OFFSET;
298- /* Don't know now whether we need an imm instruction. */
299- fragP->fr_var = INST_WORD_SIZE;
300- }
301-#endif
302 else if (S_IS_DEFINED (fragP->fr_symbol)
303 && (((S_GET_SEGMENT (fragP->fr_symbol))->flags & SEC_CODE) == 0))
304 {
305@@ -2669,6 +2646,13 @@ md_estimate_size_before_relax (fragS * fragP,
306 /* Variable part does not change. */
307 fragP->fr_var = INST_WORD_SIZE*2;
308 }
309+ else if (streq (fragP->fr_opcode, str_microblaze_64))
310+ {
311+ /* Used as an absolute value. */
312+ fragP->fr_subtype = DEFINED_64_OFFSET;
313+ /* Variable part does not change. */
314+ fragP->fr_var = INST_WORD_SIZE;
315+ }
316 else if (streq (fragP->fr_opcode, str_microblaze_ro_anchor))
317 {
318 /* It is accessed using the small data read only anchor. */
319@@ -2743,6 +2727,7 @@ md_estimate_size_before_relax (fragS * fragP,
320 case TLSTPREL_OFFSET:
321 case TLSDTPREL_OFFSET:
322 case DEFINED_64_OFFSET:
323+ case DEFINED_64_PC_OFFSET:
324 fragP->fr_var = INST_WORD_SIZE*2;
325 break;
326 case DEFINED_RO_SEGMENT:
327@@ -2796,7 +2781,7 @@ md_pcrel_from_section (fixS * fixp, segT sec ATTRIBUTE_UNUSED)
328 else
329 {
330 /* The case where we are going to resolve things... */
331- if (fixp->fx_r_type == BFD_RELOC_64_PCREL ||fixp->fx_r_type == BFD_RELOC_MICROBLAZE_64)
332+ if (fixp->fx_r_type == BFD_RELOC_64_PCREL ||fixp->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
333 return fixp->fx_where + fixp->fx_frag->fr_address + INST_WORD_SIZE;
334 else
335 return fixp->fx_where + fixp->fx_frag->fr_address;
336@@ -2831,6 +2816,7 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
337 case BFD_RELOC_MICROBLAZE_64_GOTPC:
338 case BFD_RELOC_MICROBLAZE_64_GPC:
339 case BFD_RELOC_MICROBLAZE_64:
340+ case BFD_RELOC_MICROBLAZE_64_PCREL:
341 case BFD_RELOC_MICROBLAZE_64_GOT:
342 case BFD_RELOC_MICROBLAZE_64_PLT:
343 case BFD_RELOC_MICROBLAZE_64_GOTOFF:
344--
3452.17.1
346
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0019-Fixed-MB-x-relocation-issues.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0019-Fixed-MB-x-relocation-issues.patch
new file mode 100644
index 00000000..edbfac0c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0019-Fixed-MB-x-relocation-issues.patch
@@ -0,0 +1,373 @@
1From bb6c70cfa1402a685995103ac90e7ceeccdd0991 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/43] -Fixed MB-x relocation issues -Added imml for required
5 MB-x instructions
6
7---
8 bfd/elf64-microblaze.c | 68 ++++++++++++++---
9 gas/config/tc-microblaze.c | 152 +++++++++++++++++++++++++++----------
10 gas/tc.h | 2 +-
11 3 files changed, 167 insertions(+), 55 deletions(-)
12
13diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
14index 56a45f2a05..54a2461037 100644
15--- a/bfd/elf64-microblaze.c
16+++ b/bfd/elf64-microblaze.c
17@@ -1476,8 +1476,17 @@ microblaze_elf_relocate_section (bfd *output_bfd,
18 relocation -= (input_section->output_section->vma
19 + input_section->output_offset
20 + offset + INST_WORD_SIZE);
21- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
22+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
23+ if (insn == 0xb2000000 || insn == 0xb2ffffff)
24+ {
25+ insn &= ~0x00ffffff;
26+ insn |= (relocation >> 16) & 0xffffff;
27+ bfd_put_32 (input_bfd, insn,
28 contents + offset + endian);
29+ }
30+ else
31+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
32+ contents + offset + endian);
33 bfd_put_16 (input_bfd, relocation & 0xffff,
34 contents + offset + endian + INST_WORD_SIZE);
35 }
36@@ -1567,11 +1576,28 @@ microblaze_elf_relocate_section (bfd *output_bfd,
37 else
38 {
39 if (r_type == R_MICROBLAZE_64_PCREL)
40- relocation -= (input_section->output_section->vma
41- + input_section->output_offset
42- + offset + INST_WORD_SIZE);
43- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
44+ {
45+ if (!input_section->output_section->vma &&
46+ !input_section->output_offset && !offset)
47+ relocation -= (input_section->output_section->vma
48+ + input_section->output_offset
49+ + offset);
50+ else
51+ relocation -= (input_section->output_section->vma
52+ + input_section->output_offset
53+ + offset + INST_WORD_SIZE);
54+ }
55+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
56+ if (insn == 0xb2000000 || insn == 0xb2ffffff)
57+ {
58+ insn &= ~0x00ffffff;
59+ insn |= (relocation >> 16) & 0xffffff;
60+ bfd_put_32 (input_bfd, insn,
61 contents + offset + endian);
62+ }
63+ else
64+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
65+ contents + offset + endian);
66 bfd_put_16 (input_bfd, relocation & 0xffff,
67 contents + offset + endian + INST_WORD_SIZE);
68 }
69@@ -1690,9 +1716,19 @@ static void
70 microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
71 {
72 unsigned long instr = bfd_get_32 (abfd, bfd_addr);
73- instr &= ~0x0000ffff;
74- instr |= (val & 0x0000ffff);
75- bfd_put_32 (abfd, instr, bfd_addr);
76+
77+ if (instr == 0xb2000000 || instr == 0xb2ffffff)
78+ {
79+ instr &= ~0x00ffffff;
80+ instr |= (val & 0xffffff);
81+ bfd_put_32 (abfd, instr, bfd_addr);
82+ }
83+ else
84+ {
85+ instr &= ~0x0000ffff;
86+ instr |= (val & 0x0000ffff);
87+ bfd_put_32 (abfd, instr, bfd_addr);
88+ }
89 }
90
91 /* Read-modify-write into the bfd, an immediate value into appropriate fields of
92@@ -1704,10 +1740,18 @@ microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
93 unsigned long instr_lo;
94
95 instr_hi = bfd_get_32 (abfd, bfd_addr);
96- instr_hi &= ~0x0000ffff;
97- instr_hi |= ((val >> 16) & 0x0000ffff);
98- bfd_put_32 (abfd, instr_hi, bfd_addr);
99-
100+ if (instr_hi == 0xb2000000 || instr_hi == 0xb2ffffff)
101+ {
102+ instr_hi &= ~0x00ffffff;
103+ instr_hi |= (val >> 16) & 0xffffff;
104+ bfd_put_32 (abfd, instr_hi,bfd_addr);
105+ }
106+ else
107+ {
108+ instr_hi &= ~0x0000ffff;
109+ instr_hi |= ((val >> 16) & 0x0000ffff);
110+ bfd_put_32 (abfd, instr_hi, bfd_addr);
111+ }
112 instr_lo = bfd_get_32 (abfd, bfd_addr + INST_WORD_SIZE);
113 instr_lo &= ~0x0000ffff;
114 instr_lo |= (val & 0x0000ffff);
115diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
116index 587a4d56ec..fa437b6c98 100644
117--- a/gas/config/tc-microblaze.c
118+++ b/gas/config/tc-microblaze.c
119@@ -392,7 +392,7 @@ microblaze_s_weakext (int ignore ATTRIBUTE_UNUSED)
120 Integer arg to pass to the function. */
121 /* If the pseudo-op is not found in this table, it searches in the obj-elf.c,
122 and then in the read.c table. */
123-const pseudo_typeS md_pseudo_table[] =
124+pseudo_typeS md_pseudo_table[] =
125 {
126 {"lcomm", microblaze_s_lcomm, 1},
127 {"data", microblaze_s_data, 0},
128@@ -401,7 +401,7 @@ const pseudo_typeS md_pseudo_table[] =
129 {"data32", cons, 4}, /* Same as word. */
130 {"ent", s_func, 0}, /* Treat ent as function entry point. */
131 {"end", microblaze_s_func, 1}, /* Treat end as function end point. */
132- {"gpword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
133+ {"gpword", s_rva, 4}, /* gpword label => store resolved label address in data section. */
134 {"gpdword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
135 {"weakext", microblaze_s_weakext, 0},
136 {"rodata", microblaze_s_rdata, 0},
137@@ -996,7 +996,7 @@ md_assemble (char * str)
138 unsigned reg2;
139 unsigned reg3;
140 unsigned isize;
141- unsigned int immed, immed2, temp;
142+ unsigned long immed, immed2, temp;
143 expressionS exp;
144 char name[20];
145 long immedl;
146@@ -1118,8 +1118,9 @@ md_assemble (char * str)
147 as_fatal (_("lmi pseudo instruction should not use a label in imm field"));
148 else if (streq (name, "smi"))
149 as_fatal (_("smi pseudo instruction should not use a label in imm field"));
150-
151- if (reg2 == REG_ROSDP)
152+ if(streq (name, "lli") || streq (name, "sli"))
153+ opc = str_microblaze_64;
154+ else if (reg2 == REG_ROSDP)
155 opc = str_microblaze_ro_anchor;
156 else if (reg2 == REG_RWSDP)
157 opc = str_microblaze_rw_anchor;
158@@ -1182,31 +1183,55 @@ md_assemble (char * str)
159 inst |= (immed << IMM_LOW) & IMM_MASK;
160 }
161 }
162- else
163- {
164- temp = immed & 0xFFFF8000;
165- if ((temp != 0) && (temp != 0xFFFF8000))
166- {
167+ else if (streq (name, "lli") || streq (name, "sli"))
168+ {
169+ temp = immed & 0xFFFFFF8000;
170+ if (temp != 0 && temp != 0xFFFFFF8000)
171+ {
172 /* Needs an immediate inst. */
173- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
174+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
175 if (opcode1 == NULL)
176 {
177- as_bad (_("unknown opcode \"%s\""), "imm");
178+ as_bad (_("unknown opcode \"%s\""), "imml");
179 return;
180 }
181-
182 inst1 = opcode1->bit_sequence;
183- inst1 |= ((immed & 0xFFFF0000) >> 16) & IMM_MASK;
184+ inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
185 output[0] = INST_BYTE0 (inst1);
186 output[1] = INST_BYTE1 (inst1);
187 output[2] = INST_BYTE2 (inst1);
188 output[3] = INST_BYTE3 (inst1);
189 output = frag_more (isize);
190- }
191- inst |= (reg1 << RD_LOW) & RD_MASK;
192- inst |= (reg2 << RA_LOW) & RA_MASK;
193- inst |= (immed << IMM_LOW) & IMM_MASK;
194- }
195+ }
196+ inst |= (reg1 << RD_LOW) & RD_MASK;
197+ inst |= (reg2 << RA_LOW) & RA_MASK;
198+ inst |= (immed << IMM_LOW) & IMM_MASK;
199+ }
200+ else
201+ {
202+ temp = immed & 0xFFFF8000;
203+ if ((temp != 0) && (temp != 0xFFFF8000))
204+ {
205+ /* Needs an immediate inst. */
206+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
207+ if (opcode1 == NULL)
208+ {
209+ as_bad (_("unknown opcode \"%s\""), "imm");
210+ return;
211+ }
212+
213+ inst1 = opcode1->bit_sequence;
214+ inst1 |= ((immed & 0xFFFF0000) >> 16) & IMM_MASK;
215+ output[0] = INST_BYTE0 (inst1);
216+ output[1] = INST_BYTE1 (inst1);
217+ output[2] = INST_BYTE2 (inst1);
218+ output[3] = INST_BYTE3 (inst1);
219+ output = frag_more (isize);
220+ }
221+ inst |= (reg1 << RD_LOW) & RD_MASK;
222+ inst |= (reg2 << RA_LOW) & RA_MASK;
223+ inst |= (immed << IMM_LOW) & IMM_MASK;
224+ }
225 break;
226
227 case INST_TYPE_RD_R1_IMMS:
228@@ -1832,12 +1857,20 @@ md_assemble (char * str)
229 case INST_TYPE_IMM:
230 if (streq (name, "imm"))
231 as_fatal (_("An IMM instruction should not be present in the .s file"));
232-
233- op_end = parse_imm (op_end + 1, & exp, MIN_IMM, MAX_IMM);
234+ if (microblaze_arch_size == 64)
235+ op_end = parse_imml (op_end + 1, & exp, MIN_IMML, MAX_IMML);
236+ else
237+ op_end = parse_imm (op_end + 1, & exp, MIN_IMM, MAX_IMM);
238
239 if (exp.X_op != O_constant)
240 {
241- char *opc = NULL;
242+ char *opc;
243+ if (microblaze_arch_size == 64 && (streq (name, "breai") ||
244+ streq (name, "breaid") ||
245+ streq (name, "brai") || streq (name, "braid")))
246+ opc = str_microblaze_64;
247+ else
248+ opc = NULL;
249 relax_substateT subtype;
250
251 if (exp.X_md != 0)
252@@ -1860,27 +1893,54 @@ md_assemble (char * str)
253 immed = exp.X_add_number;
254 }
255
256+ if (microblaze_arch_size == 64 && (streq (name, "breai") ||
257+ streq (name, "breaid") ||
258+ streq (name, "brai") || streq (name, "braid")))
259+ {
260+ temp = immed & 0xFFFFFF8000;
261+ if (temp != 0)
262+ {
263+ /* Needs an immediate inst. */
264+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
265+ if (opcode1 == NULL)
266+ {
267+ as_bad (_("unknown opcode \"%s\""), "imml");
268+ return;
269+ }
270
271- temp = immed & 0xFFFF8000;
272- if ((temp != 0) && (temp != 0xFFFF8000))
273- {
274- /* Needs an immediate inst. */
275- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
276- if (opcode1 == NULL)
277- {
278- as_bad (_("unknown opcode \"%s\""), "imm");
279- return;
280+ inst1 = opcode1->bit_sequence;
281+ inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
282+ output[0] = INST_BYTE0 (inst1);
283+ output[1] = INST_BYTE1 (inst1);
284+ output[2] = INST_BYTE2 (inst1);
285+ output[3] = INST_BYTE3 (inst1);
286+ output = frag_more (isize);
287 }
288+ inst |= (immed << IMM_LOW) & IMM_MASK;
289+ }
290+ else
291+ {
292+ temp = immed & 0xFFFF8000;
293+ if ((temp != 0) && (temp != 0xFFFF8000))
294+ {
295+ /* Needs an immediate inst. */
296+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
297+ if (opcode1 == NULL)
298+ {
299+ as_bad (_("unknown opcode \"%s\""), "imm");
300+ return;
301+ }
302
303- inst1 = opcode1->bit_sequence;
304- inst1 |= ((immed & 0xFFFF0000) >> 16) & IMM_MASK;
305- output[0] = INST_BYTE0 (inst1);
306- output[1] = INST_BYTE1 (inst1);
307- output[2] = INST_BYTE2 (inst1);
308- output[3] = INST_BYTE3 (inst1);
309- output = frag_more (isize);
310- }
311- inst |= (immed << IMM_LOW) & IMM_MASK;
312+ inst1 = opcode1->bit_sequence;
313+ inst1 |= ((immed & 0xFFFF0000) >> 16) & IMM_MASK;
314+ output[0] = INST_BYTE0 (inst1);
315+ output[1] = INST_BYTE1 (inst1);
316+ output[2] = INST_BYTE2 (inst1);
317+ output[3] = INST_BYTE3 (inst1);
318+ output = frag_more (isize);
319+ }
320+ inst |= (immed << IMM_LOW) & IMM_MASK;
321+ }
322 break;
323
324 case INST_TYPE_NONE:
325@@ -2460,7 +2520,7 @@ md_apply_fix (fixS * fixP,
326
327 inst1 = opcode1->bit_sequence;
328 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
329- inst1 |= ((val & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
330+ inst1 |= ((val & 0xFFFFFF0000L) >> 16) & IMML_MASK;
331 if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
332 fixP->fx_r_type = BFD_RELOC_64;
333 if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
334@@ -2628,7 +2688,14 @@ md_estimate_size_before_relax (fragS * fragP,
335 }
336 else
337 {
338- fragP->fr_subtype = UNDEFINED_PC_OFFSET;
339+ if (fragP->fr_opcode != NULL) {
340+ if (streq (fragP->fr_opcode, str_microblaze_64))
341+ fragP->fr_subtype = DEFINED_64_PC_OFFSET;
342+ else
343+ fragP->fr_subtype = UNDEFINED_PC_OFFSET;
344+ }
345+ else
346+ fragP->fr_subtype = UNDEFINED_PC_OFFSET;
347 fragP->fr_var = INST_WORD_SIZE*2;
348 }
349 break;
350@@ -2905,6 +2972,7 @@ md_parse_option (int c, const char * arg ATTRIBUTE_UNUSED)
351 case OPTION_M64:
352 //if (arg != NULL && strcmp (arg, "64") == 0)
353 microblaze_arch_size = 64;
354+ md_pseudo_table[7].poc_val = 8;
355 break;
356 default:
357 return 0;
358diff --git a/gas/tc.h b/gas/tc.h
359index 0a50a6985b..529a73b43b 100644
360--- a/gas/tc.h
361+++ b/gas/tc.h
362@@ -22,7 +22,7 @@
363 /* In theory (mine, at least!) the machine dependent part of the assembler
364 should only have to include one file. This one. -- JF */
365
366-extern const pseudo_typeS md_pseudo_table[];
367+extern pseudo_typeS md_pseudo_table[];
368
369 const char * md_atof (int, char *, int *);
370 int md_parse_option (int, const char *);
371--
3722.17.1
373
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0020-Fixing-the-branch-related-issues.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0020-Fixing-the-branch-related-issues.patch
new file mode 100644
index 00000000..528c9279
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0020-Fixing-the-branch-related-issues.patch
@@ -0,0 +1,25 @@
1From 8375ef893eb327ae4a5dc9207041ffc0e9bc6e2b 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/43] Fixing the branch related issues
5
6---
7 bfd/elf64-microblaze.c | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-)
9
10diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
11index 54a2461037..e9b3cf3a86 100644
12--- a/bfd/elf64-microblaze.c
13+++ b/bfd/elf64-microblaze.c
14@@ -2532,7 +2532,7 @@ microblaze_elf_check_relocs (bfd * abfd,
15
16 /* PR15323, ref flags aren't set for references in the same
17 object. */
18- h->root.non_ir_ref = 1;
19+ h->root.non_ir_ref_regular = 1;
20 }
21
22 switch (r_type)
23--
242.17.1
25
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0021-Fixed-address-computation-issues-with-64bit-address.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0021-Fixed-address-computation-issues-with-64bit-address.patch
new file mode 100644
index 00000000..d62f0ed2
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0021-Fixed-address-computation-issues-with-64bit-address.patch
@@ -0,0 +1,220 @@
1From 9f13e07180c09f814665676ac6c04cb7a2cd7c11 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/43] - Fixed address computation issues with 64bit address -
5 Fixed imml dissassamble issue
6
7---
8 bfd/bfd-in2.h | 5 +++
9 bfd/elf64-microblaze.c | 14 ++++----
10 gas/config/tc-microblaze.c | 74 +++++++++++++++++++++++++++++++++-----
11 opcodes/microblaze-dis.c | 2 +-
12 4 files changed, 79 insertions(+), 16 deletions(-)
13
14diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
15index de46e78902..33c9cb62d9 100644
16--- a/bfd/bfd-in2.h
17+++ b/bfd/bfd-in2.h
18@@ -5881,6 +5881,11 @@ done here - only used for relaxing */
19 * +done here - only used for relaxing */
20 BFD_RELOC_MICROBLAZE_64,
21
22+/* This is a 64 bit reloc that stores the 32 bit relative
23+ * +value in two words (with an imml instruction). No relocation is
24+ * +done here - only used for relaxing */
25+ BFD_RELOC_MICROBLAZE_EA64,
26+
27 /* This is a 64 bit reloc that stores the 32 bit pc relative
28 * +value in two words (with an imm instruction). No relocation is
29 * +done here - only used for relaxing */
30diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
31index e9b3cf3a86..40f10aac6d 100644
32--- a/bfd/elf64-microblaze.c
33+++ b/bfd/elf64-microblaze.c
34@@ -121,15 +121,15 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
35 0, /* Rightshift. */
36 4, /* Size (0 = byte, 1 = short, 2 = long). */
37 64, /* Bitsize. */
38- TRUE, /* PC_relative. */
39+ FALSE, /* PC_relative. */
40 0, /* Bitpos. */
41 complain_overflow_dont, /* Complain on overflow. */
42 bfd_elf_generic_reloc,/* Special Function. */
43 "R_MICROBLAZE_IMML_64", /* Name. */
44 FALSE, /* Partial Inplace. */
45 0, /* Source Mask. */
46- 0x0000ffff, /* Dest Mask. */
47- TRUE), /* PC relative offset? */
48+ 0xffffffffffffff, /* Dest Mask. */
49+ FALSE), /* PC relative offset? */
50
51 /* A 64 bit relocation. Table entry not really used. */
52 HOWTO (R_MICROBLAZE_64, /* Type. */
53@@ -585,9 +585,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
54 case BFD_RELOC_32:
55 microblaze_reloc = R_MICROBLAZE_32;
56 break;
57- /* RVA is treated the same as 32 */
58+ /* RVA is treated the same as 64 */
59 case BFD_RELOC_RVA:
60- microblaze_reloc = R_MICROBLAZE_32;
61+ microblaze_reloc = R_MICROBLAZE_IMML_64;
62 break;
63 case BFD_RELOC_32_PCREL:
64 microblaze_reloc = R_MICROBLAZE_32_PCREL;
65@@ -619,7 +619,7 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
66 case BFD_RELOC_VTABLE_ENTRY:
67 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
68 break;
69- case BFD_RELOC_MICROBLAZE_64:
70+ case BFD_RELOC_MICROBLAZE_EA64:
71 microblaze_reloc = R_MICROBLAZE_IMML_64;
72 break;
73 case BFD_RELOC_MICROBLAZE_64_GOTPC:
74@@ -1969,7 +1969,7 @@ microblaze_elf_relax_section (bfd *abfd,
75 efix = calc_fixup (target_address, 0, sec);
76
77 /* Validate the in-band val. */
78- val = bfd_get_32 (abfd, contents + irel->r_offset);
79+ val = bfd_get_64 (abfd, contents + irel->r_offset);
80 if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
81 fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
82 }
83diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
84index fa437b6c98..46df32e72f 100644
85--- a/gas/config/tc-microblaze.c
86+++ b/gas/config/tc-microblaze.c
87@@ -402,7 +402,6 @@ pseudo_typeS md_pseudo_table[] =
88 {"ent", s_func, 0}, /* Treat ent as function entry point. */
89 {"end", microblaze_s_func, 1}, /* Treat end as function end point. */
90 {"gpword", s_rva, 4}, /* gpword label => store resolved label address in data section. */
91- {"gpdword", s_rva, 8}, /* gpword label => store resolved label address in data section. */
92 {"weakext", microblaze_s_weakext, 0},
93 {"rodata", microblaze_s_rdata, 0},
94 {"sdata2", microblaze_s_rdata, 1},
95@@ -2479,18 +2478,74 @@ md_apply_fix (fixS * fixP,
96 case BFD_RELOC_RVA:
97 case BFD_RELOC_32_PCREL:
98 case BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM:
99+ /* Don't do anything if the symbol is not defined. */
100+ if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
101+ {
102+ if ((fixP->fx_r_type == BFD_RELOC_RVA) && (microblaze_arch_size == 64))
103+ {
104+ if (target_big_endian)
105+ {
106+ buf[0] |= ((val >> 56) & 0xff);
107+ buf[1] |= ((val >> 48) & 0xff);
108+ buf[2] |= ((val >> 40) & 0xff);
109+ buf[3] |= ((val >> 32) & 0xff);
110+ buf[4] |= ((val >> 24) & 0xff);
111+ buf[5] |= ((val >> 16) & 0xff);
112+ buf[6] |= ((val >> 8) & 0xff);
113+ buf[7] |= (val & 0xff);
114+ }
115+ else
116+ {
117+ buf[7] |= ((val >> 56) & 0xff);
118+ buf[6] |= ((val >> 48) & 0xff);
119+ buf[5] |= ((val >> 40) & 0xff);
120+ buf[4] |= ((val >> 32) & 0xff);
121+ buf[3] |= ((val >> 24) & 0xff);
122+ buf[2] |= ((val >> 16) & 0xff);
123+ buf[1] |= ((val >> 8) & 0xff);
124+ buf[0] |= (val & 0xff);
125+ }
126+ }
127+ else {
128+ if (target_big_endian)
129+ {
130+ buf[0] |= ((val >> 24) & 0xff);
131+ buf[1] |= ((val >> 16) & 0xff);
132+ buf[2] |= ((val >> 8) & 0xff);
133+ buf[3] |= (val & 0xff);
134+ }
135+ else
136+ {
137+ buf[3] |= ((val >> 24) & 0xff);
138+ buf[2] |= ((val >> 16) & 0xff);
139+ buf[1] |= ((val >> 8) & 0xff);
140+ buf[0] |= (val & 0xff);
141+ }
142+ }
143+ }
144+ break;
145+
146+ case BFD_RELOC_MICROBLAZE_EA64:
147 /* Don't do anything if the symbol is not defined. */
148 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
149 {
150 if (target_big_endian)
151 {
152- buf[0] |= ((val >> 24) & 0xff);
153- buf[1] |= ((val >> 16) & 0xff);
154- buf[2] |= ((val >> 8) & 0xff);
155- buf[3] |= (val & 0xff);
156+ buf[0] |= ((val >> 56) & 0xff);
157+ buf[1] |= ((val >> 48) & 0xff);
158+ buf[2] |= ((val >> 40) & 0xff);
159+ buf[3] |= ((val >> 32) & 0xff);
160+ buf[4] |= ((val >> 24) & 0xff);
161+ buf[5] |= ((val >> 16) & 0xff);
162+ buf[6] |= ((val >> 8) & 0xff);
163+ buf[7] |= (val & 0xff);
164 }
165 else
166 {
167+ buf[7] |= ((val >> 56) & 0xff);
168+ buf[6] |= ((val >> 48) & 0xff);
169+ buf[5] |= ((val >> 40) & 0xff);
170+ buf[4] |= ((val >> 32) & 0xff);
171 buf[3] |= ((val >> 24) & 0xff);
172 buf[2] |= ((val >> 16) & 0xff);
173 buf[1] |= ((val >> 8) & 0xff);
174@@ -2611,6 +2666,8 @@ md_apply_fix (fixS * fixP,
175 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE;
176 else if (fixP->fx_r_type == BFD_RELOC_32)
177 fixP->fx_r_type = BFD_RELOC_MICROBLAZE_32_NONE;
178+ else if(fixP->fx_r_type == BFD_RELOC_MICROBLAZE_EA64)
179+ fixP->fx_r_type = BFD_RELOC_MICROBLAZE_EA64;
180 else
181 fixP->fx_r_type = BFD_RELOC_NONE;
182 fixP->fx_addsy = section_symbol (absolute_section);
183@@ -2882,6 +2939,7 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
184 case BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM:
185 case BFD_RELOC_MICROBLAZE_64_GOTPC:
186 case BFD_RELOC_MICROBLAZE_64_GPC:
187+ case BFD_RELOC_MICROBLAZE_EA64:
188 case BFD_RELOC_MICROBLAZE_64:
189 case BFD_RELOC_MICROBLAZE_64_PCREL:
190 case BFD_RELOC_MICROBLAZE_64_GOT:
191@@ -3027,10 +3085,10 @@ cons_fix_new_microblaze (fragS * frag,
192 r = BFD_RELOC_32;
193 break;
194 case 8:
195- if (microblaze_arch_size == 64)
196+ /*if (microblaze_arch_size == 64)
197 r = BFD_RELOC_32;
198- else
199- r = BFD_RELOC_64;
200+ else*/
201+ r = BFD_RELOC_MICROBLAZE_EA64;
202 break;
203 default:
204 as_bad (_("unsupported BFD relocation size %u"), size);
205diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
206index 20ea6a885a..f679a43606 100644
207--- a/opcodes/microblaze-dis.c
208+++ b/opcodes/microblaze-dis.c
209@@ -61,7 +61,7 @@ get_field_imml (long instr)
210 {
211 char tmpstr[25];
212
213- sprintf (tmpstr, "%d", (short)((instr & IMML_MASK) >> IMM_LOW));
214+ sprintf (tmpstr, "%d", (int)((instr & IMML_MASK) >> IMM_LOW));
215 return (strdup (tmpstr));
216 }
217
218--
2192.17.1
220
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0022-Adding-new-relocation-to-support-64bit-rodata.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0022-Adding-new-relocation-to-support-64bit-rodata.patch
new file mode 100644
index 00000000..ec82926d
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0022-Adding-new-relocation-to-support-64bit-rodata.patch
@@ -0,0 +1,166 @@
1From beeceebb05a4eeaeca697f4ba7e214485b10369a 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/43] Adding new relocation to support 64bit rodata
5
6---
7 bfd/elf64-microblaze.c | 11 +++++++--
8 gas/config/tc-microblaze.c | 49 ++++++++++++++++++++++++++++++++++----
9 2 files changed, 54 insertions(+), 6 deletions(-)
10
11diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
12index 40f10aac6d..4d9b90647f 100644
13--- a/bfd/elf64-microblaze.c
14+++ b/bfd/elf64-microblaze.c
15@@ -1461,6 +1461,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
16 case (int) R_MICROBLAZE_64_PCREL :
17 case (int) R_MICROBLAZE_64:
18 case (int) R_MICROBLAZE_32:
19+ case (int) R_MICROBLAZE_IMML_64:
20 {
21 /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
22 from removed linkonce sections, or sections discarded by
23@@ -1470,6 +1471,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
24 relocation += addend;
25 if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
26 bfd_put_32 (input_bfd, relocation, contents + offset);
27+ else if (r_type == R_MICROBLAZE_IMML_64)
28+ bfd_put_64 (input_bfd, relocation, contents + offset);
29 else
30 {
31 if (r_type == R_MICROBLAZE_64_PCREL)
32@@ -1547,7 +1550,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
33 }
34 else
35 {
36- if (r_type == R_MICROBLAZE_32)
37+ if (r_type == R_MICROBLAZE_32 || r_type == R_MICROBLAZE_IMML_64)
38 {
39 outrel.r_info = ELF64_R_INFO (0, R_MICROBLAZE_REL);
40 outrel.r_addend = relocation + addend;
41@@ -1573,6 +1576,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
42 relocation += addend;
43 if (r_type == R_MICROBLAZE_32)
44 bfd_put_32 (input_bfd, relocation, contents + offset);
45+ else if (r_type == R_MICROBLAZE_IMML_64)
46+ bfd_put_64 (input_bfd, relocation, contents + offset + endian);
47 else
48 {
49 if (r_type == R_MICROBLAZE_64_PCREL)
50@@ -2085,7 +2090,8 @@ microblaze_elf_relax_section (bfd *abfd,
51 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
52 irelscan->r_addend);
53 }
54- if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
55+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32
56+ || ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64)
57 {
58 isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
59
60@@ -2591,6 +2597,7 @@ microblaze_elf_check_relocs (bfd * abfd,
61 case R_MICROBLAZE_64:
62 case R_MICROBLAZE_64_PCREL:
63 case R_MICROBLAZE_32:
64+ case R_MICROBLAZE_IMML_64:
65 {
66 if (h != NULL && !bfd_link_pic (info))
67 {
68diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
69index 46df32e72f..c6d2e4c82d 100644
70--- a/gas/config/tc-microblaze.c
71+++ b/gas/config/tc-microblaze.c
72@@ -1119,6 +1119,13 @@ md_assemble (char * str)
73 as_fatal (_("smi pseudo instruction should not use a label in imm field"));
74 if(streq (name, "lli") || streq (name, "sli"))
75 opc = str_microblaze_64;
76+ else if ((microblaze_arch_size == 64) && ((streq (name, "lbui")
77+ || streq (name, "lhui") || streq (name, "lwi") || streq (name, "sbi")
78+ || streq (name, "shi") || streq (name, "swi"))))
79+ {
80+ opc = str_microblaze_64;
81+ subtype = opcode->inst_offset_type;
82+ }
83 else if (reg2 == REG_ROSDP)
84 opc = str_microblaze_ro_anchor;
85 else if (reg2 == REG_RWSDP)
86@@ -1182,7 +1189,10 @@ md_assemble (char * str)
87 inst |= (immed << IMM_LOW) & IMM_MASK;
88 }
89 }
90- else if (streq (name, "lli") || streq (name, "sli"))
91+ else if (streq (name, "lli") || streq (name, "sli") || ((microblaze_arch_size == 64)
92+ && ((streq (name, "lbui")) || streq (name, "lhui")
93+ || streq (name, "lwi") || streq (name, "sbi")
94+ || streq (name, "shi") || streq (name, "swi"))))
95 {
96 temp = immed & 0xFFFFFF8000;
97 if (temp != 0 && temp != 0xFFFFFF8000)
98@@ -1794,6 +1804,11 @@ md_assemble (char * str)
99
100 if (exp.X_md != 0)
101 subtype = get_imm_otype(exp.X_md);
102+ else if (streq (name, "brealid") || streq (name, "breaid") || streq (name, "breai"))
103+ {
104+ opc = str_microblaze_64;
105+ subtype = opcode->inst_offset_type;
106+ }
107 else
108 subtype = opcode->inst_offset_type;
109
110@@ -1811,6 +1826,31 @@ md_assemble (char * str)
111 output = frag_more (isize);
112 immed = exp.X_add_number;
113 }
114+ if (streq (name, "brealid") || streq (name, "breaid") || streq (name, "breai"))
115+ {
116+ temp = immed & 0xFFFFFF8000;
117+ if (temp != 0 && temp != 0xFFFFFF8000)
118+ {
119+ /* Needs an immediate inst. */
120+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
121+ if (opcode1 == NULL)
122+ {
123+ as_bad (_("unknown opcode \"%s\""), "imml");
124+ return;
125+ }
126+ inst1 = opcode1->bit_sequence;
127+ inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
128+ output[0] = INST_BYTE0 (inst1);
129+ output[1] = INST_BYTE1 (inst1);
130+ output[2] = INST_BYTE2 (inst1);
131+ output[3] = INST_BYTE3 (inst1);
132+ output = frag_more (isize);
133+ }
134+ inst |= (reg1 << RD_LOW) & RD_MASK;
135+ inst |= (immed << IMM_LOW) & IMM_MASK;
136+ }
137+ else
138+ {
139
140 temp = immed & 0xFFFF8000;
141 if ((temp != 0) && (temp != 0xFFFF8000))
142@@ -1834,6 +1874,7 @@ md_assemble (char * str)
143
144 inst |= (reg1 << RD_LOW) & RD_MASK;
145 inst |= (immed << IMM_LOW) & IMM_MASK;
146+ }
147 break;
148
149 case INST_TYPE_R2:
150@@ -3085,10 +3126,10 @@ cons_fix_new_microblaze (fragS * frag,
151 r = BFD_RELOC_32;
152 break;
153 case 8:
154- /*if (microblaze_arch_size == 64)
155- r = BFD_RELOC_32;
156- else*/
157+ if (microblaze_arch_size == 64)
158 r = BFD_RELOC_MICROBLAZE_EA64;
159+ else
160+ r = BFD_RELOC_64;
161 break;
162 default:
163 as_bad (_("unsupported BFD relocation size %u"), size);
164--
1652.17.1
166
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0023-fixing-the-.bss-relocation-issue.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0023-fixing-the-.bss-relocation-issue.patch
new file mode 100644
index 00000000..d1ec5dbf
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0023-fixing-the-.bss-relocation-issue.patch
@@ -0,0 +1,76 @@
1From 3f031961082caec9e172ff0224a51c08ab6e19c3 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/43] fixing the .bss relocation issue
5
6---
7 bfd/elf64-microblaze.c | 18 ++++++++++++------
8 1 file changed, 12 insertions(+), 6 deletions(-)
9
10diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
11index 4d9b90647f..184b7d560d 100644
12--- a/bfd/elf64-microblaze.c
13+++ b/bfd/elf64-microblaze.c
14@@ -1480,7 +1480,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
15 + input_section->output_offset
16 + offset + INST_WORD_SIZE);
17 unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
18- if (insn == 0xb2000000 || insn == 0xb2ffffff)
19+ if ((insn & 0xff000000) == 0xb2000000)
20 {
21 insn &= ~0x00ffffff;
22 insn |= (relocation >> 16) & 0xffffff;
23@@ -1593,7 +1593,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
24 + offset + INST_WORD_SIZE);
25 }
26 unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
27- if (insn == 0xb2000000 || insn == 0xb2ffffff)
28+ if ((insn & 0xff000000) == 0xb2000000)
29 {
30 insn &= ~0x00ffffff;
31 insn |= (relocation >> 16) & 0xffffff;
32@@ -1722,7 +1722,7 @@ microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
33 {
34 unsigned long instr = bfd_get_32 (abfd, bfd_addr);
35
36- if (instr == 0xb2000000 || instr == 0xb2ffffff)
37+ if ((instr & 0xff000000) == 0xb2000000)
38 {
39 instr &= ~0x00ffffff;
40 instr |= (val & 0xffffff);
41@@ -1745,7 +1745,7 @@ microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
42 unsigned long instr_lo;
43
44 instr_hi = bfd_get_32 (abfd, bfd_addr);
45- if (instr_hi == 0xb2000000 || instr_hi == 0xb2ffffff)
46+ if ((instr_hi & 0xff000000) == 0xb2000000)
47 {
48 instr_hi &= ~0x00ffffff;
49 instr_hi |= (val >> 16) & 0xffffff;
50@@ -2238,7 +2238,10 @@ microblaze_elf_relax_section (bfd *abfd,
51 unsigned long instr_lo = bfd_get_32 (abfd, ocontents
52 + irelscan->r_offset
53 + INST_WORD_SIZE);
54- immediate = (instr_hi & 0x0000ffff) << 16;
55+ if ((instr_hi & 0xff000000) == 0xb2000000)
56+ immediate = (instr_hi & 0x00ffffff) << 24;
57+ else
58+ immediate = (instr_hi & 0x0000ffff) << 16;
59 immediate |= (instr_lo & 0x0000ffff);
60 offset = calc_fixup (irelscan->r_addend, 0, sec);
61 immediate -= offset;
62@@ -2282,7 +2285,10 @@ microblaze_elf_relax_section (bfd *abfd,
63 unsigned long instr_lo = bfd_get_32 (abfd, ocontents
64 + irelscan->r_offset
65 + INST_WORD_SIZE);
66- immediate = (instr_hi & 0x0000ffff) << 16;
67+ if ((instr_hi & 0xff000000) == 0xb2000000)
68+ immediate = (instr_hi & 0x00ffffff) << 24;
69+ else
70+ immediate = (instr_hi & 0x0000ffff) << 16;
71 immediate |= (instr_lo & 0x0000ffff);
72 target_address = immediate;
73 offset = calc_fixup (target_address, 0, sec);
74--
752.17.1
76
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch
new file mode 100644
index 00000000..20752939
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch
@@ -0,0 +1,44 @@
1From 843b73643718b0776462bce6aba6b2c6fdb33d85 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/43] Fixed the bug in the R_MICROBLAZE_64_NONE relocation.
5 It was adjusting only lower 16bits.
6
7---
8 bfd/elf32-microblaze.c | 4 ++--
9 bfd/elf64-microblaze.c | 4 ++--
10 2 files changed, 4 insertions(+), 4 deletions(-)
11
12diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
13index 035e71f311..2d8c062a42 100644
14--- a/bfd/elf32-microblaze.c
15+++ b/bfd/elf32-microblaze.c
16@@ -2022,8 +2022,8 @@ microblaze_elf_relax_section (bfd *abfd,
17 sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
18 efix = calc_fixup (target_address, 0, sec);
19 irel->r_addend -= (efix - sfix);
20- microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
21- + INST_WORD_SIZE, irel->r_addend);
22+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
23+ irel->r_addend);
24 }
25 break;
26 }
27diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
28index 184b7d560d..ef6a87062b 100644
29--- a/bfd/elf64-microblaze.c
30+++ b/bfd/elf64-microblaze.c
31@@ -2017,8 +2017,8 @@ microblaze_elf_relax_section (bfd *abfd,
32 sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
33 efix = calc_fixup (target_address, 0, sec);
34 irel->r_addend -= (efix - sfix);
35- microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
36- + INST_WORD_SIZE, irel->r_addend);
37+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
38+ irel->r_addend);
39 }
40 break;
41 }
42--
432.17.1
44
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch
new file mode 100644
index 00000000..50179787
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch
@@ -0,0 +1,68 @@
1From 3a5e6a9c614c3f6abcf8bf853527ef07a5370f80 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/43] [Patch,MicroBlaze]: fixed Build issue which are due to
5 conflicts in patches.
6
7---
8 bfd/elf32-microblaze.c | 1 +
9 bfd/elf64-microblaze.c | 12 ++++++------
10 gas/config/tc-microblaze.c | 4 ++--
11 3 files changed, 9 insertions(+), 8 deletions(-)
12
13diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
14index 2d8c062a42..6a795c5069 100644
15--- a/bfd/elf32-microblaze.c
16+++ b/bfd/elf32-microblaze.c
17@@ -1996,6 +1996,7 @@ microblaze_elf_relax_section (bfd *abfd,
18 /* This was a PC-relative instruction that was
19 completely resolved. */
20 int sfix, efix;
21+ unsigned int val;
22 bfd_vma target_address;
23 target_address = irel->r_addend + irel->r_offset;
24 sfix = calc_fixup (irel->r_offset, 0, sec);
25diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
26index ef6a87062b..bed534e7dd 100644
27--- a/bfd/elf64-microblaze.c
28+++ b/bfd/elf64-microblaze.c
29@@ -2854,14 +2854,14 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
30 /* If this is a weak symbol, and there is a real definition, the
31 processor independent code will have arranged for us to see the
32 real definition first, and we can just use the same value. */
33- if (h->u.weakdef != NULL)
34+ if (h->is_weakalias)
35 {
36- BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
37- || h->u.weakdef->root.type == bfd_link_hash_defweak);
38- h->root.u.def.section = h->u.weakdef->root.u.def.section;
39- h->root.u.def.value = h->u.weakdef->root.u.def.value;
40+ struct elf_link_hash_entry *def = weakdef (h);
41+ BFD_ASSERT (def->root.type == bfd_link_hash_defined);
42+ h->root.u.def.section = def->root.u.def.section;
43+ h->root.u.def.value = def->root.u.def.value;
44 return TRUE;
45- }
46+ }
47
48 /* This is a reference to a symbol defined by a dynamic object which
49 is not a function. */
50diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
51index c6d2e4c82d..b3e49f0cf0 100644
52--- a/gas/config/tc-microblaze.c
53+++ b/gas/config/tc-microblaze.c
54@@ -118,9 +118,9 @@ const relax_typeS md_relax_table[] =
55 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 15: TLSGOTTPREL_OFFSET. */
56 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 16: TLSTPREL_OFFSET. */
57 { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 17: TEXT_OFFSET. */
58- { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 18: TEXT_PC_OFFSET. */
59+ { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 }, /* 18: TEXT_PC_OFFSET. */
60 // { 0x7fffffff, 0x80000000, INST_WORD_SIZE*2, 0 } /* 16: TLSTPREL_OFFSET. */
61- { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 } /* 19: DEFINED_64_OFFSET. */
62+ { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE, 0 }, /* 19: DEFINED_64_OFFSET. */
63 { 0x7fffffffffffffff, 0x8000000000000000, INST_WORD_SIZE*2, 0 } /* 20: DEFINED_64_PC_OFFSET. */
64 };
65
66--
672.17.1
68
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch
new file mode 100644
index 00000000..aef46b3f
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch
@@ -0,0 +1,31 @@
1From e7f43c3afe90faa42c09f368671972c26c2b7b38 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/43] [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
8---
9 bfd/format.c | 5 +++++
10 1 file changed, 5 insertions(+)
11
12diff --git a/bfd/format.c b/bfd/format.c
13index 97a92291a8..3a74cc49d2 100644
14--- a/bfd/format.c
15+++ b/bfd/format.c
16@@ -292,7 +292,12 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
17
18 /* Don't check the default target twice. */
19 if (*target == &binary_vec
20+#if !BFD_SUPPORTS_PLUGINS
21 || (!abfd->target_defaulted && *target == save_targ))
22+#else
23+ || (!abfd->target_defaulted && *target == save_targ)
24+ || (*target)->match_priority > best_match)
25+#endif
26 continue;
27
28 /* If we already tried a match, the bfd is modified and may
29--
302.17.1
31
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0027-Revert-ld-Remove-unused-expression-state.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0027-Revert-ld-Remove-unused-expression-state.patch
new file mode 100644
index 00000000..b0fe8231
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0027-Revert-ld-Remove-unused-expression-state.patch
@@ -0,0 +1,76 @@
1From 69b77a73f4e609883cd7a0946b407becd46bf918 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 27 Feb 2019 15:12:32 +0530
4Subject: [PATCH 27/43] Revert "ld: Remove unused expression state"
5
6This reverts commit 65f14869fd3fbee8ed4c4ca49de8aaa86dbc66cb.
7
8Conflicts:
9 ld/ChangeLog
10---
11 ld/ldexp.c | 8 +++++---
12 ld/ldexp.h | 1 +
13 2 files changed, 6 insertions(+), 3 deletions(-)
14
15diff --git a/ld/ldexp.c b/ld/ldexp.c
16index 60b17ef576..dac4b52450 100644
17--- a/ld/ldexp.c
18+++ b/ld/ldexp.c
19@@ -1354,6 +1354,7 @@ static etree_type *
20 exp_assop (const char *dst,
21 etree_type *src,
22 enum node_tree_enum class,
23+ bfd_boolean defsym,
24 bfd_boolean hidden)
25 {
26 etree_type *n;
27@@ -1365,6 +1366,7 @@ exp_assop (const char *dst,
28 n->assign.type.node_class = class;
29 n->assign.src = src;
30 n->assign.dst = dst;
31+ n->assign.defsym = defsym;
32 n->assign.hidden = hidden;
33 return n;
34 }
35@@ -1374,7 +1376,7 @@ exp_assop (const char *dst,
36 etree_type *
37 exp_assign (const char *dst, etree_type *src, bfd_boolean hidden)
38 {
39- return exp_assop (dst, src, etree_assign, hidden);
40+ return exp_assop (dst, src, etree_assign, FALSE, hidden);
41 }
42
43 /* Handle --defsym command-line option. */
44@@ -1382,7 +1384,7 @@ exp_assign (const char *dst, etree_type *src, bfd_boolean hidden)
45 etree_type *
46 exp_defsym (const char *dst, etree_type *src)
47 {
48- return exp_assop (dst, src, etree_assign, FALSE);
49+ return exp_assop (dst, src, etree_assign, TRUE, FALSE);
50 }
51
52 /* Handle PROVIDE. */
53@@ -1390,7 +1392,7 @@ exp_defsym (const char *dst, etree_type *src)
54 etree_type *
55 exp_provide (const char *dst, etree_type *src, bfd_boolean hidden)
56 {
57- return exp_assop (dst, src, etree_provide, hidden);
58+ return exp_assop (dst, src, etree_provide, FALSE, hidden);
59 }
60
61 /* Handle ASSERT. */
62diff --git a/ld/ldexp.h b/ld/ldexp.h
63index 71395bc6c4..f94b00aedb 100644
64--- a/ld/ldexp.h
65+++ b/ld/ldexp.h
66@@ -66,6 +66,7 @@ typedef union etree_union {
67 node_type type;
68 const char *dst;
69 union etree_union *src;
70+ bfd_boolean defsym;
71 bfd_boolean hidden;
72 } assign;
73 struct {
74--
752.17.1
76
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch
new file mode 100644
index 00000000..0fd14f6d
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch
@@ -0,0 +1,33 @@
1From 282a60ab92e6705853dac30fd38aaf298d7f02b0 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 11 Mar 2019 14:23:58 +0530
4Subject: [PATCH 28/43] [Patch,Microblaze] : Binutils security check is causing
5 build error for windows builds.commenting for now.
6
7---
8 bfd/elf-attrs.c | 2 ++
9 1 file changed, 2 insertions(+)
10
11diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
12index bfe135e7fb..feb5cb37f5 100644
13--- a/bfd/elf-attrs.c
14+++ b/bfd/elf-attrs.c
15@@ -440,6 +440,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
16 /* PR 17512: file: 2844a11d. */
17 if (hdr->sh_size == 0)
18 return;
19+ #if 0
20 if (hdr->sh_size > bfd_get_file_size (abfd))
21 {
22 /* xgettext:c-format */
23@@ -448,6 +449,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
24 bfd_set_error (bfd_error_invalid_operation);
25 return;
26 }
27+ #endif
28
29 contents = (bfd_byte *) bfd_malloc (hdr->sh_size + 1);
30 if (!contents)
31--
322.17.1
33
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0029-fixing-the-long-long-long-mingw-toolchain-issue.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0029-fixing-the-long-long-long-mingw-toolchain-issue.patch
new file mode 100644
index 00000000..dbafc786
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0029-fixing-the-long-long-long-mingw-toolchain-issue.patch
@@ -0,0 +1,57 @@
1From 26662110955e26c62629f4263a999216dac326ef Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 29 Nov 2018 17:59:25 +0530
4Subject: [PATCH 29/43] fixing the long & long long mingw toolchain issue
5
6---
7 gas/config/tc-microblaze.c | 10 +++++-----
8 opcodes/microblaze-opc.h | 4 ++--
9 2 files changed, 7 insertions(+), 7 deletions(-)
10
11diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
12index b3e49f0cf0..5b506d3348 100644
13--- a/gas/config/tc-microblaze.c
14+++ b/gas/config/tc-microblaze.c
15@@ -783,7 +783,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
16 }
17
18 static char *
19-parse_imml (char * s, expressionS * e, long min, long max)
20+parse_imml (char * s, expressionS * e, long long min, long long max)
21 {
22 char *new_pointer;
23 char *atp;
24@@ -834,11 +834,11 @@ parse_imml (char * s, expressionS * e, long min, long max)
25 ; /* An error message has already been emitted. */
26 else if ((e->X_op != O_constant && e->X_op != O_symbol) )
27 as_fatal (_("operand must be a constant or a label"));
28- else if ((e->X_op == O_constant) && ((long) e->X_add_number < min
29- || (long) e->X_add_number > max))
30+ else if ((e->X_op == O_constant) && ((long long) e->X_add_number < min
31+ || (long long) e->X_add_number > max))
32 {
33- as_fatal (_("operand must be absolute in range %ld..%ld, not %ld"),
34- min, max, (long) e->X_add_number);
35+ as_fatal (_("operand must be absolute in range %lld..%lld, not %lld"),
36+ min, max, (long long) e->X_add_number);
37 }
38
39 if (atp)
40diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
41index 824afc0ab0..d59ee0a95f 100644
42--- a/opcodes/microblaze-opc.h
43+++ b/opcodes/microblaze-opc.h
44@@ -585,8 +585,8 @@ char pvr_register_prefix[] = "rpvr";
45 #define MIN_IMM6_WIDTH ((int) 0x00000001)
46 #define MAX_IMM6_WIDTH ((int) 0x00000040)
47
48-#define MIN_IMML ((long) 0xffffff8000000000L)
49-#define MAX_IMML ((long) 0x0000007fffffffffL)
50+#define MIN_IMML ((long long) 0xffffff8000000000L)
51+#define MAX_IMML ((long long) 0x0000007fffffffffL)
52
53 #endif /* MICROBLAZE_OPC */
54
55--
562.17.1
57
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0030-Added-support-to-new-arithmetic-single-register-inst.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0030-Added-support-to-new-arithmetic-single-register-inst.patch
new file mode 100644
index 00000000..8141095a
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0030-Added-support-to-new-arithmetic-single-register-inst.patch
@@ -0,0 +1,359 @@
1From 7b332d61cb3dbcae69021ce706f2c408c85af193 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Fri, 23 Aug 2019 16:18:43 +0530
4Subject: [PATCH 30/43] Added support to new arithmetic single register
5 instructions
6
7---
8 gas/config/tc-microblaze.c | 147 ++++++++++++++++++++++++++++++++++++-
9 opcodes/microblaze-dis.c | 12 +++
10 opcodes/microblaze-opc.h | 43 ++++++++++-
11 opcodes/microblaze-opcm.h | 5 +-
12 4 files changed, 201 insertions(+), 6 deletions(-)
13
14diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
15index 5b506d3348..12eef24a29 100644
16--- a/gas/config/tc-microblaze.c
17+++ b/gas/config/tc-microblaze.c
18@@ -423,12 +423,33 @@ void
19 md_begin (void)
20 {
21 struct op_code_struct * opcode;
22+ const char *prev_name = "";
23
24 opcode_hash_control = hash_new ();
25
26 /* Insert unique names into hash table. */
27- for (opcode = opcodes; opcode->name; opcode ++)
28- hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
29+ for (opcode = (struct opcodes *)opcodes; opcode->name; opcode ++)
30+ {
31+ if (strcmp (prev_name, opcode->name))
32+ {
33+ prev_name = (char *) opcode->name;
34+ hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
35+ }
36+ }
37+}
38+
39+static int
40+is_reg (char * s)
41+{
42+ int is_reg = 0;
43+ /* Strip leading whitespace. */
44+ while (ISSPACE (* s))
45+ ++ s;
46+ if (TOLOWER (s[0]) == 'r')
47+ {
48+ is_reg =1;
49+ }
50+ return is_reg;
51 }
52
53 /* Try to parse a reg name. */
54@@ -986,6 +1007,7 @@ md_assemble (char * str)
55 {
56 char * op_start;
57 char * op_end;
58+ char * temp_op_end;
59 struct op_code_struct * opcode, *opcode1;
60 char * output = NULL;
61 int nlen = 0;
62@@ -996,9 +1018,10 @@ md_assemble (char * str)
63 unsigned reg3;
64 unsigned isize;
65 unsigned long immed, immed2, temp;
66- expressionS exp;
67+ expressionS exp,exp1;
68 char name[20];
69 long immedl;
70+ int reg=0;
71
72 /* Drop leading whitespace. */
73 while (ISSPACE (* str))
74@@ -1029,7 +1052,78 @@ md_assemble (char * str)
75 as_bad (_("unknown opcode \"%s\""), name);
76 return;
77 }
78-
79+
80+ if ((microblaze_arch_size == 64) && (streq (name, "addli") || streq (name, "addlic") ||
81+ streq (name, "addlik") || streq (name, "addlikc") || streq (name, "rsubli")
82+ || streq (name, "rsublic") || streq (name, "rsublik") || streq (name, "rsublikc")
83+ || streq (name, "andli") || streq (name, "andnli") || streq (name, "orli")
84+ || streq (name, "xorli")))
85+ {
86+ temp_op_end = op_end;
87+ if (strcmp (temp_op_end, ""))
88+ temp_op_end = parse_reg (temp_op_end + 1, &reg1); /* Get rd. */
89+ if (strcmp (temp_op_end, ""))
90+ reg = is_reg (temp_op_end + 1);
91+ if (reg)
92+ {
93+
94+ opcode->inst_type=INST_TYPE_RD_R1_IMML;
95+ opcode->inst_offset_type = OPCODE_MASK_H;
96+ if (streq (name, "addli"))
97+ opcode->bit_sequence = ADDLI_MASK;
98+ else if (streq (name, "addlic"))
99+ opcode->bit_sequence = ADDLIC_MASK;
100+ else if (streq (name, "addlik"))
101+ opcode->bit_sequence = ADDLIK_MASK;
102+ else if (streq (name, "addlikc"))
103+ opcode->bit_sequence = ADDLIKC_MASK;
104+ else if (streq (name, "rsubli"))
105+ opcode->bit_sequence = RSUBLI_MASK;
106+ else if (streq (name, "rsublic"))
107+ opcode->bit_sequence = RSUBLIC_MASK;
108+ else if (streq (name, "rsublik"))
109+ opcode->bit_sequence = RSUBLIK_MASK;
110+ else if (streq (name, "rsublikc"))
111+ opcode->bit_sequence = RSUBLIKC_MASK;
112+ else if (streq (name, "andli"))
113+ opcode->bit_sequence = ANDLI_MASK;
114+ else if (streq (name, "andnli"))
115+ opcode->bit_sequence = ANDLNI_MASK;
116+ else if (streq (name, "orli"))
117+ opcode->bit_sequence = ORLI_MASK;
118+ else if (streq (name, "xorli"))
119+ opcode->bit_sequence = XORLI_MASK;
120+ }
121+ else
122+ {
123+ opcode->inst_type=INST_TYPE_RD_IMML;
124+ opcode->inst_offset_type = OPCODE_MASK_LIMM;
125+ if (streq (name, "addli"))
126+ opcode->bit_sequence = ADDLI_ONE_REG_MASK;
127+ else if (streq (name, "addlic"))
128+ opcode->bit_sequence = ADDLIC_ONE_REG_MASK;
129+ else if (streq (name, "addlik"))
130+ opcode->bit_sequence = ADDLIK_ONE_REG_MASK;
131+ else if (streq (name, "addlikc"))
132+ opcode->bit_sequence = ADDLIKC_ONE_REG_MASK;
133+ else if (streq (name, "rsubli"))
134+ opcode->bit_sequence = RSUBLI_ONE_REG_MASK;
135+ else if (streq (name, "rsublic"))
136+ opcode->bit_sequence = RSUBLIC_ONE_REG_MASK;
137+ else if (streq (name, "rsublik"))
138+ opcode->bit_sequence = RSUBLIK_ONE_REG_MASK;
139+ else if (streq (name, "rsublikc"))
140+ opcode->bit_sequence = RSUBLIKC_ONE_REG_MASK;
141+ else if (streq (name, "andli"))
142+ opcode->bit_sequence = ANDLI_ONE_REG_MASK;
143+ else if (streq (name, "andnli"))
144+ opcode->bit_sequence = ANDLNI_ONE_REG_MASK;
145+ else if (streq (name, "orli"))
146+ opcode->bit_sequence = ORLI_ONE_REG_MASK;
147+ else if (streq (name, "xorli"))
148+ opcode->bit_sequence = XORLI_ONE_REG_MASK;
149+ }
150+ }
151 inst = opcode->bit_sequence;
152 isize = 4;
153
154@@ -1480,6 +1574,51 @@ md_assemble (char * str)
155 inst |= (immed << IMM_LOW) & IMM15_MASK;
156 break;
157
158+ case INST_TYPE_RD_IMML:
159+ if (strcmp (op_end, ""))
160+ op_end = parse_reg (op_end + 1, &reg1); /* Get rd. */
161+ else
162+ {
163+ as_fatal (_("Error in statement syntax"));
164+ reg1 = 0;
165+ }
166+
167+ if (strcmp (op_end, ""))
168+ op_end = parse_imml (op_end + 1, & exp, MIN_IMML, MAX_IMML);
169+ else
170+ as_fatal (_("Error in statement syntax"));
171+
172+ /* Check for spl registers. */
173+ if (check_spl_reg (&reg1))
174+ as_fatal (_("Cannot use special register with this instruction"));
175+ if (exp.X_op != O_constant)
176+ {
177+ char *opc = NULL;
178+ relax_substateT subtype;
179+
180+ if (exp.X_md != 0)
181+ subtype = get_imm_otype(exp.X_md);
182+ else
183+ subtype = opcode->inst_offset_type;
184+
185+ output = frag_var (rs_machine_dependent,
186+ isize * 2,
187+ isize * 2,
188+ subtype,
189+ exp.X_add_symbol,
190+ exp.X_add_number,
191+ (char *) opc);
192+ immedl = 0L;
193+ }
194+ else
195+ {
196+ output = frag_more (isize);
197+ immed = exp.X_add_number;
198+ }
199+ inst |= (reg1 << RD_LOW) & RD_MASK;
200+ inst |= (immed << IMM_LOW) & IMM16_MASK;
201+ break;
202+
203 case INST_TYPE_R1_RFSL:
204 if (strcmp (op_end, ""))
205 op_end = parse_reg (op_end + 1, &reg1); /* Get r1. */
206diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
207index f679a43606..e5e880cb1c 100644
208--- a/opcodes/microblaze-dis.c
209+++ b/opcodes/microblaze-dis.c
210@@ -114,6 +114,15 @@ get_field_imm15 (long instr)
211 return (strdup (tmpstr));
212 }
213
214+static char *
215+get_field_imm16 (long instr)
216+{
217+ char tmpstr[25];
218+
219+ sprintf (tmpstr, "%d", (short)((instr & IMM16_MASK) >> IMM_LOW));
220+ return (strdup (tmpstr));
221+}
222+
223 static char *
224 get_field_special (long instr, struct op_code_struct * op)
225 {
226@@ -419,6 +428,9 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
227 case INST_TYPE_RD_IMM15:
228 print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_imm15 (inst));
229 break;
230+ case INST_TYPE_RD_IMML:
231+ print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_imm16 (inst));
232+ break;
233 /* For mbar insn. */
234 case INST_TYPE_IMM5:
235 print_func (stream, "\t%s", get_field_imm5_mbar (inst));
236diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
237index d59ee0a95f..0774f70e08 100644
238--- a/opcodes/microblaze-opc.h
239+++ b/opcodes/microblaze-opc.h
240@@ -69,6 +69,7 @@
241 #define INST_TYPE_RD_R1_IMMW_IMMS 21
242
243 #define INST_TYPE_NONE 25
244+#define INST_TYPE_RD_IMML 26
245
246
247
248@@ -84,6 +85,7 @@
249 #define IMMVAL_MASK_MFS 0x0000
250
251 #define OPCODE_MASK_H 0xFC000000 /* High 6 bits only. */
252+#define OPCODE_MASK_LIMM 0xFC1F0000 /* High 6 bits and 12-16 bits */
253 #define OPCODE_MASK_H1 0xFFE00000 /* High 11 bits. */
254 #define OPCODE_MASK_H2 0xFC1F0000 /* High 6 and bits 20-16. */
255 #define OPCODE_MASK_H12 0xFFFF0000 /* High 16. */
256@@ -106,6 +108,33 @@
257 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
258 #define OPCODE_MASK_H8 0xFF000000 /* High 8 bits only. */
259
260+/*Defines to identify 64-bit single reg instructions */
261+#define ADDLI_ONE_REG_MASK 0x68000000
262+#define ADDLIC_ONE_REG_MASK 0x68020000
263+#define ADDLIK_ONE_REG_MASK 0x68040000
264+#define ADDLIKC_ONE_REG_MASK 0x68060000
265+#define RSUBLI_ONE_REG_MASK 0x68010000
266+#define RSUBLIC_ONE_REG_MASK 0x68030000
267+#define RSUBLIK_ONE_REG_MASK 0x68050000
268+#define RSUBLIKC_ONE_REG_MASK 0x68070000
269+#define ORLI_ONE_REG_MASK 0x68100000
270+#define ANDLI_ONE_REG_MASK 0x68110000
271+#define XORLI_ONE_REG_MASK 0x68120000
272+#define ANDLNI_ONE_REG_MASK 0x68130000
273+#define ADDLI_MASK 0x20000000
274+#define ADDLIC_MASK 0x28000000
275+#define ADDLIK_MASK 0x30000000
276+#define ADDLIKC_MASK 0x38000000
277+#define RSUBLI_MASK 0x24000000
278+#define RSUBLIC_MASK 0x2C000000
279+#define RSUBLIK_MASK 0x34000000
280+#define RSUBLIKC_MASK 0x3C000000
281+#define ANDLI_MASK 0xA4000000
282+#define ANDLNI_MASK 0xAC000000
283+#define ORLI_MASK 0xA0000000
284+#define XORLI_MASK 0xA8000000
285+
286+
287 /* New Mask for msrset, msrclr insns. */
288 #define OPCODE_MASK_H23N 0xFC1F8000 /* High 6 and bits 11 - 16. */
289 /* Mask for mbar insn. */
290@@ -114,7 +143,7 @@
291 #define DELAY_SLOT 1
292 #define NO_DELAY_SLOT 0
293
294-#define MAX_OPCODES 412
295+#define MAX_OPCODES 424
296
297 struct op_code_struct
298 {
299@@ -444,13 +473,21 @@ struct op_code_struct
300 {"cmpl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000101, OPCODE_MASK_H4, cmpl, arithmetic_inst },
301 {"cmplu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000103, OPCODE_MASK_H4, cmplu, arithmetic_inst },
302 {"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 */
303+ {"addli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68000000, OPCODE_MASK_LIMM, addli, arithmetic_inst },
304 {"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 */
305+ {"rsubli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68010000, OPCODE_MASK_LIMM, rsubli, arithmetic_inst },
306 {"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 */
307+ {"addlic", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68020000, OPCODE_MASK_LIMM, addlic, arithmetic_inst },
308 {"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 */
309+ {"rsublic", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68030000, OPCODE_MASK_LIMM, rsublic, arithmetic_inst },
310 {"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 */
311+ {"addlik", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68040000, OPCODE_MASK_LIMM, addlik, arithmetic_inst },
312 {"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 */
313+ {"rsublik", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68050000, OPCODE_MASK_LIMM, rsublik, arithmetic_inst },
314 {"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 */
315+ {"addlikc", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68060000, OPCODE_MASK_LIMM, addlikc, arithmetic_inst },
316 {"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 */
317+ {"rsublikc", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68070000, OPCODE_MASK_LIMM, rsublikc, arithmetic_inst },
318 {"mull", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x40000100, OPCODE_MASK_H4, mull, mult_inst },
319 {"bslll", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000500, OPCODE_MASK_H3, bslll, barrel_shift_inst },
320 {"bslra", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000300, OPCODE_MASK_H3, bslra, barrel_shift_inst },
321@@ -501,9 +538,13 @@ struct op_code_struct
322 {"beaged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00000, OPCODE_MASK_H14, beaged, branch_inst },
323 {"bealged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00100, OPCODE_MASK_H14, bealged, branch_inst },
324 {"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 */
325+ {"orli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68100000, OPCODE_MASK_LIMM, orli, arithmetic_inst },
326 {"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 */
327+ {"andli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68110000, OPCODE_MASK_LIMM, andli, arithmetic_inst },
328 {"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 */
329+ {"xorli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68120000, OPCODE_MASK_LIMM, xorli, arithmetic_inst },
330 {"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 */
331+ {"andnli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68130000, OPCODE_MASK_LIMM, andnli, arithmetic_inst },
332 {"imml", INST_TYPE_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB2000000, OPCODE_MASK_H8, imml, immediate_inst },
333 {"breai", INST_TYPE_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8010000, OPCODE_MASK_H12, breai, branch_inst },
334 {"breaid", INST_TYPE_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8110000, OPCODE_MASK_H12, breaid, branch_inst },
335diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
336index 5f2e190d23..4d2ee2dd0d 100644
337--- a/opcodes/microblaze-opcm.h
338+++ b/opcodes/microblaze-opcm.h
339@@ -61,7 +61,9 @@ enum microblaze_instr
340 eaputd, teaputd, ecaputd, tecaputd, neaputd, tneaputd, necaputd, tnecaputd,
341
342 /* 64-bit instructions */
343- addl, rsubl, addlc, rsublc, addlk, rsublk, addlkc, rsublkc, cmpl, cmplu, mull,
344+ addl, addli, addlic, addlik, addlikc, rsubl, rsubli, rsublic, rsublik, rsublikc,
345+ addlc, rsublc, addlk, rsublk, addlkc, rsublkc, cmpl, cmplu, mull,
346+ andli, andnli, orli, xorli,
347 bslll, bslra, bslrl, bsllli, bslrai, bslrli, bslefi, bslifi, orl, andl, xorl,
348 andnl, pcmplbf, pcmpleq, pcmplne, srla, srlc, srll, sextl8, sextl16, sextl32,
349 brea, bread, breald, beaeq, bealeq, beaeqd, bealeqd, beane, bealne, beaned,
350@@ -166,5 +168,6 @@ enum microblaze_instr_type
351
352 /* Imm mask for msrset, msrclr instructions. */
353 #define IMM15_MASK 0x00007FFF
354+#define IMM16_MASK 0x0000FFFF
355
356 #endif /* MICROBLAZE-OPCM */
357--
3582.17.1
359
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch
new file mode 100644
index 00000000..f9f0fc55
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch
@@ -0,0 +1,551 @@
1From 213df2cac38d404619614939de0c9d3dcbf7557d Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 26 Aug 2019 15:29:42 +0530
4Subject: [PATCH 31/43] [Patch,MicroBlaze] : double imml generation for 64 bit
5 values.
6
7---
8 gas/config/tc-microblaze.c | 322 ++++++++++++++++++++++++++++++-------
9 opcodes/microblaze-opc.h | 4 +-
10 2 files changed, 263 insertions(+), 63 deletions(-)
11
12diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
13index 12eef24a29..3ff6a14baf 100644
14--- a/gas/config/tc-microblaze.c
15+++ b/gas/config/tc-microblaze.c
16@@ -1008,7 +1008,7 @@ md_assemble (char * str)
17 char * op_start;
18 char * op_end;
19 char * temp_op_end;
20- struct op_code_struct * opcode, *opcode1;
21+ struct op_code_struct * opcode, *opcode1, *opcode2;
22 char * output = NULL;
23 int nlen = 0;
24 int i;
25@@ -1192,7 +1192,12 @@ md_assemble (char * str)
26 reg2 = 0;
27 }
28 if (strcmp (op_end, ""))
29+ {
30+ if(microblaze_arch_size == 64)
31+ op_end = parse_imml (op_end + 1, & exp, MIN_IMML, MAX_IMML);
32+ else
33 op_end = parse_imm (op_end + 1, & exp, MIN_IMM, MAX_IMM);
34+ }
35 else
36 as_fatal (_("Error in statement syntax"));
37
38@@ -1288,24 +1293,51 @@ md_assemble (char * str)
39 || streq (name, "lwi") || streq (name, "sbi")
40 || streq (name, "shi") || streq (name, "swi"))))
41 {
42- temp = immed & 0xFFFFFF8000;
43- if (temp != 0 && temp != 0xFFFFFF8000)
44+ temp = ((long long)immed) & 0xFFFFFFFFFFFF8000;
45+ if (temp != 0 && temp != 0xFFFFFFFFFFFF8000)
46 {
47 /* Needs an immediate inst. */
48- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
49- if (opcode1 == NULL)
50+ if (((long long)immed) > (long long)-549755813888 && ((long long)immed) < (long long)549755813887)
51+ {
52+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
53+ if (opcode1 == NULL)
54+ {
55+ as_bad (_("unknown opcode \"%s\""), "imml");
56+ return;
57+ }
58+ inst1 = opcode1->bit_sequence;
59+ inst1 |= ((immed & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
60+ output[0] = INST_BYTE0 (inst1);
61+ output[1] = INST_BYTE1 (inst1);
62+ output[2] = INST_BYTE2 (inst1);
63+ output[3] = INST_BYTE3 (inst1);
64+ output = frag_more (isize);
65+ }
66+ else
67+ {
68+ opcode2 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
69+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
70+ if (opcode1 == NULL || opcode2 == NULL)
71 {
72 as_bad (_("unknown opcode \"%s\""), "imml");
73 return;
74 }
75+ inst1 = opcode2->bit_sequence;
76+ inst1 |= ((immed & 0xFFFFFF0000000000L) >> 40) & IMML_MASK;
77+ output[0] = INST_BYTE0 (inst1);
78+ output[1] = INST_BYTE1 (inst1);
79+ output[2] = INST_BYTE2 (inst1);
80+ output[3] = INST_BYTE3 (inst1);
81+ output = frag_more (isize);
82 inst1 = opcode1->bit_sequence;
83- inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
84+ inst1 |= ((immed & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
85 output[0] = INST_BYTE0 (inst1);
86 output[1] = INST_BYTE1 (inst1);
87 output[2] = INST_BYTE2 (inst1);
88 output[3] = INST_BYTE3 (inst1);
89 output = frag_more (isize);
90 }
91+ }
92 inst |= (reg1 << RD_LOW) & RD_MASK;
93 inst |= (reg2 << RA_LOW) & RA_MASK;
94 inst |= (immed << IMM_LOW) & IMM_MASK;
95@@ -1316,14 +1348,13 @@ md_assemble (char * str)
96 if ((temp != 0) && (temp != 0xFFFF8000))
97 {
98 /* Needs an immediate inst. */
99- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
100+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
101 if (opcode1 == NULL)
102 {
103 as_bad (_("unknown opcode \"%s\""), "imm");
104 return;
105 }
106-
107- inst1 = opcode1->bit_sequence;
108+ inst1 = opcode1->bit_sequence;
109 inst1 |= ((immed & 0xFFFF0000) >> 16) & IMM_MASK;
110 output[0] = INST_BYTE0 (inst1);
111 output[1] = INST_BYTE1 (inst1);
112@@ -1564,7 +1595,7 @@ md_assemble (char * str)
113 as_fatal (_("Cannot use special register with this instruction"));
114
115 if (exp.X_op != O_constant)
116- as_fatal (_("Symbol used as immediate value for msrset/msrclr instructions"));
117+ as_fatal (_("Symbol used as immediate value for arithmetic long instructions"));
118 else
119 {
120 output = frag_more (isize);
121@@ -1898,8 +1929,9 @@ md_assemble (char * str)
122 temp = immed & 0xFFFF8000;
123 if ((temp != 0) && (temp != 0xFFFF8000))
124 {
125+
126 /* Needs an immediate inst. */
127- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
128+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
129 if (opcode1 == NULL)
130 {
131 as_bad (_("unknown opcode \"%s\""), "imm");
132@@ -1928,7 +1960,12 @@ md_assemble (char * str)
133 reg1 = 0;
134 }
135 if (strcmp (op_end, ""))
136+ {
137+ if(microblaze_arch_size == 64)
138+ op_end = parse_imml (op_end + 1, & exp, MIN_IMML, MAX_IMML);
139+ else
140 op_end = parse_imm (op_end + 1, & exp, MIN_IMM, MAX_IMM);
141+ }
142 else
143 as_fatal (_("Error in statement syntax"));
144
145@@ -1967,30 +2004,55 @@ md_assemble (char * str)
146 }
147 if (streq (name, "brealid") || streq (name, "breaid") || streq (name, "breai"))
148 {
149- temp = immed & 0xFFFFFF8000;
150- if (temp != 0 && temp != 0xFFFFFF8000)
151+ temp = ((long long)immed) & 0xFFFFFFFFFFFF8000;
152+ if (temp != 0 && temp != 0xFFFFFFFFFFFF8000)
153 {
154 /* Needs an immediate inst. */
155- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
156+ if (((long long)immed) > (long long)-549755813888 && ((long long)immed) < (long long)549755813887)
157+ {
158+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
159 if (opcode1 == NULL)
160 {
161 as_bad (_("unknown opcode \"%s\""), "imml");
162 return;
163 }
164 inst1 = opcode1->bit_sequence;
165- inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
166+ inst1 |= ((immed & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
167 output[0] = INST_BYTE0 (inst1);
168 output[1] = INST_BYTE1 (inst1);
169 output[2] = INST_BYTE2 (inst1);
170 output[3] = INST_BYTE3 (inst1);
171 output = frag_more (isize);
172 }
173+ else {
174+ opcode2 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
175+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
176+ if (opcode1 == NULL || opcode2 == NULL)
177+ {
178+ as_bad (_("unknown opcode \"%s\""), "imml");
179+ return;
180+ }
181+ inst1 = opcode2->bit_sequence;
182+ inst1 |= ((immed & 0xFFFFFF0000000000L) >> 40) & IMML_MASK;
183+ output[0] = INST_BYTE0 (inst1);
184+ output[1] = INST_BYTE1 (inst1);
185+ output[2] = INST_BYTE2 (inst1);
186+ output[3] = INST_BYTE3 (inst1);
187+ output = frag_more (isize);
188+ inst1 = opcode1->bit_sequence;
189+ inst1 |= ((immed & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
190+ output[0] = INST_BYTE0 (inst1);
191+ output[1] = INST_BYTE1 (inst1);
192+ output[2] = INST_BYTE2 (inst1);
193+ output[3] = INST_BYTE3 (inst1);
194+ output = frag_more (isize);
195+ }
196+ }
197 inst |= (reg1 << RD_LOW) & RD_MASK;
198 inst |= (immed << IMM_LOW) & IMM_MASK;
199 }
200 else
201 {
202-
203 temp = immed & 0xFFFF8000;
204 if ((temp != 0) && (temp != 0xFFFF8000))
205 {
206@@ -2076,25 +2138,50 @@ md_assemble (char * str)
207 streq (name, "breaid") ||
208 streq (name, "brai") || streq (name, "braid")))
209 {
210- temp = immed & 0xFFFFFF8000;
211+ temp = immed & 0xFFFFFFFFFFFF8000;
212 if (temp != 0)
213 {
214 /* Needs an immediate inst. */
215- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
216+ if (((long long)immed) > (long long)-549755813888 && ((long long)immed) < (long long)549755813887)
217+ {
218+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
219 if (opcode1 == NULL)
220 {
221 as_bad (_("unknown opcode \"%s\""), "imml");
222 return;
223 }
224-
225 inst1 = opcode1->bit_sequence;
226- inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
227+ inst1 |= ((immed & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
228+ output[0] = INST_BYTE0 (inst1);
229+ output[1] = INST_BYTE1 (inst1);
230+ output[2] = INST_BYTE2 (inst1);
231+ output[3] = INST_BYTE3 (inst1);
232+ output = frag_more (isize);
233+ }
234+ else {
235+ opcode2 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
236+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
237+ if (opcode1 == NULL || opcode2 == NULL)
238+ {
239+ as_bad (_("unknown opcode \"%s\""), "imml");
240+ return;
241+ }
242+ inst1 = opcode2->bit_sequence;
243+ inst1 |= ((immed & 0xFFFFFF0000000000L) >> 40) & IMML_MASK;
244+ output[0] = INST_BYTE0 (inst1);
245+ output[1] = INST_BYTE1 (inst1);
246+ output[2] = INST_BYTE2 (inst1);
247+ output[3] = INST_BYTE3 (inst1);
248+ output = frag_more (isize);
249+ inst1 = opcode1->bit_sequence;
250+ inst1 |= ((immed & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
251 output[0] = INST_BYTE0 (inst1);
252 output[1] = INST_BYTE1 (inst1);
253 output[2] = INST_BYTE2 (inst1);
254 output[3] = INST_BYTE3 (inst1);
255 output = frag_more (isize);
256 }
257+ }
258 inst |= (immed << IMM_LOW) & IMM_MASK;
259 }
260 else
261@@ -2194,21 +2281,45 @@ md_assemble (char * str)
262 {
263 output = frag_more (isize);
264 immedl = exp.X_add_number;
265-
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- inst1 = opcode1->bit_sequence;
274- inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
275- output[0] = INST_BYTE0 (inst1);
276- output[1] = INST_BYTE1 (inst1);
277- output[2] = INST_BYTE2 (inst1);
278- output[3] = INST_BYTE3 (inst1);
279- output = frag_more (isize);
280+ if (((long long)immedl) > (long long)-549755813888 && ((long long)immedl) < (long long)549755813887)
281+ {
282+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
283+ if (opcode1 == NULL)
284+ {
285+ as_bad (_("unknown opcode \"%s\""), "imml");
286+ return;
287+ }
288+ inst1 = opcode1->bit_sequence;
289+ inst1 |= ((immedl & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
290+ output[0] = INST_BYTE0 (inst1);
291+ output[1] = INST_BYTE1 (inst1);
292+ output[2] = INST_BYTE2 (inst1);
293+ output[3] = INST_BYTE3 (inst1);
294+ output = frag_more (isize);
295+ }
296+ else {
297+ opcode2 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
298+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
299+ if (opcode2 == NULL || opcode1 == NULL)
300+ {
301+ as_bad (_("unknown opcode \"%s\""), "imml");
302+ return;
303+ }
304+ inst1 = opcode2->bit_sequence;
305+ inst1 |= ((immedl & 0xFFFFFF0000000000L) >> 40) & IMML_MASK;
306+ output[0] = INST_BYTE0 (inst1);
307+ output[1] = INST_BYTE1 (inst1);
308+ output[2] = INST_BYTE2 (inst1);
309+ output[3] = INST_BYTE3 (inst1);
310+ output = frag_more (isize);
311+ inst1 = opcode1->bit_sequence;
312+ inst1 |= ((immedl & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
313+ output[0] = INST_BYTE0 (inst1);
314+ output[1] = INST_BYTE1 (inst1);
315+ output[2] = INST_BYTE2 (inst1);
316+ output[3] = INST_BYTE3 (inst1);
317+ output = frag_more (isize);
318+ }
319 }
320
321 inst |= (reg1 << RD_LOW) & RD_MASK;
322@@ -2257,21 +2368,46 @@ md_assemble (char * str)
323 {
324 output = frag_more (isize);
325 immedl = exp.X_add_number;
326- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
327- if (opcode1 == NULL)
328- {
329- as_bad (_("unknown opcode \"%s\""), "imml");
330- return;
331- }
332-
333+ if (((long long)immedl) > (long long)-549755813888 && ((long long)immedl) < (long long)549755813887)
334+ {
335+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
336+ if (opcode1 == NULL)
337+ {
338+ as_bad (_("unknown opcode \"%s\""), "imml");
339+ return;
340+ }
341+ inst1 = opcode1->bit_sequence;
342+ inst1 |= ((immedl & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
343+ output[0] = INST_BYTE0 (inst1);
344+ output[1] = INST_BYTE1 (inst1);
345+ output[2] = INST_BYTE2 (inst1);
346+ output[3] = INST_BYTE3 (inst1);
347+ output = frag_more (isize);
348+ }
349+ else {
350+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
351+ opcode2 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
352+ if (opcode2 == NULL || opcode1 == NULL)
353+ {
354+ as_bad (_("unknown opcode \"%s\""), "imml");
355+ return;
356+ }
357+ inst1 = opcode2->bit_sequence;
358+ inst1 |= ((immedl & 0xFFFFFF0000000000L) >> 40) & IMML_MASK;
359+ output[0] = INST_BYTE0 (inst1);
360+ output[1] = INST_BYTE1 (inst1);
361+ output[2] = INST_BYTE2 (inst1);
362+ output[3] = INST_BYTE3 (inst1);
363+ output = frag_more (isize);
364 inst1 = opcode1->bit_sequence;
365- inst1 |= ((immedl & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK;
366+ inst1 |= ((immedl & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
367 output[0] = INST_BYTE0 (inst1);
368 output[1] = INST_BYTE1 (inst1);
369 output[2] = INST_BYTE2 (inst1);
370 output[3] = INST_BYTE3 (inst1);
371 output = frag_more (isize);
372 }
373+ }
374
375 inst |= (reg1 << RA_LOW) & RA_MASK;
376 inst |= (immedl << IMM_LOW) & IMM_MASK;
377@@ -2554,8 +2690,8 @@ md_apply_fix (fixS * fixP,
378 /* Note: use offsetT because it is signed, valueT is unsigned. */
379 offsetT val = (offsetT) * valp;
380 int i;
381- struct op_code_struct * opcode1;
382- unsigned long inst1;
383+ struct op_code_struct * opcode1, * opcode2;
384+ unsigned long inst1,inst2;
385
386 symname = fixP->fx_addsy ? S_GET_NAME (fixP->fx_addsy) : _("<unknown>");
387
388@@ -2739,30 +2875,75 @@ md_apply_fix (fixS * fixP,
389 case BFD_RELOC_MICROBLAZE_64_TEXTREL:
390 case BFD_RELOC_MICROBLAZE_64:
391 case BFD_RELOC_MICROBLAZE_64_PCREL:
392- /* Add an imm instruction. First save the current instruction. */
393- for (i = 0; i < INST_WORD_SIZE; i++)
394- buf[i + INST_WORD_SIZE] = buf[i];
395 if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64
396 || fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
397 {
398 /* Generate the imm instruction. */
399+ if (((long long)val) > (long long)-549755813888 && ((long long)val) < (long long)549755813887)
400+ {
401+ /* Add an imm instruction. First save the current instruction. */
402+ for (i = 0; i < INST_WORD_SIZE; i++)
403+ buf[i + INST_WORD_SIZE] = buf[i];
404 opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
405 if (opcode1 == NULL)
406- {
407- as_bad (_("unknown opcode \"%s\""), "imml");
408- return;
409- }
410+ {
411+ as_bad (_("unknown opcode \"%s\""), "imml");
412+ return;
413+ }
414
415 inst1 = opcode1->bit_sequence;
416 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
417- inst1 |= ((val & 0xFFFFFF0000L) >> 16) & IMML_MASK;
418+ inst1 |= ((val & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
419+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
420+ fixP->fx_r_type = BFD_RELOC_64;
421+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
422+ fixP->fx_r_type = BFD_RELOC_64_PCREL;
423+ buf[0] = INST_BYTE0 (inst1);
424+ buf[1] = INST_BYTE1 (inst1);
425+ buf[2] = INST_BYTE2 (inst1);
426+ buf[3] = INST_BYTE3 (inst1);
427+ }
428+ else {
429+ /* Add an imm instruction. First save the current instruction. */
430+ for (i = 0; i < INST_WORD_SIZE; i++)
431+ buf[i + INST_WORD_SIZE + 4] = buf[i];
432+
433+ opcode2 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
434+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
435+ if (opcode1 == NULL || opcode2 ==NULL)
436+ {
437+ as_bad (_("unknown opcode \"%s\""), "imml");
438+ return;
439+ }
440+ inst1 = opcode2->bit_sequence;
441+ if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
442+ inst1 |= ((val & 0x000000FFFFFF0000L) >> 40) & IMML_MASK;
443+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
444+ fixP->fx_r_type = BFD_RELOC_64;
445+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
446+ fixP->fx_r_type = BFD_RELOC_64_PCREL;
447+ inst2 = opcode1->bit_sequence;
448+ if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
449+ inst1 |= ((val & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
450 if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64)
451- fixP->fx_r_type = BFD_RELOC_64;
452+ fixP->fx_r_type = BFD_RELOC_64;
453 if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
454- fixP->fx_r_type = BFD_RELOC_64_PCREL;
455+ fixP->fx_r_type = BFD_RELOC_64_PCREL;
456+ buf[0] = INST_BYTE0 (inst1);
457+ buf[1] = INST_BYTE1 (inst1);
458+ buf[2] = INST_BYTE2 (inst1);
459+ buf[3] = INST_BYTE3 (inst1);
460+ buf[4] = INST_BYTE0 (inst2);
461+ buf[5] = INST_BYTE1 (inst2);
462+ buf[6] = INST_BYTE2 (inst2);
463+ buf[7] = INST_BYTE3 (inst2);
464+ }
465 }
466 else
467 {
468+ /* Add an imm instruction. First save the current instruction. */
469+ for (i = 0; i < INST_WORD_SIZE; i++)
470+ buf[i + INST_WORD_SIZE] = buf[i];
471 /* Generate the imm instruction. */
472 opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
473 if (opcode1 == NULL)
474@@ -2774,12 +2955,11 @@ md_apply_fix (fixS * fixP,
475 inst1 = opcode1->bit_sequence;
476 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
477 inst1 |= ((val & 0xFFFF0000) >> 16) & IMM_MASK;
478- }
479 buf[0] = INST_BYTE0 (inst1);
480 buf[1] = INST_BYTE1 (inst1);
481 buf[2] = INST_BYTE2 (inst1);
482 buf[3] = INST_BYTE3 (inst1);
483-
484+ }
485 /* Add the value only if the symbol is defined. */
486 if (fixP->fx_addsy == NULL || S_IS_DEFINED (fixP->fx_addsy))
487 {
488@@ -2811,21 +2991,41 @@ md_apply_fix (fixS * fixP,
489 /* Add an imm instruction. First save the current instruction. */
490 for (i = 0; i < INST_WORD_SIZE; i++)
491 buf[i + INST_WORD_SIZE] = buf[i];
492- if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
493- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
494+ if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC) {
495+ if (((long long)val) > (long long)-549755813888 && ((long long)val) < (long long)549755813887)
496+ {
497+ for (i = 0; i < INST_WORD_SIZE; i++)
498+ buf[i + INST_WORD_SIZE] = buf[i];
499+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
500+ }
501+ else {
502+ for (i = 0; i < INST_WORD_SIZE; i++)
503+ buf[i + INST_WORD_SIZE + 4] = buf[i];
504+ opcode2 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
505+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
506+ inst2 = opcode2->bit_sequence;
507+
508+ /* We can fixup call to a defined non-global address
509+ * within the same section only. */
510+ buf[4] = INST_BYTE0 (inst2);
511+ buf[5] = INST_BYTE1 (inst2);
512+ buf[6] = INST_BYTE2 (inst2);
513+ buf[7] = INST_BYTE3 (inst2);
514+ }
515+ }
516 else
517 opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
518 if (opcode1 == NULL)
519 {
520+ for (i = 0; i < INST_WORD_SIZE; i++)
521+ buf[i + INST_WORD_SIZE] = buf[i];
522 if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_GPC)
523 as_bad (_("unknown opcode \"%s\""), "imml");
524 else
525 as_bad (_("unknown opcode \"%s\""), "imm");
526 return;
527 }
528-
529 inst1 = opcode1->bit_sequence;
530-
531 /* We can fixup call to a defined non-global address
532 within the same section only. */
533 buf[0] = INST_BYTE0 (inst1);
534diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
535index 0774f70e08..bd9d91cd57 100644
536--- a/opcodes/microblaze-opc.h
537+++ b/opcodes/microblaze-opc.h
538@@ -626,8 +626,8 @@ char pvr_register_prefix[] = "rpvr";
539 #define MIN_IMM6_WIDTH ((int) 0x00000001)
540 #define MAX_IMM6_WIDTH ((int) 0x00000040)
541
542-#define MIN_IMML ((long long) 0xffffff8000000000L)
543-#define MAX_IMML ((long long) 0x0000007fffffffffL)
544+#define MIN_IMML ((long long) -9223372036854775808)
545+#define MAX_IMML ((long long) 9223372036854775807)
546
547 #endif /* MICROBLAZE_OPC */
548
549--
5502.17.1
551
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0032-Add-initial-port-of-linux-gdbserver.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0032-Add-initial-port-of-linux-gdbserver.patch
new file mode 100644
index 00000000..7ac89d2d
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0032-Add-initial-port-of-linux-gdbserver.patch
@@ -0,0 +1,435 @@
1From c347f9727cc86bb0174dc001446c0670e7306692 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 19:07:44 +0530
4Subject: [PATCH 32/43] Add initial port of linux gdbserver add
5 gdb_proc_service_h to gdbserver microblaze-linux
6
7gdbserver needs to initialise the microblaze registers
8
9other archs use this step to run a *_arch_setup() to carry out all
10architecture specific setup - may need to add in future
11
12 * add linux-ptrace.o to gdbserver configure
13 * Update breakpoint opcode
14 * fix segfault on connecting gdbserver
15 * add microblaze_linux_memory_remove_breakpoint
16 * add set_solib_svr4_fetch_link_map_offsets
17 * add set_gdbarch_fetch_tls_load_module_address
18 * Force reading of r0 as 0, prevent stores
19
20Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
21Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
22---
23 gdb/configure.host | 3 +
24 gdb/gdbserver/linux-microblaze-low.c | 189 +++++++++++++++++++++++++++
25 gdb/microblaze-linux-tdep.c | 29 +++-
26 gdb/microblaze-tdep.c | 35 ++++-
27 gdb/microblaze-tdep.h | 4 +-
28 gdb/regformats/reg-microblaze.dat | 41 ++++++
29 6 files changed, 298 insertions(+), 3 deletions(-)
30 create mode 100644 gdb/gdbserver/linux-microblaze-low.c
31 create mode 100644 gdb/regformats/reg-microblaze.dat
32
33diff --git a/gdb/configure.host b/gdb/configure.host
34index c87f997abc..de8d6b00f3 100644
35--- a/gdb/configure.host
36+++ b/gdb/configure.host
37@@ -65,6 +65,7 @@ hppa*) gdb_host_cpu=pa ;;
38 i[34567]86*) gdb_host_cpu=i386 ;;
39 m68*) gdb_host_cpu=m68k ;;
40 mips*) gdb_host_cpu=mips ;;
41+microblaze*) gdb_host_cpu=microblaze ;;
42 powerpc* | rs6000) gdb_host_cpu=powerpc ;;
43 sparcv9 | sparc64) gdb_host_cpu=sparc ;;
44 s390*) gdb_host_cpu=s390 ;;
45@@ -133,6 +134,8 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
46 mips*-*-freebsd*) gdb_host=fbsd ;;
47 mips64*-*-openbsd*) gdb_host=obsd64 ;;
48
49+microblaze*-*linux*) gdb_host=linux ;;
50+
51 powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
52 gdb_host=aix ;;
53 powerpc*-*-freebsd*) gdb_host=fbsd ;;
54diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c
55new file mode 100644
56index 0000000000..cba5d6fc58
57--- /dev/null
58+++ b/gdb/gdbserver/linux-microblaze-low.c
59@@ -0,0 +1,189 @@
60+/* GNU/Linux/Microblaze specific low level interface, for the remote server for
61+ GDB.
62+ Copyright (C) 1995-2013 Free Software Foundation, Inc.
63+
64+ This file is part of GDB.
65+
66+ This program is free software; you can redistribute it and/or modify
67+ it under the terms of the GNU General Public License as published by
68+ the Free Software Foundation; either version 3 of the License, or
69+ (at your option) any later version.
70+
71+ This program is distributed in the hope that it will be useful,
72+ but WITHOUT ANY WARRANTY; without even the implied warranty of
73+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74+ GNU General Public License for more details.
75+
76+ You should have received a copy of the GNU General Public License
77+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
78+
79+#include "server.h"
80+#include "linux-low.h"
81+
82+#include <asm/ptrace.h>
83+#include <sys/procfs.h>
84+#include <sys/ptrace.h>
85+
86+#include "gdb_proc_service.h"
87+
88+static int microblaze_regmap[] =
89+ {PT_GPR(0), PT_GPR(1), PT_GPR(2), PT_GPR(3),
90+ PT_GPR(4), PT_GPR(5), PT_GPR(6), PT_GPR(7),
91+ PT_GPR(8), PT_GPR(9), PT_GPR(10), PT_GPR(11),
92+ PT_GPR(12), PT_GPR(13), PT_GPR(14), PT_GPR(15),
93+ PT_GPR(16), PT_GPR(17), PT_GPR(18), PT_GPR(19),
94+ PT_GPR(20), PT_GPR(21), PT_GPR(22), PT_GPR(23),
95+ PT_GPR(24), PT_GPR(25), PT_GPR(26), PT_GPR(27),
96+ PT_GPR(28), PT_GPR(29), PT_GPR(30), PT_GPR(31),
97+ PT_PC, PT_MSR, PT_EAR, PT_ESR,
98+ PT_FSR
99+ };
100+
101+#define microblaze_num_regs (sizeof microblaze_regmap / sizeof microblaze_regmap[0])
102+
103+/* Defined in auto-generated file microblaze-linux.c. */
104+void init_registers_microblaze (void);
105+
106+static int
107+microblaze_cannot_store_register (int regno)
108+{
109+ if (microblaze_regmap[regno] == -1 || regno == 0)
110+ return 1;
111+
112+ return 0;
113+}
114+
115+static int
116+microblaze_cannot_fetch_register (int regno)
117+{
118+ return 0;
119+}
120+
121+static CORE_ADDR
122+microblaze_get_pc (struct regcache *regcache)
123+{
124+ unsigned long pc;
125+
126+ collect_register_by_name (regcache, "pc", &pc);
127+ return (CORE_ADDR) pc;
128+}
129+
130+static void
131+microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
132+{
133+ unsigned long newpc = pc;
134+
135+ supply_register_by_name (regcache, "pc", &newpc);
136+}
137+
138+/* dbtrap insn */
139+/* brki r16, 0x18; */
140+static const unsigned long microblaze_breakpoint = 0xba0c0018;
141+#define microblaze_breakpoint_len 4
142+
143+static int
144+microblaze_breakpoint_at (CORE_ADDR where)
145+{
146+ unsigned long insn;
147+
148+ (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
149+ if (insn == microblaze_breakpoint)
150+ return 1;
151+ /* If necessary, recognize more trap instructions here. GDB only uses the
152+ one. */
153+ return 0;
154+}
155+
156+static CORE_ADDR
157+microblaze_reinsert_addr (struct regcache *regcache)
158+{
159+ unsigned long pc;
160+ collect_register_by_name (regcache, "r15", &pc);
161+ return pc;
162+}
163+
164+#ifdef HAVE_PTRACE_GETREGS
165+
166+static void
167+microblaze_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
168+{
169+ int size = register_size (regno);
170+
171+ memset (buf, 0, sizeof (long));
172+
173+ if (size < sizeof (long))
174+ collect_register (regcache, regno, buf + sizeof (long) - size);
175+ else
176+ collect_register (regcache, regno, buf);
177+}
178+
179+static void
180+microblaze_supply_ptrace_register (struct regcache *regcache,
181+ int regno, const char *buf)
182+{
183+ int size = register_size (regno);
184+
185+ if (regno == 0) {
186+ unsigned long regbuf_0 = 0;
187+ /* clobbering r0 so that it is always 0 as enforced by hardware */
188+ supply_register (regcache, regno, (const char*)&regbuf_0);
189+ } else {
190+ if (size < sizeof (long))
191+ supply_register (regcache, regno, buf + sizeof (long) - size);
192+ else
193+ supply_register (regcache, regno, buf);
194+ }
195+}
196+
197+/* Provide only a fill function for the general register set. ps_lgetregs
198+ will use this for NPTL support. */
199+
200+static void microblaze_fill_gregset (struct regcache *regcache, void *buf)
201+{
202+ int i;
203+
204+ for (i = 0; i < 32; i++)
205+ microblaze_collect_ptrace_register (regcache, i, (char *) buf + microblaze_regmap[i]);
206+}
207+
208+static void
209+microblaze_store_gregset (struct regcache *regcache, const void *buf)
210+{
211+ int i;
212+
213+ for (i = 0; i < 32; i++)
214+ supply_register (regcache, i, (char *) buf + microblaze_regmap[i]);
215+}
216+
217+#endif /* HAVE_PTRACE_GETREGS */
218+
219+struct regset_info target_regsets[] = {
220+#ifdef HAVE_PTRACE_GETREGS
221+ { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
222+ { 0, 0, 0, -1, -1, NULL, NULL },
223+#endif /* HAVE_PTRACE_GETREGS */
224+ { 0, 0, 0, -1, -1, NULL, NULL }
225+};
226+
227+struct linux_target_ops the_low_target = {
228+ init_registers_microblaze,
229+ microblaze_num_regs,
230+ microblaze_regmap,
231+ NULL,
232+ microblaze_cannot_fetch_register,
233+ microblaze_cannot_store_register,
234+ NULL, /* fetch_register */
235+ microblaze_get_pc,
236+ microblaze_set_pc,
237+ (const unsigned char *) &microblaze_breakpoint,
238+ microblaze_breakpoint_len,
239+ microblaze_reinsert_addr,
240+ 0,
241+ microblaze_breakpoint_at,
242+ NULL,
243+ NULL,
244+ NULL,
245+ NULL,
246+ microblaze_collect_ptrace_register,
247+ microblaze_supply_ptrace_register,
248+};
249diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
250index 4e5f60cd4e..7ab650a1cc 100644
251--- a/gdb/microblaze-linux-tdep.c
252+++ b/gdb/microblaze-linux-tdep.c
253@@ -37,6 +37,22 @@
254 #include "tramp-frame.h"
255 #include "linux-tdep.h"
256
257+static int microblaze_debug_flag = 0;
258+
259+static void
260+microblaze_debug (const char *fmt, ...)
261+{
262+ if (microblaze_debug_flag)
263+ {
264+ va_list args;
265+
266+ va_start (args, fmt);
267+ printf_unfiltered ("MICROBLAZE LINUX: ");
268+ vprintf_unfiltered (fmt, args);
269+ va_end (args);
270+ }
271+}
272+
273 static int
274 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
275 struct bp_target_info *bp_tgt)
276@@ -46,18 +62,25 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
277 int val;
278 int bplen;
279 gdb_byte old_contents[BREAKPOINT_MAX];
280+ struct cleanup *cleanup;
281
282 /* Determine appropriate breakpoint contents and size for this address. */
283 bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
284
285+ /* Make sure we see the memory breakpoints. */
286+ cleanup = make_show_memory_breakpoints_cleanup (1);
287 val = target_read_memory (addr, old_contents, bplen);
288
289 /* If our breakpoint is no longer at the address, this means that the
290 program modified the code on us, so it is wrong to put back the
291 old value. */
292 if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
293- val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
294+ {
295+ val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
296+ microblaze_debug ("microblaze_linux_memory_remove_breakpoint writing back to memory at addr 0x%lx\n", addr);
297+ }
298
299+ do_cleanups (cleanup);
300 return val;
301 }
302
303@@ -129,6 +152,10 @@ microblaze_linux_init_abi (struct gdbarch_info info,
304 /* Trampolines. */
305 tramp_frame_prepend_unwinder (gdbarch,
306 &microblaze_linux_sighandler_tramp_frame);
307+
308+ /* Enable TLS support. */
309+ set_gdbarch_fetch_tls_load_module_address (gdbarch,
310+ svr4_fetch_objfile_link_map);
311 }
312
313 void
314diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
315index 1248acbdc9..730a2b281f 100644
316--- a/gdb/microblaze-tdep.c
317+++ b/gdb/microblaze-tdep.c
318@@ -137,7 +137,38 @@ microblaze_fetch_instruction (CORE_ADDR pc)
319 constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT;
320
321 typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint;
322-
323+static int
324+microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
325+ struct bp_target_info *bp_tgt)
326+{
327+ CORE_ADDR addr = bp_tgt->placed_address;
328+ const unsigned char *bp;
329+ int val;
330+ int bplen;
331+ gdb_byte old_contents[BREAKPOINT_MAX];
332+ struct cleanup *cleanup;
333+
334+ /* Determine appropriate breakpoint contents and size for this address. */
335+ bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
336+ if (bp == NULL)
337+ error (_("Software breakpoints not implemented for this target."));
338+
339+ /* Make sure we see the memory breakpoints. */
340+ cleanup = make_show_memory_breakpoints_cleanup (1);
341+ val = target_read_memory (addr, old_contents, bplen);
342+
343+ /* If our breakpoint is no longer at the address, this means that the
344+ program modified the code on us, so it is wrong to put back the
345+ old value. */
346+ if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
347+ {
348+ val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
349+ microblaze_debug ("microblaze_linux_memory_remove_breakpoint writing back to memory at addr 0x%lx\n", addr);
350+ }
351+
352+ do_cleanups (cleanup);
353+ return val;
354+}
355
356 /* Allocate and initialize a frame cache. */
357
358@@ -731,6 +762,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
359 microblaze_breakpoint::kind_from_pc);
360 set_gdbarch_sw_breakpoint_from_kind (gdbarch,
361 microblaze_breakpoint::bp_from_kind);
362+ set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint);
363
364 set_gdbarch_frame_args_skip (gdbarch, 8);
365
366@@ -770,4 +802,5 @@ When non-zero, microblaze specific debugging is enabled."),
367 NULL,
368 &setdebuglist, &showdebuglist);
369
370+
371 }
372diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
373index a0048148e4..63aab84ef6 100644
374--- a/gdb/microblaze-tdep.h
375+++ b/gdb/microblaze-tdep.h
376@@ -117,6 +117,8 @@ struct microblaze_frame_cache
377
378 /* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used.
379 Only used for native debugging. */
380-#define MICROBLAZE_BREAKPOINT {0xb9, 0xcc, 0x00, 0x60}
381+#define MICROBLAZE_BREAKPOINT {0xba, 0x0c, 0x00, 0x18}
382+#define MICROBLAZE_BREAKPOINT_LE {0x18, 0x00, 0x0c, 0xba}
383+
384
385 #endif /* microblaze-tdep.h */
386diff --git a/gdb/regformats/reg-microblaze.dat b/gdb/regformats/reg-microblaze.dat
387new file mode 100644
388index 0000000000..bd8a438442
389--- /dev/null
390+++ b/gdb/regformats/reg-microblaze.dat
391@@ -0,0 +1,41 @@
392+name:microblaze
393+expedite:r1,pc
394+32:r0
395+32:r1
396+32:r2
397+32:r3
398+32:r4
399+32:r5
400+32:r6
401+32:r7
402+32:r8
403+32:r9
404+32:r10
405+32:r11
406+32:r12
407+32:r13
408+32:r14
409+32:r15
410+32:r16
411+32:r17
412+32:r18
413+32:r19
414+32:r20
415+32:r21
416+32:r22
417+32:r23
418+32:r24
419+32:r25
420+32:r26
421+32:r27
422+32:r28
423+32:r29
424+32:r30
425+32:r31
426+32:pc
427+32:msr
428+32:ear
429+32:esr
430+32:fsr
431+32:slr
432+32:shr
433--
4342.17.1
435
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0033-Initial-port-of-core-reading-support.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0033-Initial-port-of-core-reading-support.patch
new file mode 100644
index 00000000..e6bbf2b7
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0033-Initial-port-of-core-reading-support.patch
@@ -0,0 +1,388 @@
1From 0fd864ff792d7bcbbcbed5ee0ae9f429f1fd2353 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 24 Jan 2017 14:55:56 +0530
4Subject: [PATCH 33/43] Initial port of core reading support Added support for
5 reading notes in linux core dumps Support for reading of PRSTATUS and PSINFO
6 information for rebuilding ".reg" sections of core dumps at run time.
7
8Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
9Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
10---
11 bfd/elf32-microblaze.c | 84 ++++++++++++++++++++++++++++++++++
12 gdb/configure.tgt | 2 +-
13 gdb/microblaze-linux-tdep.c | 57 +++++++++++++++++++++++
14 gdb/microblaze-tdep.c | 90 +++++++++++++++++++++++++++++++++++++
15 gdb/microblaze-tdep.h | 27 +++++++++++
16 5 files changed, 259 insertions(+), 1 deletion(-)
17
18diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
19index 6a795c5069..c280431df6 100644
20--- a/bfd/elf32-microblaze.c
21+++ b/bfd/elf32-microblaze.c
22@@ -767,6 +767,87 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
23 return _bfd_elf_is_local_label_name (abfd, name);
24 }
25
26+/* Support for core dump NOTE sections. */
27+static bfd_boolean
28+microblaze_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
29+{
30+ int offset;
31+ unsigned int size;
32+
33+ switch (note->descsz)
34+ {
35+ default:
36+ return FALSE;
37+
38+ case 228: /* Linux/MicroBlaze */
39+ /* pr_cursig */
40+ elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
41+
42+ /* pr_pid */
43+ elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
44+
45+ /* pr_reg */
46+ offset = 72;
47+ size = 50 * 4;
48+
49+ break;
50+ }
51+
52+ /* Make a ".reg/999" section. */
53+ return _bfd_elfcore_make_pseudosection (abfd, ".reg",
54+ size, note->descpos + offset);
55+}
56+
57+static bfd_boolean
58+microblaze_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
59+{
60+ switch (note->descsz)
61+ {
62+ default:
63+ return FALSE;
64+
65+ case 128: /* Linux/MicroBlaze elf_prpsinfo */
66+ elf_tdata (abfd)->core->program
67+ = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
68+ elf_tdata (abfd)->core->command
69+ = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
70+ }
71+
72+ /* Note that for some reason, a spurious space is tacked
73+ onto the end of the args in some (at least one anyway)
74+ implementations, so strip it off if it exists. */
75+
76+ {
77+ char *command = elf_tdata (abfd)->core->command;
78+ int n = strlen (command);
79+
80+ if (0 < n && command[n - 1] == ' ')
81+ command[n - 1] = '\0';
82+ }
83+
84+ return TRUE;
85+}
86+
87+/* The microblaze linker (like many others) needs to keep track of
88+ the number of relocs that it decides to copy as dynamic relocs in
89+ check_relocs for each symbol. This is so that it can later discard
90+ them if they are found to be unnecessary. We store the information
91+ in a field extending the regular ELF linker hash table. */
92+
93+struct elf32_mb_dyn_relocs
94+{
95+ struct elf32_mb_dyn_relocs *next;
96+
97+ /* The input section of the reloc. */
98+ asection *sec;
99+
100+ /* Total number of relocs copied for the input section. */
101+ bfd_size_type count;
102+
103+ /* Number of pc-relative relocs copied for the input section. */
104+ bfd_size_type pc_count;
105+};
106+
107 /* ELF linker hash entry. */
108
109 struct elf32_mb_link_hash_entry
110@@ -3672,4 +3753,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
111 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
112 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
113
114+#define elf_backend_grok_prstatus microblaze_elf_grok_prstatus
115+#define elf_backend_grok_psinfo microblaze_elf_grok_psinfo
116+
117 #include "elf32-target.h"
118diff --git a/gdb/configure.tgt b/gdb/configure.tgt
119index 27f122ad04..622bd486b3 100644
120--- a/gdb/configure.tgt
121+++ b/gdb/configure.tgt
122@@ -397,7 +397,7 @@ mep-*-*)
123
124 microblaze*-linux-*|microblaze*-*-linux*)
125 # Target: Xilinx MicroBlaze running Linux
126- gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o \
127+ gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o glibc-tdep.o \
128 symfile-mem.o linux-tdep.o"
129 gdb_sim=../sim/microblaze/libsim.a
130 ;;
131diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
132index 7ab650a1cc..e2225d778a 100644
133--- a/gdb/microblaze-linux-tdep.c
134+++ b/gdb/microblaze-linux-tdep.c
135@@ -135,11 +135,54 @@ static struct tramp_frame microblaze_linux_sighandler_tramp_frame =
136 microblaze_linux_sighandler_cache_init
137 };
138
139+const struct microblaze_gregset microblaze_linux_core_gregset;
140+
141+static void
142+microblaze_linux_supply_core_gregset (const struct regset *regset,
143+ struct regcache *regcache,
144+ int regnum, const void *gregs, size_t len)
145+{
146+ microblaze_supply_gregset (&microblaze_linux_core_gregset, regcache,
147+ regnum, gregs);
148+}
149+
150+static void
151+microblaze_linux_collect_core_gregset (const struct regset *regset,
152+ const struct regcache *regcache,
153+ int regnum, void *gregs, size_t len)
154+{
155+ microblaze_collect_gregset (&microblaze_linux_core_gregset, regcache,
156+ regnum, gregs);
157+}
158+
159+static void
160+microblaze_linux_supply_core_fpregset (const struct regset *regset,
161+ struct regcache *regcache,
162+ int regnum, const void *fpregs, size_t len)
163+{
164+ /* FIXME. */
165+ microblaze_supply_fpregset (regcache, regnum, fpregs);
166+}
167+
168+static void
169+microblaze_linux_collect_core_fpregset (const struct regset *regset,
170+ const struct regcache *regcache,
171+ int regnum, void *fpregs, size_t len)
172+{
173+ /* FIXME. */
174+ microblaze_collect_fpregset (regcache, regnum, fpregs);
175+}
176
177 static void
178 microblaze_linux_init_abi (struct gdbarch_info info,
179 struct gdbarch *gdbarch)
180 {
181+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
182+
183+ tdep->gregset = regset_alloc (gdbarch, microblaze_linux_supply_core_gregset,
184+ microblaze_linux_collect_core_gregset);
185+ tdep->sizeof_gregset = 200;
186+
187 linux_init_abi (info, gdbarch);
188
189 set_gdbarch_memory_remove_breakpoint (gdbarch,
190@@ -153,6 +196,20 @@ microblaze_linux_init_abi (struct gdbarch_info info,
191 tramp_frame_prepend_unwinder (gdbarch,
192 &microblaze_linux_sighandler_tramp_frame);
193
194+ /* BFD target for core files. */
195+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
196+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblaze");
197+ else
198+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblazeel");
199+
200+
201+ /* Shared library handling. */
202+ set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
203+ set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
204+
205+ set_gdbarch_regset_from_core_section (gdbarch,
206+ microblaze_regset_from_core_section);
207+
208 /* Enable TLS support. */
209 set_gdbarch_fetch_tls_load_module_address (gdbarch,
210 svr4_fetch_objfile_link_map);
211diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
212index 730a2b281f..49713ea9b1 100644
213--- a/gdb/microblaze-tdep.c
214+++ b/gdb/microblaze-tdep.c
215@@ -137,6 +137,14 @@ microblaze_fetch_instruction (CORE_ADDR pc)
216 constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT;
217
218 typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint;
219+static CORE_ADDR
220+microblaze_store_arguments (struct regcache *regcache, int nargs,
221+ struct value **args, CORE_ADDR sp,
222+ int struct_return, CORE_ADDR struct_addr)
223+{
224+ error (_("store_arguments not implemented"));
225+ return sp;
226+}
227 static int
228 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
229 struct bp_target_info *bp_tgt)
230@@ -541,6 +549,12 @@ microblaze_frame_base_address (struct frame_info *next_frame,
231 return cache->base;
232 }
233
234+static const struct frame_unwind *
235+microblaze_frame_sniffer (struct frame_info *next_frame)
236+{
237+ return &microblaze_frame_unwind;
238+}
239+
240 static const struct frame_base microblaze_frame_base =
241 {
242 &microblaze_frame_unwind,
243@@ -677,6 +691,71 @@ microblaze_register_g_packet_guesses (struct gdbarch *gdbarch)
244 tdesc_microblaze_with_stack_protect);
245 }
246
247+void
248+microblaze_supply_gregset (const struct microblaze_gregset *gregset,
249+ struct regcache *regcache,
250+ int regnum, const void *gregs)
251+{
252+ unsigned int *regs = gregs;
253+ if (regnum >= 0)
254+ regcache_raw_supply (regcache, regnum, regs + regnum);
255+
256+ if (regnum == -1) {
257+ int i;
258+
259+ for (i = 0; i < 50; i++) {
260+ regcache_raw_supply (regcache, i, regs + i);
261+ }
262+ }
263+}
264+
265+
266+void
267+microblaze_collect_gregset (const struct microblaze_gregset *gregset,
268+ const struct regcache *regcache,
269+ int regnum, void *gregs)
270+{
271+ /* FIXME. */
272+}
273+
274+void
275+microblaze_supply_fpregset (struct regcache *regcache,
276+ int regnum, const void *fpregs)
277+{
278+ /* FIXME. */
279+}
280+
281+void
282+microblaze_collect_fpregset (const struct regcache *regcache,
283+ int regnum, void *fpregs)
284+{
285+ /* FIXME. */
286+}
287+
288+
289+/* Return the appropriate register set for the core section identified
290+ by SECT_NAME and SECT_SIZE. */
291+
292+const struct regset *
293+microblaze_regset_from_core_section (struct gdbarch *gdbarch,
294+ const char *sect_name, size_t sect_size)
295+{
296+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
297+
298+ microblaze_debug ("microblaze_regset_from_core_section, sect_name = %s\n", sect_name);
299+
300+ if (strcmp (sect_name, ".reg") == 0 && sect_size >= tdep->sizeof_gregset)
301+ return tdep->gregset;
302+
303+ if (strcmp (sect_name, ".reg2") == 0 && sect_size >= tdep->sizeof_fpregset)
304+ return tdep->fpregset;
305+
306+ microblaze_debug ("microblaze_regset_from_core_section returning null :-( \n");
307+ return NULL;
308+}
309+
310+
311+
312 static struct gdbarch *
313 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
314 {
315@@ -733,6 +812,10 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
316 tdep = XCNEW (struct gdbarch_tdep);
317 gdbarch = gdbarch_alloc (&info, tdep);
318
319+ tdep->gregset = NULL;
320+ tdep->sizeof_gregset = 0;
321+ tdep->fpregset = NULL;
322+ tdep->sizeof_fpregset = 0;
323 set_gdbarch_long_double_bit (gdbarch, 128);
324
325 set_gdbarch_num_regs (gdbarch, MICROBLAZE_NUM_REGS);
326@@ -781,6 +864,13 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
327 frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
328 if (tdesc_data != NULL)
329 tdesc_use_registers (gdbarch, tdesc, tdesc_data);
330+ //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer);
331+
332+ /* If we have register sets, enable the generic core file support. */
333+ if (tdep->gregset) {
334+ set_gdbarch_regset_from_core_section (gdbarch,
335+ microblaze_regset_from_core_section);
336+ }
337
338 return gdbarch;
339 }
340diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
341index 63aab84ef6..02650f61d9 100644
342--- a/gdb/microblaze-tdep.h
343+++ b/gdb/microblaze-tdep.h
344@@ -22,8 +22,22 @@
345
346
347 /* Microblaze architecture-specific information. */
348+struct microblaze_gregset
349+{
350+ unsigned int gregs[32];
351+ unsigned int fpregs[32];
352+ unsigned int pregs[16];
353+};
354+
355 struct gdbarch_tdep
356 {
357+ int dummy; // declare something.
358+
359+ /* Register sets. */
360+ struct regset *gregset;
361+ size_t sizeof_gregset;
362+ struct regset *fpregset;
363+ size_t sizeof_fpregset;
364 };
365
366 /* Register numbers. */
367@@ -120,5 +134,18 @@ struct microblaze_frame_cache
368 #define MICROBLAZE_BREAKPOINT {0xba, 0x0c, 0x00, 0x18}
369 #define MICROBLAZE_BREAKPOINT_LE {0x18, 0x00, 0x0c, 0xba}
370
371+extern void microblaze_supply_gregset (const struct microblaze_gregset *gregset,
372+ struct regcache *regcache,
373+ int regnum, const void *gregs);
374+extern void microblaze_collect_gregset (const struct microblaze_gregset *gregset,
375+ const struct regcache *regcache,
376+ int regnum, void *gregs);
377+extern void microblaze_supply_fpregset (struct regcache *regcache,
378+ int regnum, const void *fpregs);
379+extern void microblaze_collect_fpregset (const struct regcache *regcache,
380+ int regnum, void *fpregs);
381+
382+extern const struct regset * microblaze_regset_from_core_section (struct gdbarch *gdbarch,
383+ const char *sect_name, size_t sect_size);
384
385 #endif /* microblaze-tdep.h */
386--
3872.17.1
388
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0034-Fix-debug-message-when-register-is-unavailable.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0034-Fix-debug-message-when-register-is-unavailable.patch
new file mode 100644
index 00000000..df5b3db3
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0034-Fix-debug-message-when-register-is-unavailable.patch
@@ -0,0 +1,40 @@
1From e44a27432ce56bb48eb9785ffaae14bc3a12bd27 Mon Sep 17 00:00:00 2001
2From: Nathan Rossi <nathan.rossi@petalogix.com>
3Date: Tue, 8 May 2012 18:11:17 +1000
4Subject: [PATCH 34/43] Fix debug message when register is unavailable
5
6Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
7---
8 gdb/frame.c | 13 ++++++++++---
9 1 file changed, 10 insertions(+), 3 deletions(-)
10
11diff --git a/gdb/frame.c b/gdb/frame.c
12index d8b5f819f1..49706dc97c 100644
13--- a/gdb/frame.c
14+++ b/gdb/frame.c
15@@ -1227,12 +1227,19 @@ frame_unwind_register_value (frame_info *next_frame, int regnum)
16 else
17 {
18 int i;
19- const gdb_byte *buf = value_contents (value);
20+ const gdb_byte *buf = NULL;
21+ if (value_entirely_available(value)) {
22+ buf = value_contents (value);
23+ }
24
25 fprintf_unfiltered (gdb_stdlog, " bytes=");
26 fprintf_unfiltered (gdb_stdlog, "[");
27- for (i = 0; i < register_size (gdbarch, regnum); i++)
28- fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
29+ if (buf != NULL) {
30+ for (i = 0; i < register_size (gdbarch, regnum); i++)
31+ fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
32+ } else {
33+ fprintf_unfiltered (gdb_stdlog, "unavailable");
34+ }
35 fprintf_unfiltered (gdb_stdlog, "]");
36 }
37 }
38--
392.17.1
40
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0035-revert-master-rebase-changes-to-gdbserver.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0035-revert-master-rebase-changes-to-gdbserver.patch
new file mode 100644
index 00000000..ddb53a07
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0035-revert-master-rebase-changes-to-gdbserver.patch
@@ -0,0 +1,31 @@
1From 1c5dbbd272854e6e7912e2602bdfd78b64399319 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Mon, 22 Jul 2013 11:16:05 +1000
4Subject: [PATCH 35/43] revert master-rebase changes to gdbserver
5
6Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
7---
8 gdb/gdbserver/configure.srv | 7 +++++++
9 1 file changed, 7 insertions(+)
10
11diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
12index d19d22b3a3..7a0be5b072 100644
13--- a/gdb/gdbserver/configure.srv
14+++ b/gdb/gdbserver/configure.srv
15@@ -210,6 +210,13 @@ case "${target}" in
16 srv_linux_usrregs=yes
17 srv_linux_thread_db=yes
18 ;;
19+ microblaze*-*-linux*) srv_regobj=microblaze-linux.o
20+ srv_tgtobj="linux-low.o linux-osdata.o linux-microblaze-low.o "
21+ srv_tgtobj="${srv_tgtobj} linux-procfs.o linux-ptrace.o"
22+ srv_linux_regsets=yes
23+ srv_linux_usrregs=yes
24+ srv_linux_thread_db=yes
25+ ;;
26 powerpc*-*-linux*) srv_regobj="powerpc-32l.o"
27 srv_regobj="${srv_regobj} powerpc-altivec32l.o"
28 srv_regobj="${srv_regobj} powerpc-cell32l.o"
29--
302.17.1
31
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch
new file mode 100644
index 00000000..f2e5e951
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch
@@ -0,0 +1,33 @@
1From bd55e11af18006afb87a8b0fbd93bb0920354e0e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 30 Apr 2018 17:09:55 +0530
4Subject: [PATCH 36/43] revert master-rebase changes to gdbserver , previous
5 commit typo's
6
7---
8 gdb/gdbserver/Makefile.in | 2 ++
9 1 file changed, 2 insertions(+)
10
11diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
12index 4ae13692a2..45d95e6cab 100644
13--- a/gdb/gdbserver/Makefile.in
14+++ b/gdb/gdbserver/Makefile.in
15@@ -169,6 +169,7 @@ SFILES = \
16 $(srcdir)/linux-low.c \
17 $(srcdir)/linux-m32r-low.c \
18 $(srcdir)/linux-m68k-low.c \
19+ $(srcdir)/linux-microblaze-low.c \
20 $(srcdir)/linux-mips-low.c \
21 $(srcdir)/linux-nios2-low.c \
22 $(srcdir)/linux-ppc-low.c \
23@@ -226,6 +227,7 @@ SFILES = \
24 $(srcdir)/nat/linux-osdata.c \
25 $(srcdir)/nat/linux-personality.c \
26 $(srcdir)/nat/mips-linux-watch.c \
27+ $(srcdir)/nat/microblaze-linux.c \
28 $(srcdir)/nat/ppc-linux.c \
29 $(srcdir)/nat/fork-inferior.c \
30 $(srcdir)/target/waitstatus.c
31--
322.17.1
33
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch
new file mode 100644
index 00000000..e2b601b6
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch
@@ -0,0 +1,32 @@
1From 988a9a41ac91ce3293af8708c1c88c51c48a2a72 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Mon, 16 Dec 2013 16:37:32 +1000
4Subject: [PATCH 37/43] microblaze: Add build_gdbserver=yes to top level
5 configure.tgt
6
7For Microblaze linux toolchains, set the build_gdbserver=yes
8to allow driving gdbserver configuration from the upper level
9
10This patch has been absorbed into the original patch to add
11linux gdbserver support for Microblaze.
12
13Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
14---
15 gdb/configure.tgt | 1 +
16 1 file changed, 1 insertion(+)
17
18diff --git a/gdb/configure.tgt b/gdb/configure.tgt
19index 622bd486b3..989523735b 100644
20--- a/gdb/configure.tgt
21+++ b/gdb/configure.tgt
22@@ -405,6 +405,7 @@ microblaze*-*-*)
23 # Target: Xilinx MicroBlaze running standalone
24 gdb_target_obs="microblaze-tdep.o"
25 gdb_sim=../sim/microblaze/libsim.a
26+ build_gdbserver=yes
27 ;;
28
29 mips*-*-linux*)
30--
312.17.1
32
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0038-Initial-support-for-native-gdb.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0038-Initial-support-for-native-gdb.patch
new file mode 100644
index 00000000..1a50f0a6
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0038-Initial-support-for-native-gdb.patch
@@ -0,0 +1,511 @@
1From aa9cb6db79c663dc944cb67928d16e63f2a69f74 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@petalogix.com>
3Date: Fri, 20 Jul 2012 15:18:35 +1000
4Subject: [PATCH 38/43] Initial support for native gdb
5
6microblaze: Follow PPC method of getting setting registers
7using PTRACE PEEK/POKE
8
9Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
10
11Conflicts:
12 gdb/Makefile.in
13---
14 gdb/Makefile.in | 4 +-
15 gdb/config/microblaze/linux.mh | 9 +
16 gdb/microblaze-linux-nat.c | 431 +++++++++++++++++++++++++++++++++
17 3 files changed, 443 insertions(+), 1 deletion(-)
18 create mode 100644 gdb/config/microblaze/linux.mh
19 create mode 100644 gdb/microblaze-linux-nat.c
20
21diff --git a/gdb/Makefile.in b/gdb/Makefile.in
22index 215ef7933c..8c9a3c07c0 100644
23--- a/gdb/Makefile.in
24+++ b/gdb/Makefile.in
25@@ -1316,6 +1316,7 @@ HFILES_NO_SRCDIR = \
26 memory-map.h \
27 memrange.h \
28 microblaze-tdep.h \
29+ microblaze-linux-tdep.h \
30 mips-linux-tdep.h \
31 mips-nbsd-tdep.h \
32 mips-tdep.h \
33@@ -1349,6 +1350,7 @@ HFILES_NO_SRCDIR = \
34 prologue-value.h \
35 psympriv.h \
36 psymtab.h \
37+ ia64-hpux-tdep.h \
38 ravenscar-thread.h \
39 record.h \
40 record-full.h \
41@@ -2263,6 +2265,7 @@ ALLDEPFILES = \
42 m68k-tdep.c \
43 microblaze-linux-tdep.c \
44 microblaze-tdep.c \
45+ microblaze-linux-nat.c \
46 mingw-hdep.c \
47 mips-fbsd-nat.c \
48 mips-fbsd-tdep.c \
49@@ -2365,7 +2368,6 @@ ALLDEPFILES = \
50 xtensa-linux-tdep.c \
51 xtensa-tdep.c \
52 xtensa-xtregs.c \
53- common/mingw-strerror.c \
54 common/posix-strerror.c
55
56 # Some files need explicit build rules (due to -Werror problems) or due
57diff --git a/gdb/config/microblaze/linux.mh b/gdb/config/microblaze/linux.mh
58new file mode 100644
59index 0000000000..a4eaf540e1
60--- /dev/null
61+++ b/gdb/config/microblaze/linux.mh
62@@ -0,0 +1,9 @@
63+# Host: Microblaze, running Linux
64+
65+NAT_FILE= config/nm-linux.h
66+NATDEPFILES= inf-ptrace.o fork-child.o \
67+ microblaze-linux-nat.o proc-service.o linux-thread-db.o \
68+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
69+NAT_CDEPS = $(srcdir)/proc-service.list
70+
71+LOADLIBES = -ldl $(RDYNAMIC)
72diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c
73new file mode 100644
74index 0000000000..e9b8c9c522
75--- /dev/null
76+++ b/gdb/microblaze-linux-nat.c
77@@ -0,0 +1,431 @@
78+/* Microblaze GNU/Linux native support.
79+
80+ Copyright (C) 1988-1989, 1991-1992, 1994, 1996, 2000-2012 Free
81+ Software Foundation, Inc.
82+
83+ This file is part of GDB.
84+
85+ This program is free software; you can redistribute it and/or modify
86+ it under the terms of the GNU General Public License as published by
87+ the Free Software Foundation; either version 3 of the License, or
88+ (at your option) any later version.
89+
90+ This program is distributed in the hope that it will be useful,
91+ but WITHOUT ANY WARRANTY; without even the implied warranty of
92+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93+ GNU General Public License for more details.
94+
95+ You should have received a copy of the GNU General Public License
96+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
97+
98+#include "defs.h"
99+#include "arch-utils.h"
100+#include "dis-asm.h"
101+#include "frame.h"
102+#include "trad-frame.h"
103+#include "symtab.h"
104+#include "value.h"
105+#include "gdbcmd.h"
106+#include "breakpoint.h"
107+#include "inferior.h"
108+#include "regcache.h"
109+#include "target.h"
110+#include "frame.h"
111+#include "frame-base.h"
112+#include "frame-unwind.h"
113+#include "dwarf2-frame.h"
114+#include "osabi.h"
115+
116+#include "gdb_assert.h"
117+#include "gdb_string.h"
118+#include "target-descriptions.h"
119+#include "opcodes/microblaze-opcm.h"
120+#include "opcodes/microblaze-dis.h"
121+
122+#include "linux-nat.h"
123+#include "target-descriptions.h"
124+
125+#include <sys/user.h>
126+#include <sys/utsname.h>
127+#include <sys/procfs.h>
128+#include <sys/ptrace.h>
129+
130+/* Prototypes for supply_gregset etc. */
131+#include "gregset.h"
132+
133+#include "microblaze-tdep.h"
134+
135+#include <elf/common.h>
136+#include "auxv.h"
137+
138+/* Defines ps_err_e, struct ps_prochandle. */
139+#include "gdb_proc_service.h"
140+
141+/* On GNU/Linux, threads are implemented as pseudo-processes, in which
142+ case we may be tracing more than one process at a time. In that
143+ case, inferior_ptid will contain the main process ID and the
144+ individual thread (process) ID. get_thread_id () is used to get
145+ the thread id if it's available, and the process id otherwise. */
146+
147+int
148+get_thread_id (ptid_t ptid)
149+{
150+ int tid = TIDGET (ptid);
151+ if (0 == tid)
152+ tid = PIDGET (ptid);
153+ return tid;
154+}
155+
156+#define GET_THREAD_ID(PTID) get_thread_id (PTID)
157+
158+/* Non-zero if our kernel may support the PTRACE_GETREGS and
159+ PTRACE_SETREGS requests, for reading and writing the
160+ general-purpose registers. Zero if we've tried one of
161+ them and gotten an error. */
162+int have_ptrace_getsetregs = 1;
163+
164+static int
165+microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
166+{
167+ int u_addr = -1;
168+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
169+ /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
170+ interface, and not the wordsize of the program's ABI. */
171+ int wordsize = sizeof (long);
172+
173+ /* General purpose registers occupy 1 slot each in the buffer. */
174+ if (regno >= MICROBLAZE_R0_REGNUM
175+ && regno <= MICROBLAZE_FSR_REGNUM)
176+ u_addr = (regno * wordsize);
177+
178+ return u_addr;
179+}
180+
181+
182+static void
183+fetch_register (struct regcache *regcache, int tid, int regno)
184+{
185+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
186+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
187+ /* This isn't really an address. But ptrace thinks of it as one. */
188+ CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
189+ int bytes_transferred;
190+ unsigned int offset; /* Offset of registers within the u area. */
191+ char buf[MAX_REGISTER_SIZE];
192+
193+ if (regaddr == -1)
194+ {
195+ memset (buf, '\0', register_size (gdbarch, regno)); /* Supply zeroes */
196+ regcache_raw_supply (regcache, regno, buf);
197+ return;
198+ }
199+
200+ /* Read the raw register using sizeof(long) sized chunks. On a
201+ 32-bit platform, 64-bit floating-point registers will require two
202+ transfers. */
203+ for (bytes_transferred = 0;
204+ bytes_transferred < register_size (gdbarch, regno);
205+ bytes_transferred += sizeof (long))
206+ {
207+ long l;
208+
209+ errno = 0;
210+ l = ptrace (PTRACE_PEEKUSER, tid, (PTRACE_TYPE_ARG3) regaddr, 0);
211+ regaddr += sizeof (long);
212+ if (errno != 0)
213+ {
214+ char message[128];
215+ sprintf (message, "reading register %s (#%d)",
216+ gdbarch_register_name (gdbarch, regno), regno);
217+ perror_with_name (message);
218+ }
219+ memcpy (&buf[bytes_transferred], &l, sizeof (l));
220+ }
221+
222+ /* Now supply the register. Keep in mind that the regcache's idea
223+ of the register's size may not be a multiple of sizeof
224+ (long). */
225+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
226+ {
227+ /* Little-endian values are always found at the left end of the
228+ bytes transferred. */
229+ regcache_raw_supply (regcache, regno, buf);
230+ }
231+ else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
232+ {
233+ /* Big-endian values are found at the right end of the bytes
234+ transferred. */
235+ size_t padding = (bytes_transferred - register_size (gdbarch, regno));
236+ regcache_raw_supply (regcache, regno, buf + padding);
237+ }
238+ else
239+ internal_error (__FILE__, __LINE__,
240+ _("fetch_register: unexpected byte order: %d"),
241+ gdbarch_byte_order (gdbarch));
242+}
243+
244+/* This function actually issues the request to ptrace, telling
245+ it to get all general-purpose registers and put them into the
246+ specified regset.
247+
248+ If the ptrace request does not exist, this function returns 0
249+ and properly sets the have_ptrace_* flag. If the request fails,
250+ this function calls perror_with_name. Otherwise, if the request
251+ succeeds, then the regcache gets filled and 1 is returned. */
252+static int
253+fetch_all_gp_regs (struct regcache *regcache, int tid)
254+{
255+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
256+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
257+ gdb_gregset_t gregset;
258+
259+ if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
260+ {
261+ if (errno == EIO)
262+ {
263+ have_ptrace_getsetregs = 0;
264+ return 0;
265+ }
266+ perror_with_name (_("Couldn't get general-purpose registers."));
267+ }
268+
269+ supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
270+
271+ return 1;
272+}
273+
274+
275+/* This is a wrapper for the fetch_all_gp_regs function. It is
276+ responsible for verifying if this target has the ptrace request
277+ that can be used to fetch all general-purpose registers at one
278+ shot. If it doesn't, then we should fetch them using the
279+ old-fashioned way, which is to iterate over the registers and
280+ request them one by one. */
281+static void
282+fetch_gp_regs (struct regcache *regcache, int tid)
283+{
284+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
285+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
286+ int i;
287+
288+ if (have_ptrace_getsetregs)
289+ if (fetch_all_gp_regs (regcache, tid))
290+ return;
291+
292+ /* If we've hit this point, it doesn't really matter which
293+ architecture we are using. We just need to read the
294+ registers in the "old-fashioned way". */
295+ for (i = MICROBLAZE_R0_REGNUM; i <= MICROBLAZE_FSR_REGNUM; i++)
296+ fetch_register (regcache, tid, i);
297+}
298+
299+
300+static void
301+store_register (const struct regcache *regcache, int tid, int regno)
302+{
303+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
304+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
305+ /* This isn't really an address. But ptrace thinks of it as one. */
306+ CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
307+ int i;
308+ size_t bytes_to_transfer;
309+ char buf[MAX_REGISTER_SIZE];
310+
311+ if (regaddr == -1)
312+ return;
313+
314+ /* First collect the register. Keep in mind that the regcache's
315+ idea of the register's size may not be a multiple of sizeof
316+ (long). */
317+ memset (buf, 0, sizeof buf);
318+ bytes_to_transfer = align_up (register_size (gdbarch, regno), sizeof (long));
319+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
320+ {
321+ /* Little-endian values always sit at the left end of the buffer. */
322+ regcache_raw_collect (regcache, regno, buf);
323+ }
324+ else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
325+ {
326+ /* Big-endian values sit at the right end of the buffer. */
327+ size_t padding = (bytes_to_transfer - register_size (gdbarch, regno));
328+ regcache_raw_collect (regcache, regno, buf + padding);
329+ }
330+
331+ for (i = 0; i < bytes_to_transfer; i += sizeof (long))
332+ {
333+ long l;
334+
335+ memcpy (&l, &buf[i], sizeof (l));
336+ errno = 0;
337+ ptrace (PTRACE_POKEUSER, tid, (PTRACE_TYPE_ARG3) regaddr, l);
338+ regaddr += sizeof (long);
339+
340+ if (errno != 0)
341+ {
342+ char message[128];
343+ sprintf (message, "writing register %s (#%d)",
344+ gdbarch_register_name (gdbarch, regno), regno);
345+ perror_with_name (message);
346+ }
347+ }
348+}
349+
350+/* This function actually issues the request to ptrace, telling
351+ it to store all general-purpose registers present in the specified
352+ regset.
353+
354+ If the ptrace request does not exist, this function returns 0
355+ and properly sets the have_ptrace_* flag. If the request fails,
356+ this function calls perror_with_name. Otherwise, if the request
357+ succeeds, then the regcache is stored and 1 is returned. */
358+static int
359+store_all_gp_regs (const struct regcache *regcache, int tid, int regno)
360+{
361+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
362+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
363+ gdb_gregset_t gregset;
364+
365+ if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
366+ {
367+ if (errno == EIO)
368+ {
369+ have_ptrace_getsetregs = 0;
370+ return 0;
371+ }
372+ perror_with_name (_("Couldn't get general-purpose registers."));
373+ }
374+
375+ fill_gregset (regcache, &gregset, regno);
376+
377+ if (ptrace (PTRACE_SETREGS, tid, 0, (void *) &gregset) < 0)
378+ {
379+ if (errno == EIO)
380+ {
381+ have_ptrace_getsetregs = 0;
382+ return 0;
383+ }
384+ perror_with_name (_("Couldn't set general-purpose registers."));
385+ }
386+
387+ return 1;
388+}
389+
390+/* This is a wrapper for the store_all_gp_regs function. It is
391+ responsible for verifying if this target has the ptrace request
392+ that can be used to store all general-purpose registers at one
393+ shot. If it doesn't, then we should store them using the
394+ old-fashioned way, which is to iterate over the registers and
395+ store them one by one. */
396+static void
397+store_gp_regs (const struct regcache *regcache, int tid, int regno)
398+{
399+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
400+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
401+ int i;
402+
403+ if (have_ptrace_getsetregs)
404+ if (store_all_gp_regs (regcache, tid, regno))
405+ return;
406+
407+ /* If we hit this point, it doesn't really matter which
408+ architecture we are using. We just need to store the
409+ registers in the "old-fashioned way". */
410+ for (i = MICROBLAZE_R0_REGNUM; i <= MICROBLAZE_FSR_REGNUM; i++)
411+ store_register (regcache, tid, i);
412+}
413+
414+
415+/* Fetch registers from the child process. Fetch all registers if
416+ regno == -1, otherwise fetch all general registers or all floating
417+ point registers depending upon the value of regno. */
418+
419+static void
420+microblaze_linux_fetch_inferior_registers (struct target_ops *ops,
421+ struct regcache *regcache, int regno)
422+{
423+ /* Get the thread id for the ptrace call. */
424+ int tid = GET_THREAD_ID (inferior_ptid);
425+
426+ if (regno == -1)
427+ fetch_gp_regs (regcache, tid);
428+ else
429+ fetch_register (regcache, tid, regno);
430+}
431+
432+/* Store registers back into the inferior. Store all registers if
433+ regno == -1, otherwise store all general registers or all floating
434+ point registers depending upon the value of regno. */
435+
436+static void
437+microblaze_linux_store_inferior_registers (struct target_ops *ops,
438+ struct regcache *regcache, int regno)
439+{
440+ /* Get the thread id for the ptrace call. */
441+ int tid = GET_THREAD_ID (inferior_ptid);
442+
443+ if (regno >= 0)
444+ store_register (regcache, tid, regno);
445+ else
446+ store_gp_regs (regcache, tid, -1);
447+}
448+
449+/* Wrapper functions for the standard regset handling, used by
450+ thread debugging. */
451+
452+void
453+fill_gregset (const struct regcache *regcache,
454+ gdb_gregset_t *gregsetp, int regno)
455+{
456+ microblaze_collect_gregset (NULL, regcache, regno, gregsetp);
457+}
458+
459+void
460+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
461+{
462+ microblaze_supply_gregset (NULL, regcache, -1, gregsetp);
463+}
464+
465+void
466+fill_fpregset (const struct regcache *regcache,
467+ gdb_fpregset_t *fpregsetp, int regno)
468+{
469+ /* FIXME. */
470+}
471+
472+void
473+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
474+{
475+ /* FIXME. */
476+}
477+
478+static const struct target_desc *
479+microblaze_linux_read_description (struct target_ops *ops)
480+{
481+ CORE_ADDR microblaze_hwcap = 0;
482+
483+ if (target_auxv_search (ops, AT_HWCAP, &microblaze_hwcap) != 1)
484+ return NULL;
485+
486+ return NULL;
487+}
488+
489+
490+void _initialize_microblaze_linux_nat (void);
491+
492+void
493+_initialize_microblaze_linux_nat (void)
494+{
495+ struct target_ops *t;
496+
497+ /* Fill in the generic GNU/Linux methods. */
498+ t = linux_target ();
499+
500+ /* Add our register access methods. */
501+ t->to_fetch_registers = microblaze_linux_fetch_inferior_registers;
502+ t->to_store_registers = microblaze_linux_store_inferior_registers;
503+
504+ t->to_read_description = microblaze_linux_read_description;
505+
506+ /* Register the target. */
507+ linux_nat_add_target (t);
508+}
509--
5102.17.1
511
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0039-Fixing-the-issues-related-to-GDB-7.12.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0039-Fixing-the-issues-related-to-GDB-7.12.patch
new file mode 100644
index 00000000..0b1475a7
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0039-Fixing-the-issues-related-to-GDB-7.12.patch
@@ -0,0 +1,309 @@
1From 0b5b76d6c9757ebb1c9677772c24272957190345 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 17 Feb 2017 14:09:40 +0530
4Subject: [PATCH 39/43] Fixing the issues related to GDB-7.12 added all the
5 required function which are new in 7.12 and removed few deprecated functions
6 from 7.6
7
8---
9 gdb/config/microblaze/linux.mh | 4 +-
10 gdb/gdbserver/configure.srv | 3 +-
11 gdb/gdbserver/linux-microblaze-low.c | 97 ++++++++++++++++++++++++----
12 gdb/microblaze-linux-tdep.c | 68 +++++++++++++++++--
13 gdb/microblaze-tdep.h | 1 +
14 5 files changed, 153 insertions(+), 20 deletions(-)
15
16diff --git a/gdb/config/microblaze/linux.mh b/gdb/config/microblaze/linux.mh
17index a4eaf540e1..74a53b854a 100644
18--- a/gdb/config/microblaze/linux.mh
19+++ b/gdb/config/microblaze/linux.mh
20@@ -1,9 +1,11 @@
21 # Host: Microblaze, running Linux
22
23+#linux-nat.o linux-waitpid.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
24 NAT_FILE= config/nm-linux.h
25 NATDEPFILES= inf-ptrace.o fork-child.o \
26 microblaze-linux-nat.o proc-service.o linux-thread-db.o \
27- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
28+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
29+ linux-waitpid.o linux-personality.o linux-namespaces.o
30 NAT_CDEPS = $(srcdir)/proc-service.list
31
32 LOADLIBES = -ldl $(RDYNAMIC)
33diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
34index 7a0be5b072..c421790bd0 100644
35--- a/gdb/gdbserver/configure.srv
36+++ b/gdb/gdbserver/configure.srv
37@@ -211,8 +211,7 @@ case "${target}" in
38 srv_linux_thread_db=yes
39 ;;
40 microblaze*-*-linux*) srv_regobj=microblaze-linux.o
41- srv_tgtobj="linux-low.o linux-osdata.o linux-microblaze-low.o "
42- srv_tgtobj="${srv_tgtobj} linux-procfs.o linux-ptrace.o"
43+ srv_tgtobj="$srv_linux_obj linux-microblaze-low.o "
44 srv_linux_regsets=yes
45 srv_linux_usrregs=yes
46 srv_linux_thread_db=yes
47diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c
48index cba5d6fc58..a2733f3c21 100644
49--- a/gdb/gdbserver/linux-microblaze-low.c
50+++ b/gdb/gdbserver/linux-microblaze-low.c
51@@ -39,10 +39,11 @@ static int microblaze_regmap[] =
52 PT_FSR
53 };
54
55-#define microblaze_num_regs (sizeof microblaze_regmap / sizeof microblaze_regmap[0])
56+#define microblaze_num_regs (sizeof (microblaze_regmap) / sizeof (microblaze_regmap[0]))
57
58 /* Defined in auto-generated file microblaze-linux.c. */
59 void init_registers_microblaze (void);
60+extern const struct target_desc *tdesc_microblaze;
61
62 static int
63 microblaze_cannot_store_register (int regno)
64@@ -81,6 +82,15 @@ microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
65 static const unsigned long microblaze_breakpoint = 0xba0c0018;
66 #define microblaze_breakpoint_len 4
67
68+/* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
69+
70+static const gdb_byte *
71+microblaze_sw_breakpoint_from_kind (int kind, int *size)
72+{
73+ *size = microblaze_breakpoint_len;
74+ return (const gdb_byte *) &microblaze_breakpoint;
75+}
76+
77 static int
78 microblaze_breakpoint_at (CORE_ADDR where)
79 {
80@@ -107,7 +117,7 @@ microblaze_reinsert_addr (struct regcache *regcache)
81 static void
82 microblaze_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
83 {
84- int size = register_size (regno);
85+ int size = register_size (regcache->tdesc, regno);
86
87 memset (buf, 0, sizeof (long));
88
89@@ -121,7 +131,7 @@ static void
90 microblaze_supply_ptrace_register (struct regcache *regcache,
91 int regno, const char *buf)
92 {
93- int size = register_size (regno);
94+ int size = register_size (regcache->tdesc, regno);
95
96 if (regno == 0) {
97 unsigned long regbuf_0 = 0;
98@@ -157,33 +167,94 @@ microblaze_store_gregset (struct regcache *regcache, const void *buf)
99
100 #endif /* HAVE_PTRACE_GETREGS */
101
102-struct regset_info target_regsets[] = {
103+static struct regset_info microblaze_regsets[] = {
104 #ifdef HAVE_PTRACE_GETREGS
105 { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
106- { 0, 0, 0, -1, -1, NULL, NULL },
107+ { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
108 #endif /* HAVE_PTRACE_GETREGS */
109- { 0, 0, 0, -1, -1, NULL, NULL }
110+ { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
111+ NULL_REGSET
112 };
113
114+static struct usrregs_info microblaze_usrregs_info =
115+ {
116+ microblaze_num_regs,
117+ microblaze_regmap,
118+ };
119+
120+static struct regsets_info microblaze_regsets_info =
121+ {
122+ microblaze_regsets, /* regsets */
123+ 0, /* num_regsets */
124+ NULL, /* disabled_regsets */
125+ };
126+
127+static struct regs_info regs_info =
128+ {
129+ NULL, /* regset_bitmap */
130+ &microblaze_usrregs_info,
131+ &microblaze_regsets_info
132+ };
133+
134+static const struct regs_info *
135+microblaze_regs_info (void)
136+{
137+ return &regs_info;
138+}
139+
140+/* Support for hardware single step. */
141+
142+static int
143+microblaze_supports_hardware_single_step (void)
144+{
145+ return 1;
146+}
147+
148+
149+static void
150+microblaze_arch_setup (void)
151+{
152+ current_process ()->tdesc = tdesc_microblaze;
153+}
154+
155 struct linux_target_ops the_low_target = {
156- init_registers_microblaze,
157- microblaze_num_regs,
158- microblaze_regmap,
159- NULL,
160+ microblaze_arch_setup,
161+ microblaze_regs_info,
162 microblaze_cannot_fetch_register,
163 microblaze_cannot_store_register,
164 NULL, /* fetch_register */
165 microblaze_get_pc,
166 microblaze_set_pc,
167- (const unsigned char *) &microblaze_breakpoint,
168- microblaze_breakpoint_len,
169- microblaze_reinsert_addr,
170+ NULL,
171+ microblaze_sw_breakpoint_from_kind,
172+ NULL,
173 0,
174 microblaze_breakpoint_at,
175 NULL,
176 NULL,
177 NULL,
178 NULL,
179+ NULL,
180 microblaze_collect_ptrace_register,
181 microblaze_supply_ptrace_register,
182+ NULL, /* siginfo_fixup */
183+ NULL, /* new_process */
184+ NULL, /* new_thread */
185+ NULL, /* new_fork */
186+ NULL, /* prepare_to_resume */
187+ NULL, /* process_qsupported */
188+ NULL, /* supports_tracepoints */
189+ NULL, /* get_thread_area */
190+ NULL, /* install_fast_tracepoint_jump_pad */
191+ NULL, /* emit_ops */
192+ NULL, /* get_min_fast_tracepoint_insn_len */
193+ NULL, /* supports_range_stepping */
194+ NULL, /* breakpoint_kind_from_current_state */
195+ microblaze_supports_hardware_single_step,
196 };
197+
198+void
199+initialize_low_arch (void)
200+{
201+ init_registers_microblaze ();
202+}
203diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
204index e2225d778a..011e513941 100644
205--- a/gdb/microblaze-linux-tdep.c
206+++ b/gdb/microblaze-linux-tdep.c
207@@ -29,13 +29,76 @@
208 #include "regcache.h"
209 #include "value.h"
210 #include "osabi.h"
211-#include "regset.h"
212 #include "solib-svr4.h"
213 #include "microblaze-tdep.h"
214 #include "trad-frame.h"
215 #include "frame-unwind.h"
216 #include "tramp-frame.h"
217 #include "linux-tdep.h"
218+#include "glibc-tdep.h"
219+
220+#include "gdb_assert.h"
221+
222+#ifndef REGSET_H
223+#define REGSET_H 1
224+
225+struct gdbarch;
226+struct regcache;
227+
228+/* Data structure for the supported register notes in a core file. */
229+struct core_regset_section
230+{
231+ const char *sect_name;
232+ int size;
233+ const char *human_name;
234+};
235+
236+/* Data structure describing a register set. */
237+
238+typedef void (supply_regset_ftype) (const struct regset *, struct regcache *,
239+ int, const void *, size_t);
240+typedef void (collect_regset_ftype) (const struct regset *,
241+ const struct regcache *,
242+ int, void *, size_t);
243+
244+struct regset
245+{
246+ /* Data pointer for private use by the methods below, presumably
247+ providing some sort of description of the register set. */
248+ const void *descr;
249+
250+ /* Function supplying values in a register set to a register cache. */
251+ supply_regset_ftype *supply_regset;
252+
253+ /* Function collecting values in a register set from a register cache. */
254+ collect_regset_ftype *collect_regset;
255+
256+ /* Architecture associated with the register set. */
257+ struct gdbarch *arch;
258+};
259+
260+#endif
261+
262+/* Allocate a fresh 'struct regset' whose supply_regset function is
263+ SUPPLY_REGSET, and whose collect_regset function is COLLECT_REGSET.
264+ If the regset has no collect_regset function, pass NULL for
265+ COLLECT_REGSET.
266+
267+ The object returned is allocated on ARCH's obstack. */
268+
269+struct regset *
270+regset_alloc (struct gdbarch *arch,
271+ supply_regset_ftype *supply_regset,
272+ collect_regset_ftype *collect_regset)
273+{
274+ struct regset *regset = GDBARCH_OBSTACK_ZALLOC (arch, struct regset);
275+
276+ regset->arch = arch;
277+ regset->supply_regset = supply_regset;
278+ regset->collect_regset = collect_regset;
279+
280+ return regset;
281+}
282
283 static int microblaze_debug_flag = 0;
284
285@@ -207,9 +270,6 @@ microblaze_linux_init_abi (struct gdbarch_info info,
286 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
287 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
288
289- set_gdbarch_regset_from_core_section (gdbarch,
290- microblaze_regset_from_core_section);
291-
292 /* Enable TLS support. */
293 set_gdbarch_fetch_tls_load_module_address (gdbarch,
294 svr4_fetch_objfile_link_map);
295diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
296index 02650f61d9..3777cbb6a8 100644
297--- a/gdb/microblaze-tdep.h
298+++ b/gdb/microblaze-tdep.h
299@@ -24,6 +24,7 @@
300 /* Microblaze architecture-specific information. */
301 struct microblaze_gregset
302 {
303+ microblaze_gregset() {}
304 unsigned int gregs[32];
305 unsigned int fpregs[32];
306 unsigned int pregs[16];
307--
3082.17.1
309
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0040-Patch-microblaze-Adding-64-bit-MB-support.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0040-Patch-microblaze-Adding-64-bit-MB-support.patch
new file mode 100644
index 00000000..6582af01
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0040-Patch-microblaze-Adding-64-bit-MB-support.patch
@@ -0,0 +1,1168 @@
1From 34e572e123b166122cc54a8d8e66676c36515711 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 31 Jan 2019 14:36:00 +0530
4Subject: [PATCH 40/43] [Patch, microblaze]: Adding 64 bit MB support Added new
5 architecture to Microblaze 64-bit support to GDB Signed-off-by :Nagaraju
6 Mekala <nmekala@xilix.com>
7
8Merged on top of binutils work.
9
10Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
11---
12 bfd/archures.c | 2 +
13 bfd/bfd-in2.h | 2 +
14 bfd/cpu-microblaze.c | 12 +-
15 bfd/elf32-microblaze.c | 93 +-------
16 gas/config/tc-microblaze.c | 16 +-
17 gas/config/tc-microblaze.h | 4 +
18 gdb/Makefile.in | 2 +-
19 gdb/features/Makefile | 3 +
20 gdb/features/microblaze-core.xml | 6 +-
21 gdb/features/microblaze-stack-protect.xml | 4 +-
22 gdb/features/microblaze-with-stack-protect.c | 8 +-
23 gdb/features/microblaze.c | 6 +-
24 gdb/features/microblaze64-core.xml | 69 ++++++
25 gdb/features/microblaze64-stack-protect.xml | 12 +
26 .../microblaze64-with-stack-protect.c | 79 +++++++
27 .../microblaze64-with-stack-protect.xml | 12 +
28 gdb/features/microblaze64.c | 77 +++++++
29 gdb/features/microblaze64.xml | 11 +
30 gdb/microblaze-tdep.c | 207 ++++++++++++++++--
31 gdb/microblaze-tdep.h | 8 +-
32 .../microblaze-with-stack-protect.dat | 4 +-
33 opcodes/microblaze-opc.h | 1 -
34 22 files changed, 504 insertions(+), 134 deletions(-)
35 create mode 100644 gdb/features/microblaze64-core.xml
36 create mode 100644 gdb/features/microblaze64-stack-protect.xml
37 create mode 100644 gdb/features/microblaze64-with-stack-protect.c
38 create mode 100644 gdb/features/microblaze64-with-stack-protect.xml
39 create mode 100644 gdb/features/microblaze64.c
40 create mode 100644 gdb/features/microblaze64.xml
41
42diff --git a/bfd/archures.c b/bfd/archures.c
43index 647cf0d8d4..3fdf7c3c0e 100644
44--- a/bfd/archures.c
45+++ b/bfd/archures.c
46@@ -512,6 +512,8 @@ DESCRIPTION
47 . bfd_arch_lm32, {* Lattice Mico32. *}
48 .#define bfd_mach_lm32 1
49 . bfd_arch_microblaze,{* Xilinx MicroBlaze. *}
50+.#define bfd_mach_microblaze 1
51+.#define bfd_mach_microblaze64 2
52 . bfd_arch_tilepro, {* Tilera TILEPro. *}
53 . bfd_arch_tilegx, {* Tilera TILE-Gx. *}
54 .#define bfd_mach_tilepro 1
55diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
56index 33c9cb62d9..db624c62b9 100644
57--- a/bfd/bfd-in2.h
58+++ b/bfd/bfd-in2.h
59@@ -2411,6 +2411,8 @@ enum bfd_architecture
60 bfd_arch_lm32, /* Lattice Mico32. */
61 #define bfd_mach_lm32 1
62 bfd_arch_microblaze,/* Xilinx MicroBlaze. */
63+#define bfd_mach_microblaze 1
64+#define bfd_mach_microblaze64 2
65 bfd_arch_tilepro, /* Tilera TILEPro. */
66 bfd_arch_tilegx, /* Tilera TILE-Gx. */
67 #define bfd_mach_tilepro 1
68diff --git a/bfd/cpu-microblaze.c b/bfd/cpu-microblaze.c
69index c91ba46f75..8e7bcead28 100644
70--- a/bfd/cpu-microblaze.c
71+++ b/bfd/cpu-microblaze.c
72@@ -30,8 +30,8 @@ const bfd_arch_info_type bfd_microblaze_arch[] =
73 64, /* 32 bits in a word. */
74 64, /* 32 bits in an address. */
75 8, /* 8 bits in a byte. */
76- bfd_arch_microblaze, /* Architecture. */
77- 0, /* Machine number - 0 for now. */
78+ bfd_arch_microblaze, /* Architecture. */
79+ bfd_mach_microblaze64, /* 64 bit Machine */
80 "microblaze", /* Architecture name. */
81 "MicroBlaze", /* Printable name. */
82 3, /* Section align power. */
83@@ -46,7 +46,7 @@ const bfd_arch_info_type bfd_microblaze_arch[] =
84 32, /* 32 bits in an address. */
85 8, /* 8 bits in a byte. */
86 bfd_arch_microblaze, /* Architecture. */
87- 0, /* Machine number - 0 for now. */
88+ bfd_mach_microblaze, /* 32 bit Machine */
89 "microblaze", /* Architecture name. */
90 "MicroBlaze", /* Printable name. */
91 3, /* Section align power. */
92@@ -62,7 +62,7 @@ const bfd_arch_info_type bfd_microblaze_arch[] =
93 32, /* 32 bits in an address. */
94 8, /* 8 bits in a byte. */
95 bfd_arch_microblaze, /* Architecture. */
96- 0, /* Machine number - 0 for now. */
97+ bfd_mach_microblaze, /* 32 bit Machine */
98 "microblaze", /* Architecture name. */
99 "MicroBlaze", /* Printable name. */
100 3, /* Section align power. */
101@@ -76,8 +76,8 @@ const bfd_arch_info_type bfd_microblaze_arch[] =
102 64, /* 32 bits in a word. */
103 64, /* 32 bits in an address. */
104 8, /* 8 bits in a byte. */
105- bfd_arch_microblaze, /* Architecture. */
106- 0, /* Machine number - 0 for now. */
107+ bfd_arch_microblaze, /* Architecture. */
108+ bfd_mach_microblaze64, /* 64 bit Machine */
109 "microblaze", /* Architecture name. */
110 "MicroBlaze", /* Printable name. */
111 3, /* Section align power. */
112diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
113index c280431df6..f9996eae12 100644
114--- a/bfd/elf32-microblaze.c
115+++ b/bfd/elf32-microblaze.c
116@@ -767,87 +767,6 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
117 return _bfd_elf_is_local_label_name (abfd, name);
118 }
119
120-/* Support for core dump NOTE sections. */
121-static bfd_boolean
122-microblaze_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
123-{
124- int offset;
125- unsigned int size;
126-
127- switch (note->descsz)
128- {
129- default:
130- return FALSE;
131-
132- case 228: /* Linux/MicroBlaze */
133- /* pr_cursig */
134- elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
135-
136- /* pr_pid */
137- elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
138-
139- /* pr_reg */
140- offset = 72;
141- size = 50 * 4;
142-
143- break;
144- }
145-
146- /* Make a ".reg/999" section. */
147- return _bfd_elfcore_make_pseudosection (abfd, ".reg",
148- size, note->descpos + offset);
149-}
150-
151-static bfd_boolean
152-microblaze_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
153-{
154- switch (note->descsz)
155- {
156- default:
157- return FALSE;
158-
159- case 128: /* Linux/MicroBlaze elf_prpsinfo */
160- elf_tdata (abfd)->core->program
161- = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
162- elf_tdata (abfd)->core->command
163- = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
164- }
165-
166- /* Note that for some reason, a spurious space is tacked
167- onto the end of the args in some (at least one anyway)
168- implementations, so strip it off if it exists. */
169-
170- {
171- char *command = elf_tdata (abfd)->core->command;
172- int n = strlen (command);
173-
174- if (0 < n && command[n - 1] == ' ')
175- command[n - 1] = '\0';
176- }
177-
178- return TRUE;
179-}
180-
181-/* The microblaze linker (like many others) needs to keep track of
182- the number of relocs that it decides to copy as dynamic relocs in
183- check_relocs for each symbol. This is so that it can later discard
184- them if they are found to be unnecessary. We store the information
185- in a field extending the regular ELF linker hash table. */
186-
187-struct elf32_mb_dyn_relocs
188-{
189- struct elf32_mb_dyn_relocs *next;
190-
191- /* The input section of the reloc. */
192- asection *sec;
193-
194- /* Total number of relocs copied for the input section. */
195- bfd_size_type count;
196-
197- /* Number of pc-relative relocs copied for the input section. */
198- bfd_size_type pc_count;
199-};
200-
201 /* ELF linker hash entry. */
202
203 struct elf32_mb_link_hash_entry
204@@ -3683,6 +3602,14 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
205 return TRUE;
206 }
207
208+
209+static bfd_boolean
210+elf_microblaze_object_p (bfd *abfd)
211+{
212+ /* Set the right machine number for an s390 elf32 file. */
213+ return bfd_default_set_arch_mach (abfd, bfd_arch_microblaze, bfd_mach_microblaze);
214+}
215+
216 /* Hook called by the linker routine which adds symbols from an object
217 file. We use it to put .comm items in .sbss, and not .bss. */
218
219@@ -3752,8 +3679,6 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
220 #define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
221 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
222 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
223-
224-#define elf_backend_grok_prstatus microblaze_elf_grok_prstatus
225-#define elf_backend_grok_psinfo microblaze_elf_grok_psinfo
226+#define elf_backend_object_p elf_microblaze_object_p
227
228 #include "elf32-target.h"
229diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
230index 3ff6a14baf..95a1e69729 100644
231--- a/gas/config/tc-microblaze.c
232+++ b/gas/config/tc-microblaze.c
233@@ -426,7 +426,10 @@ md_begin (void)
234 const char *prev_name = "";
235
236 opcode_hash_control = hash_new ();
237-
238+ if (microblaze_arch_size == 64)
239+ bfd_set_arch_mach (stdoutput, bfd_arch_microblaze, bfd_mach_microblaze64);
240+ else
241+ bfd_set_arch_mach (stdoutput, bfd_arch_microblaze, bfd_mach_microblaze);
242 /* Insert unique names into hash table. */
243 for (opcode = (struct opcodes *)opcodes; opcode->name; opcode ++)
244 {
245@@ -1348,7 +1351,7 @@ md_assemble (char * str)
246 if ((temp != 0) && (temp != 0xFFFF8000))
247 {
248 /* Needs an immediate inst. */
249- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
250+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imm");
251 if (opcode1 == NULL)
252 {
253 as_bad (_("unknown opcode \"%s\""), "imm");
254@@ -3431,6 +3434,15 @@ md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
255 }
256
257
258+unsigned long
259+microblaze_mach (void)
260+{
261+ if (microblaze_arch_size == 64)
262+ return bfd_mach_microblaze64;
263+ else
264+ return bfd_mach_microblaze;
265+}
266+
267 /* Create a fixup for a cons expression. If parse_cons_expression_microblaze
268 found a machine specific op in an expression,
269 then we create relocs accordingly. */
270diff --git a/gas/config/tc-microblaze.h b/gas/config/tc-microblaze.h
271index 9d38d2ced5..13f58917e7 100644
272--- a/gas/config/tc-microblaze.h
273+++ b/gas/config/tc-microblaze.h
274@@ -23,6 +23,10 @@
275 #define TC_MICROBLAZE 1
276
277 #define TARGET_ARCH bfd_arch_microblaze
278+#define TARGET_MACH (microblaze_mach ())
279+#define DEFAULT_MACHINE bfd_mach_microblaze64
280+extern unsigned long microblaze_mach (void);
281+
282 #ifndef TARGET_BYTES_BIG_ENDIAN
283 /* Used to initialise target_big_endian. */
284 #define TARGET_BYTES_BIG_ENDIAN 1
285diff --git a/gdb/Makefile.in b/gdb/Makefile.in
286index 8c9a3c07c0..15387197c7 100644
287--- a/gdb/Makefile.in
288+++ b/gdb/Makefile.in
289@@ -2265,7 +2265,7 @@ ALLDEPFILES = \
290 m68k-tdep.c \
291 microblaze-linux-tdep.c \
292 microblaze-tdep.c \
293- microblaze-linux-nat.c \
294+ microblaze-linux-nat.c \
295 mingw-hdep.c \
296 mips-fbsd-nat.c \
297 mips-fbsd-tdep.c \
298diff --git a/gdb/features/Makefile b/gdb/features/Makefile
299index 3d84ca09a1..fdeec19753 100644
300--- a/gdb/features/Makefile
301+++ b/gdb/features/Makefile
302@@ -64,6 +64,7 @@ WHICH = aarch64 \
303 i386/x32-avx-avx512-linux \
304 mips-linux mips-dsp-linux \
305 microblaze-with-stack-protect \
306+ microblaze64-with-stack-protect \
307 mips64-linux mips64-dsp-linux \
308 nios2-linux \
309 rs6000/powerpc-32 \
310@@ -135,7 +136,9 @@ XMLTOC = \
311 arm/arm-with-vfpv2.xml \
312 arm/arm-with-vfpv3.xml \
313 microblaze-with-stack-protect.xml \
314+ microblaze64-with-stack-protect.xml \
315 microblaze.xml \
316+ microblaze64.xml \
317 mips-dsp-linux.xml \
318 mips-linux.xml \
319 mips64-dsp-linux.xml \
320diff --git a/gdb/features/microblaze-core.xml b/gdb/features/microblaze-core.xml
321index 88c93e5d66..5bc3e49f84 100644
322--- a/gdb/features/microblaze-core.xml
323+++ b/gdb/features/microblaze-core.xml
324@@ -8,7 +8,7 @@
325 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
326 <feature name="org.gnu.gdb.microblaze.core">
327 <reg name="r0" bitsize="32" regnum="0"/>
328- <reg name="r1" bitsize="32" type="data_ptr"/>
329+ <reg name="r1" bitsize="32"/>
330 <reg name="r2" bitsize="32"/>
331 <reg name="r3" bitsize="32"/>
332 <reg name="r4" bitsize="32"/>
333@@ -39,7 +39,7 @@
334 <reg name="r29" bitsize="32"/>
335 <reg name="r30" bitsize="32"/>
336 <reg name="r31" bitsize="32"/>
337- <reg name="rpc" bitsize="32" type="code_ptr"/>
338+ <reg name="rpc" bitsize="32"/>
339 <reg name="rmsr" bitsize="32"/>
340 <reg name="rear" bitsize="32"/>
341 <reg name="resr" bitsize="32"/>
342@@ -64,4 +64,6 @@
343 <reg name="rtlbsx" bitsize="32"/>
344 <reg name="rtlblo" bitsize="32"/>
345 <reg name="rtlbhi" bitsize="32"/>
346+ <reg name="slr" bitsize="32"/>
347+ <reg name="shr" bitsize="32"/>
348 </feature>
349diff --git a/gdb/features/microblaze-stack-protect.xml b/gdb/features/microblaze-stack-protect.xml
350index 870c148bb0..a7f27b903c 100644
351--- a/gdb/features/microblaze-stack-protect.xml
352+++ b/gdb/features/microblaze-stack-protect.xml
353@@ -7,6 +7,6 @@
354
355 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
356 <feature name="org.gnu.gdb.microblaze.stack-protect">
357- <reg name="rslr" bitsize="32"/>
358- <reg name="rshr" bitsize="32"/>
359+ <reg name="slr" bitsize="32"/>
360+ <reg name="shr" bitsize="32"/>
361 </feature>
362diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c
363index b39aa19887..609934e2b4 100644
364--- a/gdb/features/microblaze-with-stack-protect.c
365+++ b/gdb/features/microblaze-with-stack-protect.c
366@@ -14,7 +14,7 @@ initialize_tdesc_microblaze_with_stack_protect (void)
367
368 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core");
369 tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
370- tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "data_ptr");
371+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
372 tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
373 tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int");
374 tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int");
375@@ -45,7 +45,7 @@ initialize_tdesc_microblaze_with_stack_protect (void)
376 tdesc_create_reg (feature, "r29", 29, 1, NULL, 32, "int");
377 tdesc_create_reg (feature, "r30", 30, 1, NULL, 32, "int");
378 tdesc_create_reg (feature, "r31", 31, 1, NULL, 32, "int");
379- tdesc_create_reg (feature, "rpc", 32, 1, NULL, 32, "code_ptr");
380+ tdesc_create_reg (feature, "rpc", 32, 1, NULL, 32, "int");
381 tdesc_create_reg (feature, "rmsr", 33, 1, NULL, 32, "int");
382 tdesc_create_reg (feature, "rear", 34, 1, NULL, 32, "int");
383 tdesc_create_reg (feature, "resr", 35, 1, NULL, 32, "int");
384@@ -72,8 +72,8 @@ initialize_tdesc_microblaze_with_stack_protect (void)
385 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
386
387 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.stack-protect");
388- tdesc_create_reg (feature, "rslr", 57, 1, NULL, 32, "int");
389- tdesc_create_reg (feature, "rshr", 58, 1, NULL, 32, "int");
390+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 32, "int");
391+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 32, "int");
392
393 tdesc_microblaze_with_stack_protect = result;
394 }
395diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c
396index 6c86fc0770..ceb98ca8b8 100644
397--- a/gdb/features/microblaze.c
398+++ b/gdb/features/microblaze.c
399@@ -14,7 +14,7 @@ initialize_tdesc_microblaze (void)
400
401 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core");
402 tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
403- tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "data_ptr");
404+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
405 tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
406 tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int");
407 tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int");
408@@ -45,7 +45,7 @@ initialize_tdesc_microblaze (void)
409 tdesc_create_reg (feature, "r29", 29, 1, NULL, 32, "int");
410 tdesc_create_reg (feature, "r30", 30, 1, NULL, 32, "int");
411 tdesc_create_reg (feature, "r31", 31, 1, NULL, 32, "int");
412- tdesc_create_reg (feature, "rpc", 32, 1, NULL, 32, "code_ptr");
413+ tdesc_create_reg (feature, "rpc", 32, 1, NULL, 32, "int");
414 tdesc_create_reg (feature, "rmsr", 33, 1, NULL, 32, "int");
415 tdesc_create_reg (feature, "rear", 34, 1, NULL, 32, "int");
416 tdesc_create_reg (feature, "resr", 35, 1, NULL, 32, "int");
417@@ -70,6 +70,8 @@ initialize_tdesc_microblaze (void)
418 tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
419 tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
420 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
421+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
422+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
423
424 tdesc_microblaze = result;
425 }
426diff --git a/gdb/features/microblaze64-core.xml b/gdb/features/microblaze64-core.xml
427new file mode 100644
428index 0000000000..96e99e2fb2
429--- /dev/null
430+++ b/gdb/features/microblaze64-core.xml
431@@ -0,0 +1,69 @@
432+<?xml version="1.0"?>
433+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
434+
435+ Copying and distribution of this file, with or without modification,
436+ are permitted in any medium without royalty provided the copyright
437+ notice and this notice are preserved. -->
438+
439+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
440+<feature name="org.gnu.gdb.microblaze64.core">
441+ <reg name="r0" bitsize="64" regnum="0"/>
442+ <reg name="r1" bitsize="64"/>
443+ <reg name="r2" bitsize="64"/>
444+ <reg name="r3" bitsize="64"/>
445+ <reg name="r4" bitsize="64"/>
446+ <reg name="r5" bitsize="64"/>
447+ <reg name="r6" bitsize="64"/>
448+ <reg name="r7" bitsize="64"/>
449+ <reg name="r8" bitsize="64"/>
450+ <reg name="r9" bitsize="64"/>
451+ <reg name="r10" bitsize="64"/>
452+ <reg name="r11" bitsize="64"/>
453+ <reg name="r12" bitsize="64"/>
454+ <reg name="r13" bitsize="64"/>
455+ <reg name="r14" bitsize="64"/>
456+ <reg name="r15" bitsize="64"/>
457+ <reg name="r16" bitsize="64"/>
458+ <reg name="r17" bitsize="64"/>
459+ <reg name="r18" bitsize="64"/>
460+ <reg name="r19" bitsize="64"/>
461+ <reg name="r20" bitsize="64"/>
462+ <reg name="r21" bitsize="64"/>
463+ <reg name="r22" bitsize="64"/>
464+ <reg name="r23" bitsize="64"/>
465+ <reg name="r24" bitsize="64"/>
466+ <reg name="r25" bitsize="64"/>
467+ <reg name="r26" bitsize="64"/>
468+ <reg name="r27" bitsize="64"/>
469+ <reg name="r28" bitsize="64"/>
470+ <reg name="r29" bitsize="64"/>
471+ <reg name="r30" bitsize="64"/>
472+ <reg name="r31" bitsize="64"/>
473+ <reg name="rpc" bitsize="64"/>
474+ <reg name="rmsr" bitsize="32"/>
475+ <reg name="rear" bitsize="64"/>
476+ <reg name="resr" bitsize="32"/>
477+ <reg name="rfsr" bitsize="32"/>
478+ <reg name="rbtr" bitsize="64"/>
479+ <reg name="rpvr0" bitsize="32"/>
480+ <reg name="rpvr1" bitsize="32"/>
481+ <reg name="rpvr2" bitsize="32"/>
482+ <reg name="rpvr3" bitsize="32"/>
483+ <reg name="rpvr4" bitsize="32"/>
484+ <reg name="rpvr5" bitsize="32"/>
485+ <reg name="rpvr6" bitsize="32"/>
486+ <reg name="rpvr7" bitsize="32"/>
487+ <reg name="rpvr8" bitsize="64"/>
488+ <reg name="rpvr9" bitsize="64"/>
489+ <reg name="rpvr10" bitsize="32"/>
490+ <reg name="rpvr11" bitsize="32"/>
491+ <reg name="redr" bitsize="32"/>
492+ <reg name="rpid" bitsize="32"/>
493+ <reg name="rzpr" bitsize="32"/>
494+ <reg name="rtlbx" bitsize="32"/>
495+ <reg name="rtlbsx" bitsize="32"/>
496+ <reg name="rtlblo" bitsize="32"/>
497+ <reg name="rtlbhi" bitsize="32"/>
498+ <reg name="slr" bitsize="64"/>
499+ <reg name="shr" bitsize="64"/>
500+</feature>
501diff --git a/gdb/features/microblaze64-stack-protect.xml b/gdb/features/microblaze64-stack-protect.xml
502new file mode 100644
503index 0000000000..1bbf5fc3ce
504--- /dev/null
505+++ b/gdb/features/microblaze64-stack-protect.xml
506@@ -0,0 +1,12 @@
507+<?xml version="1.0"?>
508+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
509+
510+ Copying and distribution of this file, with or without modification,
511+ are permitted in any medium without royalty provided the copyright
512+ notice and this notice are preserved. -->
513+
514+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
515+<feature name="org.gnu.gdb.microblaze64.stack-protect">
516+ <reg name="slr" bitsize="64"/>
517+ <reg name="shr" bitsize="64"/>
518+</feature>
519diff --git a/gdb/features/microblaze64-with-stack-protect.c b/gdb/features/microblaze64-with-stack-protect.c
520new file mode 100644
521index 0000000000..f448c9a749
522--- /dev/null
523+++ b/gdb/features/microblaze64-with-stack-protect.c
524@@ -0,0 +1,79 @@
525+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
526+ Original: microblaze-with-stack-protect.xml */
527+
528+#include "defs.h"
529+#include "osabi.h"
530+#include "target-descriptions.h"
531+
532+struct target_desc *tdesc_microblaze64_with_stack_protect;
533+static void
534+initialize_tdesc_microblaze64_with_stack_protect (void)
535+{
536+ struct target_desc *result = allocate_target_description ();
537+ struct tdesc_feature *feature;
538+
539+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.core");
540+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64");
541+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64");
542+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64");
543+ tdesc_create_reg (feature, "r3", 3, 1, NULL, 64, "uint64");
544+ tdesc_create_reg (feature, "r4", 4, 1, NULL, 64, "uint64");
545+ tdesc_create_reg (feature, "r5", 5, 1, NULL, 64, "uint64");
546+ tdesc_create_reg (feature, "r6", 6, 1, NULL, 64, "uint64");
547+ tdesc_create_reg (feature, "r7", 7, 1, NULL, 64, "uint64");
548+ tdesc_create_reg (feature, "r8", 8, 1, NULL, 64, "uint64");
549+ tdesc_create_reg (feature, "r9", 9, 1, NULL, 64, "uint64");
550+ tdesc_create_reg (feature, "r10", 10, 1, NULL, 64, "uint64");
551+ tdesc_create_reg (feature, "r11", 11, 1, NULL, 64, "uint64");
552+ tdesc_create_reg (feature, "r12", 12, 1, NULL, 64, "uint64");
553+ tdesc_create_reg (feature, "r13", 13, 1, NULL, 64, "uint64");
554+ tdesc_create_reg (feature, "r14", 14, 1, NULL, 64, "uint64");
555+ tdesc_create_reg (feature, "r15", 15, 1, NULL, 64, "uint64");
556+ tdesc_create_reg (feature, "r16", 16, 1, NULL, 64, "uint64");
557+ tdesc_create_reg (feature, "r17", 17, 1, NULL, 64, "uint64");
558+ tdesc_create_reg (feature, "r18", 18, 1, NULL, 64, "uint64");
559+ tdesc_create_reg (feature, "r19", 19, 1, NULL, 64, "uint64");
560+ tdesc_create_reg (feature, "r20", 20, 1, NULL, 64, "uint64");
561+ tdesc_create_reg (feature, "r21", 21, 1, NULL, 64, "uint64");
562+ tdesc_create_reg (feature, "r22", 22, 1, NULL, 64, "uint64");
563+ tdesc_create_reg (feature, "r23", 23, 1, NULL, 64, "uint64");
564+ tdesc_create_reg (feature, "r24", 24, 1, NULL, 64, "uint64");
565+ tdesc_create_reg (feature, "r25", 25, 1, NULL, 64, "uint64");
566+ tdesc_create_reg (feature, "r26", 26, 1, NULL, 64, "uint64");
567+ tdesc_create_reg (feature, "r27", 27, 1, NULL, 64, "uint64");
568+ tdesc_create_reg (feature, "r28", 28, 1, NULL, 64, "uint64");
569+ tdesc_create_reg (feature, "r29", 29, 1, NULL, 64, "uint64");
570+ tdesc_create_reg (feature, "r30", 30, 1, NULL, 64, "uint64");
571+ tdesc_create_reg (feature, "r31", 31, 1, NULL, 64, "uint64");
572+ tdesc_create_reg (feature, "rpc", 32, 1, NULL, 64, "uint64");
573+ tdesc_create_reg (feature, "rmsr", 33, 1, NULL, 32, "int");
574+ tdesc_create_reg (feature, "rear", 34, 1, NULL, 64, "int");
575+ tdesc_create_reg (feature, "resr", 35, 1, NULL, 32, "int");
576+ tdesc_create_reg (feature, "rfsr", 36, 1, NULL, 32, "int");
577+ tdesc_create_reg (feature, "rbtr", 37, 1, NULL, 64, "uint64");
578+ tdesc_create_reg (feature, "rpvr0", 38, 1, NULL, 32, "int");
579+ tdesc_create_reg (feature, "rpvr1", 39, 1, NULL, 32, "int");
580+ tdesc_create_reg (feature, "rpvr2", 40, 1, NULL, 32, "int");
581+ tdesc_create_reg (feature, "rpvr3", 41, 1, NULL, 32, "int");
582+ tdesc_create_reg (feature, "rpvr4", 42, 1, NULL, 32, "int");
583+ tdesc_create_reg (feature, "rpvr5", 43, 1, NULL, 32, "int");
584+ tdesc_create_reg (feature, "rpvr6", 44, 1, NULL, 32, "int");
585+ tdesc_create_reg (feature, "rpvr7", 45, 1, NULL, 32, "int");
586+ tdesc_create_reg (feature, "rpvr8", 46, 1, NULL, 64, "uint64");
587+ tdesc_create_reg (feature, "rpvr9", 47, 1, NULL, 64, "uint64");
588+ tdesc_create_reg (feature, "rpvr10", 48, 1, NULL, 32, "int");
589+ tdesc_create_reg (feature, "rpvr11", 49, 1, NULL, 32, "int");
590+ tdesc_create_reg (feature, "redr", 50, 1, NULL, 32, "int");
591+ tdesc_create_reg (feature, "rpid", 51, 1, NULL, 32, "int");
592+ tdesc_create_reg (feature, "rzpr", 52, 1, NULL, 32, "int");
593+ tdesc_create_reg (feature, "rtlbx", 53, 1, NULL, 32, "int");
594+ tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
595+ tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
596+ tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
597+
598+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.stack-protect");
599+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
600+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
601+
602+ tdesc_microblaze64_with_stack_protect = result;
603+}
604diff --git a/gdb/features/microblaze64-with-stack-protect.xml b/gdb/features/microblaze64-with-stack-protect.xml
605new file mode 100644
606index 0000000000..0e9f01611f
607--- /dev/null
608+++ b/gdb/features/microblaze64-with-stack-protect.xml
609@@ -0,0 +1,12 @@
610+<?xml version="1.0"?>
611+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
612+
613+ Copying and distribution of this file, with or without modification,
614+ are permitted in any medium without royalty provided the copyright
615+ notice and this notice are preserved. -->
616+
617+<!DOCTYPE target SYSTEM "gdb-target.dtd">
618+<target>
619+ <xi:include href="microblaze64-core.xml"/>
620+ <xi:include href="microblaze64-stack-protect.xml"/>
621+</target>
622diff --git a/gdb/features/microblaze64.c b/gdb/features/microblaze64.c
623new file mode 100644
624index 0000000000..1aa37c4512
625--- /dev/null
626+++ b/gdb/features/microblaze64.c
627@@ -0,0 +1,77 @@
628+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
629+ Original: microblaze.xml */
630+
631+#include "defs.h"
632+#include "osabi.h"
633+#include "target-descriptions.h"
634+
635+struct target_desc *tdesc_microblaze64;
636+static void
637+initialize_tdesc_microblaze64 (void)
638+{
639+ struct target_desc *result = allocate_target_description ();
640+ struct tdesc_feature *feature;
641+
642+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.core");
643+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64");
644+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64");
645+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64");
646+ tdesc_create_reg (feature, "r3", 3, 1, NULL, 64, "uint64");
647+ tdesc_create_reg (feature, "r4", 4, 1, NULL, 64, "uint64");
648+ tdesc_create_reg (feature, "r5", 5, 1, NULL, 64, "uint64");
649+ tdesc_create_reg (feature, "r6", 6, 1, NULL, 64, "uint64");
650+ tdesc_create_reg (feature, "r7", 7, 1, NULL, 64, "uint64");
651+ tdesc_create_reg (feature, "r8", 8, 1, NULL, 64, "uint64");
652+ tdesc_create_reg (feature, "r9", 9, 1, NULL, 64, "uint64");
653+ tdesc_create_reg (feature, "r10", 10, 1, NULL, 64, "uint64");
654+ tdesc_create_reg (feature, "r11", 11, 1, NULL, 64, "uint64");
655+ tdesc_create_reg (feature, "r12", 12, 1, NULL, 64, "uint64");
656+ tdesc_create_reg (feature, "r13", 13, 1, NULL, 64, "uint64");
657+ tdesc_create_reg (feature, "r14", 14, 1, NULL, 64, "uint64");
658+ tdesc_create_reg (feature, "r15", 15, 1, NULL, 64, "uint64");
659+ tdesc_create_reg (feature, "r16", 16, 1, NULL, 64, "uint64");
660+ tdesc_create_reg (feature, "r17", 17, 1, NULL, 64, "uint64");
661+ tdesc_create_reg (feature, "r18", 18, 1, NULL, 64, "uint64");
662+ tdesc_create_reg (feature, "r19", 19, 1, NULL, 64, "uint64");
663+ tdesc_create_reg (feature, "r20", 20, 1, NULL, 64, "uint64");
664+ tdesc_create_reg (feature, "r21", 21, 1, NULL, 64, "uint64");
665+ tdesc_create_reg (feature, "r22", 22, 1, NULL, 64, "uint64");
666+ tdesc_create_reg (feature, "r23", 23, 1, NULL, 64, "uint64");
667+ tdesc_create_reg (feature, "r24", 24, 1, NULL, 64, "uint64");
668+ tdesc_create_reg (feature, "r25", 25, 1, NULL, 64, "uint64");
669+ tdesc_create_reg (feature, "r26", 26, 1, NULL, 64, "uint64");
670+ tdesc_create_reg (feature, "r27", 27, 1, NULL, 64, "uint64");
671+ tdesc_create_reg (feature, "r28", 28, 1, NULL, 64, "uint64");
672+ tdesc_create_reg (feature, "r29", 29, 1, NULL, 64, "uint64");
673+ tdesc_create_reg (feature, "r30", 30, 1, NULL, 64, "uint64");
674+ tdesc_create_reg (feature, "r31", 31, 1, NULL, 64, "uint64");
675+ tdesc_create_reg (feature, "rpc", 32, 1, NULL, 64, "uint64");
676+ tdesc_create_reg (feature, "rmsr", 33, 1, NULL, 32, "int");
677+ tdesc_create_reg (feature, "rear", 34, 1, NULL, 64, "uint64");
678+ tdesc_create_reg (feature, "resr", 35, 1, NULL, 32, "int");
679+ tdesc_create_reg (feature, "rfsr", 36, 1, NULL, 32, "int");
680+ tdesc_create_reg (feature, "rbtr", 37, 1, NULL, 64, "uint64");
681+ tdesc_create_reg (feature, "rpvr0", 38, 1, NULL, 32, "int");
682+ tdesc_create_reg (feature, "rpvr1", 39, 1, NULL, 32, "int");
683+ tdesc_create_reg (feature, "rpvr2", 40, 1, NULL, 32, "int");
684+ tdesc_create_reg (feature, "rpvr3", 41, 1, NULL, 32, "int");
685+ tdesc_create_reg (feature, "rpvr4", 42, 1, NULL, 32, "int");
686+ tdesc_create_reg (feature, "rpvr5", 43, 1, NULL, 32, "int");
687+ tdesc_create_reg (feature, "rpvr6", 44, 1, NULL, 32, "int");
688+ tdesc_create_reg (feature, "rpvr7", 45, 1, NULL, 32, "int");
689+ tdesc_create_reg (feature, "rpvr8", 46, 1, NULL, 64, "uint64");
690+ tdesc_create_reg (feature, "rpvr9", 47, 1, NULL, 64, "uint64");
691+ tdesc_create_reg (feature, "rpvr10", 48, 1, NULL, 32, "int");
692+ tdesc_create_reg (feature, "rpvr11", 49, 1, NULL, 32, "int");
693+ tdesc_create_reg (feature, "redr", 50, 1, NULL, 32, "int");
694+ tdesc_create_reg (feature, "rpid", 51, 1, NULL, 32, "int");
695+ tdesc_create_reg (feature, "rzpr", 52, 1, NULL, 32, "int");
696+ tdesc_create_reg (feature, "rtlbx", 53, 1, NULL, 32, "int");
697+ tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
698+ tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
699+ tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
700+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
701+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
702+
703+ tdesc_microblaze64 = result;
704+}
705diff --git a/gdb/features/microblaze64.xml b/gdb/features/microblaze64.xml
706new file mode 100644
707index 0000000000..515d18e65c
708--- /dev/null
709+++ b/gdb/features/microblaze64.xml
710@@ -0,0 +1,11 @@
711+<?xml version="1.0"?>
712+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
713+
714+ Copying and distribution of this file, with or without modification,
715+ are permitted in any medium without royalty provided the copyright
716+ notice and this notice are preserved. -->
717+
718+<!DOCTYPE target SYSTEM "gdb-target.dtd">
719+<target>
720+ <xi:include href="microblaze64-core.xml"/>
721+</target>
722diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
723index 49713ea9b1..0605283c9e 100644
724--- a/gdb/microblaze-tdep.c
725+++ b/gdb/microblaze-tdep.c
726@@ -40,7 +40,9 @@
727 #include "remote.h"
728
729 #include "features/microblaze-with-stack-protect.c"
730+#include "features/microblaze64-with-stack-protect.c"
731 #include "features/microblaze.c"
732+#include "features/microblaze64.c"
733
734 /* Instruction macros used for analyzing the prologue. */
735 /* This set of instruction macros need to be changed whenever the
736@@ -75,12 +77,13 @@ static const char *microblaze_register_names[] =
737 "rpvr0", "rpvr1", "rpvr2", "rpvr3", "rpvr4", "rpvr5", "rpvr6",
738 "rpvr7", "rpvr8", "rpvr9", "rpvr10", "rpvr11",
739 "redr", "rpid", "rzpr", "rtlbx", "rtlbsx", "rtlblo", "rtlbhi",
740- "rslr", "rshr"
741+ "slr", "shr"
742 };
743
744 #define MICROBLAZE_NUM_REGS ARRAY_SIZE (microblaze_register_names)
745
746 static unsigned int microblaze_debug_flag = 0;
747+int reg_size = 4;
748
749 static void ATTRIBUTE_PRINTF (1, 2)
750 microblaze_debug (const char *fmt, ...)
751@@ -145,6 +148,7 @@ microblaze_store_arguments (struct regcache *regcache, int nargs,
752 error (_("store_arguments not implemented"));
753 return sp;
754 }
755+#if 0
756 static int
757 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
758 struct bp_target_info *bp_tgt)
759@@ -154,7 +158,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
760 int val;
761 int bplen;
762 gdb_byte old_contents[BREAKPOINT_MAX];
763- struct cleanup *cleanup;
764+ //struct cleanup *cleanup;
765
766 /* Determine appropriate breakpoint contents and size for this address. */
767 bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
768@@ -162,7 +166,8 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
769 error (_("Software breakpoints not implemented for this target."));
770
771 /* Make sure we see the memory breakpoints. */
772- cleanup = make_show_memory_breakpoints_cleanup (1);
773+ scoped_restore
774+ cleanup = make_scoped_restore_show_memory_breakpoints (1);
775 val = target_read_memory (addr, old_contents, bplen);
776
777 /* If our breakpoint is no longer at the address, this means that the
778@@ -178,6 +183,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
779 return val;
780 }
781
782+#endif
783 /* Allocate and initialize a frame cache. */
784
785 static struct microblaze_frame_cache *
786@@ -570,17 +576,16 @@ microblaze_extract_return_value (struct type *type, struct regcache *regcache,
787 gdb_byte *valbuf)
788 {
789 gdb_byte buf[8];
790-
791 /* Copy the return value (starting) in RETVAL_REGNUM to VALBUF. */
792 switch (TYPE_LENGTH (type))
793 {
794 case 1: /* return last byte in the register. */
795 regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf);
796- memcpy(valbuf, buf + MICROBLAZE_REGISTER_SIZE - 1, 1);
797+ memcpy(valbuf, buf + reg_size - 1, 1);
798 return;
799 case 2: /* return last 2 bytes in register. */
800 regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf);
801- memcpy(valbuf, buf + MICROBLAZE_REGISTER_SIZE - 2, 2);
802+ memcpy(valbuf, buf + reg_size - 2, 2);
803 return;
804 case 4: /* for sizes 4 or 8, copy the required length. */
805 case 8:
806@@ -647,7 +652,119 @@ microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
807 return (TYPE_LENGTH (type) == 16);
808 }
809
810-
811+#if 0
812+static std::vector<CORE_ADDR>
813+microblaze_software_single_step (struct regcache *regcache)
814+{
815+// struct gdbarch *arch = get_frame_arch(frame);
816+ struct gdbarch *arch = get_regcache_arch (regcache);
817+ struct address_space *aspace = get_regcache_aspace (regcache);
818+// struct address_space *aspace = get_frame_address_space (frame);
819+ struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
820+ static char le_breakp[] = MICROBLAZE_BREAKPOINT_LE;
821+ static char be_breakp[] = MICROBLAZE_BREAKPOINT;
822+ enum bfd_endian byte_order = gdbarch_byte_order (arch);
823+ char *breakp = byte_order == BFD_ENDIAN_BIG ? be_breakp : le_breakp;
824+ std::vector<CORE_ADDR> ret = 0;
825+
826+ /* Save the address and the values of the next_pc and the target */
827+ static struct sstep_breaks
828+ {
829+ CORE_ADDR address;
830+ bfd_boolean valid;
831+ /* Shadow contents. */
832+ char data[INST_WORD_SIZE];
833+ } stepbreaks[2];
834+ int ii;
835+
836+ if (1)
837+ {
838+ CORE_ADDR pc;
839+ std::vector<CORE_ADDR> *next_pcs = NULL;
840+ long insn;
841+ enum microblaze_instr minstr;
842+ bfd_boolean isunsignednum;
843+ enum microblaze_instr_type insn_type;
844+ short delay_slots;
845+ int imm;
846+ bfd_boolean immfound = FALSE;
847+
848+ /* Set a breakpoint at the next instruction */
849+ /* If the current instruction is an imm, set it at the inst after */
850+ /* If the instruction has a delay slot, skip the delay slot */
851+ pc = regcache_read_pc (regcache);
852+ insn = microblaze_fetch_instruction (pc);
853+ minstr = get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
854+ if (insn_type == immediate_inst)
855+ {
856+ int rd, ra, rb;
857+ immfound = TRUE;
858+ minstr = microblaze_decode_insn (insn, &rd, &ra, &rb, &imm);
859+ pc = pc + INST_WORD_SIZE;
860+ insn = microblaze_fetch_instruction (pc);
861+ minstr = get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
862+ }
863+ stepbreaks[0].address = pc + (delay_slots * INST_WORD_SIZE) + INST_WORD_SIZE;
864+ if (insn_type != return_inst) {
865+ stepbreaks[0].valid = TRUE;
866+ } else {
867+ stepbreaks[0].valid = FALSE;
868+ }
869+
870+ microblaze_debug ("single-step insn_type=%x insn=%x\n", insn_type, insn);
871+ /* Now check for branch or return instructions */
872+ if (insn_type == branch_inst || insn_type == return_inst) {
873+ int limm;
874+ int lrd, lra, lrb;
875+ int ra, rb;
876+ bfd_boolean targetvalid;
877+ bfd_boolean unconditionalbranch;
878+ microblaze_decode_insn(insn, &lrd, &lra, &lrb, &limm);
879+ if (lra >= 0 && lra < MICROBLAZE_NUM_REGS)
880+ ra = regcache_raw_get_unsigned(regcache, lra);
881+ else
882+ ra = 0;
883+ if (lrb >= 0 && lrb < MICROBLAZE_NUM_REGS)
884+ rb = regcache_raw_get_unsigned(regcache, lrb);
885+ else
886+ rb = 0;
887+ stepbreaks[1].address = microblaze_get_target_address (insn, immfound, imm, pc, ra, rb, &targetvalid, &unconditionalbranch);
888+ microblaze_debug ("single-step uncondbr=%d targetvalid=%d target=%x\n", unconditionalbranch, targetvalid, stepbreaks[1].address);
889+ if (unconditionalbranch)
890+ stepbreaks[0].valid = FALSE; /* This is a unconditional branch: will not come to the next address */
891+ if (targetvalid && (stepbreaks[0].valid == FALSE ||
892+ (stepbreaks[0].address != stepbreaks[1].address))
893+ && (stepbreaks[1].address != pc)) {
894+ stepbreaks[1].valid = TRUE;
895+ } else {
896+ stepbreaks[1].valid = FALSE;
897+ }
898+ } else {
899+ stepbreaks[1].valid = FALSE;
900+ }
901+
902+ /* Insert the breakpoints */
903+ for (ii = 0; ii < 2; ++ii)
904+ {
905+
906+ /* ignore invalid breakpoint. */
907+ if (stepbreaks[ii].valid) {
908+ VEC_safe_push (CORE_ADDR, next_pcs, stepbreaks[ii].address);;
909+// insert_single_step_breakpoint (arch, aspace, stepbreaks[ii].address);
910+ ret = next_pcs;
911+ }
912+ }
913+ }
914+ return ret;
915+}
916+#endif
917+
918+static void
919+microblaze_write_pc (struct regcache *regcache, CORE_ADDR pc)
920+{
921+ regcache_cooked_write_unsigned (regcache, MICROBLAZE_PC_REGNUM, pc);
922+}
923+
924 static int dwarf2_to_reg_map[78] =
925 { 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */
926 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */
927@@ -682,13 +799,14 @@ microblaze_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg)
928 static void
929 microblaze_register_g_packet_guesses (struct gdbarch *gdbarch)
930 {
931+
932 register_remote_g_packet_guess (gdbarch,
933- 4 * MICROBLAZE_NUM_CORE_REGS,
934- tdesc_microblaze);
935+ 4 * MICROBLAZE_NUM_REGS,
936+ tdesc_microblaze64);
937
938 register_remote_g_packet_guess (gdbarch,
939 4 * MICROBLAZE_NUM_REGS,
940- tdesc_microblaze_with_stack_protect);
941+ tdesc_microblaze64_with_stack_protect);
942 }
943
944 void
945@@ -696,15 +814,15 @@ microblaze_supply_gregset (const struct microblaze_gregset *gregset,
946 struct regcache *regcache,
947 int regnum, const void *gregs)
948 {
949- unsigned int *regs = gregs;
950+ const gdb_byte *regs = (const gdb_byte *) gregs;
951 if (regnum >= 0)
952- regcache_raw_supply (regcache, regnum, regs + regnum);
953+ regcache->raw_supply (regnum, regs + regnum);
954
955 if (regnum == -1) {
956 int i;
957
958 for (i = 0; i < 50; i++) {
959- regcache_raw_supply (regcache, i, regs + i);
960+ regcache->raw_supply (regnum, regs + i);
961 }
962 }
963 }
964@@ -755,6 +873,17 @@ microblaze_regset_from_core_section (struct gdbarch *gdbarch,
965 }
966
967
968+static void
969+make_regs (struct gdbarch *arch)
970+{
971+ struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
972+ int mach = gdbarch_bfd_arch_info (arch)->mach;
973+
974+ if (mach == bfd_mach_microblaze64)
975+ {
976+ set_gdbarch_ptr_bit (arch, 64);
977+ }
978+}
979
980 static struct gdbarch *
981 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
982@@ -769,8 +898,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
983 if (arches != NULL)
984 return arches->gdbarch;
985 if (tdesc == NULL)
986- tdesc = tdesc_microblaze;
987-
988+ {
989+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64)
990+ {
991+ tdesc = tdesc_microblaze64;
992+ reg_size = 8;
993+ }
994+ else
995+ tdesc = tdesc_microblaze;
996+ }
997 /* Check any target description for validity. */
998 if (tdesc_has_registers (tdesc))
999 {
1000@@ -778,27 +914,35 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1001 int valid_p;
1002 int i;
1003
1004- feature = tdesc_find_feature (tdesc,
1005+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64)
1006+ feature = tdesc_find_feature (tdesc,
1007+ "org.gnu.gdb.microblaze64.core");
1008+ else
1009+ feature = tdesc_find_feature (tdesc,
1010 "org.gnu.gdb.microblaze.core");
1011 if (feature == NULL)
1012 return NULL;
1013 tdesc_data = tdesc_data_alloc ();
1014
1015 valid_p = 1;
1016- for (i = 0; i < MICROBLAZE_NUM_CORE_REGS; i++)
1017+ for (i = 0; i < MICROBLAZE_NUM_REGS; i++)
1018 valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
1019 microblaze_register_names[i]);
1020- feature = tdesc_find_feature (tdesc,
1021+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64)
1022+ feature = tdesc_find_feature (tdesc,
1023+ "org.gnu.gdb.microblaze64.stack-protect");
1024+ else
1025+ feature = tdesc_find_feature (tdesc,
1026 "org.gnu.gdb.microblaze.stack-protect");
1027 if (feature != NULL)
1028 {
1029 valid_p = 1;
1030 valid_p &= tdesc_numbered_register (feature, tdesc_data,
1031 MICROBLAZE_SLR_REGNUM,
1032- "rslr");
1033+ "slr");
1034 valid_p &= tdesc_numbered_register (feature, tdesc_data,
1035 MICROBLAZE_SHR_REGNUM,
1036- "rshr");
1037+ "shr");
1038 }
1039
1040 if (!valid_p)
1041@@ -806,6 +950,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1042 tdesc_data_cleanup (tdesc_data);
1043 return NULL;
1044 }
1045+
1046 }
1047
1048 /* Allocate space for the new architecture. */
1049@@ -825,7 +970,17 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1050 /* Register numbers of various important registers. */
1051 set_gdbarch_sp_regnum (gdbarch, MICROBLAZE_SP_REGNUM);
1052 set_gdbarch_pc_regnum (gdbarch, MICROBLAZE_PC_REGNUM);
1053+
1054+ /* Register set.
1055+ make_regs (gdbarch); */
1056+ switch (info.bfd_arch_info->mach)
1057+ {
1058+ case bfd_mach_microblaze64:
1059+ set_gdbarch_ptr_bit (gdbarch, 64);
1060+ break;
1061+ }
1062
1063+
1064 /* Map Dwarf2 registers to GDB registers. */
1065 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum);
1066
1067@@ -845,13 +1000,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1068 microblaze_breakpoint::kind_from_pc);
1069 set_gdbarch_sw_breakpoint_from_kind (gdbarch,
1070 microblaze_breakpoint::bp_from_kind);
1071- set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint);
1072+// set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint);
1073+
1074+// set_gdbarch_software_single_step (gdbarch, microblaze_software_single_step);
1075
1076 set_gdbarch_frame_args_skip (gdbarch, 8);
1077
1078 set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc);
1079
1080- microblaze_register_g_packet_guesses (gdbarch);
1081+ //microblaze_register_g_packet_guesses (gdbarch);
1082
1083 frame_base_set_default (gdbarch, &microblaze_frame_base);
1084
1085@@ -866,11 +1023,11 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1086 tdesc_use_registers (gdbarch, tdesc, tdesc_data);
1087 //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer);
1088
1089- /* If we have register sets, enable the generic core file support. */
1090+ /* If we have register sets, enable the generic core file support.
1091 if (tdep->gregset) {
1092 set_gdbarch_regset_from_core_section (gdbarch,
1093 microblaze_regset_from_core_section);
1094- }
1095+ }*/
1096
1097 return gdbarch;
1098 }
1099@@ -882,6 +1039,8 @@ _initialize_microblaze_tdep (void)
1100
1101 initialize_tdesc_microblaze_with_stack_protect ();
1102 initialize_tdesc_microblaze ();
1103+ initialize_tdesc_microblaze64_with_stack_protect ();
1104+ initialize_tdesc_microblaze64 ();
1105 /* Debug this files internals. */
1106 add_setshow_zuinteger_cmd ("microblaze", class_maintenance,
1107 &microblaze_debug_flag, _("\
1108diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
1109index 3777cbb6a8..55f5dd1962 100644
1110--- a/gdb/microblaze-tdep.h
1111+++ b/gdb/microblaze-tdep.h
1112@@ -27,7 +27,7 @@ struct microblaze_gregset
1113 microblaze_gregset() {}
1114 unsigned int gregs[32];
1115 unsigned int fpregs[32];
1116- unsigned int pregs[16];
1117+ unsigned int pregs[18];
1118 };
1119
1120 struct gdbarch_tdep
1121@@ -101,9 +101,9 @@ enum microblaze_regnum
1122 MICROBLAZE_RTLBSX_REGNUM,
1123 MICROBLAZE_RTLBLO_REGNUM,
1124 MICROBLAZE_RTLBHI_REGNUM,
1125- MICROBLAZE_SLR_REGNUM, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_SLR_REGNUM,
1126+ MICROBLAZE_SLR_REGNUM,
1127 MICROBLAZE_SHR_REGNUM,
1128- MICROBLAZE_NUM_REGS
1129+ MICROBLAZE_NUM_REGS, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_NUM_REGS
1130 };
1131
1132 struct microblaze_frame_cache
1133@@ -128,7 +128,7 @@ struct microblaze_frame_cache
1134 struct trad_frame_saved_reg *saved_regs;
1135 };
1136 /* All registers are 32 bits. */
1137-#define MICROBLAZE_REGISTER_SIZE 4
1138+//#define MICROBLAZE_REGISTER_SIZE 8
1139
1140 /* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used.
1141 Only used for native debugging. */
1142diff --git a/gdb/regformats/microblaze-with-stack-protect.dat b/gdb/regformats/microblaze-with-stack-protect.dat
1143index 8040a7b3fd..450e321d49 100644
1144--- a/gdb/regformats/microblaze-with-stack-protect.dat
1145+++ b/gdb/regformats/microblaze-with-stack-protect.dat
1146@@ -60,5 +60,5 @@ expedite:r1,rpc
1147 32:rtlbsx
1148 32:rtlblo
1149 32:rtlbhi
1150-32:rslr
1151-32:rshr
1152+32:slr
1153+32:shr
1154diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
1155index bd9d91cd57..12d4456bc2 100644
1156--- a/opcodes/microblaze-opc.h
1157+++ b/opcodes/microblaze-opc.h
1158@@ -134,7 +134,6 @@
1159 #define ORLI_MASK 0xA0000000
1160 #define XORLI_MASK 0xA8000000
1161
1162-
1163 /* New Mask for msrset, msrclr insns. */
1164 #define OPCODE_MASK_H23N 0xFC1F8000 /* High 6 and bits 11 - 16. */
1165 /* Mask for mbar insn. */
1166--
11672.17.1
1168
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0041-patch-MicroBlaze-porting-GDB-for-linux.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0041-patch-MicroBlaze-porting-GDB-for-linux.patch
new file mode 100644
index 00000000..1a0153b8
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0041-patch-MicroBlaze-porting-GDB-for-linux.patch
@@ -0,0 +1,155 @@
1From 07757f455d343beb50ac04815c77b04075bf9534 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Dec 2019 14:56:17 +0530
4Subject: [PATCH 41/43] [patch,MicroBlaze] : porting GDB for linux
5
6---
7 gdb/features/microblaze-linux.xml | 12 ++++++++++
8 gdb/gdbserver/Makefile.in | 2 ++
9 gdb/gdbserver/configure.srv | 3 ++-
10 gdb/microblaze-linux-tdep.c | 39 ++++++++++++++++++++++++-------
11 4 files changed, 47 insertions(+), 9 deletions(-)
12 create mode 100644 gdb/features/microblaze-linux.xml
13
14diff --git a/gdb/features/microblaze-linux.xml b/gdb/features/microblaze-linux.xml
15new file mode 100644
16index 0000000000..8983e66eb3
17--- /dev/null
18+++ b/gdb/features/microblaze-linux.xml
19@@ -0,0 +1,12 @@
20+<?xml version="1.0"?>
21+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
22+
23+ Copying and distribution of this file, with or without modification,
24+ are permitted in any medium without royalty provided the copyright
25+ notice and this notice are preserved. -->
26+
27+<!DOCTYPE target SYSTEM "gdb-target.dtd">
28+<target>
29+ <osabi>GNU/Linux</osabi>
30+ <xi:include href="microblaze-core.xml"/>
31+</target>
32diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
33index 45d95e6cab..7c8fa3c246 100644
34--- a/gdb/gdbserver/Makefile.in
35+++ b/gdb/gdbserver/Makefile.in
36@@ -633,6 +633,8 @@ common/%.o: ../common/%.c
37
38 %-generated.c: ../regformats/rs6000/%.dat | $(regdat_sh)
39 $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $< $@
40+microblaze-linux.c : $(srcdir)/../regformats/reg-microblaze.dat $(regdat_sh)
41+ $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-microblaze.dat microblaze-linux.c
42
43 #
44 # Dependency tracking.
45diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
46index c421790bd0..6ad0ac9fa6 100644
47--- a/gdb/gdbserver/configure.srv
48+++ b/gdb/gdbserver/configure.srv
49@@ -210,8 +210,9 @@ case "${target}" in
50 srv_linux_usrregs=yes
51 srv_linux_thread_db=yes
52 ;;
53- microblaze*-*-linux*) srv_regobj=microblaze-linux.o
54+ microblaze*-*-linux*) srv_regobj="microblaze-linux.o"
55 srv_tgtobj="$srv_linux_obj linux-microblaze-low.o "
56+ srv_xmlfiles="microblaze-linux.xml"
57 srv_linux_regsets=yes
58 srv_linux_usrregs=yes
59 srv_linux_thread_db=yes
60diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
61index 011e513941..e3d2a7508d 100644
62--- a/gdb/microblaze-linux-tdep.c
63+++ b/gdb/microblaze-linux-tdep.c
64@@ -41,7 +41,7 @@
65
66 #ifndef REGSET_H
67 #define REGSET_H 1
68-
69+int MICROBLAZE_REGISTER_SIZE=4;
70 struct gdbarch;
71 struct regcache;
72
73@@ -115,7 +115,7 @@ microblaze_debug (const char *fmt, ...)
74 va_end (args);
75 }
76 }
77-
78+#if 0
79 static int
80 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
81 struct bp_target_info *bp_tgt)
82@@ -131,7 +131,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
83 bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
84
85 /* Make sure we see the memory breakpoints. */
86- cleanup = make_show_memory_breakpoints_cleanup (1);
87+ cleanup = make_scoped_restore_show_memory_breakpoints (1);
88 val = target_read_memory (addr, old_contents, bplen);
89
90 /* If our breakpoint is no longer at the address, this means that the
91@@ -146,6 +146,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
92 do_cleanups (cleanup);
93 return val;
94 }
95+#endif
96
97 static void
98 microblaze_linux_sigtramp_cache (struct frame_info *next_frame,
99@@ -248,8 +249,8 @@ microblaze_linux_init_abi (struct gdbarch_info info,
100
101 linux_init_abi (info, gdbarch);
102
103- set_gdbarch_memory_remove_breakpoint (gdbarch,
104- microblaze_linux_memory_remove_breakpoint);
105+// set_gdbarch_memory_remove_breakpoint (gdbarch,
106+// microblaze_linux_memory_remove_breakpoint);
107
108 /* Shared library handling. */
109 set_solib_svr4_fetch_link_map_offsets (gdbarch,
110@@ -261,10 +262,30 @@ microblaze_linux_init_abi (struct gdbarch_info info,
111
112 /* BFD target for core files. */
113 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
114- set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblaze");
115+ {
116+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64) {
117+ set_gdbarch_gcore_bfd_target (gdbarch, "elf64-microblaze");
118+ MICROBLAZE_REGISTER_SIZE=8;
119+ }
120+ else
121+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblaze");
122+ }
123 else
124- set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblazeel");
125+ {
126+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64) {
127+ set_gdbarch_gcore_bfd_target (gdbarch, "elf64-microblazeel");
128+ MICROBLAZE_REGISTER_SIZE=8;
129+ }
130+ else
131+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblazeel");
132+ }
133
134+ switch (info.bfd_arch_info->mach)
135+ {
136+ case bfd_mach_microblaze64:
137+ set_gdbarch_ptr_bit (gdbarch, 64);
138+ break;
139+ }
140
141 /* Shared library handling. */
142 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
143@@ -278,6 +299,8 @@ microblaze_linux_init_abi (struct gdbarch_info info,
144 void
145 _initialize_microblaze_linux_tdep (void)
146 {
147- gdbarch_register_osabi (bfd_arch_microblaze, 0, GDB_OSABI_LINUX,
148+ gdbarch_register_osabi (bfd_arch_microblaze, bfd_mach_microblaze, GDB_OSABI_LINUX,
149+ microblaze_linux_init_abi);
150+ gdbarch_register_osabi (bfd_arch_microblaze, bfd_mach_microblaze64, GDB_OSABI_LINUX,
151 microblaze_linux_init_abi);
152 }
153--
1542.17.1
155
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch
new file mode 100644
index 00000000..ad8dcb53
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch
@@ -0,0 +1,146 @@
1From c2a4667e87bd610a48a6690fcc9fdc6761398bcf Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 19 Dec 2019 12:22:04 +0530
4Subject: [PATCH 42/43] Correcting the register names from slr & shr to rslr &
5 rshr
6
7---
8 gdb/features/microblaze-core.xml | 4 ++--
9 gdb/features/microblaze-stack-protect.xml | 4 ++--
10 gdb/features/microblaze-with-stack-protect.c | 4 ++--
11 gdb/features/microblaze.c | 4 ++--
12 gdb/features/microblaze64-core.xml | 4 ++--
13 gdb/features/microblaze64-stack-protect.xml | 4 ++--
14 gdb/features/microblaze64-with-stack-protect.c | 4 ++--
15 gdb/features/microblaze64.c | 4 ++--
16 gdb/microblaze-tdep.c | 2 +-
17 9 files changed, 17 insertions(+), 17 deletions(-)
18
19diff --git a/gdb/features/microblaze-core.xml b/gdb/features/microblaze-core.xml
20index 5bc3e49f84..6f73f4eb84 100644
21--- a/gdb/features/microblaze-core.xml
22+++ b/gdb/features/microblaze-core.xml
23@@ -64,6 +64,6 @@
24 <reg name="rtlbsx" bitsize="32"/>
25 <reg name="rtlblo" bitsize="32"/>
26 <reg name="rtlbhi" bitsize="32"/>
27- <reg name="slr" bitsize="32"/>
28- <reg name="shr" bitsize="32"/>
29+ <reg name="rslr" bitsize="32"/>
30+ <reg name="rshr" bitsize="32"/>
31 </feature>
32diff --git a/gdb/features/microblaze-stack-protect.xml b/gdb/features/microblaze-stack-protect.xml
33index a7f27b903c..870c148bb0 100644
34--- a/gdb/features/microblaze-stack-protect.xml
35+++ b/gdb/features/microblaze-stack-protect.xml
36@@ -7,6 +7,6 @@
37
38 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
39 <feature name="org.gnu.gdb.microblaze.stack-protect">
40- <reg name="slr" bitsize="32"/>
41- <reg name="shr" bitsize="32"/>
42+ <reg name="rslr" bitsize="32"/>
43+ <reg name="rshr" bitsize="32"/>
44 </feature>
45diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c
46index 609934e2b4..ab162fd258 100644
47--- a/gdb/features/microblaze-with-stack-protect.c
48+++ b/gdb/features/microblaze-with-stack-protect.c
49@@ -72,8 +72,8 @@ initialize_tdesc_microblaze_with_stack_protect (void)
50 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
51
52 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.stack-protect");
53- tdesc_create_reg (feature, "slr", 57, 1, NULL, 32, "int");
54- tdesc_create_reg (feature, "shr", 58, 1, NULL, 32, "int");
55+ tdesc_create_reg (feature, "rslr", 57, 1, NULL, 32, "int");
56+ tdesc_create_reg (feature, "rshr", 58, 1, NULL, 32, "int");
57
58 tdesc_microblaze_with_stack_protect = result;
59 }
60diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c
61index ceb98ca8b8..7919ac96e6 100644
62--- a/gdb/features/microblaze.c
63+++ b/gdb/features/microblaze.c
64@@ -70,8 +70,8 @@ initialize_tdesc_microblaze (void)
65 tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
66 tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
67 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
68- tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
69- tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
70+ tdesc_create_reg (feature, "rslr", 57, 1, NULL, 64, "uint64");
71+ tdesc_create_reg (feature, "rshr", 58, 1, NULL, 64, "uint64");
72
73 tdesc_microblaze = result;
74 }
75diff --git a/gdb/features/microblaze64-core.xml b/gdb/features/microblaze64-core.xml
76index 96e99e2fb2..b9adadfade 100644
77--- a/gdb/features/microblaze64-core.xml
78+++ b/gdb/features/microblaze64-core.xml
79@@ -64,6 +64,6 @@
80 <reg name="rtlbsx" bitsize="32"/>
81 <reg name="rtlblo" bitsize="32"/>
82 <reg name="rtlbhi" bitsize="32"/>
83- <reg name="slr" bitsize="64"/>
84- <reg name="shr" bitsize="64"/>
85+ <reg name="rslr" bitsize="64"/>
86+ <reg name="rshr" bitsize="64"/>
87 </feature>
88diff --git a/gdb/features/microblaze64-stack-protect.xml b/gdb/features/microblaze64-stack-protect.xml
89index 1bbf5fc3ce..9d7ea8b9fd 100644
90--- a/gdb/features/microblaze64-stack-protect.xml
91+++ b/gdb/features/microblaze64-stack-protect.xml
92@@ -7,6 +7,6 @@
93
94 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
95 <feature name="org.gnu.gdb.microblaze64.stack-protect">
96- <reg name="slr" bitsize="64"/>
97- <reg name="shr" bitsize="64"/>
98+ <reg name="rslr" bitsize="64"/>
99+ <reg name="rshr" bitsize="64"/>
100 </feature>
101diff --git a/gdb/features/microblaze64-with-stack-protect.c b/gdb/features/microblaze64-with-stack-protect.c
102index f448c9a749..249cb534da 100644
103--- a/gdb/features/microblaze64-with-stack-protect.c
104+++ b/gdb/features/microblaze64-with-stack-protect.c
105@@ -72,8 +72,8 @@ initialize_tdesc_microblaze64_with_stack_protect (void)
106 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
107
108 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.stack-protect");
109- tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
110- tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
111+ tdesc_create_reg (feature, "rslr", 57, 1, NULL, 64, "uint64");
112+ tdesc_create_reg (feature, "rshr", 58, 1, NULL, 64, "uint64");
113
114 tdesc_microblaze64_with_stack_protect = result;
115 }
116diff --git a/gdb/features/microblaze64.c b/gdb/features/microblaze64.c
117index 1aa37c4512..5d3e2c8cd9 100644
118--- a/gdb/features/microblaze64.c
119+++ b/gdb/features/microblaze64.c
120@@ -70,8 +70,8 @@ initialize_tdesc_microblaze64 (void)
121 tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
122 tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
123 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
124- tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
125- tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
126+ tdesc_create_reg (feature, "rslr", 57, 1, NULL, 64, "uint64");
127+ tdesc_create_reg (feature, "rshr", 58, 1, NULL, 64, "uint64");
128
129 tdesc_microblaze64 = result;
130 }
131diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
132index 0605283c9e..7a0c2527f4 100644
133--- a/gdb/microblaze-tdep.c
134+++ b/gdb/microblaze-tdep.c
135@@ -77,7 +77,7 @@ static const char *microblaze_register_names[] =
136 "rpvr0", "rpvr1", "rpvr2", "rpvr3", "rpvr4", "rpvr5", "rpvr6",
137 "rpvr7", "rpvr8", "rpvr9", "rpvr10", "rpvr11",
138 "redr", "rpid", "rzpr", "rtlbx", "rtlbsx", "rtlblo", "rtlbhi",
139- "slr", "shr"
140+ "rslr", "rshr"
141 };
142
143 #define MICROBLAZE_NUM_REGS ARRAY_SIZE (microblaze_register_names)
144--
1452.17.1
146
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch
new file mode 100644
index 00000000..930e161c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch
@@ -0,0 +1,24 @@
1From 9562530bc48c76d8f824b8f4901ad90dd2969086 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Fri, 17 Jan 2020 15:45:48 +0530
4Subject: [PATCH 43/43] Removing the header "gdb_assert.h" from MB target file
5
6---
7 gdb/microblaze-linux-tdep.c | 1 -
8 1 file changed, 1 deletion(-)
9
10diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
11index e3d2a7508d..5ef937219c 100644
12--- a/gdb/microblaze-linux-tdep.c
13+++ b/gdb/microblaze-linux-tdep.c
14@@ -37,7 +37,6 @@
15 #include "linux-tdep.h"
16 #include "glibc-tdep.h"
17
18-#include "gdb_assert.h"
19
20 #ifndef REGSET_H
21 #define REGSET_H 1
22--
232.17.1
24
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch
new file mode 100644
index 00000000..29e198cd
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch
@@ -0,0 +1,364 @@
1From 4f0e06249d23629e1d56b296e7a040b6968484e9 Mon Sep 17 00:00:00 2001
2From: Mark Hatle <mark.hatle@xilinx.com>
3Date: Mon, 20 Jan 2020 12:48:13 -0800
4Subject: [PATCH 44/45] gdb/microblaze-linux-nat.c: Fix target compilation of
5 gdb
6
7Add the nat to the configure file
8
9Remove gdb_assert.h and gdb_string.h.
10
11Adjust include for opcodes as well.
12
13Update to match latest style of components, similar to ppc-linux-nat.c
14
15Update:
16 get_regcache_arch(regcache) to regcache->arch()
17 regcache_raw_supply(regcache, ...) to regcache->raw_supply(...)
18 regcache_raw_collect(regcache, ...) to regcache->raw_collect(...)
19
20Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
21---
22 gdb/configure.nat | 4 +
23 gdb/microblaze-linux-nat.c | 149 +++++++++++++------------------------
24 gdb/microblaze-tdep.c | 3 +-
25 3 files changed, 57 insertions(+), 99 deletions(-)
26
27diff --git a/gdb/configure.nat b/gdb/configure.nat
28index 3118263ac6..b8dc7398a5 100644
29--- a/gdb/configure.nat
30+++ b/gdb/configure.nat
31@@ -260,6 +260,10 @@ case ${gdb_host} in
32 # Host: Motorola m68k running GNU/Linux.
33 NATDEPFILES="${NATDEPFILES} m68k-linux-nat.o"
34 ;;
35+ microblaze*)
36+ # Host: Microblaze, running Linux
37+ NATDEPFILES="${NATDEPFILES} microblaze-linux-nat.o"
38+ ;;
39 mips)
40 # Host: Linux/MIPS
41 NATDEPFILES="${NATDEPFILES} linux-nat-trad.o \
42diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c
43index e9b8c9c522..e09a86bb3f 100644
44--- a/gdb/microblaze-linux-nat.c
45+++ b/gdb/microblaze-linux-nat.c
46@@ -36,11 +36,9 @@
47 #include "dwarf2-frame.h"
48 #include "osabi.h"
49
50-#include "gdb_assert.h"
51-#include "gdb_string.h"
52 #include "target-descriptions.h"
53-#include "opcodes/microblaze-opcm.h"
54-#include "opcodes/microblaze-dis.h"
55+#include "../opcodes/microblaze-opcm.h"
56+#include "../opcodes/microblaze-dis.h"
57
58 #include "linux-nat.h"
59 #include "target-descriptions.h"
60@@ -61,34 +59,27 @@
61 /* Defines ps_err_e, struct ps_prochandle. */
62 #include "gdb_proc_service.h"
63
64-/* On GNU/Linux, threads are implemented as pseudo-processes, in which
65- case we may be tracing more than one process at a time. In that
66- case, inferior_ptid will contain the main process ID and the
67- individual thread (process) ID. get_thread_id () is used to get
68- the thread id if it's available, and the process id otherwise. */
69-
70-int
71-get_thread_id (ptid_t ptid)
72-{
73- int tid = TIDGET (ptid);
74- if (0 == tid)
75- tid = PIDGET (ptid);
76- return tid;
77-}
78-
79-#define GET_THREAD_ID(PTID) get_thread_id (PTID)
80-
81 /* Non-zero if our kernel may support the PTRACE_GETREGS and
82 PTRACE_SETREGS requests, for reading and writing the
83 general-purpose registers. Zero if we've tried one of
84 them and gotten an error. */
85 int have_ptrace_getsetregs = 1;
86
87+struct microblaze_linux_nat_target final : public linux_nat_target
88+{
89+ /* Add our register access methods. */
90+ void fetch_registers (struct regcache *, int) override;
91+ void store_registers (struct regcache *, int) override;
92+
93+ const struct target_desc *read_description () override;
94+};
95+
96+static microblaze_linux_nat_target the_microblaze_linux_nat_target;
97+
98 static int
99 microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
100 {
101 int u_addr = -1;
102- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
103 /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
104 interface, and not the wordsize of the program's ABI. */
105 int wordsize = sizeof (long);
106@@ -105,18 +96,16 @@ microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
107 static void
108 fetch_register (struct regcache *regcache, int tid, int regno)
109 {
110- struct gdbarch *gdbarch = get_regcache_arch (regcache);
111- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
112+ struct gdbarch *gdbarch = regcache->arch();
113 /* This isn't really an address. But ptrace thinks of it as one. */
114 CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
115 int bytes_transferred;
116- unsigned int offset; /* Offset of registers within the u area. */
117- char buf[MAX_REGISTER_SIZE];
118+ char buf[sizeof(long)];
119
120 if (regaddr == -1)
121 {
122 memset (buf, '\0', register_size (gdbarch, regno)); /* Supply zeroes */
123- regcache_raw_supply (regcache, regno, buf);
124+ regcache->raw_supply (regno, buf);
125 return;
126 }
127
128@@ -149,14 +138,14 @@ fetch_register (struct regcache *regcache, int tid, int regno)
129 {
130 /* Little-endian values are always found at the left end of the
131 bytes transferred. */
132- regcache_raw_supply (regcache, regno, buf);
133+ regcache->raw_supply (regno, buf);
134 }
135 else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
136 {
137 /* Big-endian values are found at the right end of the bytes
138 transferred. */
139 size_t padding = (bytes_transferred - register_size (gdbarch, regno));
140- regcache_raw_supply (regcache, regno, buf + padding);
141+ regcache->raw_supply (regno, buf + padding);
142 }
143 else
144 internal_error (__FILE__, __LINE__,
145@@ -175,8 +164,6 @@ fetch_register (struct regcache *regcache, int tid, int regno)
146 static int
147 fetch_all_gp_regs (struct regcache *regcache, int tid)
148 {
149- struct gdbarch *gdbarch = get_regcache_arch (regcache);
150- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
151 gdb_gregset_t gregset;
152
153 if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
154@@ -204,8 +191,6 @@ fetch_all_gp_regs (struct regcache *regcache, int tid)
155 static void
156 fetch_gp_regs (struct regcache *regcache, int tid)
157 {
158- struct gdbarch *gdbarch = get_regcache_arch (regcache);
159- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
160 int i;
161
162 if (have_ptrace_getsetregs)
163@@ -219,17 +204,29 @@ fetch_gp_regs (struct regcache *regcache, int tid)
164 fetch_register (regcache, tid, i);
165 }
166
167+/* Fetch registers from the child process. Fetch all registers if
168+ regno == -1, otherwise fetch all general registers or all floating
169+ point registers depending upon the value of regno. */
170+void
171+microblaze_linux_nat_target::fetch_registers (struct regcache *regcache, int regno)
172+{
173+ pid_t tid = get_ptrace_pid (regcache->ptid ());
174+
175+ if (regno == -1)
176+ fetch_gp_regs (regcache, tid);
177+ else
178+ fetch_register (regcache, tid, regno);
179+}
180
181 static void
182 store_register (const struct regcache *regcache, int tid, int regno)
183 {
184- struct gdbarch *gdbarch = get_regcache_arch (regcache);
185- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
186+ struct gdbarch *gdbarch = regcache->arch();
187 /* This isn't really an address. But ptrace thinks of it as one. */
188 CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
189 int i;
190 size_t bytes_to_transfer;
191- char buf[MAX_REGISTER_SIZE];
192+ char buf[sizeof(long)];
193
194 if (regaddr == -1)
195 return;
196@@ -242,13 +239,13 @@ store_register (const struct regcache *regcache, int tid, int regno)
197 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
198 {
199 /* Little-endian values always sit at the left end of the buffer. */
200- regcache_raw_collect (regcache, regno, buf);
201+ regcache->raw_collect (regno, buf);
202 }
203 else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
204 {
205 /* Big-endian values sit at the right end of the buffer. */
206 size_t padding = (bytes_to_transfer - register_size (gdbarch, regno));
207- regcache_raw_collect (regcache, regno, buf + padding);
208+ regcache->raw_collect (regno, buf + padding);
209 }
210
211 for (i = 0; i < bytes_to_transfer; i += sizeof (long))
212@@ -281,8 +278,6 @@ store_register (const struct regcache *regcache, int tid, int regno)
213 static int
214 store_all_gp_regs (const struct regcache *regcache, int tid, int regno)
215 {
216- struct gdbarch *gdbarch = get_regcache_arch (regcache);
217- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
218 gdb_gregset_t gregset;
219
220 if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
221@@ -319,8 +314,6 @@ store_all_gp_regs (const struct regcache *regcache, int tid, int regno)
222 static void
223 store_gp_regs (const struct regcache *regcache, int tid, int regno)
224 {
225- struct gdbarch *gdbarch = get_regcache_arch (regcache);
226- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
227 int i;
228
229 if (have_ptrace_getsetregs)
230@@ -335,33 +328,10 @@ store_gp_regs (const struct regcache *regcache, int tid, int regno)
231 }
232
233
234-/* Fetch registers from the child process. Fetch all registers if
235- regno == -1, otherwise fetch all general registers or all floating
236- point registers depending upon the value of regno. */
237-
238-static void
239-microblaze_linux_fetch_inferior_registers (struct target_ops *ops,
240- struct regcache *regcache, int regno)
241-{
242- /* Get the thread id for the ptrace call. */
243- int tid = GET_THREAD_ID (inferior_ptid);
244-
245- if (regno == -1)
246- fetch_gp_regs (regcache, tid);
247- else
248- fetch_register (regcache, tid, regno);
249-}
250-
251-/* Store registers back into the inferior. Store all registers if
252- regno == -1, otherwise store all general registers or all floating
253- point registers depending upon the value of regno. */
254-
255-static void
256-microblaze_linux_store_inferior_registers (struct target_ops *ops,
257- struct regcache *regcache, int regno)
258+void
259+microblaze_linux_nat_target::store_registers (struct regcache *regcache, int regno)
260 {
261- /* Get the thread id for the ptrace call. */
262- int tid = GET_THREAD_ID (inferior_ptid);
263+ pid_t tid = get_ptrace_pid (regcache->ptid ());
264
265 if (regno >= 0)
266 store_register (regcache, tid, regno);
267@@ -373,59 +343,44 @@ microblaze_linux_store_inferior_registers (struct target_ops *ops,
268 thread debugging. */
269
270 void
271-fill_gregset (const struct regcache *regcache,
272- gdb_gregset_t *gregsetp, int regno)
273+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
274 {
275- microblaze_collect_gregset (NULL, regcache, regno, gregsetp);
276+ microblaze_supply_gregset (NULL, regcache, -1, gregsetp);
277 }
278
279 void
280-supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
281+fill_gregset (const struct regcache *regcache,
282+ gdb_gregset_t *gregsetp, int regno)
283 {
284- microblaze_supply_gregset (NULL, regcache, -1, gregsetp);
285+ microblaze_collect_gregset (NULL, regcache, regno, gregsetp);
286 }
287
288 void
289-fill_fpregset (const struct regcache *regcache,
290- gdb_fpregset_t *fpregsetp, int regno)
291+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
292 {
293 /* FIXME. */
294+ return;
295 }
296
297 void
298-supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
299+fill_fpregset (const struct regcache *regcache,
300+ gdb_fpregset_t *fpregsetp, int regno)
301 {
302 /* FIXME. */
303+ return;
304 }
305
306-static const struct target_desc *
307-microblaze_linux_read_description (struct target_ops *ops)
308+const struct target_desc *
309+microblaze_linux_nat_target::read_description ()
310 {
311- CORE_ADDR microblaze_hwcap = 0;
312-
313- if (target_auxv_search (ops, AT_HWCAP, &microblaze_hwcap) != 1)
314- return NULL;
315-
316 return NULL;
317 }
318
319-
320-void _initialize_microblaze_linux_nat (void);
321-
322 void
323 _initialize_microblaze_linux_nat (void)
324 {
325- struct target_ops *t;
326-
327- /* Fill in the generic GNU/Linux methods. */
328- t = linux_target ();
329-
330- /* Add our register access methods. */
331- t->to_fetch_registers = microblaze_linux_fetch_inferior_registers;
332- t->to_store_registers = microblaze_linux_store_inferior_registers;
333-
334- t->to_read_description = microblaze_linux_read_description;
335+ linux_target = &the_microblaze_linux_nat_target;
336
337 /* Register the target. */
338- linux_nat_add_target (t);
339+ add_inf_child_target (linux_target);
340 }
341diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
342index 7a0c2527f4..23deb24d26 100644
343--- a/gdb/microblaze-tdep.c
344+++ b/gdb/microblaze-tdep.c
345@@ -657,7 +657,7 @@ static std::vector<CORE_ADDR>
346 microblaze_software_single_step (struct regcache *regcache)
347 {
348 // struct gdbarch *arch = get_frame_arch(frame);
349- struct gdbarch *arch = get_regcache_arch (regcache);
350+ struct gdbarch *arch = regcache->arch();
351 struct address_space *aspace = get_regcache_aspace (regcache);
352 // struct address_space *aspace = get_frame_address_space (frame);
353 struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
354@@ -876,7 +876,6 @@ microblaze_regset_from_core_section (struct gdbarch *gdbarch,
355 static void
356 make_regs (struct gdbarch *arch)
357 {
358- struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
359 int mach = gdbarch_bfd_arch_info (arch)->mach;
360
361 if (mach == bfd_mach_microblaze64)
362--
3632.17.1
364
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0045-Fixed-bug-in-generation-of-IMML-instruction-for-the.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0045-Fixed-bug-in-generation-of-IMML-instruction-for-the.patch
new file mode 100644
index 00000000..118c5629
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0045-Fixed-bug-in-generation-of-IMML-instruction-for-the.patch
@@ -0,0 +1,86 @@
1From d64ce07a2b9206ce1e53d8958b28de02cc7cca2b Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Wed, 22 Jan 2020 16:31:12 +0530
4Subject: [PATCH 45/45] Fixed bug in generation of IMML instruction for the new
5 MB-64 instructions with single register.
6
7---
8 gas/config/tc-microblaze.c | 50 +++++++++++++++++++++++++++++++++++---
9 1 file changed, 47 insertions(+), 3 deletions(-)
10
11diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
12index 95a1e69729..dc79328df6 100644
13--- a/gas/config/tc-microblaze.c
14+++ b/gas/config/tc-microblaze.c
15@@ -1642,12 +1642,56 @@ md_assemble (char * str)
16 exp.X_add_symbol,
17 exp.X_add_number,
18 (char *) opc);
19- immedl = 0L;
20+ immed = 0L;
21 }
22 else
23 {
24 output = frag_more (isize);
25 immed = exp.X_add_number;
26+ temp = ((long long)immed) & 0xFFFFFFFFFFFF8000;
27+ if (temp != 0 && temp != 0xFFFFFFFFFFFF8000 && temp != 0x8000)
28+ {
29+ /* Needs an immediate inst. */
30+ if (((long long)immed) > (long long)-549755813888 && ((long long)immed) < (long long)549755813887)
31+ {
32+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
33+ if (opcode1 == NULL)
34+ {
35+ as_bad (_("unknown opcode \"%s\""), "imml");
36+ return;
37+ }
38+ inst1 = opcode1->bit_sequence;
39+ inst1 |= ((immed & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
40+ output[0] = INST_BYTE0 (inst1);
41+ output[1] = INST_BYTE1 (inst1);
42+ output[2] = INST_BYTE2 (inst1);
43+ output[3] = INST_BYTE3 (inst1);
44+ output = frag_more (isize);
45+ }
46+ else {
47+ opcode2 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
48+ opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml");
49+ if (opcode1 == NULL || opcode2 == NULL)
50+ {
51+ as_bad (_("unknown opcode \"%s\""), "imml");
52+ return;
53+ }
54+ inst1 = opcode2->bit_sequence;
55+ inst1 |= ((immed & 0xFFFFFF0000000000L) >> 40) & IMML_MASK;
56+ output[0] = INST_BYTE0 (inst1);
57+ output[1] = INST_BYTE1 (inst1);
58+ output[2] = INST_BYTE2 (inst1);
59+ output[3] = INST_BYTE3 (inst1);
60+ output = frag_more (isize);
61+ inst1 = opcode1->bit_sequence;
62+ inst1 |= ((immed & 0x000000FFFFFF0000L) >> 16) & IMML_MASK;
63+ output[0] = INST_BYTE0 (inst1);
64+ output[1] = INST_BYTE1 (inst1);
65+ output[2] = INST_BYTE2 (inst1);
66+ output[3] = INST_BYTE3 (inst1);
67+ output = frag_more (isize);
68+ }
69+ }
70 }
71 inst |= (reg1 << RD_LOW) & RD_MASK;
72 inst |= (immed << IMM_LOW) & IMM16_MASK;
73@@ -2141,8 +2185,8 @@ md_assemble (char * str)
74 streq (name, "breaid") ||
75 streq (name, "brai") || streq (name, "braid")))
76 {
77- temp = immed & 0xFFFFFFFFFFFF8000;
78- if (temp != 0)
79+ temp = ((long long)immed) & 0xFFFFFFFFFFFF8000;
80+ if (temp != 0 && temp != 0xFFFFFFFFFFFF8000 && temp != 0x8000)
81 {
82 /* Needs an immediate inst. */
83 if (((long long)immed) > (long long)-549755813888 && ((long long)immed) < (long long)549755813887)
84--
852.17.1
86
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0046-Patch-MicroBlaze-m64-This-patch-will-remove-imml-0-a.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0046-Patch-MicroBlaze-m64-This-patch-will-remove-imml-0-a.patch
new file mode 100644
index 00000000..7677ab35
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0046-Patch-MicroBlaze-m64-This-patch-will-remove-imml-0-a.patch
@@ -0,0 +1,38 @@
1From 9c8f4f1c11d324f0788da3a077b06c6bc9e6f2b8 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 16 Apr 2020 18:08:58 +0530
4Subject: [PATCH] [Patch,MicroBlaze m64] : This patch will remove imml 0 and
5 imml -1 instructions when the offset is less than 16 bit for Type A branch EA
6 instructions.
7
8---
9 gas/config/tc-microblaze.c | 6 ++----
10 1 file changed, 2 insertions(+), 4 deletions(-)
11
12diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
13index 088eae73a9..12fd145a03 100644
14--- a/gas/config/tc-microblaze.c
15+++ b/gas/config/tc-microblaze.c
16@@ -2150,9 +2150,7 @@ md_assemble (char * str)
17 if (exp.X_op != O_constant)
18 {
19 char *opc;
20- if (microblaze_arch_size == 64 && (streq (name, "breai") ||
21- streq (name, "breaid") ||
22- streq (name, "brai") || streq (name, "braid")))
23+ if (microblaze_arch_size == 64 && (streq (name, "brai") || streq (name, "braid")))
24 opc = str_microblaze_64;
25 else
26 opc = NULL;
27@@ -2920,7 +2918,7 @@ md_apply_fix (fixS * fixP,
28 case BFD_RELOC_MICROBLAZE_64:
29 case BFD_RELOC_MICROBLAZE_64_PCREL:
30 if (fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64
31- || fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL)
32+ || fixP->fx_r_type == BFD_RELOC_MICROBLAZE_64_PCREL || (fixP->fx_r_type == BFD_RELOC_64_PCREL && microblaze_arch_size == 64))
33 {
34 /* Generate the imm instruction. */
35 if (((long long)val) > (long long)-549755813888 && ((long long)val) < (long long)549755813887)
36--
372.17.1
38
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0047-Patch-MicroBlaze-commit-for-triggering-build-to-remo.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0047-Patch-MicroBlaze-commit-for-triggering-build-to-remo.patch
new file mode 100644
index 00000000..93314594
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0047-Patch-MicroBlaze-commit-for-triggering-build-to-remo.patch
@@ -0,0 +1,25 @@
1From 2ab2547493c871b452adb2cb8754691b0adf5f03 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Sun, 19 Apr 2020 21:17:03 +0530
4Subject: [PATCH 47/49] [Patch,MicroBlaze] : commit for triggering build to
5 remove imml for Type A BEA insns.
6
7---
8 gas/config/tc-microblaze.c | 1 +
9 1 file changed, 1 insertion(+)
10
11diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
12index 12fd145a03..7ae0dbc018 100644
13--- a/gas/config/tc-microblaze.c
14+++ b/gas/config/tc-microblaze.c
15@@ -2150,6 +2150,7 @@ md_assemble (char * str)
16 if (exp.X_op != O_constant)
17 {
18 char *opc;
19+/* removal imml 0 and imml -1 for bea type A insns */
20 if (microblaze_arch_size == 64 && (streq (name, "brai") || streq (name, "braid")))
21 opc = str_microblaze_64;
22 else
23--
242.17.1
25
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0048-Patch-MicroBlaze-Adding-more-description-to-the-imml.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0048-Patch-MicroBlaze-Adding-more-description-to-the-imml.patch
new file mode 100644
index 00000000..30fbbe7b
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0048-Patch-MicroBlaze-Adding-more-description-to-the-imml.patch
@@ -0,0 +1,27 @@
1From 9b61edf44e44303f1937e98a02a7d78f750a9b24 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 30 Apr 2020 19:40:16 +0530
4Subject: [PATCH 48/49] [Patch,MicroBlaze] : Adding more description to the
5 imml removal for bea type B insns.
6
7---
8 gas/config/tc-microblaze.c | 3 ++-
9 1 file changed, 2 insertions(+), 1 deletion(-)
10
11diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
12index 7ae0dbc018..1d37af54bf 100644
13--- a/gas/config/tc-microblaze.c
14+++ b/gas/config/tc-microblaze.c
15@@ -2150,7 +2150,8 @@ md_assemble (char * str)
16 if (exp.X_op != O_constant)
17 {
18 char *opc;
19-/* removal imml 0 and imml -1 for bea type A insns */
20+/* removal of imml 0 and imml -1 for bea type A insns.
21+if offset is 16 bit then imml instructions are redundant */
22 if (microblaze_arch_size == 64 && (streq (name, "brai") || streq (name, "braid")))
23 opc = str_microblaze_64;
24 else
25--
262.17.1
27
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0049-Patch-MicroBlaze-improper-address-mapping-of-PROVIDE.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0049-Patch-MicroBlaze-improper-address-mapping-of-PROVIDE.patch
new file mode 100644
index 00000000..b751f294
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0049-Patch-MicroBlaze-improper-address-mapping-of-PROVIDE.patch
@@ -0,0 +1,39 @@
1From ba660177916ffb8a0a9882c27246a201dbc218bd Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 17 Jun 2020 21:20:26 +0530
4Subject: [PATCH 49/49] [Patch,MicroBlaze] : improper address mapping of
5 PROVIDE directive symbols[DTOR_END] are causing runtime loops and we don't
6 need to override PROVIDE symbols if symbols are defined in libraries and
7 linker so I am disabling override for PROVIDE symbols.
8
9---
10 ld/ldlang.c | 12 +++++++++---
11 1 file changed, 9 insertions(+), 3 deletions(-)
12
13diff --git a/ld/ldlang.c b/ld/ldlang.c
14index 33f6bda292..a0b404c04d 100644
15--- a/ld/ldlang.c
16+++ b/ld/ldlang.c
17@@ -3559,10 +3559,16 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode)
18 plugin_insert = NULL;
19 #endif
20 break;
21+ /* This is from a --defsym on the command line. */
22 case lang_assignment_statement_enum:
23- if (s->assignment_statement.exp->type.node_class != etree_assert)
24- exp_fold_tree_no_dot (s->assignment_statement.exp);
25- break;
26+ if (s->assignment_statement.exp->type.node_class != etree_assert)
27+ {
28+ if(!(s->assignment_statement.exp->assign.defsym) && (s->assignment_statement.exp->type.node_class == etree_provide))
29+ ;
30+ else
31+ exp_fold_tree_no_dot (s->assignment_statement.exp);
32+ }
33+ break;
34 default:
35 break;
36 }
37--
382.17.1
39
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils/0050-Fix-i386-md_pseudo_table.patch b/meta-microblaze/recipes-microblaze/binutils/binutils/0050-Fix-i386-md_pseudo_table.patch
new file mode 100644
index 00000000..9469732e
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils/0050-Fix-i386-md_pseudo_table.patch
@@ -0,0 +1,28 @@
1Fix a possible compilation issue on i386 when using microblaze patches
2
3Due to patch 0019, a later item may need to refer to this table.
4
5| ../../gas/config/tc-i386.c:1155:20: error: conflicting types for ‘md_pseudo_table’
6| const pseudo_typeS md_pseudo_table[] =
7| ^~~~~~~~~~~~~~~
8| In file included from ../../gas/as.h:565:0,
9| from ../../gas/config/tc-i386.c:28:
10| ../../gas/tc.h:25:21: note: previous declaration of ‘md_pseudo_table’ was here
11| extern pseudo_typeS md_pseudo_table[];
12| ^~~~~~~~~~~~~~~
13
14Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
15
16Index: git/gas/config/tc-i386.c
17===================================================================
18--- git.orig/gas/config/tc-i386.c
19+++ git/gas/config/tc-i386.c
20@@ -1152,7 +1152,7 @@ pe_lcomm (int needs_align)
21 }
22 #endif
23
24-const pseudo_typeS md_pseudo_table[] =
25+pseudo_typeS md_pseudo_table[] =
26 {
27 #if !defined(OBJ_AOUT) && !defined(USE_ALIGN_PTWO)
28 {"align", s_align_bytes, 0},
diff --git a/meta-microblaze/recipes-microblaze/binutils/binutils_%.bbappend b/meta-microblaze/recipes-microblaze/binutils/binutils_%.bbappend
new file mode 100644
index 00000000..e439cae7
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/binutils/binutils_%.bbappend
@@ -0,0 +1,4 @@
1MICROBLAZEPATCHES = ""
2MICROBLAZEPATCHES_microblaze = "binutils-microblaze.inc"
3
4require ${MICROBLAZEPATCHES}
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch
new file mode 100644
index 00000000..28247daa
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch
@@ -0,0 +1,35 @@
1From 23e6126392ab228c1d6483c02ffc32b15f00777e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 13:13:57 +0530
4Subject: [PATCH 01/63] LOCAL]: Testsuite - builtins tests require fpic
5 Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
6
7Conflicts:
8
9 gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
10---
11 gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp | 8 ++++++++
12 1 file changed, 8 insertions(+)
13
14diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
15index acb9eac..363ce07 100644
16--- a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
17+++ b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
18@@ -48,6 +48,14 @@ if { [istarget *-*-eabi*]
19 lappend additional_flags "-Wl,--allow-multiple-definition"
20 }
21
22+<<<<<<< HEAD
23+=======
24+if [istarget "microblaze*-*-linux*"] {
25+ lappend additional_flags "-Wl,-zmuldefs"
26+ lappend additional_flags "-fPIC"
27+}
28+
29+>>>>>>> 6ef6e5b... [LOCAL]: Testsuite - builtins tests require fpic
30 foreach src [lsort [find $srcdir/$subdir *.c]] {
31 if {![string match *-lib.c $src] && [runtest_file_p $runtests $src]} {
32 c-torture-execute [list $src \
33--
342.7.4
35
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch
new file mode 100644
index 00000000..8e4a2a32
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch
@@ -0,0 +1,31 @@
1From e9c8884f473eae307945ceabaa1ff03278236c23 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 14:31:10 +0530
4Subject: [PATCH 02/63] [LOCAL]: Quick fail g++.dg/opt/memcpy1.C This
5 particular testcase fails with a timeout. Instead, fail it at compile-time
6 for microblaze. This speeds up the testsuite without removing it from the
7 FAIL reports.
8
9Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10---
11 gcc/testsuite/g++.dg/opt/memcpy1.C | 4 ++++
12 1 file changed, 4 insertions(+)
13
14diff --git a/gcc/testsuite/g++.dg/opt/memcpy1.C b/gcc/testsuite/g++.dg/opt/memcpy1.C
15index 3862756..db9f990 100644
16--- a/gcc/testsuite/g++.dg/opt/memcpy1.C
17+++ b/gcc/testsuite/g++.dg/opt/memcpy1.C
18@@ -4,6 +4,10 @@
19 // { dg-do compile }
20 // { dg-options "-O" }
21
22+#if defined (__MICROBLAZE__)
23+#error "too slow on mb. Investigate."
24+#endif
25+
26 typedef unsigned char uint8_t;
27 typedef uint8_t uint8;
28 __extension__ typedef __SIZE_TYPE__ size_t;
29--
302.7.4
31
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0003-LOCAL-Testsuite-explicitly-add-fivopts-for-tests-tha.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0003-LOCAL-Testsuite-explicitly-add-fivopts-for-tests-tha.patch
new file mode 100644
index 00000000..ef994457
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0003-LOCAL-Testsuite-explicitly-add-fivopts-for-tests-tha.patch
@@ -0,0 +1,119 @@
1From fb4b4d4ecba04859d52a653d7c453df92014dc38 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 15:28:38 +0530
4Subject: [PATCH 03/63] [LOCAL]: Testsuite - explicitly add -fivopts for tests
5 that depend on it (test gcc/testsuite/gcc.dg/tree-ssa/ivopts-lt.c doesnt
6 exist in 4.6 branch)
7
8Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
9
10Conflicts:
11 gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
12---
13 gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C | 2 +-
14 gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C | 2 +-
15 gcc/testsuite/gcc.dg/tree-ssa/loop-2.c | 2 +-
16 gcc/testsuite/gcc.dg/tree-ssa/loop-4.c | 2 +-
17 gcc/testsuite/gcc.dg/tree-ssa/loop-5.c | 2 +-
18 gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c | 2 +-
19 gcc/testsuite/gcc.dg/tree-ssa/pr19590.c | 2 +-
20 gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c | 2 +-
21 8 files changed, 8 insertions(+), 8 deletions(-)
22
23diff --git a/gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C b/gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C
24index 438db88..ede883e 100644
25--- a/gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C
26+++ b/gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C
27@@ -1,5 +1,5 @@
28 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
29-/* { dg-options "-O2 -fdump-tree-ivopts-details" } */
30+/* { dg-options "-O2 -fivopts -fdump-tree-ivopts-details" } */
31
32 void test (int *b, int *e, int stride)
33 {
34diff --git a/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C b/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C
35index 07ff1b7..a09710c 100644
36--- a/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C
37+++ b/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C
38@@ -1,5 +1,5 @@
39 // { dg-do compile }
40-// { dg-options "-O2 -fdump-tree-ivopts-details" }
41+// { dg-options "-O2 -fivopts -fdump-tree-ivopts-details" }
42
43 class MinimalVec3
44 {
45diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c
46index bda2516..22c8a5d 100644
47--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c
48+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c
49@@ -1,7 +1,7 @@
50 /* A test for strength reduction and induction variable elimination. */
51
52 /* { dg-do compile } */
53-/* { dg-options "-O1 -fdump-tree-optimized" } */
54+/* { dg-options "-O1 -fivopts -fdump-tree-optimized" } */
55 /* { dg-require-effective-target size32plus } */
56
57 /* Size of this structure should be sufficiently weird so that no memory
58diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-4.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-4.c
59index f0770ab..65d74c8 100644
60--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-4.c
61+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-4.c
62@@ -1,7 +1,7 @@
63 /* A test for strength reduction and induction variable elimination. */
64
65 /* { dg-do compile } */
66-/* { dg-options "-O1 -fdump-tree-optimized" } */
67+/* { dg-options "-O1 -fivopts -fdump-tree-optimized" } */
68 /* { dg-require-effective-target size32plus } */
69
70 /* Size of this structure should be sufficiently weird so that no memory
71diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-5.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-5.c
72index 5f42857..9bc86ee 100644
73--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-5.c
74+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-5.c
75@@ -1,7 +1,7 @@
76 /* A test for induction variable merging. */
77
78 /* { dg-do compile } */
79-/* { dg-options "-O1 -fdump-tree-optimized" } */
80+/* { dg-options "-O1 -fivopts -fdump-tree-optimized" } */
81
82 void foo(long);
83
84diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
85index 50d86a0..1e3eacd 100644
86--- a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
87+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
88@@ -1,5 +1,5 @@
89 /* { dg-do compile } */
90-/* { dg-options "-O2 -fopt-info-loop-missed" } */
91+/* { dg-options "-O2 -fivopts -fopt-info-loop-missed" } */
92 extern void g(void);
93
94 void
95diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c
96index 2c6cfc6..648e6e6 100644
97--- a/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c
98+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c
99@@ -1,5 +1,5 @@
100 /* { dg-do compile } */
101-/* { dg-options "-O2 -fdump-tree-ivopts" } */
102+/* { dg-options "-O2 -fivopts -fdump-tree-ivopts" } */
103
104 void vnum_test8(int *data)
105 {
106diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c
107index e911bfc..5d3e7e0 100644
108--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c
109+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c
110@@ -1,5 +1,5 @@
111 /* { dg-do compile } */
112-/* { dg-options "-Os -fdump-tree-optimized" } */
113+/* { dg-options "-Os -fivopts -fdump-tree-optimized" } */
114
115 /* Slightly changed testcase from PR middle-end/40815. */
116 void bar(char*, char*, int);
117--
1182.7.4
119
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0004-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0004-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch
new file mode 100644
index 00000000..a575b518
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0004-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch
@@ -0,0 +1,35 @@
1From 38022a87b01cf2e36b605d4f6d0faab22a0d2f44 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 15:46:28 +0530
4Subject: [PATCH 04/63] [LOCAL]: For dejagnu static testing on qemu, suppress
5 warnings about multiple definitions from the test function and libc in line
6 with method used by powerpc. Dynamic linking and using a qemu binary which
7 understands sysroot resolves all test failures with builtins
8
9Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
10---
11 gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp | 4 ----
12 1 file changed, 4 deletions(-)
13
14diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
15index 363ce07..56b1a9a 100644
16--- a/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
17+++ b/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp
18@@ -48,14 +48,10 @@ if { [istarget *-*-eabi*]
19 lappend additional_flags "-Wl,--allow-multiple-definition"
20 }
21
22-<<<<<<< HEAD
23-=======
24 if [istarget "microblaze*-*-linux*"] {
25 lappend additional_flags "-Wl,-zmuldefs"
26- lappend additional_flags "-fPIC"
27 }
28
29->>>>>>> 6ef6e5b... [LOCAL]: Testsuite - builtins tests require fpic
30 foreach src [lsort [find $srcdir/$subdir *.c]] {
31 if {![string match *-lib.c $src] && [runtest_file_p $runtests $src]} {
32 c-torture-execute [list $src \
33--
342.7.4
35
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0005-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0005-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch
new file mode 100644
index 00000000..18fd6dec
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0005-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch
@@ -0,0 +1,35 @@
1From a7dfb5f158f16f88b30aabe903c4fb088889eeef Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 15:50:35 +0530
4Subject: [PATCH 05/63] [Patch, testsuite]: Add MicroBlaze to target-supports
5 for atomic buil. .tin tests
6
7MicroBlaze added to supported targets for atomic builtin tests.
8
9Changelog/testsuite
10
112014-02-14 David Holsgrove <david.holsgrove@xilinx.com>
12
13 * gcc/testsuite/lib/target-supports.exp: Add microblaze to
14 check_effective_target_sync_int_long.
15
16Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
17---
18 gcc/testsuite/lib/target-supports.exp | 1 +
19 1 file changed, 1 insertion(+)
20
21diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
22index cda0f3d..0a69659e 100644
23--- a/gcc/testsuite/lib/target-supports.exp
24+++ b/gcc/testsuite/lib/target-supports.exp
25@@ -6829,6 +6829,7 @@ proc check_effective_target_sync_int_long { } {
26 && [check_effective_target_arm_acq_rel])
27 || [istarget bfin*-*linux*]
28 || [istarget hppa*-*linux*]
29+ || [istarget microblaze*-*linux*]
30 || [istarget s390*-*-*]
31 || [istarget powerpc*-*-*]
32 || [istarget crisv32-*-*] || [istarget cris-*-*]
33--
342.7.4
35
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0005-Testsuite-explicitly-add-fivopts-for-tests-that-depe.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0005-Testsuite-explicitly-add-fivopts-for-tests-that-depe.patch
new file mode 100644
index 00000000..b428d121
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0005-Testsuite-explicitly-add-fivopts-for-tests-that-depe.patch
@@ -0,0 +1,118 @@
1From 7f0a129701ce9809d79ea4618f3293062bd24bbf Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Sat, 26 Aug 2017 19:21:18 -0700
4Subject: [PATCH] Testsuite - explicitly add -fivopts for tests that depend on
5 it
6
7Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
8Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
9Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
10Upstream-Status: Pending
11---
12 gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C | 2 +-
13 gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C | 2 +-
14 gcc/testsuite/gcc.dg/tree-ssa/loop-2.c | 2 +-
15 gcc/testsuite/gcc.dg/tree-ssa/loop-4.c | 2 +-
16 gcc/testsuite/gcc.dg/tree-ssa/loop-5.c | 2 +-
17 gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c | 2 +-
18 gcc/testsuite/gcc.dg/tree-ssa/pr19590.c | 2 +-
19 gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c | 2 +-
20 8 files changed, 8 insertions(+), 8 deletions(-)
21
22diff --git a/gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C b/gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C
23index 438db88204..ede883eb28 100644
24--- a/gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C
25+++ b/gcc/testsuite/g++.dg/tree-ssa/ivopts-2.C
26@@ -1,5 +1,5 @@
27 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
28-/* { dg-options "-O2 -fdump-tree-ivopts-details" } */
29+/* { dg-options "-O2 -fivopts -fdump-tree-ivopts-details" } */
30
31 void test (int *b, int *e, int stride)
32 {
33diff --git a/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C b/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C
34index eb72581390..02f3ea4a7d 100644
35--- a/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C
36+++ b/gcc/testsuite/g++.dg/tree-ssa/ivopts-3.C
37@@ -1,5 +1,5 @@
38 // { dg-do compile }
39-// { dg-options "-O2 -fdump-tree-ivopts-details" }
40+// { dg-options "-O2 -fivopts -fdump-tree-ivopts-details" }
41
42 class MinimalVec3
43 {
44diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c
45index bda2516735..22c8a5dcff 100644
46--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c
47+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c
48@@ -1,7 +1,7 @@
49 /* A test for strength reduction and induction variable elimination. */
50
51 /* { dg-do compile } */
52-/* { dg-options "-O1 -fdump-tree-optimized" } */
53+/* { dg-options "-O1 -fivopts -fdump-tree-optimized" } */
54 /* { dg-require-effective-target size32plus } */
55
56 /* Size of this structure should be sufficiently weird so that no memory
57diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-4.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-4.c
58index f0770abdbb..65d74c8e62 100644
59--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-4.c
60+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-4.c
61@@ -1,7 +1,7 @@
62 /* A test for strength reduction and induction variable elimination. */
63
64 /* { dg-do compile } */
65-/* { dg-options "-O1 -fdump-tree-optimized" } */
66+/* { dg-options "-O1 -fivopts -fdump-tree-optimized" } */
67 /* { dg-require-effective-target size32plus } */
68
69 /* Size of this structure should be sufficiently weird so that no memory
70diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-5.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-5.c
71index 5f42857fe1..9bc86ee0d2 100644
72--- a/gcc/testsuite/gcc.dg/tree-ssa/loop-5.c
73+++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-5.c
74@@ -1,7 +1,7 @@
75 /* A test for induction variable merging. */
76
77 /* { dg-do compile } */
78-/* { dg-options "-O1 -fdump-tree-optimized" } */
79+/* { dg-options "-O1 -fivopts -fdump-tree-optimized" } */
80
81 void foo(long);
82
83diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
84index 3c8ee06016..db192a657f 100644
85--- a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
86+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
87@@ -1,5 +1,5 @@
88 /* { dg-do compile } */
89-/* { dg-options "-O2 -Wunsafe-loop-optimizations" } */
90+/* { dg-options "-O2 -fivopts -Wunsafe-loop-optimizations" } */
91 extern void g(void);
92
93 void
94diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c
95index 2c6cfc6f83..648e6e67e8 100644
96--- a/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c
97+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19590.c
98@@ -1,5 +1,5 @@
99 /* { dg-do compile } */
100-/* { dg-options "-O2 -fdump-tree-ivopts" } */
101+/* { dg-options "-O2 -fivopts -fdump-tree-ivopts" } */
102
103 void vnum_test8(int *data)
104 {
105diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c
106index e911bfcd52..5d3e7e0801 100644
107--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c
108+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-19.c
109@@ -1,5 +1,5 @@
110 /* { dg-do compile } */
111-/* { dg-options "-Os -fdump-tree-optimized" } */
112+/* { dg-options "-Os -fivopts -fdump-tree-optimized" } */
113
114 /* Slightly changed testcase from PR middle-end/40815. */
115 void bar(char*, char*, int);
116--
1172.14.2
118
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0006-Patch-testsuite-Update-MicroBlaze-strings-test.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0006-Patch-testsuite-Update-MicroBlaze-strings-test.patch
new file mode 100644
index 00000000..e4a86dc4
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0006-Patch-testsuite-Update-MicroBlaze-strings-test.patch
@@ -0,0 +1,43 @@
1From e23b1a424cfd852f7a33f29c0b80d867ca533c3b Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 11 Jan 2017 16:20:01 +0530
4Subject: [PATCH 06/63] [Patch, testsuite]: Update MicroBlaze strings test for
5 new scan-assembly output resulting in use of $LC label
6
7ChangeLog/testsuite
8
92014-02-14 David Holsgrove <david.holsgrove@xilinx.com>
10
11 * gcc/testsuite/gcc.target/microblaze/others/strings1.c: Update
12 to include $LC label.
13
14Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
15---
16 gcc/testsuite/gcc.target/microblaze/others/strings1.c | 6 ++++--
17 1 file changed, 4 insertions(+), 2 deletions(-)
18
19diff --git a/gcc/testsuite/gcc.target/microblaze/others/strings1.c b/gcc/testsuite/gcc.target/microblaze/others/strings1.c
20index 7a63faf..0403b7b 100644
21--- a/gcc/testsuite/gcc.target/microblaze/others/strings1.c
22+++ b/gcc/testsuite/gcc.target/microblaze/others/strings1.c
23@@ -1,13 +1,15 @@
24 /* { dg-options "-O3" } */
25
26+/* { dg-final { scan-assembler "\.rodata*" } } */
27+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),\\\$LC.*" } } */
28+/* { dg-final { scan-assembler "\lwi\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),*" } } */
29+
30 #include <string.h>
31
32-/* { dg-final { scan-assembler "\.rodata*" } } */
33 extern void somefunc (char *);
34 int testfunc ()
35 {
36 char string2[80];
37-/* { dg-final { scan-assembler "\lwi\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,.LC*" } } */
38 strcpy (string2, "hello");
39 somefunc (string2);
40 }
41--
422.7.4
43
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0007-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0007-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch
new file mode 100644
index 00000000..8c43de05
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0007-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch
@@ -0,0 +1,67 @@
1From c210044f15df2433438b6b74e5c2bcf79458c2e4 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:14:15 +0530
4Subject: [PATCH 07/63] [Patch, testsuite]: Allow MicroBlaze .weakext pattern
5 in regex match Extend regex pattern to include optional ext at the end of
6 .weak to match the MicroBlaze weak label .weakext
7
8ChangeLog/testsuite
9
102014-02-14 David Holsgrove <david.holsgrove@xilinx.com>
11
12 * gcc/testsuite/g++.dg/abi/rtti3.C: Extend scan-assembler
13 pattern to take optional ext after .weak.
14 * gcc/testsuite/g++.dg/abi/thunk4.C: Likewise.
15
16Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
17
18Conflicts:
19
20 gcc/testsuite/g++.dg/abi/rtti3.C
21---
22 gcc/testsuite/g++.dg/abi/rtti3.C | 4 ++--
23 gcc/testsuite/g++.dg/abi/thunk3.C | 2 +-
24 gcc/testsuite/g++.dg/abi/thunk4.C | 2 +-
25 3 files changed, 4 insertions(+), 4 deletions(-)
26
27diff --git a/gcc/testsuite/g++.dg/abi/rtti3.C b/gcc/testsuite/g++.dg/abi/rtti3.C
28index 0cc7d3e..f284cd9 100644
29--- a/gcc/testsuite/g++.dg/abi/rtti3.C
30+++ b/gcc/testsuite/g++.dg/abi/rtti3.C
31@@ -3,8 +3,8 @@
32
33 // { dg-require-weak "" }
34 // { dg-skip-if "Linkonce not weak" { *-*-mingw* *-*-cygwin } }
35-// { dg-final { scan-assembler ".weak\[ \t\]_?_ZTSPP1A" { target { ! { *-*-darwin* hppa*-*-hpux* } } } } }
36-// { dg-final { scan-assembler-not ".weak\[ \t\]_?_ZTIPP1A" { target { ! { *-*-darwin* } } } } }
37+// { dg-final { scan-assembler ".weak(ext)?\[ \t\]_?_ZTSPP1A" { target { ! { *-*-darwin* } } } } }
38+// { dg-final { scan-assembler-not ".weak(ext)?\[ \t\]_?_ZTIPP1A" { target { ! { *-*-darwin* } } } } }
39 // { dg-final { scan-assembler ".weak_definition\[ \t\]_?_ZTSPP1A" { target { *-*-darwin* } } } }
40 // { dg-final { scan-assembler-not ".weak_definition\[ \t\]_?_ZTIPP1A" { target { *-*-darwin* } } } }
41
42diff --git a/gcc/testsuite/g++.dg/abi/thunk3.C b/gcc/testsuite/g++.dg/abi/thunk3.C
43index f2347f7..dcec8a7 100644
44--- a/gcc/testsuite/g++.dg/abi/thunk3.C
45+++ b/gcc/testsuite/g++.dg/abi/thunk3.C
46@@ -1,5 +1,5 @@
47 // { dg-require-weak "" }
48-// { dg-final { scan-assembler-not ".weak\[\t \]_?_ZThn._N7Derived3FooEv" { target { ! { *-*-darwin* } } } } }
49+// { dg-final { scan-assembler-not ".weak(ext)?\[\t \]_?_ZThn._N7Derived3FooEv" { target { ! { *-*-darwin* } } } } }
50 // { dg-final { scan-assembler-not ".weak_definition\[\t \]_?_ZThn._N7Derived3FooEv" { target { *-*-darwin* } } } }
51
52 struct Base
53diff --git a/gcc/testsuite/g++.dg/abi/thunk4.C b/gcc/testsuite/g++.dg/abi/thunk4.C
54index 6e8f124..d1d34fe 100644
55--- a/gcc/testsuite/g++.dg/abi/thunk4.C
56+++ b/gcc/testsuite/g++.dg/abi/thunk4.C
57@@ -1,6 +1,6 @@
58 // { dg-require-weak "" }
59 // { dg-skip-if "Linkonce not weak" { *-*-mingw* *-*-cygwin } }
60-// { dg-final { scan-assembler ".weak\[ \t\]_?_ZThn._N7Derived3FooEv" { target { ! { *-*-darwin* } } } } }
61+// { dg-final { scan-assembler ".weak(ext)?\[ \t\]_?_ZThn._N7Derived3FooEv" { target { ! { *-*-darwin* } } } } }
62 // { dg-final { scan-assembler ".weak_definition\[ \t\]_?_ZThn._N7Derived3FooEv" { target { *-*-darwin* } } } }
63
64 struct Base
65--
662.7.4
67
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0008-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0008-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch
new file mode 100644
index 00000000..d02be316
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0008-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch
@@ -0,0 +1,28 @@
1From 283d8576d2599b3c38814e7c70e3f36ed51df9da Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:34:27 +0530
4Subject: [PATCH 08/63] [Patch, testsuite]: Add MicroBlaze to
5 check_profiling_available Testsuite, add microblaze*-*-* target in
6 check_profiling_available inline with other archs setting
7 profiling_available_saved to 0
8
9Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
10---
11 gcc/testsuite/lib/target-supports.exp | 1 +
12 1 file changed, 1 insertion(+)
13
14diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
15index 0a69659e..d47819c 100644
16--- a/gcc/testsuite/lib/target-supports.exp
17+++ b/gcc/testsuite/lib/target-supports.exp
18@@ -678,6 +678,7 @@ proc check_profiling_available { test_what } {
19 || [istarget m68k-*-elf]
20 || [istarget m68k-*-uclinux*]
21 || [istarget mips*-*-elf*]
22+ || [istarget microblaze*-*-*]
23 || [istarget mmix-*-*]
24 || [istarget mn10300-*-elf*]
25 || [istarget moxie-*-elf*]
26--
272.7.4
28
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0009-Patch-microblaze-Fix-atomic-side-effects.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0009-Patch-microblaze-Fix-atomic-side-effects.patch
new file mode 100644
index 00000000..ae24c080
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0009-Patch-microblaze-Fix-atomic-side-effects.patch
@@ -0,0 +1,68 @@
1From 1905061b279e6fe5fd9861fc490fd4075edac4a8 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:41:43 +0530
4Subject: [PATCH 09/63] [Patch, microblaze]: Fix atomic side effects. In
5 atomic_compare_and_swapsi, add side effects to prevent incorrect assumptions
6 during optimization. Previously, the outputs were considered unused; this
7 generated assembly code with undefined side effects after invocation of the
8 atomic.
9
10Signed-off-by: Kirk Meyer <kirk.meyer@sencore.com>
11Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
12
13Conflicts:
14 gcc/config/microblaze/microblaze.md
15---
16 gcc/config/microblaze/microblaze.md | 3 +++
17 gcc/config/microblaze/sync.md | 21 +++++++++++++--------
18 2 files changed, 16 insertions(+), 8 deletions(-)
19
20diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
21index 183afff..7a40c53 100644
22--- a/gcc/config/microblaze/microblaze.md
23+++ b/gcc/config/microblaze/microblaze.md
24@@ -43,6 +43,9 @@
25 (UNSPEC_TLS 106) ;; jump table
26 (UNSPEC_SET_TEXT 107) ;; set text start
27 (UNSPEC_TEXT 108) ;; data text relative
28+ (UNSPECV_CAS_BOOL 201) ;; compare and swap (bool)
29+ (UNSPECV_CAS_VAL 202) ;; compare and swap (val)
30+ (UNSPECV_CAS_MEM 203) ;; compare and swap (mem)
31 ])
32
33 (define_c_enum "unspec" [
34diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md
35index 6f16ca6..bebab5c 100644
36--- a/gcc/config/microblaze/sync.md
37+++ b/gcc/config/microblaze/sync.md
38@@ -18,14 +18,19 @@
39 ;; <http://www.gnu.org/licenses/>.
40
41 (define_insn "atomic_compare_and_swapsi"
42- [(match_operand:SI 0 "register_operand" "=&d") ;; bool output
43- (match_operand:SI 1 "register_operand" "=&d") ;; val output
44- (match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory
45- (match_operand:SI 3 "register_operand" "d") ;; expected value
46- (match_operand:SI 4 "register_operand" "d") ;; desired value
47- (match_operand:SI 5 "const_int_operand" "") ;; is_weak
48- (match_operand:SI 6 "const_int_operand" "") ;; mod_s
49- (match_operand:SI 7 "const_int_operand" "") ;; mod_f
50+ [(set (match_operand:SI 0 "register_operand" "=&d") ;; bool output
51+ (unspec_volatile:SI
52+ [(match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory
53+ (match_operand:SI 3 "register_operand" "d") ;; expected value
54+ (match_operand:SI 4 "register_operand" "d")] ;; desired value
55+ UNSPECV_CAS_BOOL))
56+ (set (match_operand:SI 1 "register_operand" "=&d") ;; val output
57+ (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_VAL))
58+ (set (match_dup 2)
59+ (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_MEM))
60+ (match_operand:SI 5 "const_int_operand" "") ;; is_weak
61+ (match_operand:SI 6 "const_int_operand" "") ;; mod_s
62+ (match_operand:SI 7 "const_int_operand" "") ;; mod_f
63 (clobber (match_scratch:SI 8 "=&d"))]
64 ""
65 {
66--
672.7.4
68
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0010-Patch-microblaze-Fix-atomic-boolean-return-value.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0010-Patch-microblaze-Fix-atomic-boolean-return-value.patch
new file mode 100644
index 00000000..07a43177
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0010-Patch-microblaze-Fix-atomic-boolean-return-value.patch
@@ -0,0 +1,40 @@
1From 65bc1969bd652df4bf9d01d30547a947da293550 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:45:45 +0530
4Subject: [PATCH 10/63] [Patch, microblaze]: Fix atomic boolean return value.
5 In atomic_compare_and_swapsi, fix boolean return value. Previously, it
6 contained zero if successful and non-zero if unsuccessful.
7
8Signed-off-by: Kirk Meyer <kirk.meyer@sencore.com>
9Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
10---
11 gcc/config/microblaze/sync.md | 7 ++++---
12 1 file changed, 4 insertions(+), 3 deletions(-)
13
14diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md
15index bebab5c..72eac09 100644
16--- a/gcc/config/microblaze/sync.md
17+++ b/gcc/config/microblaze/sync.md
18@@ -34,15 +34,16 @@
19 (clobber (match_scratch:SI 8 "=&d"))]
20 ""
21 {
22- output_asm_insn ("addc \tr0,r0,r0", operands);
23+ output_asm_insn ("add \t%0,r0,r0", operands);
24 output_asm_insn ("lwx \t%1,%y2,r0", operands);
25 output_asm_insn ("addic\t%8,r0,0", operands);
26 output_asm_insn ("bnei \t%8,.-8", operands);
27- output_asm_insn ("cmp \t%0,%1,%3", operands);
28- output_asm_insn ("bnei \t%0,.+16", operands);
29+ output_asm_insn ("cmp \t%8,%1,%3", operands);
30+ output_asm_insn ("bnei \t%8,.+20", operands);
31 output_asm_insn ("swx \t%4,%y2,r0", operands);
32 output_asm_insn ("addic\t%8,r0,0", operands);
33 output_asm_insn ("bnei \t%8,.-28", operands);
34+ output_asm_insn ("addi \t%0,r0,1", operands);
35 return "";
36 }
37 )
38--
392.7.4
40
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0011-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0011-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch
new file mode 100644
index 00000000..b9ba239f
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0011-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch
@@ -0,0 +1,33 @@
1From 4e4409f10b450ec9254e69445ffeb8d116906d16 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:50:17 +0530
4Subject: [PATCH 11/63] [Patch, microblaze]: Fix the Microblaze crash with
5 msmall-divides flag Compiler is crashing when we use msmall-divides and
6 mxl-barrel-shift flag. This is because when use above flags
7 microblaze_expand_divide function will be called for division operation. In
8 microblaze_expand_divide function we are using sub_reg but MicroBlaze doesn't
9 have subreg register due to this compiler was crashing. Changed the logic to
10 avoid sub_reg call
11
12Signed-off-by:Nagaraju Mekala <nmekala@xilix.com>
13---
14 gcc/config/microblaze/microblaze.c | 3 +--
15 1 file changed, 1 insertion(+), 2 deletions(-)
16
17diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
18index 55c1bec..ae45038 100644
19--- a/gcc/config/microblaze/microblaze.c
20+++ b/gcc/config/microblaze/microblaze.c
21@@ -3715,8 +3715,7 @@ microblaze_expand_divide (rtx operands[])
22 mem_rtx = gen_rtx_MEM (QImode,
23 gen_rtx_PLUS (Pmode, regt1, div_table_rtx));
24
25- insn = emit_insn (gen_movqi (regqi, mem_rtx));
26- insn = emit_insn (gen_movsi (operands[0], gen_rtx_SUBREG (SImode, regqi, 0)));
27+ insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
28 jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
29 JUMP_LABEL (jump) = div_end_label;
30 LABEL_NUSES (div_end_label) = 1;
31--
322.7.4
33
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0012-Patch-microblaze-Added-ashrsi3_with_size_opt.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0012-Patch-microblaze-Added-ashrsi3_with_size_opt.patch
new file mode 100644
index 00000000..fc47bae6
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0012-Patch-microblaze-Added-ashrsi3_with_size_opt.patch
@@ -0,0 +1,48 @@
1From 6dbeb53f0185dd587ece39d624d193768633a7ab Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 16:52:56 +0530
4Subject: [PATCH 12/63] [Patch, microblaze]: Added ashrsi3_with_size_opt Added
5 ashrsi3_with_size_opt pattern to optimize the sra instructions when the -Os
6 optimization is used. lshrsi3_with_size_opt is being removed as it has
7 conflicts with unsigned int variables
8
9Signed-off-by:Nagaraju Mekala <nmekala@xilix.com>
10---
11 gcc/config/microblaze/microblaze.md | 21 +++++++++++++++++++++
12 1 file changed, 21 insertions(+)
13
14diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
15index 7a40c53..3d2636e 100644
16--- a/gcc/config/microblaze/microblaze.md
17+++ b/gcc/config/microblaze/microblaze.md
18@@ -1508,6 +1508,27 @@
19 (set_attr "length" "4,4")]
20 )
21
22+(define_insn "*ashrsi3_with_size_opt"
23+ [(set (match_operand:SI 0 "register_operand" "=&d")
24+ (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
25+ (match_operand:SI 2 "immediate_operand" "I")))]
26+ "(INTVAL (operands[2]) > 5 && optimize_size)"
27+ {
28+ operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
29+
30+ output_asm_insn ("ori\t%3,r0,%2", operands);
31+ if (REGNO (operands[0]) != REGNO (operands[1]))
32+ output_asm_insn ("addk\t%0,%1,r0", operands);
33+
34+ output_asm_insn ("addik\t%3,%3,-1", operands);
35+ output_asm_insn ("bneid\t%3,.-4", operands);
36+ return "sra\t%0,%0";
37+ }
38+ [(set_attr "type" "arith")
39+ (set_attr "mode" "SI")
40+ (set_attr "length" "20")]
41+)
42+
43 (define_insn "*ashrsi_inline"
44 [(set (match_operand:SI 0 "register_operand" "=&d")
45 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
46--
472.7.4
48
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0013-Patch-microblaze-Fixed-missing-save-of-r18-in-fast_i.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0013-Patch-microblaze-Fixed-missing-save-of-r18-in-fast_i.patch
new file mode 100644
index 00000000..3b4b4c70
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0013-Patch-microblaze-Fixed-missing-save-of-r18-in-fast_i.patch
@@ -0,0 +1,41 @@
1From 53ab5a3fec283aeb9d2efeb632d423b774192e65 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 17:50:03 +0530
4Subject: [PATCH 13/63] [Patch, microblaze]: Fixed missing save of r18 in
5 fast_interrupt. Register 18 is used as a clobber register, and must be stored
6 when entering a fast_interrupt. Before this fix, register 18 was only saved
7 if it was used directly in the interrupt function.
8
9However, if the fast_interrupt function called a function that used
10r18, the register would not be saved, and thus be mangled
11upon returning from the interrupt.
12
13Changelog
14
152014-02-27 Klaus Petersen <klauspetersen@gmail.com>
16
17 * gcc/config/microblaze/microblaze.c: Check for fast_interrupt in
18 microblaze_must_save_register.
19
20Signed-off-by: Klaus Petersen <klauspetersen@gmail.com>
21Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
22---
23 gcc/config/microblaze/microblaze.c | 2 +-
24 1 file changed, 1 insertion(+), 1 deletion(-)
25
26diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
27index ae45038..c834b49 100644
28--- a/gcc/config/microblaze/microblaze.c
29+++ b/gcc/config/microblaze/microblaze.c
30@@ -2043,7 +2043,7 @@ microblaze_must_save_register (int regno)
31 {
32 if (df_regs_ever_live_p (regno)
33 || regno == MB_ABI_MSR_SAVE_REG
34- || (interrupt_handler
35+ || ((interrupt_handler || fast_interrupt)
36 && (regno == MB_ABI_ASM_TEMP_REGNUM
37 || regno == MB_ABI_EXCEPTION_RETURN_ADDR_REGNUM)))
38 return 1;
39--
402.7.4
41
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0014-Patch-microblaze-Use-bralid-for-profiler-calls.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0014-Patch-microblaze-Use-bralid-for-profiler-calls.patch
new file mode 100644
index 00000000..889a1e69
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0014-Patch-microblaze-Use-bralid-for-profiler-calls.patch
@@ -0,0 +1,26 @@
1From cbf1854e3569122ee1143e6716ff68275c26aced Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 10:57:19 +0530
4Subject: [PATCH 14/63] [Patch, microblaze]: Use bralid for profiler calls
5 Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
6
7---
8 gcc/config/microblaze/microblaze.h | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
12index fa0806e..0a435b8 100644
13--- a/gcc/config/microblaze/microblaze.h
14+++ b/gcc/config/microblaze/microblaze.h
15@@ -486,7 +486,7 @@ typedef struct microblaze_args
16
17 #define FUNCTION_PROFILER(FILE, LABELNO) { \
18 { \
19- fprintf (FILE, "\tbrki\tr16,_mcount\n"); \
20+ fprintf (FILE, "\tbralid\tr15,_mcount\nnop\n"); \
21 } \
22 }
23
24--
252.7.4
26
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0015-Patch-microblaze-Disable-fivopts-by-default.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0015-Patch-microblaze-Disable-fivopts-by-default.patch
new file mode 100644
index 00000000..0ada80eb
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0015-Patch-microblaze-Disable-fivopts-by-default.patch
@@ -0,0 +1,42 @@
1From 604cae83ce9d2942568178966f69614acbbcbefd Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 11:10:21 +0530
4Subject: [PATCH 15/63] [Patch, microblaze]: Disable fivopts by default Turn
5 off ivopts by default. Interferes with cse.
6
7Changelog
8
92013-03-18 Edgar E. Iglesias <edgar.iglesias@xilinx.com>
10
11 * gcc/common/config/microblaze/microblaze-common.c
12 (microblaze_option_optimization_table): Disable fivopts by default.
13
14Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
15Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
16---
17 gcc/common/config/microblaze/microblaze-common.c | 9 +++++++++
18 1 file changed, 9 insertions(+)
19
20diff --git a/gcc/common/config/microblaze/microblaze-common.c b/gcc/common/config/microblaze/microblaze-common.c
21index c30bdef..9b6ef21 100644
22--- a/gcc/common/config/microblaze/microblaze-common.c
23+++ b/gcc/common/config/microblaze/microblaze-common.c
24@@ -24,6 +24,15 @@
25 #include "common/common-target.h"
26 #include "common/common-target-def.h"
27
28+/* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
29+static const struct default_options microblaze_option_optimization_table[] =
30+ {
31+ /* Turn off ivopts by default. It messes up cse. */
32+ { OPT_LEVELS_ALL, OPT_fivopts, NULL, 0 },
33+ { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
34+ { OPT_LEVELS_NONE, 0, NULL, 0 }
35+ };
36+
37 #undef TARGET_DEFAULT_TARGET_FLAGS
38 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
39
40--
412.7.4
42
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0016-Patch-microblaze-Removed-moddi3-routinue.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0016-Patch-microblaze-Removed-moddi3-routinue.patch
new file mode 100644
index 00000000..87bc1668
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0016-Patch-microblaze-Removed-moddi3-routinue.patch
@@ -0,0 +1,160 @@
1From 14ddb3217fbb84c48903124ec6a3614b4707630d Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Jan 2017 17:36:16 +0530
4Subject: [PATCH 16/63] [Patch, microblaze]: Removed moddi3 routinue Using the
5 default moddi3 function as the existing implementation has many bugs
6
7Signed-off-by:Nagaraju <nmekala@xilix.com>
8
9Conflicts:
10 libgcc/config/microblaze/moddi3.S
11---
12 libgcc/config/microblaze/moddi3.S | 121 ----------------------------------
13 libgcc/config/microblaze/t-microblaze | 3 +-
14 2 files changed, 1 insertion(+), 123 deletions(-)
15 delete mode 100644 libgcc/config/microblaze/moddi3.S
16
17diff --git a/libgcc/config/microblaze/moddi3.S b/libgcc/config/microblaze/moddi3.S
18deleted file mode 100644
19index abfe4fc..0000000
20--- a/libgcc/config/microblaze/moddi3.S
21+++ /dev/null
22@@ -1,121 +0,0 @@
23-###################################
24-#
25-# Copyright (C) 2009-2019 Free Software Foundation, Inc.
26-#
27-# Contributed by Michael Eager <eager@eagercon.com>.
28-#
29-# This file is free software; you can redistribute it and/or modify it
30-# under the terms of the GNU General Public License as published by the
31-# Free Software Foundation; either version 3, or (at your option) any
32-# later version.
33-#
34-# GCC is distributed in the hope that it will be useful, but WITHOUT
35-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
36-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
37-# License for more details.
38-#
39-# Under Section 7 of GPL version 3, you are granted additional
40-# permissions described in the GCC Runtime Library Exception, version
41-# 3.1, as published by the Free Software Foundation.
42-#
43-# You should have received a copy of the GNU General Public License and
44-# a copy of the GCC Runtime Library Exception along with this program;
45-# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
46-# <http://www.gnu.org/licenses/>.
47-#
48-# modsi3.S
49-#
50-# modulo operation for 64 bit integers.
51-#
52-#######################################
53-
54-
55-/* An executable stack is *not* required for these functions. */
56-#ifdef __linux__
57-.section .note.GNU-stack,"",%progbits
58-.previous
59-#endif
60-
61- .globl __moddi3
62- .ent __moddi3
63-__moddi3:
64- .frame r1,0,r15
65-
66-#Change the stack pointer value and Save callee saved regs
67- addik r1,r1,-24
68- swi r25,r1,0
69- swi r26,r1,4
70- swi r27,r1,8 # used for sign
71- swi r28,r1,12 # used for loop count
72- swi r29,r1,16 # Used for div value High
73- swi r30,r1,20 # Used for div value Low
74-
75-#Check for Zero Value in the divisor/dividend
76- OR r9,r5,r6 # Check for the op1 being zero
77- BEQID r9,$LaResult_Is_Zero # Result is zero
78- OR r9,r7,r8 # Check for the dividend being zero
79- BEQI r9,$LaDiv_By_Zero # Div_by_Zero # Division Error
80- BGEId r5,$La1_Pos
81- XOR r27,r5,r7 # Get the sign of the result
82- RSUBI r6,r6,0 # Make dividend positive
83- RSUBIC r5,r5,0 # Make dividend positive
84-$La1_Pos:
85- BGEI r7,$La2_Pos
86- RSUBI r8,r8,0 # Make Divisor Positive
87- RSUBIC r9,r9,0 # Make Divisor Positive
88-$La2_Pos:
89- ADDIK r4,r0,0 # Clear mod low
90- ADDIK r3,r0,0 # Clear mod high
91- ADDIK r29,r0,0 # clear div high
92- ADDIK r30,r0,0 # clear div low
93- ADDIK r28,r0,64 # Initialize the loop count
94- # First part try to find the first '1' in the r5/r6
95-$LaDIV1:
96- ADD r6,r6,r6
97- ADDC r5,r5,r5 # left shift logical r5
98- BGEID r5,$LaDIV1
99- ADDIK r28,r28,-1
100-$LaDIV2:
101- ADD r6,r6,r6
102- ADDC r5,r5,r5 # left shift logical r5/r6 get the '1' into the Carry
103- ADDC r4,r4,r4 # Move that bit into the Mod register
104- ADDC r3,r3,r3 # Move carry into high mod register
105- rsub r18,r7,r3 # Compare the High Parts of Mod and Divisor
106- bnei r18,$L_High_EQ
107- rsub r18,r6,r4 # Compare Low Parts only if Mod[h] == Divisor[h]
108-$L_High_EQ:
109- rSUB r26,r8,r4 # Subtract divisor[L] from Mod[L]
110- rsubc r25,r7,r3 # Subtract divisor[H] from Mod[H]
111- BLTi r25,$LaMOD_TOO_SMALL
112- OR r3,r0,r25 # move r25 to mod [h]
113- OR r4,r0,r26 # move r26 to mod [l]
114- ADDI r30,r30,1
115- ADDC r29,r29,r0
116-$LaMOD_TOO_SMALL:
117- ADDIK r28,r28,-1
118- BEQi r28,$LaLOOP_END
119- ADD r30,r30,r30 # Shift in the '1' into div [low]
120- ADDC r29,r29,r29 # Move the carry generated into high
121- BRI $LaDIV2 # Div2
122-$LaLOOP_END:
123- BGEI r27,$LaRETURN_HERE
124- rsubi r30,r30,0
125- rsubc r29,r29,r0
126- BRI $LaRETURN_HERE
127-$LaDiv_By_Zero:
128-$LaResult_Is_Zero:
129- or r29,r0,r0 # set result to 0 [High]
130- or r30,r0,r0 # set result to 0 [Low]
131-$LaRETURN_HERE:
132-# Restore values of CSRs and that of r29 and the divisor and the dividend
133-
134- lwi r25,r1,0
135- lwi r26,r1,4
136- lwi r27,r1,8
137- lwi r28,r1,12
138- lwi r29,r1,16
139- lwi r30,r1,20
140- rtsd r15,8
141- addik r1,r1,24
142- .end __moddi3
143-
144diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
145index 96959f0..8d954a4 100644
146--- a/libgcc/config/microblaze/t-microblaze
147+++ b/libgcc/config/microblaze/t-microblaze
148@@ -1,8 +1,7 @@
149-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _moddi3 _mulsi3 _udivsi3 _umodsi3
150+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
151
152 LIB2ADD += \
153 $(srcdir)/config/microblaze/divsi3.S \
154- $(srcdir)/config/microblaze/moddi3.S \
155 $(srcdir)/config/microblaze/modsi3.S \
156 $(srcdir)/config/microblaze/muldi3_hard.S \
157 $(srcdir)/config/microblaze/mulsi3.S \
158--
1592.7.4
160
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0017-Patch-microblaze-Add-INIT_PRIORITY-support.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0017-Patch-microblaze-Add-INIT_PRIORITY-support.patch
new file mode 100644
index 00000000..ca1c2d1c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0017-Patch-microblaze-Add-INIT_PRIORITY-support.patch
@@ -0,0 +1,101 @@
1From 032e50c1b267306338cff4d136db88f08350de72 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 14:41:58 +0530
4Subject: [PATCH 17/63] [Patch, microblaze]: Add INIT_PRIORITY support Added
5 TARGET_ASM_CONSTRUCTOR and TARGET_ASM_DESTRUCTOR macros.
6
7These macros allows users to control the order of initialization
8of objects defined at namespace scope with the init_priority
9attribute by specifying a relative priority, a constant integral
10expression currently bounded between 101 and 65535 inclusive.
11
12Lower numbers indicate a higher priority.
13
14Changelog
15
162013-11-26 Nagaraju Mekala <nagaraju.mekala@xilinx.com>
17
18 * gcc/config/microblaze/microblaze.c: Add microblaze_asm_constructor,
19 microblaze_asm_destructor. Define TARGET_ASM_CONSTRUCTOR and
20 TARGET_ASM_DESTRUCTOR.
21
22Signed-off-by:nagaraju <nmekala@xilix.com>
23Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
24---
25 gcc/config/microblaze/microblaze.c | 53 ++++++++++++++++++++++++++++++++++++++
26 1 file changed, 53 insertions(+)
27
28diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
29index c834b49..c54b96b 100644
30--- a/gcc/config/microblaze/microblaze.c
31+++ b/gcc/config/microblaze/microblaze.c
32@@ -2642,6 +2642,53 @@ print_operand_address (FILE * file, rtx addr)
33 }
34 }
35
36+/* Output an element in the table of global constructors. */
37+void
38+microblaze_asm_constructor (rtx symbol ATTRIBUTE_UNUSED, int priority)
39+{
40+ const char *section = ".ctors";
41+ char buf[16];
42+
43+ if (priority != DEFAULT_INIT_PRIORITY)
44+ {
45+ sprintf (buf, ".ctors.%.5u",
46+ /* Invert the numbering so the linker puts us in the proper
47+ order; constructors are run from right to left, and the
48+ linker sorts in increasing order. */
49+ MAX_INIT_PRIORITY - priority);
50+ section = buf;
51+ }
52+
53+ switch_to_section (get_section (section, 0, NULL));
54+ assemble_align (POINTER_SIZE);
55+ fputs ("\t.word\t", asm_out_file);
56+ output_addr_const (asm_out_file, symbol);
57+ fputs ("\n", asm_out_file);
58+}
59+
60+/* Output an element in the table of global destructors. */
61+void
62+microblaze_asm_destructor (rtx symbol, int priority)
63+{
64+ const char *section = ".dtors";
65+ char buf[16];
66+ if (priority != DEFAULT_INIT_PRIORITY)
67+ {
68+ sprintf (buf, ".dtors.%.5u",
69+ /* Invert the numbering so the linker puts us in the proper
70+ order; constructors are run from right to left, and the
71+ linker sorts in increasing order. */
72+ MAX_INIT_PRIORITY - priority);
73+ section = buf;
74+ }
75+
76+ switch_to_section (get_section (section, 0, NULL));
77+ assemble_align (POINTER_SIZE);
78+ fputs ("\t.word\t", asm_out_file);
79+ output_addr_const (asm_out_file, symbol);
80+ fputs ("\n", asm_out_file);
81+}
82+
83 /* Emit either a label, .comm, or .lcomm directive, and mark that the symbol
84 is used, so that we don't emit an .extern for it in
85 microblaze_asm_file_end. */
86@@ -3981,6 +4028,12 @@ microblaze_starting_frame_offset (void)
87 #undef TARGET_ATTRIBUTE_TABLE
88 #define TARGET_ATTRIBUTE_TABLE microblaze_attribute_table
89
90+#undef TARGET_ASM_CONSTRUCTOR
91+#define TARGET_ASM_CONSTRUCTOR microblaze_asm_constructor
92+
93+#undef TARGET_ASM_DESTRUCTOR
94+#define TARGET_ASM_DESTRUCTOR microblaze_asm_destructor
95+
96 #undef TARGET_IN_SMALL_DATA_P
97 #define TARGET_IN_SMALL_DATA_P microblaze_elf_in_small_data_p
98
99--
1002.7.4
101
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0018-Patch-microblaze-Add-optimized-lshrsi3.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0018-Patch-microblaze-Add-optimized-lshrsi3.patch
new file mode 100644
index 00000000..de35f286
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0018-Patch-microblaze-Add-optimized-lshrsi3.patch
@@ -0,0 +1,81 @@
1From 6db9d068e32a424ac04c27e963d1e58cb3ef8bdf Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 15:23:57 +0530
4Subject: [PATCH 18/63] [Patch, microblaze]: Add optimized lshrsi3 When barrel
5 shifter is not present, the immediate value is greater than #5 and
6 optimization is -OS, the compiler will generate shift operation using loop.
7
8Changelog
9
102013-11-26 David Holsgrove <david.holsgrove@xilinx.com>
11
12 * gcc/config/microblaze/microblaze.md: Add size optimized lshrsi3 insn
13
14ChangeLog/testsuite
15
162014-02-12 David Holsgrove <david.holsgrove@xilinx.com>
17
18 * gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c: New test.
19
20Signed-off-by:Nagaraju <nmekala@xilix.com>
21Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
22---
23 gcc/config/microblaze/microblaze.md | 21 +++++++++++++++++++++
24 .../gcc.target/microblaze/others/lshrsi_Os_1.c | 13 +++++++++++++
25 2 files changed, 34 insertions(+)
26 create mode 100644 gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c
27
28diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
29index 3d2636e..aa2eda3 100644
30--- a/gcc/config/microblaze/microblaze.md
31+++ b/gcc/config/microblaze/microblaze.md
32@@ -1618,6 +1618,27 @@
33 (set_attr "length" "4,4")]
34 )
35
36+(define_insn "*lshrsi3_with_size_opt"
37+ [(set (match_operand:SI 0 "register_operand" "=&d")
38+ (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
39+ (match_operand:SI 2 "immediate_operand" "I")))]
40+ "(INTVAL (operands[2]) > 5 && optimize_size)"
41+ {
42+ operands[3] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
43+
44+ output_asm_insn ("ori\t%3,r0,%2", operands);
45+ if (REGNO (operands[0]) != REGNO (operands[1]))
46+ output_asm_insn ("addk\t%0,%1,r0", operands);
47+
48+ output_asm_insn ("addik\t%3,%3,-1", operands);
49+ output_asm_insn ("bneid\t%3,.-4", operands);
50+ return "srl\t%0,%0";
51+ }
52+ [(set_attr "type" "multi")
53+ (set_attr "mode" "SI")
54+ (set_attr "length" "20")]
55+)
56+
57 (define_insn "*lshrsi_inline"
58 [(set (match_operand:SI 0 "register_operand" "=&d")
59 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
60diff --git a/gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c b/gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c
61new file mode 100644
62index 0000000..32a3be7
63--- /dev/null
64+++ b/gcc/testsuite/gcc.target/microblaze/others/lshrsi_Os_1.c
65@@ -0,0 +1,13 @@
66+/* { dg-options "-Os -mno-xl-barrel-shift" } */
67+
68+void testfunc(void)
69+{
70+ unsigned volatile int z = 8192;
71+ z >>= 8;
72+}
73+/* { dg-final { scan-assembler-not "\bsrli" } } */
74+/* { dg-final { scan-assembler "\ori\tr18,r0" } } */
75+/* { dg-final { scan-assembler "addk\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0" } } */
76+/* { dg-final { scan-assembler "addik\tr18,r18,-1" } } */
77+/* { dg-final { scan-assembler "bneid\tr18,.-4" } } */
78+/* { dg-final { scan-assembler "\srl\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])" } } */
79--
802.7.4
81
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0019-Patch-microblaze-Modified-trap-instruction.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0019-Patch-microblaze-Modified-trap-instruction.patch
new file mode 100644
index 00000000..dc9b61cf
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0019-Patch-microblaze-Modified-trap-instruction.patch
@@ -0,0 +1,29 @@
1From 614bacc058b94c7b12cd40fde1b19b4709870f3b Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 15:42:15 +0530
4Subject: [PATCH 19/63] [Patch, microblaze]: Modified trap instruction The
5 instruction was wrongly written to brki r0,-1 it should be bri r0. Modified
6 with the correct instruction
7
8Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
9 :Ajit Agarwal <ajitkum@xilinx.com>
10---
11 gcc/config/microblaze/microblaze.md | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
15index aa2eda3..3c80760 100644
16--- a/gcc/config/microblaze/microblaze.md
17+++ b/gcc/config/microblaze/microblaze.md
18@@ -2348,7 +2348,7 @@
19 (define_insn "trap"
20 [(trap_if (const_int 1) (const_int 0))]
21 ""
22- "brki\tr0,-1"
23+ "bri\t0"
24 [(set_attr "type" "trap")]
25 )
26
27--
282.7.4
29
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0020-Patch-microblaze-Reducing-Stack-space-for-arguments.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0020-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
new file mode 100644
index 00000000..b60a4e95
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0020-Patch-microblaze-Reducing-Stack-space-for-arguments.patch
@@ -0,0 +1,206 @@
1From 372bbc75146166df9b82ca5e8f236971b7cef16e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 16:42:44 +0530
4Subject: [PATCH 20/63] [Patch, microblaze]: Reducing Stack space for arguments
5 Currently in Microblaze target stack space for arguments in register is being
6 allocated even if there are no arguments in the function. This patch will
7 optimize the extra 24 bytes that are being allocated.
8
9Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
10 :Ajit Agarwal <ajitkum@xilinx.com>
11
12ChangeLog:
132015-04-17 Nagaraju Mekala <nmekala@xilix.com>
14 Ajit Agarwal <ajitkum@xilinx.com>
15
16 *microblaze.c (microblaze_parm_needs_stack, microblaze_function_parms_need_stack): New
17 *microblaze.c (REG_PARM_STACK_SPACE): Modify
18---
19 gcc/config/microblaze/microblaze-protos.h | 1 +
20 gcc/config/microblaze/microblaze.c | 134 +++++++++++++++++++++++++++++-
21 gcc/config/microblaze/microblaze.h | 4 +-
22 3 files changed, 136 insertions(+), 3 deletions(-)
23
24diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h
25index 1f5ca80..6647cbc 100644
26--- a/gcc/config/microblaze/microblaze-protos.h
27+++ b/gcc/config/microblaze/microblaze-protos.h
28@@ -59,6 +59,7 @@ extern int symbol_mentioned_p (rtx);
29 extern int label_mentioned_p (rtx);
30 extern bool microblaze_cannot_force_const_mem (machine_mode, rtx);
31 extern void microblaze_eh_return (rtx op0);
32+int microblaze_reg_parm_stack_space(tree fun);
33 #endif /* RTX_CODE */
34
35 /* Declare functions in microblaze-c.c. */
36diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
37index c54b96b..0ce9d13 100644
38--- a/gcc/config/microblaze/microblaze.c
39+++ b/gcc/config/microblaze/microblaze.c
40@@ -2065,6 +2065,138 @@ microblaze_must_save_register (int regno)
41 return 0;
42 }
43
44+static bool
45+microblaze_parm_needs_stack (cumulative_args_t args_so_far, tree type)
46+{
47+ enum machine_mode mode;
48+ int unsignedp;
49+ rtx entry_parm;
50+
51+ /* Catch errors. */
52+ if (type == NULL || type == error_mark_node)
53+ return true;
54+
55+ if (TREE_CODE (type) == POINTER_TYPE)
56+ return true;
57+
58+ /* Handle types with no storage requirement. */
59+ if (TYPE_MODE (type) == VOIDmode)
60+ return false;
61+
62+ /* Handle complex types. */
63+ if (TREE_CODE (type) == COMPLEX_TYPE)
64+ return (microblaze_parm_needs_stack (args_so_far, TREE_TYPE (type))
65+ || microblaze_parm_needs_stack (args_so_far, TREE_TYPE (type)));
66+
67+ /* Handle transparent aggregates. */
68+ if ((TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == RECORD_TYPE)
69+ && TYPE_TRANSPARENT_AGGR (type))
70+ type = TREE_TYPE (first_field (type));
71+
72+ /* See if this arg was passed by invisible reference. */
73+ if (pass_by_reference (get_cumulative_args (args_so_far),
74+ TYPE_MODE (type), type, true))
75+ type = build_pointer_type (type);
76+
77+ /* Find mode as it is passed by the ABI. */
78+ unsignedp = TYPE_UNSIGNED (type);
79+ mode = promote_mode (type, TYPE_MODE (type), &unsignedp);
80+
81+/* If there is no incoming register, we need a stack. */
82+ entry_parm = microblaze_function_arg (args_so_far, mode, type, true);
83+ if (entry_parm == NULL)
84+ return true;
85+
86+ /* Likewise if we need to pass both in registers and on the stack. */
87+ if (GET_CODE (entry_parm) == PARALLEL
88+ && XEXP (XVECEXP (entry_parm, 0, 0), 0) == NULL_RTX)
89+ return true;
90+
91+ /* Also true if we're partially in registers and partially not. */
92+ if (function_arg_partial_bytes (args_so_far, mode, type, true) != 0)
93+ return true;
94+
95+ /* Update info on where next arg arrives in registers. */
96+ microblaze_function_arg_advance (args_so_far, mode, type, true);
97+ return false;
98+ }
99+
100+static bool
101+microblaze_function_parms_need_stack (tree fun, bool incoming)
102+{
103+ tree fntype, result;
104+ CUMULATIVE_ARGS args_so_far_v;
105+ cumulative_args_t args_so_far;
106+ int num_of_args = 0;
107+
108+ /* Must be a libcall, all of which only use reg parms. */
109+ if (!fun)
110+ return true;
111+
112+ fntype = fun;
113+ if (!TYPE_P (fun))
114+ fntype = TREE_TYPE (fun);
115+
116+ /* Varargs functions need the parameter save area. */
117+ if ((!incoming && !prototype_p (fntype)) || stdarg_p (fntype))
118+ return true;
119+
120+ INIT_CUMULATIVE_ARGS(args_so_far_v, fntype, NULL_RTX,0,0);
121+ args_so_far = pack_cumulative_args (&args_so_far_v);
122+
123+ /* When incoming, we will have been passed the function decl.
124+ * It is necessary to use the decl to handle K&R style functions,
125+ * where TYPE_ARG_TYPES may not be available. */
126+ if (incoming)
127+ {
128+ gcc_assert (DECL_P (fun));
129+ result = DECL_RESULT (fun);
130+ }
131+ else
132+ result = TREE_TYPE (fntype);
133+
134+ if (result && aggregate_value_p (result, fntype))
135+ {
136+ if (!TYPE_P (result))
137+ result = build_pointer_type (result);
138+ microblaze_parm_needs_stack (args_so_far, result);
139+ }
140+
141+ if (incoming)
142+ {
143+ tree parm;
144+ for (parm = DECL_ARGUMENTS (fun);
145+ parm && parm != void_list_node;
146+ parm = TREE_CHAIN (parm))
147+ if (microblaze_parm_needs_stack (args_so_far, TREE_TYPE (parm)))
148+ return true;
149+ }
150+ else
151+ {
152+ function_args_iterator args_iter;
153+ tree arg_type;
154+
155+ FOREACH_FUNCTION_ARGS (fntype, arg_type, args_iter)
156+ {
157+ num_of_args++;
158+ if (microblaze_parm_needs_stack (args_so_far, arg_type))
159+ return true;
160+ }
161+ }
162+
163+ if (num_of_args > 3) return true;
164+
165+ return false;
166+}
167+
168+int microblaze_reg_parm_stack_space(tree fun)
169+{
170+ if (microblaze_function_parms_need_stack (fun,false))
171+ return MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD;
172+ else
173+ return 0;
174+}
175+
176 /* Return the bytes needed to compute the frame pointer from the current
177 stack pointer.
178
179@@ -3411,7 +3543,7 @@ microblaze_asm_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
180 emit_insn (gen_indirect_jump (temp2));
181
182 /* Run just enough of rest_of_compilation. This sequence was
183- "borrowed" from rs6000.c. */
184+ "borrowed" from microblaze.c. */
185 insn = get_insns ();
186 shorten_branches (insn);
187 final_start_function (insn, file, 1);
188diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
189index 0a435b8..346e47b 100644
190--- a/gcc/config/microblaze/microblaze.h
191+++ b/gcc/config/microblaze/microblaze.h
192@@ -434,9 +434,9 @@ extern struct microblaze_frame_info current_frame_info;
193
194 #define ARG_POINTER_CFA_OFFSET(FNDECL) 0
195
196-#define REG_PARM_STACK_SPACE(FNDECL) (MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD)
197+#define REG_PARM_STACK_SPACE(FNDECL) microblaze_reg_parm_stack_space(FNDECL)
198
199-#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
200+#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
201
202 #define STACK_BOUNDARY 32
203
204--
2052.7.4
206
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0021-Patch-microblaze-Add-cbranchsi4_reg.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0021-Patch-microblaze-Add-cbranchsi4_reg.patch
new file mode 100644
index 00000000..c79f9552
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0021-Patch-microblaze-Add-cbranchsi4_reg.patch
@@ -0,0 +1,159 @@
1From 1c226901aec38e2e824177418dcd82b6cd49ffca Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 17:04:37 +0530
4Subject: [PATCH 21/63] [Patch, microblaze]: Add cbranchsi4_reg This patch
5 optimizes the generation of pcmpne/pcmpeq instruction if the compare
6 instruction has no immediate values.For the immediate values the xor
7 instruction is generated
8
9Signed-off-by: Nagaraju Mekala <nmekala@xilix.com>
10Signed-off-by: Ajit Agarwal <ajitkum@xilinx.com>
11
12ChangeLog:
132015-01-13 Nagaraju Mekala <nmekala@xilix.com>
14 Ajit Agarwal <ajitkum@xilinx.com>
15
16 *microblaze.md (cbranchsi4_reg): New
17 *microblaze.c (microblaze_expand_conditional_branch_reg): New
18
19Conflicts:
20
21 gcc/config/microblaze/microblaze-protos.h
22---
23 gcc/config/microblaze/microblaze-protos.h | 2 +-
24 gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c | 2 +-
25 gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c | 2 +-
26 gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c | 2 +-
27 gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c | 2 +-
28 gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c | 14 +++++++-------
29 gcc/testsuite/gcc.target/microblaze/isa/vanilla.c | 12 ++++++------
30 gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c | 2 +-
31 8 files changed, 19 insertions(+), 19 deletions(-)
32
33diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h
34index 6647cbc..bdc9b69 100644
35--- a/gcc/config/microblaze/microblaze-protos.h
36+++ b/gcc/config/microblaze/microblaze-protos.h
37@@ -33,7 +33,7 @@ extern int microblaze_expand_shift (rtx *);
38 extern bool microblaze_expand_move (machine_mode, rtx *);
39 extern bool microblaze_expand_block_move (rtx, rtx, rtx, rtx);
40 extern void microblaze_expand_divide (rtx *);
41-extern void microblaze_expand_conditional_branch (machine_mode, rtx *);
42+extern void microblaze_expand_conditional_branch (enum machine_mode, rtx *);
43 extern void microblaze_expand_conditional_branch_reg (machine_mode, rtx *);
44 extern void microblaze_expand_conditional_branch_sf (rtx *);
45 extern int microblaze_can_use_return_insn (void);
46diff --git a/gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c b/gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c
47index 4041a24..ccc6a46 100644
48--- a/gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c
49+++ b/gcc/testsuite/gcc.target/microblaze/isa/fcmp1.c
50@@ -6,5 +6,5 @@ void float_func ()
51 {
52 /* { dg-final { scan-assembler "fcmp\.(le|gt)\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
53 if (f2 <= f3)
54- print ("le");
55+ f2 = f3;
56 }
57diff --git a/gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c b/gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c
58index 3902b83..1dd5fe6 100644
59--- a/gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c
60+++ b/gcc/testsuite/gcc.target/microblaze/isa/fcmp2.c
61@@ -6,5 +6,5 @@ void float_func ()
62 {
63 /* { dg-final { scan-assembler "fcmp\.(lt|ge)\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
64 if (f2 < f3)
65- print ("lt");
66+ f2 = f3;
67 }
68diff --git a/gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c b/gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c
69index 8555974..d6f80fb 100644
70--- a/gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c
71+++ b/gcc/testsuite/gcc.target/microblaze/isa/fcmp3.c
72@@ -6,5 +6,5 @@ void float_func ()
73 {
74 /* { dg-final { scan-assembler "fcmp\.(eq|ne)\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
75 if (f2 == f3)
76- print ("eq");
77+ f1 = f2 + f3;
78 }
79diff --git a/gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c b/gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c
80index 79cc5f9..d117724 100644
81--- a/gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c
82+++ b/gcc/testsuite/gcc.target/microblaze/isa/fcmp4.c
83@@ -5,5 +5,5 @@ void float_func(float f1, float f2, float f3)
84 /* { dg-final { scan-assembler "fcmp\.eq\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
85 /* { dg-final { scan-assembler "fcmp\.le\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r(\[0-9]\|\[1-2]\[0-9]\|3\[0-1])\[^0-9]" } } */
86 if(f1==f2 && f1<=f3)
87- print ("f1 eq f2 && f1 le f3");
88+ f2 = f3;
89 }
90diff --git a/gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c b/gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c
91index ebfb170..7582297 100644
92--- a/gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c
93+++ b/gcc/testsuite/gcc.target/microblaze/isa/nofcmp.c
94@@ -5,17 +5,17 @@ volatile float f1, f2, f3;
95 void float_func ()
96 {
97 /* { dg-final { scan-assembler-not "fcmp" } } */
98- if (f2 <= f3)
99- print ("le");
100+ if (f2 <= f3)
101+ f1 = f3;
102 else if (f2 == f3)
103- print ("eq");
104+ f1 = f3;
105 else if (f2 < f3)
106- print ("lt");
107+ f1 = f3;
108 else if (f2 > f3)
109- print ("gt");
110+ f1 = f3;
111 else if (f2 >= f3)
112- print ("ge");
113+ f1 = f3;
114 else if (f2 != f3)
115- print ("ne");
116+ f1 = f3;
117
118 }
119diff --git a/gcc/testsuite/gcc.target/microblaze/isa/vanilla.c b/gcc/testsuite/gcc.target/microblaze/isa/vanilla.c
120index 1d6ba80..532c035 100644
121--- a/gcc/testsuite/gcc.target/microblaze/isa/vanilla.c
122+++ b/gcc/testsuite/gcc.target/microblaze/isa/vanilla.c
123@@ -74,16 +74,16 @@ void float_cmp_func ()
124 {
125 /* { dg-final { scan-assembler-not "fcmp" } } */
126 if (f2 <= f3)
127- print ("le");
128+ f1 = f3;
129 else if (f2 == f3)
130- print ("eq");
131+ f1 = f3;
132 else if (f2 < f3)
133- print ("lt");
134+ f1 = f3;
135 else if (f2 > f3)
136- print ("gt");
137+ f1 = f3;
138 else if (f2 >= f3)
139- print ("ge");
140+ f1 = f3;
141 else if (f2 != f3)
142- print ("ne");
143+ f1 = f3;
144
145 }
146diff --git a/gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c b/gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c
147index fdcde1f..580b4db 100644
148--- a/gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c
149+++ b/gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c
150@@ -5,4 +5,4 @@ void trap ()
151 __builtin_trap ();
152 }
153
154-/* { dg-final { scan-assembler "brki\tr0,-1" } } */
155\ No newline at end of file
156+/* { dg-final { scan-assembler "bri\t0" } } */
157--
1582.7.4
159
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0022-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0022-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch
new file mode 100644
index 00000000..c3822d06
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0022-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch
@@ -0,0 +1,58 @@
1From 791d65feae4f3cab47833579bc6f523e54194cbd Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 17:11:04 +0530
4Subject: [PATCH 22/63] [Patch,microblaze]: Inline Expansion of fsqrt builtin.
5 The changes are made in the patch for the inline expansion of the fsqrt
6 builtin with fqrt instruction. The sqrt math function takes double as
7 argument and return double as argument. The pattern is selected while
8 expanding the unary op through expand_unop which passes DFmode and the DFmode
9 pattern was not there returning zero. Thus the sqrt math function is not
10 inlined and expanded. The pattern with DFmode argument is added. Also the
11 source and destination argument is not same the DF through two different
12 consecutive registers with lower 32 bit is the argument passed to sqrt and
13 the higher 32 bit is zero. If the source and destinations are different the
14 DFmode 64 bits registers is not set properly giving the problem in runtime.
15 Such changes are taken care in the implementation of the pattern for DFmode
16 for inline expansion of the sqrt.
17
18ChangeLog:
192015-06-16 Ajit Agarwal <ajitkum@xilinx.com>
20 Nagaraju Mekala <nmekala@xilinx.com>
21
22 * config/microblaze/microblaze.md (sqrtdf2): New
23 pattern.
24
25Signed-off-by:Ajit Agarwal ajitkum@xilinx.com
26 Nagaraju Mekala nmekala@xilinx.com
27---
28 gcc/config/microblaze/microblaze.md | 14 ++++++++++++++
29 1 file changed, 14 insertions(+)
30
31diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
32index 3c80760..1fb5582 100644
33--- a/gcc/config/microblaze/microblaze.md
34+++ b/gcc/config/microblaze/microblaze.md
35@@ -451,6 +451,20 @@
36 (set_attr "mode" "SF")
37 (set_attr "length" "4")])
38
39+(define_insn "sqrtdf2"
40+ [(set (match_operand:DF 0 "register_operand" "=d")
41+ (sqrt:DF (match_operand:DF 1 "register_operand" "dG")))]
42+ "TARGET_HARD_FLOAT && TARGET_FLOAT_SQRT"
43+ {
44+ if (REGNO (operands[0]) == REGNO (operands[1]))
45+ return "fsqrt\t%0,%1";
46+ else
47+ return "fsqrt\t%0,%1\n\taddk\t%D0,%D1,r0";
48+ }
49+ [(set_attr "type" "fsqrt")
50+ (set_attr "mode" "SF")
51+ (set_attr "length" "4")])
52+
53 (define_insn "fix_truncsfsi2"
54 [(set (match_operand:SI 0 "register_operand" "=d")
55 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
56--
572.7.4
58
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0023-Patch-OPT-Update-heuristics-for-loop-invariant-for-a.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0023-Patch-OPT-Update-heuristics-for-loop-invariant-for-a.patch
new file mode 100644
index 00000000..a314170f
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0023-Patch-OPT-Update-heuristics-for-loop-invariant-for-a.patch
@@ -0,0 +1,47 @@
1From 2c4a1d46e4f1b2342f899d6741d09dbf7cc87aa2 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 17:33:31 +0530
4Subject: [PATCH 23/63] [Patch] OPT: Update heuristics for loop-invariant for
5 address arithme. .tic.
6
7The changes are made in the patch to update the heuristics
8for loop invariant for address arithmetic. The heuristics is
9changed to calculate the estimated register pressure cost when
10ira based register pressure is not enabled. The estimated
11register pressure cost modifies the existing calculation cost
12associated to perform the Loop invariant code motion for address
13arithmetic.
14
15ChangeLog:
162015-06-17 Ajit Agarwal <ajitkum@xilinx.com>
17 Nagaraju Mekala <nmekala@xilinx.com>
18
19 * loop-invariant.c (gain_for_invariant): update the
20 heuristics for estimate_reg_pressure_cost.
21
22Signed-off-by:Ajit Agarwal ajitkum@xilinx.com
23 Nagaraju Mekala nmekala@xilinx.com
24---
25 gcc/loop-invariant.c | 6 ++----
26 1 file changed, 2 insertions(+), 4 deletions(-)
27
28diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
29index b880ead..fd7a019 100644
30--- a/gcc/loop-invariant.c
31+++ b/gcc/loop-invariant.c
32@@ -1465,10 +1465,8 @@ gain_for_invariant (struct invariant *inv, unsigned *regs_needed,
33
34 if (! flag_ira_loop_pressure)
35 {
36- size_cost = (estimate_reg_pressure_cost (new_regs[0] + regs_needed[0],
37- regs_used, speed, call_p)
38- - estimate_reg_pressure_cost (new_regs[0],
39- regs_used, speed, call_p));
40+ size_cost = estimate_reg_pressure_cost (regs_needed[0],
41+ regs_used, speed, call_p);
42 }
43 else if (ret < 0)
44 return -1;
45--
462.7.4
47
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0024-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0024-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch
new file mode 100644
index 00000000..a786ba09
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0024-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch
@@ -0,0 +1,63 @@
1From c2b64f2f7a06231d8da0a53c6761939583ac56da Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 18:07:24 +0530
4Subject: [PATCH 24/63] [PATCH] microblaze.md: Improve 'adddi3' and 'subdi3'
5 insn definitions Change adddi3 to handle DI immediates as the second operand,
6 this requires modification to the output template however reduces the need to
7 specify seperate templates for 16-bit positive/negative immediate operands.
8 The use of 32-bit immediates for the addi and addic instructions is handled
9 by the assembler, which will emit the imm instructions when required. This
10 conveniently handles the optimizable cases where the immediate constant value
11 does not need the higher half words of the operands upper/lower words.
12
13Change the constraints of the subdi3 instruction definition such that it
14does not match the second operand as an immediate value. This is because
15there is no definition to handle this case nor is it possible to
16implement purely with instructions as microblaze does not provide an
17instruction to perform a forward arithmetic subtraction (it only
18provides reverse 'rD = IMM - rA').
19
20Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
21---
22 gcc/config/microblaze/microblaze.md | 13 ++++++-------
23 1 file changed, 6 insertions(+), 7 deletions(-)
24
25diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
26index 1fb5582..216219b 100644
27--- a/gcc/config/microblaze/microblaze.md
28+++ b/gcc/config/microblaze/microblaze.md
29@@ -502,17 +502,16 @@
30 ;; Adding 2 DI operands in register or reg/imm
31
32 (define_insn "adddi3"
33- [(set (match_operand:DI 0 "register_operand" "=d,d,d")
34- (plus:DI (match_operand:DI 1 "register_operand" "%d,d,d")
35- (match_operand:DI 2 "arith_operand32" "d,P,N")))]
36+ [(set (match_operand:DI 0 "register_operand" "=d,d")
37+ (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
38+ (match_operand:DI 2 "arith_operand" "d,i")))]
39 ""
40 "@
41 add\t%L0,%L1,%L2\;addc\t%M0,%M1,%M2
42- addi\t%L0,%L1,%2\;addc\t%M0,%M1,r0
43- addi\t%L0,%L1,%2\;addc\t%M0,%M1,r0\;addi\t%M0,%M0,-1"
44+ addi\t%L0,%L1,%j2\;addic\t%M0,%M1,%h2"
45 [(set_attr "type" "darith")
46 (set_attr "mode" "DI")
47- (set_attr "length" "8,8,12")])
48+ (set_attr "length" "8,8")])
49
50 ;;----------------------------------------------------------------
51 ;; Subtraction
52@@ -549,7 +548,7 @@
53 (define_insn "subdi3"
54 [(set (match_operand:DI 0 "register_operand" "=&d")
55 (minus:DI (match_operand:DI 1 "register_operand" "d")
56- (match_operand:DI 2 "arith_operand32" "d")))]
57+ (match_operand:DI 2 "register_operand" "d")))]
58 ""
59 "rsub\t%L0,%L2,%L1\;rsubc\t%M0,%M2,%M1"
60 [(set_attr "type" "darith")
61--
622.7.4
63
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0025-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0025-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch
new file mode 100644
index 00000000..98310b36
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0025-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch
@@ -0,0 +1,72 @@
1From c7e5c253b1e7800bc5ec8cc69850118ed938e22f Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 18:18:41 +0530
4Subject: [PATCH 25/63] [Patch, microblaze]: Update ashlsi3 & movsf patterns
5 This patch removes the use of HOST_WIDE_INT_PRINT_HEX macro in print_operand
6 of ashlsi3_with_mul_nodelay,ashlsi3_with_mul_delay and movsf_internal
7 patterns beacuse HOST_WIDE_INT_PRINT_HEX is generating 64-bit value which our
8 instruction doesn't support so using gen_int_mode function
9
10Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11 :Ajit Agarwal <ajitkum@xilinx.com>
12
13ChangeLog:
142016-01-07 Nagaraju Mekala <nmekala@xilix.com>
15 Ajit Agarwal <ajitkum@xilinx.com>
16
17 *microblaze.md (ashlsi3_with_mul_nodelay,
18 ashlsi3_with_mul_delay,
19 movsf_internal):
20 Updated the patterns to use gen_int_mode function
21 *microblaze.c (print_operand):
22 updated the 'F' case to use "unsinged int" instead
23 of HOST_WIDE_INT_PRINT_HEX
24---
25 gcc/config/microblaze/microblaze.c | 2 +-
26 gcc/config/microblaze/microblaze.md | 10 ++++++++--
27 2 files changed, 9 insertions(+), 3 deletions(-)
28
29diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
30index 0ce9d13..7669668 100644
31--- a/gcc/config/microblaze/microblaze.c
32+++ b/gcc/config/microblaze/microblaze.c
33@@ -2608,7 +2608,7 @@ print_operand (FILE * file, rtx op, int letter)
34 unsigned long value_long;
35 REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (op),
36 value_long);
37- fprintf (file, HOST_WIDE_INT_PRINT_HEX, value_long);
38+ fprintf (file, "0x%08x", (unsigned int) value_long);
39 }
40 else
41 {
42diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
43index 216219b..4bc209c 100644
44--- a/gcc/config/microblaze/microblaze.md
45+++ b/gcc/config/microblaze/microblaze.md
46@@ -1368,7 +1368,10 @@
47 (match_operand:SI 2 "immediate_operand" "I")))]
48 "!TARGET_SOFT_MUL
49 && ((1 << INTVAL (operands[2])) <= 32767 && (1 << INTVAL (operands[2])) >= -32768)"
50- "muli\t%0,%1,%m2"
51+ {
52+ operands[2] = gen_int_mode (1 << INTVAL (operands[2]), SImode);
53+ return "muli\t%0,%1,%2";
54+ }
55 ;; This MUL will not generate an imm. Can go into a delay slot.
56 [(set_attr "type" "arith")
57 (set_attr "mode" "SI")
58@@ -1380,7 +1383,10 @@
59 (ashift:SI (match_operand:SI 1 "register_operand" "d")
60 (match_operand:SI 2 "immediate_operand" "I")))]
61 "!TARGET_SOFT_MUL"
62- "muli\t%0,%1,%m2"
63+ {
64+ operands[2] = gen_int_mode (1 << INTVAL (operands[2]), SImode);
65+ return "muli\t%0,%1,%2";
66+ }
67 ;; This MUL will generate an IMM. Cannot go into a delay slot
68 [(set_attr "type" "no_delay_arith")
69 (set_attr "mode" "SI")
70--
712.7.4
72
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0026-Patch-microblaze-8-stage-pipeline-for-microblaze.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0026-Patch-microblaze-8-stage-pipeline-for-microblaze.patch
new file mode 100644
index 00000000..ba80ce45
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0026-Patch-microblaze-8-stage-pipeline-for-microblaze.patch
@@ -0,0 +1,193 @@
1From c3b633b0ee8d228a7d70a02b574822aba9a0fd93 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 17 Jan 2017 19:50:34 +0530
4Subject: [PATCH 26/63] [Patch, microblaze]: 8-stage pipeline for microblaze
5 This patch adds the support for the 8-stage pipeline. The new 8-stage
6 pipeline reduces the latencies of float & integer division drastically
7
8Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
9
10ChangeLog:
112016-01-18 Nagaraju Mekala <nmekala@xilix.com>
12
13 *microblaze.md (define_automaton mbpipe_8): New
14
15 *microblaze.c (microblaze_option_override): Update
16 Updated the logic to generate only when MB version is 10.0
17
18 *microblaze.h (pipeline_type): Update
19 Update the enum with MICROBLAZE_PIPE_8
20
21 *microblaze.opt (mxl-frequency): New
22 New flag added for 8-stage pipeline
23---
24 gcc/config/microblaze/microblaze.c | 13 ++++++
25 gcc/config/microblaze/microblaze.h | 3 +-
26 gcc/config/microblaze/microblaze.md | 79 +++++++++++++++++++++++++++++++++++-
27 gcc/config/microblaze/microblaze.opt | 4 ++
28 4 files changed, 96 insertions(+), 3 deletions(-)
29
30diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
31index 7669668..ae7d5dd 100644
32--- a/gcc/config/microblaze/microblaze.c
33+++ b/gcc/config/microblaze/microblaze.c
34@@ -1848,6 +1848,19 @@ microblaze_option_override (void)
35 "%<-mcpu=v8.30.a%>");
36 TARGET_REORDER = 0;
37 }
38+ ver = ver_int - microblaze_version_to_int("v10.0");
39+ if (ver < 0)
40+ {
41+ if (TARGET_AREA_OPTIMIZED_2)
42+ warning (0, "-mxl-frequency can be used only with -mcpu=v10.0 or greater");
43+ }
44+ else
45+ {
46+ if (TARGET_AREA_OPTIMIZED_2)
47+ microblaze_pipe = MICROBLAZE_PIPE_8;
48+ if (TARGET_BARREL_SHIFT)
49+ microblaze_has_bitfield = 1;
50+ }
51
52 if (TARGET_MULTIPLY_HIGH && TARGET_SOFT_MUL)
53 error ("%<-mxl-multiply-high%> requires %<-mno-xl-soft-mul%>");
54diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
55index 346e47b..bf7f3b4 100644
56--- a/gcc/config/microblaze/microblaze.h
57+++ b/gcc/config/microblaze/microblaze.h
58@@ -27,7 +27,8 @@
59 enum pipeline_type
60 {
61 MICROBLAZE_PIPE_3 = 0,
62- MICROBLAZE_PIPE_5 = 1
63+ MICROBLAZE_PIPE_5 = 1,
64+ MICROBLAZE_PIPE_8 = 2
65 };
66
67 #define MICROBLAZE_MASK_NO_UNSAFE_DELAY 0x00000001
68diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
69index 4bc209c..b7c16ac 100644
70--- a/gcc/config/microblaze/microblaze.md
71+++ b/gcc/config/microblaze/microblaze.md
72@@ -35,6 +35,7 @@
73 (R_GOT 20) ;; GOT ptr reg
74 (MB_PIPE_3 0) ;; Microblaze 3-stage pipeline
75 (MB_PIPE_5 1) ;; Microblaze 5-stage pipeline
76+ (MB_PIPE_8 2) ;; Microblaze 8-stage pipeline
77 (UNSPEC_SET_GOT 101) ;;
78 (UNSPEC_GOTOFF 102) ;; GOT offset
79 (UNSPEC_PLT 103) ;; jump table
80@@ -82,7 +83,7 @@
81 ;; bshift Shift operations
82
83 (define_attr "type"
84- "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt,trap"
85+ "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt,fint,trap"
86 (const_string "unknown"))
87
88 ;; Main data type used by the insn
89@@ -224,6 +225,80 @@
90 ;;-----------------------------------------------------------------
91
92
93+
94+;;----------------------------------------------------------------
95+;; Microblaze 8-stage pipeline description (v10.0 and later)
96+;;----------------------------------------------------------------
97+
98+(define_automaton "mbpipe_8")
99+(define_cpu_unit "mb8_issue,mb8_iu,mb8_wb,mb8_fpu,mb8_fpu_2,mb8_mul,mb8_mul_2,mb8_div,mb8_div_2,mb8_bs,mb8_bs_2" "mbpipe_8")
100+
101+(define_insn_reservation "mb8-integer" 1
102+ (and (eq_attr "type" "branch,jump,call,arith,darith,icmp,nop,no_delay_arith")
103+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
104+ "mb8_issue,mb8_iu,mb8_wb")
105+
106+(define_insn_reservation "mb8-special-move" 2
107+ (and (eq_attr "type" "move")
108+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
109+ "mb8_issue,mb8_iu*2,mb8_wb")
110+
111+(define_insn_reservation "mb8-mem-load" 3
112+ (and (eq_attr "type" "load,no_delay_load")
113+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
114+ "mb8_issue,mb8_iu,mb8_wb")
115+
116+(define_insn_reservation "mb8-mem-store" 1
117+ (and (eq_attr "type" "store,no_delay_store")
118+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
119+ "mb8_issue,mb8_iu,mb8_wb")
120+
121+(define_insn_reservation "mb8-mul" 3
122+ (and (eq_attr "type" "imul,no_delay_imul")
123+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
124+ "mb8_issue,mb8_mul,mb8_mul_2*2,mb8_wb")
125+
126+(define_insn_reservation "mb8-div" 30
127+ (and (eq_attr "type" "idiv")
128+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
129+ "mb8_issue,mb8_div,mb8_div_2*29,mb8_wb")
130+
131+(define_insn_reservation "mb8-bs" 2
132+ (and (eq_attr "type" "bshift")
133+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
134+ "mb8_issue,mb8_bs,mb8_bs_2,mb8_wb")
135+
136+(define_insn_reservation "mb8-fpu-add-sub-mul" 1
137+ (and (eq_attr "type" "fadd,frsub,fmul")
138+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
139+ "mb8_issue,mb8_fpu,mb8_wb")
140+
141+(define_insn_reservation "mb8-fpu-fcmp" 3
142+ (and (eq_attr "type" "fcmp")
143+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
144+ "mb8_issue,mb8_fpu,mb8_fpu*2,mb8_wb")
145+
146+(define_insn_reservation "mb8-fpu-div" 24
147+ (and (eq_attr "type" "fdiv")
148+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
149+ "mb8_issue,mb8_fpu,mb8_fpu_2*23,mb8_wb")
150+
151+(define_insn_reservation "mb8-fpu-sqrt" 23
152+ (and (eq_attr "type" "fsqrt")
153+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
154+ "mb8_issue,mb8_fpu,mb8_fpu_2*22,mb8_wb")
155+
156+(define_insn_reservation "mb8-fpu-fcvt" 1
157+ (and (eq_attr "type" "fcvt")
158+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
159+ "mb8_issue,mb8_fpu,mb8_wb")
160+
161+(define_insn_reservation "mb8-fpu-fint" 2
162+ (and (eq_attr "type" "fint")
163+ (eq (symbol_ref "microblaze_pipe") (const_int MB_PIPE_8)))
164+ "mb8_issue,mb8_fpu,mb8_wb")
165+
166+
167 ;;----------------------------------------------------------------
168 ;; Microblaze 5-stage pipeline description (v5.00.a and later)
169 ;;----------------------------------------------------------------
170@@ -470,7 +545,7 @@
171 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
172 "TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
173 "fint\t%0,%1"
174- [(set_attr "type" "fcvt")
175+ [(set_attr "type" "fint")
176 (set_attr "mode" "SF")
177 (set_attr "length" "4")])
178
179diff --git a/gcc/config/microblaze/microblaze.opt b/gcc/config/microblaze/microblaze.opt
180index 2e46941..d23f376 100644
181--- a/gcc/config/microblaze/microblaze.opt
182+++ b/gcc/config/microblaze/microblaze.opt
183@@ -133,3 +133,7 @@ Data referenced by offset from start of text instead of GOT (with -fPIC/-fPIE).
184
185 mxl-mode-xilkernel
186 Target
187+
188+mxl-frequency
189+Target Mask(AREA_OPTIMIZED_2)
190+Use 8 stage pipeline (frequency optimization)
191--
1922.7.4
193
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0027-Patch-rtl-Optimization-Better-register-pressure-esti.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0027-Patch-rtl-Optimization-Better-register-pressure-esti.patch
new file mode 100644
index 00000000..330b5494
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0027-Patch-rtl-Optimization-Better-register-pressure-esti.patch
@@ -0,0 +1,142 @@
1From 650cbdea7bc810e2bd0ebc5eb5647ed513498670 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 11:08:40 +0530
4Subject: [PATCH 27/63] [Patch,rtl Optimization]: Better register pressure
5 estimate for loop . .invariant code motion
6
7Calculate the loop liveness used for regs for calculating the register pressure
8in the cost estimation. Loop liveness is based on the following properties.
9We only need to find the set of objects that are live at the birth or the header
10of the loop. We don't need to calculate the live through the loop by considering
11live in and live out of all the basic blocks of the loop. This is based on the
12point that the set of objects that are live-in at the birth or header of the loop
13will be live-in at every node in the loop.
14
15If a v live is out at the header of the loop then the variable is live-in at every node
16in the loop. To prove this, consider a loop L with header h such that the variable v
17defined at d is live-in at h. Since v is live at h, d is not part of L. This follows i
18from the dominance property, i.e. h is strictly dominated by d. Furthermore, there
19exists a path from h to a use of v which does not go through d. For every node p in
20the loop, since the loop is strongly connected and node is a component of the CFG,
21there exists a path, consisting only of nodes of L from p to h. Concatenating these
22two paths proves that v is live-in and live-out of p.
23
24Calculate the live-out and live-in for the exit edge of the loop. This patch considers
25liveness for not only the loop latch but also the liveness outside the loops.
26
27ChangeLog:
282016-01-22 Ajit Agarwal <ajitkum@xilinx.com>
29
30 * loop-invariant.c
31 (find_invariants_to_move): Add the logic of regs_used based
32 on liveness.
33 * cfgloopanal.c
34 (estimate_reg_pressure_cost): Update the heuristics in presence
35 of call_p.
36
37Signed-off-by:Ajit Agarwal ajitkum@xilinx.com.
38---
39 gcc/cfgloopanal.c | 4 +++-
40 gcc/loop-invariant.c | 63 +++++++++++++++++++++++++++++++++++++++-------------
41 2 files changed, 50 insertions(+), 17 deletions(-)
42
43diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
44index 6dbe96f..ec5cba2 100644
45--- a/gcc/cfgloopanal.c
46+++ b/gcc/cfgloopanal.c
47@@ -411,7 +411,9 @@ estimate_reg_pressure_cost (unsigned n_new, unsigned n_old, bool speed,
48 if (regs_needed + target_res_regs <= available_regs)
49 return 0;
50
51- if (regs_needed <= available_regs)
52+ if ((regs_needed <= available_regs)
53+ || (call_p && (regs_needed <=
54+ (available_regs + target_clobbered_regs))))
55 /* If we are close to running out of registers, try to preserve
56 them. */
57 cost = target_reg_cost [speed] * n_new;
58diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
59index fd7a019..ad54297 100644
60--- a/gcc/loop-invariant.c
61+++ b/gcc/loop-invariant.c
62@@ -1519,7 +1519,7 @@ gain_for_invariant (struct invariant *inv, unsigned *regs_needed,
63 size_cost = 0;
64 }
65
66- return comp_cost - size_cost;
67+ return comp_cost - size_cost + 1;
68 }
69
70 /* Finds invariant with best gain for moving. Returns the gain, stores
71@@ -1613,22 +1613,53 @@ find_invariants_to_move (bool speed, bool call_p)
72 /* REGS_USED is actually never used when the flag is on. */
73 regs_used = 0;
74 else
75- /* We do not really do a good job in estimating number of
76- registers used; we put some initial bound here to stand for
77- induction variables etc. that we do not detect. */
78+ /* The logic used in estimating the number of regs_used is changed.
79+ Now it will be based on liveness of the loop. */
80 {
81- unsigned int n_regs = DF_REG_SIZE (df);
82-
83- regs_used = 2;
84-
85- for (i = 0; i < n_regs; i++)
86- {
87- if (!DF_REGNO_FIRST_DEF (i) && DF_REGNO_LAST_USE (i))
88- {
89- /* This is a value that is used but not changed inside loop. */
90- regs_used++;
91- }
92- }
93+ int i;
94+ edge e;
95+ vec<edge> edges;
96+ bitmap_head regs_live;
97+
98+ bitmap_initialize (&regs_live, &reg_obstack);
99+ edges = get_loop_exit_edges (curr_loop);
100+
101+ /* Loop liveness is based on the following properties.
102+ We only need to find the set of objects that are live at the
103+ birth or the header of the loop.
104+ We don't need to calculate the live through the loop considering
105+ live-in and live-out of all the basic blocks of the loop. This is
106+ based on the point that the set of objects that are live-in at the
107+ birth or header of the loop will be live-in at every block in the
108+ loop.
109+
110+ If a v live out at the header of the loop then the variable is
111+ live-in at every node in the Loop. To prove this, consider a loop
112+ L with header h such that the variable v defined at d is live-in
113+ at h. Since v is live at h, d is not part of L. This follows from
114+ the dominance property, i.e. h is strictly dominated by d. Furthermore,
115+ there exists a path from h to a use of v which does not go through d.
116+ For every node of the loop, p, since the loop is strongly connected
117+ component of the CFG, there exists a path, consisting only of nodes
118+ of L from p to h. Concatenating these two paths prove that v is
119+ live-in and live-out of p. */
120+
121+ bitmap_ior_into (&regs_live, DF_LR_IN (curr_loop->header));
122+ bitmap_ior_into (&regs_live, DF_LR_OUT (curr_loop->header));
123+
124+ /* Calculate the live-out and live-in for the exit edge of the loop.
125+ This considers liveness for not only the loop latch but also the
126+ liveness outside the loops. */
127+
128+ FOR_EACH_VEC_ELT (edges, i, e)
129+ {
130+ bitmap_ior_into (&regs_live, DF_LR_OUT (e->src));
131+ bitmap_ior_into (&regs_live, DF_LR_IN (e->dest));
132+ }
133+
134+ regs_used = bitmap_count_bits (&regs_live) + 2;
135+ bitmap_clear (&regs_live);
136+ edges.release ();
137 }
138
139 if (! flag_ira_loop_pressure)
140--
1412.7.4
142
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0028-Patch-microblaze-Correct-the-const-high-double-immed.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0028-Patch-microblaze-Correct-the-const-high-double-immed.patch
new file mode 100644
index 00000000..b5ee2c8c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0028-Patch-microblaze-Correct-the-const-high-double-immed.patch
@@ -0,0 +1,69 @@
1From 8f8c6cd35a2cf79449c0155fa865a665d730e541 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 11:25:48 +0530
4Subject: [PATCH 28/63] [Patch, microblaze]: Correct the const high double
5 immediate value With this patch the loading of the DI mode immediate values
6 will be using REAL_VALUE_FROM_CONST_DOUBLE and REAL_VALUE_TO_TARGET_DOUBLE
7 functions, as CONST_DOUBLE_HIGH was returning the sign extension value even
8 of the unsigned long long constants also
9
10Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11 Ajit Agarwal <ajitkum@xilinx.com>
12
13ChangeLog:
142016-02-03 Nagaraju Mekala <nmekala@xilix.com>
15 Ajit Agarwal <ajitkum@xilinx.com>
16
17 *microblaze.c (print_operand): Use REAL_VALUE_FROM_CONST_DOUBLE &
18 REAL_VALUE_TO_TARGET_DOUBLE
19 *long.c (new): Added new testcase
20---
21 gcc/config/microblaze/microblaze.c | 8 ++++++--
22 gcc/testsuite/gcc.target/microblaze/long.c | 10 ++++++++++
23 2 files changed, 16 insertions(+), 2 deletions(-)
24 create mode 100644 gcc/testsuite/gcc.target/microblaze/long.c
25
26diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
27index ae7d5dd..002d7a5 100644
28--- a/gcc/config/microblaze/microblaze.c
29+++ b/gcc/config/microblaze/microblaze.c
30@@ -2594,14 +2594,18 @@ print_operand (FILE * file, rtx op, int letter)
31 else if (letter == 'h' || letter == 'j')
32 {
33 long val[2];
34+ long l[2];
35 if (code == CONST_DOUBLE)
36 {
37 if (GET_MODE (op) == DFmode)
38 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
39 else
40 {
41- val[0] = CONST_DOUBLE_HIGH (op);
42- val[1] = CONST_DOUBLE_LOW (op);
43+ REAL_VALUE_TYPE rv;
44+ REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
45+ REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
46+ val[1] = l[WORDS_BIG_ENDIAN == 0];
47+ val[0] = l[WORDS_BIG_ENDIAN != 0];
48 }
49 }
50 else if (code == CONST_INT)
51diff --git a/gcc/testsuite/gcc.target/microblaze/long.c b/gcc/testsuite/gcc.target/microblaze/long.c
52new file mode 100644
53index 0000000..4d45186
54--- /dev/null
55+++ b/gcc/testsuite/gcc.target/microblaze/long.c
56@@ -0,0 +1,10 @@
57+/* { dg-options "-O0" } */
58+#define BASEADDR 0xF0000000ULL
59+int main ()
60+{
61+ unsigned long long start;
62+ start = (unsigned long long) BASEADDR;
63+ return 0;
64+}
65+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0x00000000" } } */
66+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0xf0000000" } } */
67--
682.7.4
69
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0029-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0029-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch
new file mode 100644
index 00000000..cbfc98de
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0029-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch
@@ -0,0 +1,36 @@
1From 30402c3bcfeb8a93656957b22558997b65d69cb8 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 11:49:58 +0530
4Subject: [PATCH 29/63] [Fix, microblaze]: Fix internal compiler error with
5 msmall-divides This patch will fix the internal error
6 microblaze_expand_divide function which comes because of rtx PLUS where the
7 mem_rtx is of type SI and the operand is of type QImode. This patch modifies
8 the mem_rtx as QImode and Plus as QImode to fix the error.
9
10Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
11 Ajit Agarwal <ajitkum@xilinx.com>
12ChangeLog:
13 2016-02-23 Nagaraju Mekala <nmekala@xilix.com>
14 Ajit Agarwal <ajitkum@xilinx.com>
15
16 *microblaze.c (microblaze_expand_divide): Update
17---
18 gcc/config/microblaze/microblaze.c | 2 +-
19 1 file changed, 1 insertion(+), 1 deletion(-)
20
21diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
22index 002d7a5..c662952 100644
23--- a/gcc/config/microblaze/microblaze.c
24+++ b/gcc/config/microblaze/microblaze.c
25@@ -3909,7 +3909,7 @@ microblaze_expand_divide (rtx operands[])
26 emit_insn (gen_ashlsi3_bshift (regt1, operands[1], GEN_INT(4)));
27 emit_insn (gen_addsi3 (regt1, regt1, operands[2]));
28 mem_rtx = gen_rtx_MEM (QImode,
29- gen_rtx_PLUS (Pmode, regt1, div_table_rtx));
30+ gen_rtx_PLUS (QImode, regt1, div_table_rtx));
31
32 insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
33 jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
34--
352.7.4
36
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0030-patch-microblaze-Fix-the-calculation-of-high-word-in.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0030-patch-microblaze-Fix-the-calculation-of-high-word-in.patch
new file mode 100644
index 00000000..fce06359
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0030-patch-microblaze-Fix-the-calculation-of-high-word-in.patch
@@ -0,0 +1,45 @@
1From 5ac80cf926c4dc96cbfd189f02c9250865b52dd3 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 12:03:39 +0530
4Subject: [PATCH 30/63] [patch,microblaze]: Fix the calculation of high word in
5 a long long 6. .4-bit
6
7This patch will change the calculation of high word in a long long 64-bit.
8Earlier to this patch the high word of long long word (0xF0000000ULL) is
9coming to be 0xFFFFFFFF and low word is 0xF0000000. Instead the high word
10should be 0x00000000 and the low word should be 0xF0000000. This patch
11removes the condition of checking high word = 0 & low word < 0.
12This check is not required for the correctness of calculating 32-bit high
13and low words in a 64-bit long long.
14
15Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
16 Ajit Agarwal <ajitkum@xilinx.com>
17
18ChangeLog:
192016-03-01 Nagaraju Mekala <nmekala@xilix.com>
20 Ajit Agarwal <ajitkum@xilinx.com>
21
22 *config/microblaze/microblaze.c (print_operand): Remove the condition of checking
23 high word = 0 & low word < 0.
24 *testsuite/gcc.target/microblaze/others/long.c: Add -O0 option.
25---
26 gcc/config/microblaze/microblaze.c | 3 ---
27 1 file changed, 3 deletions(-)
28
29diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
30index c662952..8013a2c 100644
31--- a/gcc/config/microblaze/microblaze.c
32+++ b/gcc/config/microblaze/microblaze.c
33@@ -2612,9 +2612,6 @@ print_operand (FILE * file, rtx op, int letter)
34 {
35 val[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
36 val[1] = INTVAL (op) & 0x00000000ffffffffLL;
37- if (val[0] == 0 && val[1] < 0)
38- val[0] = -1;
39-
40 }
41 fprintf (file, "0x%8.8lx", (letter == 'h') ? val[0] : val[1]);
42 }
43--
442.7.4
45
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0031-Patch-microblaze-Add-new-bit-field-instructions.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0031-Patch-microblaze-Add-new-bit-field-instructions.patch
new file mode 100644
index 00000000..cbf64d97
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0031-Patch-microblaze-Add-new-bit-field-instructions.patch
@@ -0,0 +1,120 @@
1From 45deb5bd3ae8c3db360ef181c9873e37d2288848 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 12:14:51 +0530
4Subject: [PATCH 31/63] [Patch, microblaze]: Add new bit-field instructions
5 This patches adds new bsefi and bsifi instructions. BSEFI- The instruction
6 shall extract a bit field from a register and place it right-adjusted in the
7 destination register. The other bits in the destination register shall be set
8 to zero BSIFI- The instruction shall insert a right-adjusted bit field from a
9 register at another position in the destination register. The rest of the
10 bits in the destination register shall be unchanged
11
12Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
13
14ChangeLog:
15 2016-02-03 Nagaraju Mekala <nmekala@xilix.com>
16
17 *microblaze.md (Update): Added new patterns
18---
19 gcc/config/microblaze/microblaze.md | 73 +++++++++++++++++++++++++++++++++++++
20 1 file changed, 73 insertions(+)
21
22diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
23index b7c16ac..67b298a 100644
24--- a/gcc/config/microblaze/microblaze.md
25+++ b/gcc/config/microblaze/microblaze.md
26@@ -982,6 +982,8 @@
27 (set_attr "mode" "DI")
28 (set_attr "length" "20,20,20")])
29
30+
31+
32 ;;----------------------------------------------------------------
33 ;; Data movement
34 ;;----------------------------------------------------------------
35@@ -1776,6 +1778,7 @@
36 (set_attr "length" "28")]
37 )
38
39+
40 ;;----------------------------------------------------------------
41 ;; Setting a register from an integer comparison.
42 ;;----------------------------------------------------------------
43@@ -2489,4 +2492,74 @@
44 DONE;
45 }")
46
47+(define_expand "extvsi"
48+ [(set (match_operand:SI 0 "register_operand" "r")
49+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
50+ (match_operand:SI 2 "immediate_operand" "I")
51+ (match_operand:SI 3 "immediate_operand" "I")))]
52+"TARGET_HAS_BITFIELD"
53+"
54+{
55+ unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
56+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
57+
58+ if ((len == 0) || (pos + len > 32) )
59+ FAIL;
60+
61+ ;;if (!register_operand (operands[1], VOIDmode))
62+ ;; FAIL;
63+ if (operands[0] == operands[1])
64+ FAIL;
65+ if (GET_CODE (operands[1]) == ASHIFT)
66+ FAIL;
67+;; operands[2] = GEN_INT(INTVAL(operands[2])+1 );
68+ emit_insn (gen_extv_32 (operands[0], operands[1],
69+ operands[2], operands[3]));
70+ DONE;
71+}")
72+
73+(define_insn "extv_32"
74+ [(set (match_operand:SI 0 "register_operand" "=r")
75+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
76+ (match_operand:SI 2 "immediate_operand" "I")
77+ (match_operand:SI 3 "immediate_operand" "I")))]
78+ "TARGET_HAS_BITFIELD && (UINTVAL (operands[2]) > 0)
79+ && ((UINTVAL (operands[2]) + UINTVAL (operands[3])) <= 32)"
80+ "bsefi %0,%1,%2,%3"
81+ [(set_attr "type" "bshift")
82+ (set_attr "length" "4")])
83+
84+(define_expand "insvsi"
85+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
86+ (match_operand:SI 1 "immediate_operand" "I")
87+ (match_operand:SI 2 "immediate_operand" "I"))
88+ (match_operand:SI 3 "register_operand" "r"))]
89+ "TARGET_HAS_BITFIELD"
90+ "
91+{
92+ unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
93+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
94+
95+ if (len <= 0 || pos + len > 32)
96+ FAIL;
97+
98+ ;;if (!register_operand (operands[0], VOIDmode))
99+ ;; FAIL;
100+
101+ emit_insn (gen_insv_32 (operands[0], operands[1],
102+ operands[2], operands[3]));
103+ DONE;
104+}")
105+
106+(define_insn "insv_32"
107+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
108+ (match_operand:SI 1 "immediate_operand" "I")
109+ (match_operand:SI 2 "immediate_operand" "I"))
110+ (match_operand:SI 3 "register_operand" "r"))]
111+ "TARGET_HAS_BITFIELD && UINTVAL (operands[1]) > 0
112+ && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
113+ "bsifi %0, %3, %1, %2"
114+ [(set_attr "type" "bshift")
115+ (set_attr "length" "4")])
116+
117 (include "sync.md")
118--
1192.7.4
120
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0032-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0032-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch
new file mode 100644
index 00000000..86df58b3
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0032-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch
@@ -0,0 +1,247 @@
1From bc95cc12b2c4d96ea709eefc4b99181b8c40b19c Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 12:42:10 +0530
4Subject: [PATCH 32/63] [Patch, microblaze]: Fix bug in MB version calculation
5 This patch fixes the bug in microblaze_version_to_int function. Earlier the
6 conversion of vXX.YY.Z to int has a bug which is fixed now.
7
8Signed-off-by : Mahesh Bodapati <mbodapat@xilinx.com>
9 Nagaraju Mekala <nmekala@xilix.com>
10---
11 gcc/config/microblaze/microblaze.c | 147 ++++++++++++++++++-------------------
12 1 file changed, 70 insertions(+), 77 deletions(-)
13
14diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
15index 8013a2c..3f68ef0 100644
16--- a/gcc/config/microblaze/microblaze.c
17+++ b/gcc/config/microblaze/microblaze.c
18@@ -239,6 +239,63 @@ section *sdata2_section;
19 #define TARGET_HAVE_TLS true
20 #endif
21
22+/* Convert a version number of the form "vX.YY.Z" to an integer encoding
23+ for easier range comparison. */
24+static int
25+microblaze_version_to_int (const char *version)
26+{
27+ const char *p, *v;
28+ const char *tmpl = "vXX.YY.Z";
29+ int iver1 =0, iver2 =0, iver3 =0;
30+
31+ p = version;
32+ v = tmpl;
33+
34+ while (*p)
35+ {
36+ if (*v == 'X')
37+ { /* Looking for major */
38+ if (*p == '.')
39+ {
40+ *v++;
41+ }
42+ else
43+ {
44+ if (!(*p >= '0' && *p <= '9'))
45+ return -1;
46+ iver1 += (int) (*p - '0');
47+ iver1 *= 1000;
48+ }
49+ }
50+ else if (*v == 'Y')
51+ { /* Looking for minor */
52+ if (!(*p >= '0' && *p <= '9'))
53+ return -1;
54+ iver2 += (int) (*p - '0');
55+ iver2 *= 10;
56+ }
57+ else if (*v == 'Z')
58+ { /* Looking for compat */
59+ if (!(*p >= 'a' && *p <= 'z'))
60+ return -1;
61+ iver3 = ((int) (*p)) - 96;
62+ }
63+ else
64+ {
65+ if (*p != *v)
66+ return -1;
67+ }
68+
69+ v++;
70+ p++;
71+ }
72+
73+ if (*p)
74+ return -1;
75+
76+ return iver1 + iver2 + iver3;
77+}
78+
79 /* Return truth value if a CONST_DOUBLE is ok to be a legitimate constant. */
80 static bool
81 microblaze_const_double_ok (rtx op, machine_mode mode)
82@@ -1338,8 +1395,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
83 {
84 if (TARGET_BARREL_SHIFT)
85 {
86- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a")
87- >= 0)
88+ if (microblaze_version_to_int(microblaze_select_cpu) >= microblaze_version_to_int("v5.00.a"))
89 *total = COSTS_N_INSNS (1);
90 else
91 *total = COSTS_N_INSNS (2);
92@@ -1400,8 +1456,7 @@ microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED,
93 }
94 else if (!TARGET_SOFT_MUL)
95 {
96- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a")
97- >= 0)
98+ if (microblaze_version_to_int(microblaze_select_cpu) >= microblaze_version_to_int("v5.00.a"))
99 *total = COSTS_N_INSNS (1);
100 else
101 *total = COSTS_N_INSNS (3);
102@@ -1682,72 +1737,13 @@ function_arg_partial_bytes (cumulative_args_t cum_v, machine_mode mode,
103 return 0;
104 }
105
106-/* Convert a version number of the form "vX.YY.Z" to an integer encoding
107- for easier range comparison. */
108-static int
109-microblaze_version_to_int (const char *version)
110-{
111- const char *p, *v;
112- const char *tmpl = "vXX.YY.Z";
113- int iver = 0;
114-
115- p = version;
116- v = tmpl;
117-
118- while (*p)
119- {
120- if (*v == 'X')
121- { /* Looking for major */
122- if (*p == '.')
123- {
124- v++;
125- }
126- else
127- {
128- if (!(*p >= '0' && *p <= '9'))
129- return -1;
130- iver += (int) (*p - '0');
131- iver *= 10;
132- }
133- }
134- else if (*v == 'Y')
135- { /* Looking for minor */
136- if (!(*p >= '0' && *p <= '9'))
137- return -1;
138- iver += (int) (*p - '0');
139- iver *= 10;
140- }
141- else if (*v == 'Z')
142- { /* Looking for compat */
143- if (!(*p >= 'a' && *p <= 'z'))
144- return -1;
145- iver *= 10;
146- iver += (int) (*p - 'a');
147- }
148- else
149- {
150- if (*p != *v)
151- return -1;
152- }
153-
154- v++;
155- p++;
156- }
157-
158- if (*p)
159- return -1;
160-
161- return iver;
162-}
163-
164-
165 static void
166 microblaze_option_override (void)
167 {
168 register int i, start;
169 register int regno;
170 register machine_mode mode;
171- int ver;
172+ int ver,ver_int;
173
174 microblaze_section_threshold = (global_options_set.x_g_switch_value
175 ? g_switch_value
176@@ -1768,13 +1764,13 @@ microblaze_option_override (void)
177 /* Check the MicroBlaze CPU version for any special action to be done. */
178 if (microblaze_select_cpu == NULL)
179 microblaze_select_cpu = MICROBLAZE_DEFAULT_CPU;
180- ver = microblaze_version_to_int (microblaze_select_cpu);
181- if (ver == -1)
182+ ver_int = microblaze_version_to_int (microblaze_select_cpu);
183+ if (ver_int == -1)
184 {
185 error ("%qs is an invalid argument to %<-mcpu=%>", microblaze_select_cpu);
186 }
187
188- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v3.00.a");
189+ ver = ver_int - microblaze_version_to_int("v3.00.a");
190 if (ver < 0)
191 {
192 /* No hardware exceptions in earlier versions. So no worries. */
193@@ -1785,8 +1781,7 @@ microblaze_option_override (void)
194 microblaze_pipe = MICROBLAZE_PIPE_3;
195 }
196 else if (ver == 0
197- || (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v4.00.b")
198- == 0))
199+ || (ver_int == microblaze_version_to_int("v4.00.b")))
200 {
201 #if 0
202 microblaze_select_flags |= (MICROBLAZE_MASK_NO_UNSAFE_DELAY);
203@@ -1803,11 +1798,9 @@ microblaze_option_override (void)
204 #endif
205 microblaze_no_unsafe_delay = 0;
206 microblaze_pipe = MICROBLAZE_PIPE_5;
207- if (MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v5.00.a") == 0
208- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
209- "v5.00.b") == 0
210- || MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu,
211- "v5.00.c") == 0)
212+ if ((ver_int == microblaze_version_to_int("v5.00.a"))
213+ || (ver_int == microblaze_version_to_int("v5.00.b"))
214+ || (ver_int == microblaze_version_to_int("v5.00.c")))
215 {
216 /* Pattern compares are to be turned on by default only when
217 compiling for MB v5.00.'z'. */
218@@ -1815,7 +1808,7 @@ microblaze_option_override (void)
219 }
220 }
221
222- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v6.00.a");
223+ ver = ver_int - microblaze_version_to_int("v6.00.a");
224 if (ver < 0)
225 {
226 if (TARGET_MULTIPLY_HIGH)
227@@ -1824,7 +1817,7 @@ microblaze_option_override (void)
228 "%<-mcpu=v6.00.a%> or greater");
229 }
230
231- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.10.a");
232+ ver = ver_int - microblaze_version_to_int("v8.10.a");
233 microblaze_has_clz = 1;
234 if (ver < 0)
235 {
236@@ -1833,7 +1826,7 @@ microblaze_option_override (void)
237 }
238
239 /* TARGET_REORDER defaults to 2 if -mxl-reorder not specified. */
240- ver = MICROBLAZE_VERSION_COMPARE (microblaze_select_cpu, "v8.30.a");
241+ ver = ver_int - microblaze_version_to_int("v8.30.a");
242 if (ver < 0)
243 {
244 if (TARGET_REORDER == 1)
245--
2462.7.4
247
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0033-Fixing-the-bug-in-the-bit-field-instruction.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0033-Fixing-the-bug-in-the-bit-field-instruction.patch
new file mode 100644
index 00000000..68f70ae8
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0033-Fixing-the-bug-in-the-bit-field-instruction.patch
@@ -0,0 +1,48 @@
1From 51da0572e0650378e422030b26d1258c8fc76df6 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 13:57:48 +0530
4Subject: [PATCH 33/63] Fixing the bug in the bit-field instruction. Bit field
5 instruction should be generated only if mcpu >10.0
6
7---
8 gcc/config/microblaze/microblaze.c | 3 +++
9 gcc/config/microblaze/microblaze.h | 2 ++
10 2 files changed, 5 insertions(+)
11
12diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
13index 3f68ef0..a37f08eea 100644
14--- a/gcc/config/microblaze/microblaze.c
15+++ b/gcc/config/microblaze/microblaze.c
16@@ -164,6 +164,9 @@ int microblaze_no_unsafe_delay;
17 /* Set to one if the targeted core has the CLZ insn. */
18 int microblaze_has_clz = 0;
19
20+/* Set to one if the targeted core has barrel-shift and cpu > 10.0 */
21+int microblaze_has_bitfield = 0;
22+
23 /* Which CPU pipeline do we use. We haven't really standardized on a CPU
24 version having only a particular type of pipeline. There can still be
25 options on the CPU to scale pipeline features up or down. :(
26diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
27index bf7f3b4..1d05e6e 100644
28--- a/gcc/config/microblaze/microblaze.h
29+++ b/gcc/config/microblaze/microblaze.h
30@@ -44,6 +44,7 @@ extern int microblaze_dbx_regno[];
31
32 extern int microblaze_no_unsafe_delay;
33 extern int microblaze_has_clz;
34+extern int microblaze_has_bitfield;
35 extern enum pipeline_type microblaze_pipe;
36
37 #define OBJECT_FORMAT_ELF
38@@ -62,6 +63,7 @@ extern enum pipeline_type microblaze_pipe;
39
40 /* Do we have CLZ? */
41 #define TARGET_HAS_CLZ (TARGET_PATTERN_COMPARE && microblaze_has_clz)
42+#define TARGET_HAS_BITFIELD (TARGET_BARREL_SHIFT && microblaze_has_bitfield)
43
44 /* The default is to support PIC. */
45 #define TARGET_SUPPORTS_PIC 1
46--
472.7.4
48
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0034-Patch-microblaze-Macros-used-in-Xilinx-internal-patc.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0034-Patch-microblaze-Macros-used-in-Xilinx-internal-patc.patch
new file mode 100644
index 00000000..04326205
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0034-Patch-microblaze-Macros-used-in-Xilinx-internal-patc.patch
@@ -0,0 +1,32 @@
1From 132b913b721f66c5db17f62dd5559bbca11bb875 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 18 Jan 2017 20:57:10 +0530
4Subject: [PATCH 34/63] [Patch, microblaze]: Macros used in Xilinx internal
5 patches has been removed in gcc 6.2 version so modified the code accordingly.
6
7---
8 gcc/config/microblaze/microblaze.c | 8 +++-----
9 1 file changed, 3 insertions(+), 5 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
12index a37f08eea..71640e5 100644
13--- a/gcc/config/microblaze/microblaze.c
14+++ b/gcc/config/microblaze/microblaze.c
15@@ -2597,11 +2597,9 @@ print_operand (FILE * file, rtx op, int letter)
16 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
17 else
18 {
19- REAL_VALUE_TYPE rv;
20- REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
21- REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
22- val[1] = l[WORDS_BIG_ENDIAN == 0];
23- val[0] = l[WORDS_BIG_ENDIAN != 0];
24+ REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), l);
25+ val[1] = l[WORDS_BIG_ENDIAN == 0];
26+ val[0] = l[WORDS_BIG_ENDIAN != 0];
27 }
28 }
29 else if (code == CONST_INT)
30--
312.7.4
32
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0035-Fixing-the-issue-with-the-builtin_alloc.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0035-Fixing-the-issue-with-the-builtin_alloc.patch
new file mode 100644
index 00000000..91ac0d02
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0035-Fixing-the-issue-with-the-builtin_alloc.patch
@@ -0,0 +1,44 @@
1From e672184af6a43b773131181270c7a8c5c5273bd8 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 23 Feb 2017 17:09:04 +0530
4Subject: [PATCH 35/63] Fixing the issue with the builtin_alloc. register r18
5 was not properly handling the stack pattern which was resolved by using free
6 available register
7
8signed-off-by:nagaraju mekala <nmekala@xilinx.com>
9---
10 gcc/config/microblaze/microblaze.md | 8 ++++----
11 1 file changed, 4 insertions(+), 4 deletions(-)
12
13diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
14index 67b298a..7bae957 100644
15--- a/gcc/config/microblaze/microblaze.md
16+++ b/gcc/config/microblaze/microblaze.md
17@@ -2078,10 +2078,10 @@
18 ""
19 {
20 rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx);
21- rtx rtmp = gen_rtx_REG (SImode, R_TMP);
22+ rtx reg = gen_reg_rtx (Pmode);
23 rtx neg_op0;
24
25- emit_move_insn (rtmp, retaddr);
26+ emit_move_insn (reg, retaddr);
27 if (GET_CODE (operands[1]) != CONST_INT)
28 {
29 neg_op0 = gen_reg_rtx (Pmode);
30@@ -2090,9 +2090,9 @@
31 neg_op0 = GEN_INT (- INTVAL (operands[1]));
32
33 emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
34- emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), rtmp);
35+ emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), reg);
36 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
37- emit_insn (gen_rtx_CLOBBER (SImode, rtmp));
38+ emit_insn (gen_rtx_CLOBBER (SImode, reg));
39 DONE;
40 }
41 )
42--
432.7.4
44
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0036-Patch-Microblaze-reverting-the-cost-check-before-pro.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0036-Patch-Microblaze-reverting-the-cost-check-before-pro.patch
new file mode 100644
index 00000000..7079789f
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0036-Patch-Microblaze-reverting-the-cost-check-before-pro.patch
@@ -0,0 +1,49 @@
1From ac30efb4a5f5b6d289fdd27b268c2095d60dcb42 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 2 Mar 2017 19:02:31 +0530
4Subject: [PATCH 36/63] [Patch,Microblaze]:reverting the cost check before
5 propagating constants.
6
7---
8 gcc/cprop.c | 4 ++++
9 1 file changed, 4 insertions(+)
10
11diff --git a/gcc/cprop.c b/gcc/cprop.c
12index 65c0130..42bcc81 100644
13--- a/gcc/cprop.c
14+++ b/gcc/cprop.c
15@@ -733,6 +733,7 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
16 int success = 0;
17 rtx set = single_set (insn);
18
19+#if 0
20 bool check_rtx_costs = true;
21 bool speed = optimize_bb_for_speed_p (BLOCK_FOR_INSN (insn));
22 int old_cost = set ? set_rtx_cost (set, speed) : 0;
23@@ -744,6 +745,7 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
24 && (GET_CODE (XEXP (note, 0)) == CONST
25 || CONSTANT_P (XEXP (note, 0)))))
26 check_rtx_costs = false;
27+#endif
28
29 /* Usually we substitute easy stuff, so we won't copy everything.
30 We however need to take care to not duplicate non-trivial CONST
31@@ -752,6 +754,7 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
32
33 validate_replace_src_group (from, to, insn);
34
35+#if 0
36 /* If TO is a constant, check the cost of the set after propagation
37 to the cost of the set before the propagation. If the cost is
38 higher, then do not replace FROM with TO. */
39@@ -764,6 +767,7 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
40 return false;
41 }
42
43+#endif
44
45 if (num_changes_pending () && apply_change_group ())
46 success = 1;
47--
482.7.4
49
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0037-Patch-Microblaze-update-in-constraints-for-bitfield-.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0037-Patch-Microblaze-update-in-constraints-for-bitfield-.patch
new file mode 100644
index 00000000..ba0f8e80
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0037-Patch-Microblaze-update-in-constraints-for-bitfield-.patch
@@ -0,0 +1,80 @@
1From f436198b817f33d56aaddb88ff629378498de489 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 19 Feb 2018 18:06:16 +0530
4Subject: [PATCH 37/63] [Patch,Microblaze]: update in constraints for bitfield
5 insert and extract instructions.
6
7---
8 gcc/config/microblaze/microblaze.md | 43 ++++++-------------------------------
9 1 file changed, 7 insertions(+), 36 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index 7bae957..6101387 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -2492,33 +2492,17 @@
16 DONE;
17 }")
18
19-(define_expand "extvsi"
20+(define_expand "extzvsi"
21 [(set (match_operand:SI 0 "register_operand" "r")
22 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
23 (match_operand:SI 2 "immediate_operand" "I")
24 (match_operand:SI 3 "immediate_operand" "I")))]
25 "TARGET_HAS_BITFIELD"
26-"
27-{
28- unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
29- unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
30-
31- if ((len == 0) || (pos + len > 32) )
32- FAIL;
33-
34- ;;if (!register_operand (operands[1], VOIDmode))
35- ;; FAIL;
36- if (operands[0] == operands[1])
37- FAIL;
38- if (GET_CODE (operands[1]) == ASHIFT)
39- FAIL;
40-;; operands[2] = GEN_INT(INTVAL(operands[2])+1 );
41- emit_insn (gen_extv_32 (operands[0], operands[1],
42- operands[2], operands[3]));
43- DONE;
44-}")
45+""
46+)
47
48-(define_insn "extv_32"
49+
50+(define_insn "extzv_32"
51 [(set (match_operand:SI 0 "register_operand" "=r")
52 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
53 (match_operand:SI 2 "immediate_operand" "I")
54@@ -2535,21 +2519,8 @@
55 (match_operand:SI 2 "immediate_operand" "I"))
56 (match_operand:SI 3 "register_operand" "r"))]
57 "TARGET_HAS_BITFIELD"
58- "
59-{
60- unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
61- unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
62-
63- if (len <= 0 || pos + len > 32)
64- FAIL;
65-
66- ;;if (!register_operand (operands[0], VOIDmode))
67- ;; FAIL;
68-
69- emit_insn (gen_insv_32 (operands[0], operands[1],
70- operands[2], operands[3]));
71- DONE;
72-}")
73+""
74+)
75
76 (define_insn "insv_32"
77 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
78--
792.7.4
80
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0038-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0038-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch
new file mode 100644
index 00000000..2b90880f
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0038-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch
@@ -0,0 +1,38 @@
1From 89aa1907ab0abad38e394f46f7e5f577bdb26498 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 4 Jun 2018 10:10:18 +0530
4Subject: [PATCH 38/63] [Patch,Microblaze] : Removed fsqrt generation for
5 double values.
6
7---
8 gcc/config/microblaze/microblaze.md | 14 --------------
9 1 file changed, 14 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index 6101387..eb01221 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -526,20 +526,6 @@
16 (set_attr "mode" "SF")
17 (set_attr "length" "4")])
18
19-(define_insn "sqrtdf2"
20- [(set (match_operand:DF 0 "register_operand" "=d")
21- (sqrt:DF (match_operand:DF 1 "register_operand" "dG")))]
22- "TARGET_HARD_FLOAT && TARGET_FLOAT_SQRT"
23- {
24- if (REGNO (operands[0]) == REGNO (operands[1]))
25- return "fsqrt\t%0,%1";
26- else
27- return "fsqrt\t%0,%1\n\taddk\t%D0,%D1,r0";
28- }
29- [(set_attr "type" "fsqrt")
30- (set_attr "mode" "SF")
31- (set_attr "length" "4")])
32-
33 (define_insn "fix_truncsfsi2"
34 [(set (match_operand:SI 0 "register_operand" "=d")
35 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
36--
372.7.4
38
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0039-Intial-commit-of-64-bit-Microblaze.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0039-Intial-commit-of-64-bit-Microblaze.patch
new file mode 100644
index 00000000..f524cba2
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0039-Intial-commit-of-64-bit-Microblaze.patch
@@ -0,0 +1,804 @@
1From 68359cc8e82f63d01a77c39c68e782e6757cd71e Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 3 Apr 2018 16:48:39 +0530
4Subject: [PATCH 39/63] Intial commit of 64-bit Microblaze
5
6Conflicts:
7 gcc/config/microblaze/microblaze.opt
8---
9 gcc/config/microblaze/microblaze-protos.h | 1 +
10 gcc/config/microblaze/microblaze.c | 109 +++++++--
11 gcc/config/microblaze/microblaze.h | 4 +-
12 gcc/config/microblaze/microblaze.md | 370 +++++++++++++++++++++++++++++-
13 gcc/config/microblaze/microblaze.opt | 7 +-
14 gcc/config/microblaze/t-microblaze | 7 +-
15 6 files changed, 460 insertions(+), 38 deletions(-)
16
17diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h
18index bdc9b69..7d6c189 100644
19--- a/gcc/config/microblaze/microblaze-protos.h
20+++ b/gcc/config/microblaze/microblaze-protos.h
21@@ -36,6 +36,7 @@ extern void microblaze_expand_divide (rtx *);
22 extern void microblaze_expand_conditional_branch (enum machine_mode, rtx *);
23 extern void microblaze_expand_conditional_branch_reg (machine_mode, rtx *);
24 extern void microblaze_expand_conditional_branch_sf (rtx *);
25+extern void microblaze_expand_conditional_branch_df (rtx *);
26 extern int microblaze_can_use_return_insn (void);
27 extern void print_operand (FILE *, rtx, int);
28 extern void print_operand_address (FILE *, rtx);
29diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
30index 71640e5..f740f5c 100644
31--- a/gcc/config/microblaze/microblaze.c
32+++ b/gcc/config/microblaze/microblaze.c
33@@ -3570,11 +3570,11 @@ microblaze_expand_move (machine_mode mode, rtx operands[])
34 op0 = operands[0];
35 op1 = operands[1];
36
37- if (!register_operand (op0, SImode)
38- && !register_operand (op1, SImode)
39+ if (!register_operand (op0, mode)
40+ && !register_operand (op1, mode)
41 && (GET_CODE (op1) != CONST_INT || INTVAL (op1) != 0))
42 {
43- rtx temp = force_reg (SImode, op1);
44+ rtx temp = force_reg (mode, op1);
45 emit_move_insn (op0, temp);
46 return true;
47 }
48@@ -3639,12 +3639,12 @@ microblaze_expand_move (machine_mode mode, rtx operands[])
49 && (flag_pic == 2 || microblaze_tls_symbol_p (p0)
50 || !SMALL_INT (p1)))))
51 {
52- rtx temp = force_reg (SImode, p0);
53+ rtx temp = force_reg (mode, p0);
54 rtx temp2 = p1;
55
56 if (flag_pic && reload_in_progress)
57 df_set_regs_ever_live (PIC_OFFSET_TABLE_REGNUM, true);
58- emit_move_insn (op0, gen_rtx_PLUS (SImode, temp, temp2));
59+ emit_move_insn (op0, gen_rtx_PLUS (mode, temp, temp2));
60 return true;
61 }
62 }
63@@ -3775,7 +3775,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
64 rtx cmp_op0 = operands[1];
65 rtx cmp_op1 = operands[2];
66 rtx label1 = operands[3];
67- rtx comp_reg = gen_reg_rtx (SImode);
68+ rtx comp_reg = gen_reg_rtx (mode);
69 rtx condition;
70
71 gcc_assert ((GET_CODE (cmp_op0) == REG) || (GET_CODE (cmp_op0) == SUBREG));
72@@ -3784,23 +3784,36 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
73 if (cmp_op1 == const0_rtx)
74 {
75 comp_reg = cmp_op0;
76- condition = gen_rtx_fmt_ee (signed_condition (code), SImode, comp_reg, const0_rtx);
77- emit_jump_insn (gen_condjump (condition, label1));
78+ condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
79+ if (mode == SImode)
80+ emit_jump_insn (gen_condjump (condition, label1));
81+ else
82+ emit_jump_insn (gen_long_condjump (condition, label1));
83+
84 }
85
86 else if (code == EQ || code == NE)
87 {
88 /* Use xor for equal/not-equal comparison. */
89- emit_insn (gen_xorsi3 (comp_reg, cmp_op0, cmp_op1));
90- condition = gen_rtx_fmt_ee (signed_condition (code), SImode, comp_reg, const0_rtx);
91- emit_jump_insn (gen_condjump (condition, label1));
92+ if (mode == SImode)
93+ emit_insn (gen_xorsi3 (comp_reg, cmp_op0, cmp_op1));
94+ else
95+ emit_insn (gen_xordi3 (comp_reg, cmp_op0, cmp_op1));
96+ condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
97+ if (mode == SImode)
98+ emit_jump_insn (gen_condjump (condition, label1));
99+ else
100+ emit_jump_insn (gen_long_condjump (condition, label1));
101 }
102 else
103 {
104 /* Generate compare and branch in single instruction. */
105 cmp_op1 = force_reg (mode, cmp_op1);
106 condition = gen_rtx_fmt_ee (code, mode, cmp_op0, cmp_op1);
107- emit_jump_insn (gen_branch_compare(condition, cmp_op0, cmp_op1, label1));
108+ if (mode == SImode)
109+ emit_jump_insn (gen_branch_compare(condition, cmp_op0, cmp_op1, label1));
110+ else
111+ emit_jump_insn (gen_long_branch_compare(condition, cmp_op0, cmp_op1, label1));
112 }
113 }
114
115@@ -3811,7 +3824,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
116 rtx cmp_op0 = operands[1];
117 rtx cmp_op1 = operands[2];
118 rtx label1 = operands[3];
119- rtx comp_reg = gen_reg_rtx (SImode);
120+ rtx comp_reg = gen_reg_rtx (mode);
121 rtx condition;
122
123 gcc_assert ((GET_CODE (cmp_op0) == REG)
124@@ -3822,30 +3835,63 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
125 {
126 comp_reg = cmp_op0;
127 condition = gen_rtx_fmt_ee (signed_condition (code),
128- SImode, comp_reg, const0_rtx);
129- emit_jump_insn (gen_condjump (condition, label1));
130+ mode, comp_reg, const0_rtx);
131+ if (mode == SImode)
132+ emit_jump_insn (gen_condjump (condition, label1));
133+ else
134+ emit_jump_insn (gen_long_condjump (condition, label1));
135 }
136 else if (code == EQ)
137 {
138- emit_insn (gen_seq_internal_pat (comp_reg,
139- cmp_op0, cmp_op1));
140- condition = gen_rtx_EQ (SImode, comp_reg, const0_rtx);
141- emit_jump_insn (gen_condjump (condition, label1));
142+ if (mode == SImode)
143+ {
144+ emit_insn (gen_seq_internal_pat (comp_reg, cmp_op0,
145+ cmp_op1));
146+ }
147+ else
148+ {
149+ emit_insn (gen_seq_internal_pat (comp_reg, cmp_op0,
150+ cmp_op1));
151+ }
152+ condition = gen_rtx_EQ (mode, comp_reg, const0_rtx);
153+ if (mode == SImode)
154+ emit_jump_insn (gen_condjump (condition, label1));
155+ else
156+ emit_jump_insn (gen_long_condjump (condition, label1));
157+
158 }
159 else if (code == NE)
160 {
161- emit_insn (gen_sne_internal_pat (comp_reg, cmp_op0,
162- cmp_op1));
163- condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
164- emit_jump_insn (gen_condjump (condition, label1));
165+ if (mode == SImode)
166+ {
167+ emit_insn (gen_sne_internal_pat (comp_reg, cmp_op0,
168+ cmp_op1));
169+ }
170+ else
171+ {
172+ emit_insn (gen_sne_internal_pat (comp_reg, cmp_op0,
173+ cmp_op1));
174+ }
175+ condition = gen_rtx_NE (mode, comp_reg, const0_rtx);
176+ if (mode == SImode)
177+ emit_jump_insn (gen_condjump (condition, label1));
178+ else
179+ emit_jump_insn (gen_long_condjump (condition, label1));
180 }
181 else
182 {
183 /* Generate compare and branch in single instruction. */
184 cmp_op1 = force_reg (mode, cmp_op1);
185 condition = gen_rtx_fmt_ee (code, mode, cmp_op0, cmp_op1);
186- emit_jump_insn (gen_branch_compare (condition, cmp_op0,
187- cmp_op1, label1));
188+ if (mode == SImode)
189+ emit_jump_insn (gen_branch_compare (condition, cmp_op0,
190+ cmp_op1, label1));
191+ else
192+ {
193+ emit_jump_insn (gen_long_branch_compare (condition, cmp_op0,
194+ cmp_op1, label1));
195+ }
196+
197 }
198 }
199
200@@ -3862,6 +3908,19 @@ microblaze_expand_conditional_branch_sf (rtx operands[])
201 emit_jump_insn (gen_condjump (condition, operands[3]));
202 }
203
204+void
205+microblaze_expand_conditional_branch_df (rtx operands[])
206+{
207+ rtx condition;
208+ rtx cmp_op0 = XEXP (operands[0], 0);
209+ rtx cmp_op1 = XEXP (operands[0], 1);
210+ rtx comp_reg = gen_reg_rtx (DImode);
211+
212+ emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
213+ condition = gen_rtx_NE (DImode, comp_reg, const0_rtx);
214+ emit_jump_insn (gen_long_condjump (condition, operands[3]));
215+}
216+
217 /* Implement TARGET_FRAME_POINTER_REQUIRED. */
218
219 static bool
220diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
221index 1d05e6e..2ca44f5 100644
222--- a/gcc/config/microblaze/microblaze.h
223+++ b/gcc/config/microblaze/microblaze.h
224@@ -102,6 +102,7 @@ extern enum pipeline_type microblaze_pipe;
225 #define ASM_SPEC "\
226 %(target_asm_spec) \
227 %{mbig-endian:-EB} \
228+%{m64:-m64} \
229 %{mlittle-endian:-EL}"
230
231 /* Extra switches sometimes passed to the linker. */
232@@ -110,6 +111,7 @@ extern enum pipeline_type microblaze_pipe;
233 #define LINK_SPEC "%{shared:-shared} -N -relax \
234 %{mbig-endian:-EB --oformat=elf32-microblaze} \
235 %{mlittle-endian:-EL --oformat=elf32-microblazeel} \
236+ %{m64:-EL --oformat=elf64-microblazeel} \
237 %{Zxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
238 %{mxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
239 %{mxl-gp-opt:%{G*}} %{!mxl-gp-opt: -G 0} \
240@@ -217,7 +219,7 @@ extern enum pipeline_type microblaze_pipe;
241 #define MIN_UNITS_PER_WORD 4
242 #define INT_TYPE_SIZE 32
243 #define SHORT_TYPE_SIZE 16
244-#define LONG_TYPE_SIZE 32
245+#define LONG_TYPE_SIZE 64
246 #define LONG_LONG_TYPE_SIZE 64
247 #define FLOAT_TYPE_SIZE 32
248 #define DOUBLE_TYPE_SIZE 64
249diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
250index eb01221..dbb592e 100644
251--- a/gcc/config/microblaze/microblaze.md
252+++ b/gcc/config/microblaze/microblaze.md
253@@ -497,7 +497,6 @@
254 (set_attr "mode" "SF")
255 (set_attr "length" "4")])
256
257-
258 (define_insn "divsf3"
259 [(set (match_operand:SF 0 "register_operand" "=d")
260 (div:SF (match_operand:SF 1 "register_operand" "d")
261@@ -508,6 +507,7 @@
262 (set_attr "mode" "SF")
263 (set_attr "length" "4")])
264
265+
266 (define_insn "sqrtsf2"
267 [(set (match_operand:SF 0 "register_operand" "=d")
268 (sqrt:SF (match_operand:SF 1 "register_operand" "d")))]
269@@ -562,6 +562,18 @@
270
271 ;; Adding 2 DI operands in register or reg/imm
272
273+(define_insn "adddi3_long"
274+ [(set (match_operand:DI 0 "register_operand" "=d,d")
275+ (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%dJ,dJ")
276+ (match_operand:DI 2 "arith_plus_operand" "d,K")))]
277+ "TARGET_MB_64"
278+ "@
279+ addlk\t%0,%z1,%2
280+ addlik\t%0,%z1,%2"
281+ [(set_attr "type" "arith,arith")
282+ (set_attr "mode" "DI,DI")
283+ (set_attr "length" "4,4")])
284+
285 (define_insn "adddi3"
286 [(set (match_operand:DI 0 "register_operand" "=d,d")
287 (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
288@@ -606,6 +618,18 @@
289 ;; Double Precision Subtraction
290 ;;----------------------------------------------------------------
291
292+(define_insn "subdi3_long"
293+ [(set (match_operand:DI 0 "register_operand" "=d,d")
294+ (minus:DI (match_operand:DI 1 "register_operand" "d,d")
295+ (match_operand:DI 2 "register_operand" "d,n")))]
296+ "TARGET_MB_64"
297+ "@
298+ rsubl\t%0,%2,%1
299+ addlik\t%0,%z1,-%2"
300+ [(set_attr "type" "darith")
301+ (set_attr "mode" "DI,DI")
302+ (set_attr "length" "4,4")])
303+
304 (define_insn "subdi3"
305 [(set (match_operand:DI 0 "register_operand" "=&d")
306 (minus:DI (match_operand:DI 1 "register_operand" "d")
307@@ -795,6 +819,15 @@
308 (set_attr "mode" "SI")
309 (set_attr "length" "4")])
310
311+(define_insn "negdi2_long"
312+ [(set (match_operand:DI 0 "register_operand" "=d")
313+ (neg:DI (match_operand:DI 1 "register_operand" "d")))]
314+ "TARGET_MB_64"
315+ "rsubl\t%0,%1,r0"
316+ [(set_attr "type" "darith")
317+ (set_attr "mode" "DI")
318+ (set_attr "length" "4")])
319+
320 (define_insn "negdi2"
321 [(set (match_operand:DI 0 "register_operand" "=d")
322 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
323@@ -814,6 +847,15 @@
324 (set_attr "mode" "SI")
325 (set_attr "length" "4")])
326
327+(define_insn "one_cmpldi2_long"
328+ [(set (match_operand:DI 0 "register_operand" "=d")
329+ (not:DI (match_operand:DI 1 "register_operand" "d")))]
330+ "TARGET_MB_64"
331+ "xorli\t%0,%1,-1"
332+ [(set_attr "type" "arith")
333+ (set_attr "mode" "DI")
334+ (set_attr "length" "4")])
335+
336 (define_insn "*one_cmpldi2"
337 [(set (match_operand:DI 0 "register_operand" "=d")
338 (not:DI (match_operand:DI 1 "register_operand" "d")))]
339@@ -840,6 +882,20 @@
340 ;; Logical
341 ;;----------------------------------------------------------------
342
343+(define_insn "anddi3"
344+ [(set (match_operand:DI 0 "register_operand" "=d,d")
345+ (and:DI (match_operand:DI 1 "arith_operand" "d,d")
346+ (match_operand:DI 2 "arith_operand" "d,K")))]
347+ "TARGET_MB_64"
348+ "@
349+ andl\t%0,%1,%2
350+ andli\t%0,%1,%2 #andl1"
351+ ;; andli\t%0,%1,%2 #andl3
352+ ;; andli\t%0,%1,%2 #andl2
353+ [(set_attr "type" "arith,arith")
354+ (set_attr "mode" "DI,DI")
355+ (set_attr "length" "4,4")])
356+
357 (define_insn "andsi3"
358 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
359 (and:SI (match_operand:SI 1 "arith_operand" "%d,d,d,d")
360@@ -855,6 +911,18 @@
361 (set_attr "length" "4,8,8,8")])
362
363
364+(define_insn "iordi3"
365+ [(set (match_operand:DI 0 "register_operand" "=d,d")
366+ (ior:DI (match_operand:DI 1 "arith_operand" "d,d")
367+ (match_operand:DI 2 "arith_operand" "d,K")))]
368+ "TARGET_MB_64"
369+ "@
370+ orl\t%0,%1,%2
371+ orli\t%0,%1,%2 #andl1"
372+ [(set_attr "type" "arith,arith")
373+ (set_attr "mode" "DI,DI")
374+ (set_attr "length" "4,4")])
375+
376 (define_insn "iorsi3"
377 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
378 (ior:SI (match_operand:SI 1 "arith_operand" "%d,d,d,d")
379@@ -869,6 +937,19 @@
380 (set_attr "mode" "SI,SI,SI,SI")
381 (set_attr "length" "4,8,8,8")])
382
383+(define_insn "xordi3"
384+ [(set (match_operand:DI 0 "register_operand" "=d,d")
385+ (xor:DI (match_operand:DI 1 "arith_operand" "%d,d")
386+ (match_operand:DI 2 "arith_operand" "d,K")))]
387+ "TARGET_MB_64"
388+ "@
389+ xorl\t%0,%1,%2
390+ xorli\t%0,%1,%2 #andl1"
391+ [(set_attr "type" "arith,arith")
392+ (set_attr "mode" "DI,DI")
393+ (set_attr "length" "4,4")])
394+
395+
396 (define_insn "xorsi3"
397 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
398 (xor:SI (match_operand:SI 1 "arith_operand" "%d,d,d")
399@@ -937,6 +1018,26 @@
400 (set_attr "mode" "SI")
401 (set_attr "length" "4")])
402
403+;;(define_expand "extendqidi2"
404+;; [(set (match_operand:DI 0 "register_operand" "=d")
405+;; (sign_extend:DI (match_operand:QI 1 "general_operand" "d")))]
406+;; "TARGET_MB_64"
407+;; {
408+;; if (GET_CODE (operands[1]) != REG)
409+;; FAIL;
410+;; }
411+;;)
412+
413+
414+;;(define_insn "extendqidi2"
415+;; [(set (match_operand:DI 0 "register_operand" "=d")
416+;; (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
417+;; "TARGET_MB_64"
418+;; "sextl8\t%0,%1"
419+;; [(set_attr "type" "arith")
420+;; (set_attr "mode" "DI")
421+;; (set_attr "length" "4")])
422+
423 (define_insn "extendhisi2"
424 [(set (match_operand:SI 0 "register_operand" "=d")
425 (sign_extend:SI (match_operand:HI 1 "register_operand" "d")))]
426@@ -946,6 +1047,16 @@
427 (set_attr "mode" "SI")
428 (set_attr "length" "4")])
429
430+(define_insn "extendhidi2"
431+ [(set (match_operand:DI 0 "register_operand" "=d")
432+ (sign_extend:DI (match_operand:HI 1 "register_operand" "d")))]
433+ "TARGET_MB_64"
434+ "sextl16\t%0,%1"
435+ [(set_attr "type" "arith")
436+ (set_attr "mode" "DI")
437+ (set_attr "length" "4")])
438+
439+
440 ;; Those for integer source operand are ordered
441 ;; widest source type first.
442
443@@ -1011,7 +1122,6 @@
444 )
445
446
447-
448 (define_insn "*movdi_internal"
449 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
450 (match_operand:DI 1 "general_operand" " d,i,J,R,o,d,d"))]
451@@ -1423,6 +1533,36 @@
452 (set_attr "length" "4,4")]
453 )
454
455+;; Barrel shift left
456+(define_expand "ashldi3"
457+ [(set (match_operand:DI 0 "register_operand" "=&d")
458+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
459+ (match_operand:DI 2 "arith_operand" "")))]
460+"TARGET_MB_64"
461+{
462+;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
463+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
464+ {
465+ emit_insn(gen_ashldi3_long (operands[0], operands[1],operands[2]));
466+ DONE;
467+ }
468+else
469+ FAIL;
470+}
471+)
472+
473+(define_insn "ashldi3_long"
474+ [(set (match_operand:DI 0 "register_operand" "=d,d")
475+ (ashift:DI (match_operand:DI 1 "register_operand" "d,d")
476+ (match_operand:DI 2 "arith_operand" "I,d")))]
477+ "TARGET_MB_64"
478+ "@
479+ bsllli\t%0,%1,%2
480+ bslll\t%0,%1,%2"
481+ [(set_attr "type" "bshift,bshift")
482+ (set_attr "mode" "DI,DI")
483+ (set_attr "length" "4,4")]
484+)
485 ;; The following patterns apply when there is no barrel shifter present
486
487 (define_insn "*ashlsi3_with_mul_delay"
488@@ -1548,6 +1688,36 @@
489 ;;----------------------------------------------------------------
490 ;; 32-bit right shifts
491 ;;----------------------------------------------------------------
492+;; Barrel shift left
493+(define_expand "ashrdi3"
494+ [(set (match_operand:DI 0 "register_operand" "=&d")
495+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
496+ (match_operand:DI 2 "arith_operand" "")))]
497+"TARGET_MB_64"
498+{
499+;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
500+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
501+ {
502+ emit_insn(gen_ashrdi3_long (operands[0], operands[1],operands[2]));
503+ DONE;
504+ }
505+else
506+ FAIL;
507+}
508+)
509+
510+(define_insn "ashrdi3_long"
511+ [(set (match_operand:DI 0 "register_operand" "=d,d")
512+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
513+ (match_operand:DI 2 "arith_operand" "I,d")))]
514+ "TARGET_MB_64"
515+ "@
516+ bslrai\t%0,%1,%2
517+ bslra\t%0,%1,%2"
518+ [(set_attr "type" "bshift,bshift")
519+ (set_attr "mode" "DI,DI")
520+ (set_attr "length" "4,4")]
521+ )
522 (define_expand "ashrsi3"
523 [(set (match_operand:SI 0 "register_operand" "=&d")
524 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
525@@ -1657,6 +1827,36 @@
526 ;;----------------------------------------------------------------
527 ;; 32-bit right shifts (logical)
528 ;;----------------------------------------------------------------
529+;; Barrel shift left
530+(define_expand "lshrdi3"
531+ [(set (match_operand:DI 0 "register_operand" "=&d")
532+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
533+ (match_operand:DI 2 "arith_operand" "")))]
534+"TARGET_MB_64"
535+{
536+;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
537+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
538+ {
539+ emit_insn(gen_lshrdi3_long (operands[0], operands[1],operands[2]));
540+ DONE;
541+ }
542+else
543+ FAIL;
544+}
545+)
546+
547+(define_insn "lshrdi3_long"
548+ [(set (match_operand:DI 0 "register_operand" "=d,d")
549+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
550+ (match_operand:DI 2 "arith_operand" "I,d")))]
551+ "TARGET_MB_64"
552+ "@
553+ bslrli\t%0,%1,%2
554+ bslrl\t%0,%1,%2"
555+ [(set_attr "type" "bshift,bshift")
556+ (set_attr "mode" "DI,DI")
557+ (set_attr "length" "4,4")]
558+ )
559
560 (define_expand "lshrsi3"
561 [(set (match_operand:SI 0 "register_operand" "=&d")
562@@ -1803,6 +2003,8 @@
563 (set_attr "length" "4")]
564 )
565
566+
567+
568 ;;----------------------------------------------------------------
569 ;; Setting a register from an floating point comparison.
570 ;;----------------------------------------------------------------
571@@ -1818,6 +2020,18 @@
572 (set_attr "length" "4")]
573 )
574
575+(define_insn "cstoredf4"
576+ [(set (match_operand:DI 0 "register_operand" "=r")
577+ (match_operator:DI 1 "ordered_comparison_operator"
578+ [(match_operand:DF 2 "register_operand" "r")
579+ (match_operand:DF 3 "register_operand" "r")]))]
580+ "TARGET_MB_64"
581+ "dcmp.%C1\t%0,%3,%2"
582+ [(set_attr "type" "fcmp")
583+ (set_attr "mode" "DF")
584+ (set_attr "length" "4")]
585+)
586+
587 ;;----------------------------------------------------------------
588 ;; Conditional branches
589 ;;----------------------------------------------------------------
590@@ -1930,6 +2144,115 @@
591 (set_attr "length" "12")]
592 )
593
594+
595+(define_expand "cbranchdi4"
596+ [(set (pc)
597+ (if_then_else (match_operator 0 "ordered_comparison_operator"
598+ [(match_operand:DI 1 "register_operand")
599+ (match_operand:DI 2 "arith_operand" "I,i")])
600+ (label_ref (match_operand 3 ""))
601+ (pc)))]
602+ "TARGET_MB_64"
603+{
604+ microblaze_expand_conditional_branch (DImode, operands);
605+ DONE;
606+})
607+
608+(define_expand "cbranchdi4_reg"
609+ [(set (pc)
610+ (if_then_else (match_operator 0 "ordered_comparison_operator"
611+ [(match_operand:DI 1 "register_operand")
612+ (match_operand:DI 2 "register_operand")])
613+ (label_ref (match_operand 3 ""))
614+ (pc)))]
615+ "TARGET_MB_64"
616+{
617+ microblaze_expand_conditional_branch_reg (DImode, operands);
618+ DONE;
619+})
620+
621+(define_expand "cbranchdf4"
622+ [(set (pc)
623+ (if_then_else (match_operator 0 "ordered_comparison_operator"
624+ [(match_operand:DF 1 "register_operand")
625+ (match_operand:DF 2 "register_operand")])
626+ (label_ref (match_operand 3 ""))
627+ (pc)))]
628+ "TARGET_MB_64"
629+{
630+ microblaze_expand_conditional_branch_df (operands);
631+ DONE;
632+
633+})
634+
635+;; Used to implement comparison instructions
636+(define_expand "long_condjump"
637+ [(set (pc)
638+ (if_then_else (match_operand 0)
639+ (label_ref (match_operand 1))
640+ (pc)))])
641+
642+(define_insn "long_branch_zero"
643+ [(set (pc)
644+ (if_then_else (match_operator:DI 0 "ordered_comparison_operator"
645+ [(match_operand:DI 1 "register_operand" "d")
646+ (const_int 0)])
647+ (match_operand:DI 2 "pc_or_label_operand" "")
648+ (match_operand:DI 3 "pc_or_label_operand" "")))
649+ ]
650+ "TARGET_MB_64"
651+ {
652+ if (operands[3] == pc_rtx)
653+ return "beal%C0i%?\t%z1,%2";
654+ else
655+ return "beal%N0i%?\t%z1,%3";
656+ }
657+ [(set_attr "type" "branch")
658+ (set_attr "mode" "none")
659+ (set_attr "length" "4")]
660+)
661+
662+(define_insn "long_branch_compare"
663+ [(set (pc)
664+ (if_then_else (match_operator:DI 0 "cmp_op"
665+ [(match_operand:DI 1 "register_operand" "d")
666+ (match_operand:DI 2 "register_operand" "d")
667+ ])
668+ (label_ref (match_operand 3))
669+ (pc)))
670+ (clobber(reg:DI R_TMP))]
671+ "TARGET_MB_64"
672+ {
673+ operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
674+ enum rtx_code code = GET_CODE (operands[0]);
675+
676+ if (code == GT || code == LE)
677+ {
678+ output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
679+ code = swap_condition (code);
680+ }
681+ else if (code == GTU || code == LEU)
682+ {
683+ output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
684+ code = swap_condition (code);
685+ }
686+ else if (code == GE || code == LT)
687+ {
688+ output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
689+ }
690+ else if (code == GEU || code == LTU)
691+ {
692+ output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
693+ }
694+
695+ operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
696+ return "beal%C0i%?\tr18,%3";
697+ }
698+ [(set_attr "type" "branch")
699+ (set_attr "mode" "none")
700+ (set_attr "length" "12")]
701+)
702+
703 ;;----------------------------------------------------------------
704 ;; Unconditional branches
705 ;;----------------------------------------------------------------
706@@ -2478,17 +2801,33 @@
707 DONE;
708 }")
709
710-(define_expand "extzvsi"
711+(define_expand "extvsi"
712 [(set (match_operand:SI 0 "register_operand" "r")
713 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
714 (match_operand:SI 2 "immediate_operand" "I")
715 (match_operand:SI 3 "immediate_operand" "I")))]
716 "TARGET_HAS_BITFIELD"
717-""
718-)
719-
720+"
721+{
722+ unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
723+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
724+
725+ if ((len == 0) || (pos + len > 32) )
726+ FAIL;
727+
728+ ;;if (!register_operand (operands[1], VOIDmode))
729+ ;; FAIL;
730+ if (operands[0] == operands[1])
731+ FAIL;
732+ if (GET_CODE (operands[1]) == ASHIFT)
733+ FAIL;
734+;; operands[2] = GEN_INT(INTVAL(operands[2])+1 );
735+ emit_insn (gen_extv_32 (operands[0], operands[1],
736+ operands[2], operands[3]));
737+ DONE;
738+}")
739
740-(define_insn "extzv_32"
741+(define_insn "extv_32"
742 [(set (match_operand:SI 0 "register_operand" "=r")
743 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
744 (match_operand:SI 2 "immediate_operand" "I")
745@@ -2505,8 +2844,21 @@
746 (match_operand:SI 2 "immediate_operand" "I"))
747 (match_operand:SI 3 "register_operand" "r"))]
748 "TARGET_HAS_BITFIELD"
749-""
750-)
751+ "
752+{
753+ unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
754+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
755+
756+ if (len <= 0 || pos + len > 32)
757+ FAIL;
758+
759+ ;;if (!register_operand (operands[0], VOIDmode))
760+ ;; FAIL;
761+
762+ emit_insn (gen_insv_32 (operands[0], operands[1],
763+ operands[2], operands[3]));
764+ DONE;
765+}")
766
767 (define_insn "insv_32"
768 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
769diff --git a/gcc/config/microblaze/microblaze.opt b/gcc/config/microblaze/microblaze.opt
770index d23f376..f316e27 100644
771--- a/gcc/config/microblaze/microblaze.opt
772+++ b/gcc/config/microblaze/microblaze.opt
773@@ -136,4 +136,9 @@ Target
774
775 mxl-frequency
776 Target Mask(AREA_OPTIMIZED_2)
777-Use 8 stage pipeline (frequency optimization)
778+Use 8 stage pipeline (frequency optimization).
779+
780+m64
781+Target Mask(MB_64)
782+MicroBlaze 64-bit mode.
783+
784diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
785index 41fa9a9..e9a1921 100644
786--- a/gcc/config/microblaze/t-microblaze
787+++ b/gcc/config/microblaze/t-microblaze
788@@ -1,8 +1,11 @@
789-MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian
790-MULTILIB_DIRNAMES = bs m mh le
791+MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian m64
792+MULTILIB_DIRNAMES = bs m mh le m64
793 MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
794 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
795+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64
796 MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
797+MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
798+MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
799
800 # Extra files
801 microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.c \
802--
8032.7.4
804
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0040-Added-load-store-pattern-movdi-and-also-adding-missi.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0040-Added-load-store-pattern-movdi-and-also-adding-missi.patch
new file mode 100644
index 00000000..a973f4cd
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0040-Added-load-store-pattern-movdi-and-also-adding-missi.patch
@@ -0,0 +1,83 @@
1From 95615e1bfae642dc4f5f1b03e1ffaea4f16aa99c Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Wed, 4 Apr 2018 16:41:41 +0530
4Subject: [PATCH 40/63] Added load store pattern movdi and also adding missing
5 files
6
7---
8 gcc/config/microblaze/constraints.md | 5 +++++
9 gcc/config/microblaze/microblaze.md | 26 ++++++++++++++++++++++++++
10 gcc/config/microblaze/t-microblaze | 4 ++--
11 3 files changed, 33 insertions(+), 2 deletions(-)
12
13diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md
14index 5e1d79a..69bcb24 100644
15--- a/gcc/config/microblaze/constraints.md
16+++ b/gcc/config/microblaze/constraints.md
17@@ -52,6 +52,11 @@
18 (and (match_code "const_int")
19 (match_test "ival > 0 && ival < 0x10000")))
20
21+(define_constraint "K"
22+ "A constant in the range 0xffffff8000000000L to 0x0000007fffffffffL (inclusive)."
23+ (and (match_code "const_int")
24+ (match_test "ival > (long)0xffffff8000000000L && ival < (long)0x0000007fffffffffL")))
25+
26 ;; Define floating point constraints
27
28 (define_constraint "G"
29diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
30index dbb592e..eb52957 100644
31--- a/gcc/config/microblaze/microblaze.md
32+++ b/gcc/config/microblaze/microblaze.md
33@@ -1122,6 +1122,32 @@
34 )
35
36
37+(define_insn "*movdi_internal_64"
38+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
39+ (match_operand:DI 1 "general_operand" " d,K,J,R,o,d,d"))]
40+ "TARGET_MB_64 && (INTVAL(operands[1]) < 0x7fffffffff) && (INTVAL(operands[1]) > 0xffffff8000000000)"
41+ {
42+ switch (which_alternative)
43+ {
44+ case 0:
45+ return "addlk\t%0,%1";
46+ case 1:
47+ return "addlik\t%0,r0,%1";
48+ case 2:
49+ return "addlk\t%0,r0,r0";
50+ case 3:
51+ case 4:
52+ return "lli\t%0,%1";
53+ case 5:
54+ case 6:
55+ return "sli\t%1,%0";
56+ }
57+ return "unreachable";
58+ }
59+ [(set_attr "type" "no_delay_move,no_delay_arith,no_delay_arith,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
60+ (set_attr "mode" "DI")
61+ (set_attr "length" "8,8,8,8,12,8,12")])
62+
63 (define_insn "*movdi_internal"
64 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
65 (match_operand:DI 1 "general_operand" " d,i,J,R,o,d,d"))]
66diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
67index e9a1921..7671f63 100644
68--- a/gcc/config/microblaze/t-microblaze
69+++ b/gcc/config/microblaze/t-microblaze
70@@ -4,8 +4,8 @@ MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
71 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
72 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64
73 MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
74-MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
75-MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
76+#MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
77+#MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
78
79 # Extra files
80 microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.c \
81--
822.7.4
83
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0041-Intial-commit-for-64bit-MB-sources.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0041-Intial-commit-for-64bit-MB-sources.patch
new file mode 100644
index 00000000..b022eb77
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0041-Intial-commit-for-64bit-MB-sources.patch
@@ -0,0 +1,2463 @@
1From 7c68b1c9771f09f7cc53410248e8432c562d24bf Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 27 Jul 2018 15:23:41 +0530
4Subject: [PATCH 41/63] Intial commit for 64bit-MB sources. Need to cleanup the
5 code later.
6
7---
8 gcc/config/microblaze/constraints.md | 2 +-
9 gcc/config/microblaze/microblaze-c.c | 6 +
10 gcc/config/microblaze/microblaze.c | 218 ++++++++----
11 gcc/config/microblaze/microblaze.h | 63 ++--
12 gcc/config/microblaze/microblaze.md | 606 ++++++++++++++++++++++++--------
13 gcc/config/microblaze/t-microblaze | 7 +-
14 libgcc/config/microblaze/crti.S | 4 +-
15 libgcc/config/microblaze/crtn.S | 4 +-
16 libgcc/config/microblaze/divdi3.S | 98 ++++++
17 libgcc/config/microblaze/divdi3_table.c | 62 ++++
18 libgcc/config/microblaze/moddi3.S | 97 +++++
19 libgcc/config/microblaze/muldi3.S | 73 ++++
20 libgcc/config/microblaze/t-microblaze | 11 +-
21 libgcc/config/microblaze/udivdi3.S | 107 ++++++
22 libgcc/config/microblaze/umoddi3.S | 110 ++++++
23 15 files changed, 1232 insertions(+), 236 deletions(-)
24 create mode 100644 libgcc/config/microblaze/divdi3.S
25 create mode 100644 libgcc/config/microblaze/divdi3_table.c
26 create mode 100644 libgcc/config/microblaze/moddi3.S
27 create mode 100644 libgcc/config/microblaze/muldi3.S
28 create mode 100644 libgcc/config/microblaze/udivdi3.S
29 create mode 100644 libgcc/config/microblaze/umoddi3.S
30
31diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md
32index 69bcb24..2fce91e 100644
33--- a/gcc/config/microblaze/constraints.md
34+++ b/gcc/config/microblaze/constraints.md
35@@ -55,7 +55,7 @@
36 (define_constraint "K"
37 "A constant in the range 0xffffff8000000000L to 0x0000007fffffffffL (inclusive)."
38 (and (match_code "const_int")
39- (match_test "ival > (long)0xffffff8000000000L && ival < (long)0x0000007fffffffffL")))
40+ (match_test "ival > (long)-549755813888 && ival < (long)549755813887")))
41
42 ;; Define floating point constraints
43
44diff --git a/gcc/config/microblaze/microblaze-c.c b/gcc/config/microblaze/microblaze-c.c
45index cd21319..d2b0c76 100644
46--- a/gcc/config/microblaze/microblaze-c.c
47+++ b/gcc/config/microblaze/microblaze-c.c
48@@ -100,4 +100,10 @@ microblaze_cpp_define (cpp_reader *pfile)
49 builtin_define ("HAVE_HW_FPU_SQRT");
50 builtin_define ("__HAVE_HW_FPU_SQRT__");
51 }
52+ if (TARGET_MB_64)
53+ {
54+ builtin_define ("__arch64__");
55+ builtin_define ("__microblaze64__");
56+ builtin_define ("__MICROBLAZE64__");
57+ }
58 }
59diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
60index f740f5c..d5ff7af 100644
61--- a/gcc/config/microblaze/microblaze.c
62+++ b/gcc/config/microblaze/microblaze.c
63@@ -383,10 +383,10 @@ simple_memory_operand (rtx op, machine_mode mode ATTRIBUTE_UNUSED)
64 {
65 return 1;
66 }
67- else if (GET_CODE (plus0) == REG && GET_CODE (plus1) == REG)
68+ /*else if (GET_CODE (plus0) == REG && GET_CODE (plus1) == REG)
69 {
70 return 1;
71- }
72+ }*/
73 else
74 return 0;
75
76@@ -434,7 +434,7 @@ double_memory_operand (rtx op, machine_mode mode)
77 return 1;
78
79 return memory_address_p ((GET_MODE_CLASS (mode) == MODE_INT
80- ? E_SImode : E_SFmode),
81+ ? Pmode : E_SFmode),
82 plus_constant (Pmode, addr, 4));
83 }
84
85@@ -681,7 +681,7 @@ microblaze_legitimize_tls_address(rtx x, rtx reg)
86 /* Load the addend. */
87 addend = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, x, GEN_INT (TLS_DTPREL)),
88 UNSPEC_TLS);
89- addend = force_reg (SImode, gen_rtx_CONST (SImode, addend));
90+ addend = force_reg (Pmode, gen_rtx_CONST (Pmode, addend));
91 dest = gen_rtx_PLUS (Pmode, dest, addend);
92 break;
93
94@@ -699,7 +699,7 @@ microblaze_classify_unspec (struct microblaze_address_info *info, rtx x)
95
96 if (XINT (x, 1) == UNSPEC_GOTOFF)
97 {
98- info->regA = gen_rtx_REG (SImode, PIC_OFFSET_TABLE_REGNUM);
99+ info->regA = gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM);
100 info->type = ADDRESS_GOTOFF;
101 }
102 else if (XINT (x, 1) == UNSPEC_PLT)
103@@ -1302,8 +1302,16 @@ microblaze_block_move_loop (rtx dest, rtx src, HOST_WIDE_INT length)
104 emit_move_insn (dest_reg, plus_constant (Pmode, dest_reg, MAX_MOVE_BYTES));
105
106 /* Emit the test & branch. */
107- emit_insn (gen_cbranchsi4 (gen_rtx_NE (SImode, src_reg, final_src),
108+
109+ if (TARGET_MB_64) {
110+ emit_insn (gen_cbranchdi4 (gen_rtx_NE (Pmode, src_reg, final_src),
111+ src_reg, final_src, label));
112+ }
113+ else {
114+ emit_insn (gen_cbranchsi4 (gen_rtx_NE (Pmode, src_reg, final_src),
115 src_reg, final_src, label));
116+
117+ }
118
119 /* Mop up any left-over bytes. */
120 if (leftover)
121@@ -1634,14 +1642,20 @@ microblaze_function_arg_advance (cumulative_args_t cum_v,
122 break;
123
124 case E_DFmode:
125- cum->arg_words += 2;
126+ if (TARGET_MB_64)
127+ cum->arg_words++;
128+ else
129+ cum->arg_words += 2;
130 if (!cum->gp_reg_found && cum->arg_number <= 2)
131 cum->fp_code += 2 << ((cum->arg_number - 1) * 2);
132 break;
133
134 case E_DImode:
135 cum->gp_reg_found = 1;
136- cum->arg_words += 2;
137+ if (TARGET_MB_64)
138+ cum->arg_words++;
139+ else
140+ cum->arg_words += 2;
141 break;
142
143 case E_QImode:
144@@ -2295,7 +2309,7 @@ compute_frame_size (HOST_WIDE_INT size)
145
146 if (regno != MB_ABI_SUB_RETURN_ADDR_REGNUM)
147 /* Don't account for link register. It is accounted specially below. */
148- gp_reg_size += GET_MODE_SIZE (SImode);
149+ gp_reg_size += GET_MODE_SIZE (Pmode);
150
151 mask |= (1L << (regno - GP_REG_FIRST));
152 }
153@@ -2564,7 +2578,7 @@ print_operand (FILE * file, rtx op, int letter)
154
155 if ((letter == 'M' && !WORDS_BIG_ENDIAN)
156 || (letter == 'L' && WORDS_BIG_ENDIAN) || letter == 'D')
157- regnum++;
158+ regnum++;
159
160 fprintf (file, "%s", reg_names[regnum]);
161 }
162@@ -2590,6 +2604,7 @@ print_operand (FILE * file, rtx op, int letter)
163 else if (letter == 'h' || letter == 'j')
164 {
165 long val[2];
166+ int val1[2];
167 long l[2];
168 if (code == CONST_DOUBLE)
169 {
170@@ -2602,12 +2617,12 @@ print_operand (FILE * file, rtx op, int letter)
171 val[0] = l[WORDS_BIG_ENDIAN != 0];
172 }
173 }
174- else if (code == CONST_INT)
175+ else if (code == CONST_INT || code == CONST)// || code == SYMBOL_REF ||code == LABEL_REF)
176 {
177- val[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
178- val[1] = INTVAL (op) & 0x00000000ffffffffLL;
179+ val1[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
180+ val1[1] = INTVAL (op) & 0x00000000ffffffffLL;
181 }
182- fprintf (file, "0x%8.8lx", (letter == 'h') ? val[0] : val[1]);
183+ fprintf (file, "0x%8.8lx", (letter == 'h') ? val1[0] : val1[1]);
184 }
185 else if (code == CONST_DOUBLE)
186 {
187@@ -2801,7 +2816,10 @@ microblaze_asm_constructor (rtx symbol ATTRIBUTE_UNUSED, int priority)
188
189 switch_to_section (get_section (section, 0, NULL));
190 assemble_align (POINTER_SIZE);
191- fputs ("\t.word\t", asm_out_file);
192+ if (TARGET_MB_64)
193+ fputs ("\t.dword\t", asm_out_file);
194+ else
195+ fputs ("\t.word\t", asm_out_file);
196 output_addr_const (asm_out_file, symbol);
197 fputs ("\n", asm_out_file);
198 }
199@@ -2824,7 +2842,10 @@ microblaze_asm_destructor (rtx symbol, int priority)
200
201 switch_to_section (get_section (section, 0, NULL));
202 assemble_align (POINTER_SIZE);
203- fputs ("\t.word\t", asm_out_file);
204+ if (TARGET_MB_64)
205+ fputs ("\t.dword\t", asm_out_file);
206+ else
207+ fputs ("\t.word\t", asm_out_file);
208 output_addr_const (asm_out_file, symbol);
209 fputs ("\n", asm_out_file);
210 }
211@@ -2890,7 +2911,7 @@ save_restore_insns (int prologue)
212 /* For interrupt_handlers, need to save/restore the MSR. */
213 if (microblaze_is_interrupt_variant ())
214 {
215- isr_mem_rtx = gen_rtx_MEM (SImode,
216+ isr_mem_rtx = gen_rtx_MEM (Pmode,
217 gen_rtx_PLUS (Pmode, base_reg_rtx,
218 GEN_INT (current_frame_info.
219 gp_offset -
220@@ -2898,8 +2919,8 @@ save_restore_insns (int prologue)
221
222 /* Do not optimize in flow analysis. */
223 MEM_VOLATILE_P (isr_mem_rtx) = 1;
224- isr_reg_rtx = gen_rtx_REG (SImode, MB_ABI_MSR_SAVE_REG);
225- isr_msr_rtx = gen_rtx_REG (SImode, ST_REG);
226+ isr_reg_rtx = gen_rtx_REG (Pmode, MB_ABI_MSR_SAVE_REG);
227+ isr_msr_rtx = gen_rtx_REG (Pmode, ST_REG);
228 }
229
230 if (microblaze_is_interrupt_variant () && !prologue)
231@@ -2907,8 +2928,8 @@ save_restore_insns (int prologue)
232 emit_move_insn (isr_reg_rtx, isr_mem_rtx);
233 emit_move_insn (isr_msr_rtx, isr_reg_rtx);
234 /* Do not optimize in flow analysis. */
235- emit_insn (gen_rtx_USE (SImode, isr_reg_rtx));
236- emit_insn (gen_rtx_USE (SImode, isr_msr_rtx));
237+ emit_insn (gen_rtx_USE (Pmode, isr_reg_rtx));
238+ emit_insn (gen_rtx_USE (Pmode, isr_msr_rtx));
239 }
240
241 for (regno = GP_REG_FIRST; regno <= GP_REG_LAST; regno++)
242@@ -2919,9 +2940,9 @@ save_restore_insns (int prologue)
243 /* Don't handle here. Already handled as the first register. */
244 continue;
245
246- reg_rtx = gen_rtx_REG (SImode, regno);
247+ reg_rtx = gen_rtx_REG (Pmode, regno);
248 insn = gen_rtx_PLUS (Pmode, base_reg_rtx, GEN_INT (gp_offset));
249- mem_rtx = gen_rtx_MEM (SImode, insn);
250+ mem_rtx = gen_rtx_MEM (Pmode, insn);
251 if (microblaze_is_interrupt_variant () || save_volatiles)
252 /* Do not optimize in flow analysis. */
253 MEM_VOLATILE_P (mem_rtx) = 1;
254@@ -2936,7 +2957,7 @@ save_restore_insns (int prologue)
255 insn = emit_move_insn (reg_rtx, mem_rtx);
256 }
257
258- gp_offset += GET_MODE_SIZE (SImode);
259+ gp_offset += GET_MODE_SIZE (Pmode);
260 }
261 }
262
263@@ -2946,8 +2967,8 @@ save_restore_insns (int prologue)
264 emit_move_insn (isr_mem_rtx, isr_reg_rtx);
265
266 /* Do not optimize in flow analysis. */
267- emit_insn (gen_rtx_USE (SImode, isr_reg_rtx));
268- emit_insn (gen_rtx_USE (SImode, isr_msr_rtx));
269+ emit_insn (gen_rtx_USE (Pmode, isr_reg_rtx));
270+ emit_insn (gen_rtx_USE (Pmode, isr_msr_rtx));
271 }
272
273 /* Done saving and restoring */
274@@ -3037,7 +3058,10 @@ microblaze_elf_asm_cdtor (rtx symbol, int priority, bool is_ctor)
275
276 switch_to_section (s);
277 assemble_align (POINTER_SIZE);
278- fputs ("\t.word\t", asm_out_file);
279+ if (TARGET_MB_64)
280+ fputs ("\t.dword\t", asm_out_file);
281+ else
282+ fputs ("\t.word\t", asm_out_file);
283 output_addr_const (asm_out_file, symbol);
284 fputs ("\n", asm_out_file);
285 }
286@@ -3182,10 +3206,10 @@ microblaze_expand_prologue (void)
287 {
288 if (offset != 0)
289 ptr = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (offset));
290- emit_move_insn (gen_rtx_MEM (SImode, ptr),
291- gen_rtx_REG (SImode, regno));
292+ emit_move_insn (gen_rtx_MEM (Pmode, ptr),
293+ gen_rtx_REG (Pmode, regno));
294
295- offset += GET_MODE_SIZE (SImode);
296+ offset += GET_MODE_SIZE (Pmode);
297 }
298 }
299
300@@ -3194,15 +3218,23 @@ microblaze_expand_prologue (void)
301 rtx fsiz_rtx = GEN_INT (fsiz);
302
303 rtx_insn *insn = NULL;
304- insn = emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
305+ if (TARGET_MB_64)
306+ {
307+
308+ insn = emit_insn (gen_subdi3 (stack_pointer_rtx, stack_pointer_rtx,
309 fsiz_rtx));
310+ }
311+ else {
312+ insn = emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
313+ fsiz_rtx));
314+ }
315 if (insn)
316 RTX_FRAME_RELATED_P (insn) = 1;
317
318 /* Handle SUB_RETURN_ADDR_REGNUM specially at first. */
319 if (!crtl->is_leaf || interrupt_handler)
320 {
321- mem_rtx = gen_rtx_MEM (SImode,
322+ mem_rtx = gen_rtx_MEM (Pmode,
323 gen_rtx_PLUS (Pmode, stack_pointer_rtx,
324 const0_rtx));
325
326@@ -3210,7 +3242,7 @@ microblaze_expand_prologue (void)
327 /* Do not optimize in flow analysis. */
328 MEM_VOLATILE_P (mem_rtx) = 1;
329
330- reg_rtx = gen_rtx_REG (SImode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
331+ reg_rtx = gen_rtx_REG (Pmode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
332 insn = emit_move_insn (mem_rtx, reg_rtx);
333 RTX_FRAME_RELATED_P (insn) = 1;
334 }
335@@ -3320,12 +3352,12 @@ microblaze_expand_epilogue (void)
336 if (!crtl->is_leaf || interrupt_handler)
337 {
338 mem_rtx =
339- gen_rtx_MEM (SImode,
340+ gen_rtx_MEM (Pmode,
341 gen_rtx_PLUS (Pmode, stack_pointer_rtx, const0_rtx));
342 if (interrupt_handler)
343 /* Do not optimize in flow analysis. */
344 MEM_VOLATILE_P (mem_rtx) = 1;
345- reg_rtx = gen_rtx_REG (SImode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
346+ reg_rtx = gen_rtx_REG (Pmode, MB_ABI_SUB_RETURN_ADDR_REGNUM);
347 emit_move_insn (reg_rtx, mem_rtx);
348 }
349
350@@ -3341,15 +3373,25 @@ microblaze_expand_epilogue (void)
351 /* _restore_ registers for epilogue. */
352 save_restore_insns (0);
353 emit_insn (gen_blockage ());
354- emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
355+ if (TARGET_MB_64)
356+ emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
357+ else
358+ emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
359 }
360
361 if (crtl->calls_eh_return)
362- emit_insn (gen_addsi3 (stack_pointer_rtx,
363+ if (TARGET_MB_64) {
364+ emit_insn (gen_adddi3 (stack_pointer_rtx,
365 stack_pointer_rtx,
366- gen_raw_REG (SImode,
367+ gen_raw_REG (Pmode,
368 MB_EH_STACKADJ_REGNUM)));
369-
370+ }
371+ else {
372+ emit_insn (gen_addsi3 (stack_pointer_rtx,
373+ stack_pointer_rtx,
374+ gen_raw_REG (Pmode,
375+ MB_EH_STACKADJ_REGNUM)));
376+ }
377 emit_jump_insn (gen_return_internal (gen_rtx_REG (Pmode, GP_REG_FIRST +
378 MB_ABI_SUB_RETURN_ADDR_REGNUM)));
379 }
380@@ -3515,9 +3557,14 @@ microblaze_asm_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
381 else
382 this_rtx = gen_rtx_REG (Pmode, MB_ABI_FIRST_ARG_REGNUM);
383
384- /* Apply the constant offset, if required. */
385+ /* Apply the constant offset, if required. */
386 if (delta)
387- emit_insn (gen_addsi3 (this_rtx, this_rtx, GEN_INT (delta)));
388+ {
389+ if (TARGET_MB_64)
390+ emit_insn (gen_adddi3 (this_rtx, this_rtx, GEN_INT (delta)));
391+ else
392+ emit_insn (gen_addsi3 (this_rtx, this_rtx, GEN_INT (delta)));
393+ }
394
395 /* Apply the offset from the vtable, if required. */
396 if (vcall_offset)
397@@ -3530,7 +3577,10 @@ microblaze_asm_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
398 rtx loc = gen_rtx_PLUS (Pmode, temp1, vcall_offset_rtx);
399 emit_move_insn (temp1, gen_rtx_MEM (Pmode, loc));
400
401- emit_insn (gen_addsi3 (this_rtx, this_rtx, temp1));
402+ if (TARGET_MB_64)
403+ emit_insn (gen_adddi3 (this_rtx, this_rtx, temp1));
404+ else
405+ emit_insn (gen_addsi3 (this_rtx, this_rtx, temp1));
406 }
407
408 /* Generate a tail call to the target function. */
409@@ -3704,7 +3754,7 @@ microblaze_eh_return (rtx op0)
410 /* Queue an .ident string in the queue of top-level asm statements.
411 If the string size is below the threshold, put it into .sdata2.
412 If the front-end is done, we must be being called from toplev.c.
413- In that case, do nothing. */
414+ In that case, do nothing. */
415 void
416 microblaze_asm_output_ident (const char *string)
417 {
418@@ -3759,9 +3809,9 @@ microblaze_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
419 emit_block_move (m_tramp, assemble_trampoline_template (),
420 GEN_INT (6*UNITS_PER_WORD), BLOCK_OP_NORMAL);
421
422- mem = adjust_address (m_tramp, SImode, 16);
423+ mem = adjust_address (m_tramp, Pmode, 16);
424 emit_move_insn (mem, chain_value);
425- mem = adjust_address (m_tramp, SImode, 20);
426+ mem = adjust_address (m_tramp, Pmode, 20);
427 emit_move_insn (mem, fnaddr);
428 }
429
430@@ -3785,7 +3835,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
431 {
432 comp_reg = cmp_op0;
433 condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
434- if (mode == SImode)
435+ if (mode == Pmode)
436 emit_jump_insn (gen_condjump (condition, label1));
437 else
438 emit_jump_insn (gen_long_condjump (condition, label1));
439@@ -3904,7 +3954,7 @@ microblaze_expand_conditional_branch_sf (rtx operands[])
440 rtx comp_reg = gen_reg_rtx (SImode);
441
442 emit_insn (gen_cstoresf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
443- condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
444+ condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
445 emit_jump_insn (gen_condjump (condition, operands[3]));
446 }
447
448@@ -3914,10 +3964,10 @@ microblaze_expand_conditional_branch_df (rtx operands[])
449 rtx condition;
450 rtx cmp_op0 = XEXP (operands[0], 0);
451 rtx cmp_op1 = XEXP (operands[0], 1);
452- rtx comp_reg = gen_reg_rtx (DImode);
453+ rtx comp_reg = gen_reg_rtx (Pmode);
454
455 emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
456- condition = gen_rtx_NE (DImode, comp_reg, const0_rtx);
457+ condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
458 emit_jump_insn (gen_long_condjump (condition, operands[3]));
459 }
460
461@@ -3938,8 +3988,8 @@ microblaze_expand_divide (rtx operands[])
462 {
463 /* Table lookup software divides. Works for all (nr/dr) where (0 <= nr,dr <= 15). */
464
465- rtx regt1 = gen_reg_rtx (SImode);
466- rtx reg18 = gen_rtx_REG (SImode, R_TMP);
467+ rtx regt1 = gen_reg_rtx (Pmode);
468+ rtx reg18 = gen_rtx_REG (Pmode, R_TMP);
469 rtx regqi = gen_reg_rtx (QImode);
470 rtx_code_label *div_label = gen_label_rtx ();
471 rtx_code_label *div_end_label = gen_label_rtx ();
472@@ -3947,17 +3997,31 @@ microblaze_expand_divide (rtx operands[])
473 rtx mem_rtx;
474 rtx ret;
475 rtx_insn *jump, *cjump, *insn;
476-
477- insn = emit_insn (gen_iorsi3 (regt1, operands[1], operands[2]));
478- cjump = emit_jump_insn_after (gen_cbranchsi4 (
479- gen_rtx_GTU (SImode, regt1, GEN_INT (15)),
480+
481+ if (TARGET_MB_64) {
482+ insn = emit_insn (gen_iordi3 (regt1, operands[1], operands[2]));
483+ cjump = emit_jump_insn_after (gen_cbranchdi4 (
484+ gen_rtx_GTU (Pmode, regt1, GEN_INT (15)),
485+ regt1, GEN_INT (15), div_label), insn);
486+ }
487+ else {
488+ insn = emit_insn (gen_iorsi3 (regt1, operands[1], operands[2]));
489+ cjump = emit_jump_insn_after (gen_cbranchsi4 (
490+ gen_rtx_GTU (Pmode, regt1, GEN_INT (15)),
491 regt1, GEN_INT (15), div_label), insn);
492+ }
493 LABEL_NUSES (div_label) = 1;
494 JUMP_LABEL (cjump) = div_label;
495- emit_insn (gen_rtx_CLOBBER (SImode, reg18));
496+ emit_insn (gen_rtx_CLOBBER (Pmode, reg18));
497
498- emit_insn (gen_ashlsi3_bshift (regt1, operands[1], GEN_INT(4)));
499- emit_insn (gen_addsi3 (regt1, regt1, operands[2]));
500+ if (TARGET_MB_64) {
501+ emit_insn (gen_ashldi3_long (regt1, operands[1], GEN_INT(4)));
502+ emit_insn (gen_adddi3 (regt1, regt1, operands[2]));
503+ }
504+ else {
505+ emit_insn (gen_ashlsi3_bshift (regt1, operands[1], GEN_INT(4)));
506+ emit_insn (gen_addsi3 (regt1, regt1, operands[2]));
507+ }
508 mem_rtx = gen_rtx_MEM (QImode,
509 gen_rtx_PLUS (QImode, regt1, div_table_rtx));
510
511@@ -4104,7 +4168,7 @@ insert_wic_for_ilb_runout (rtx_insn *first)
512 {
513 insn =
514 emit_insn_before (gen_iprefetch
515- (gen_int_mode (addr_offset, SImode)),
516+ (gen_int_mode (addr_offset, Pmode)),
517 before_4);
518 recog_memoized (insn);
519 INSN_LOCATION (insn) = INSN_LOCATION (before_4);
520@@ -4114,7 +4178,27 @@ insert_wic_for_ilb_runout (rtx_insn *first)
521 }
522 }
523 }
524-
525+
526+/* Set the names for various arithmetic operations according to the
527+ * MICROBLAZE ABI. */
528+static void
529+microblaze_init_libfuncs (void)
530+{
531+ set_optab_libfunc (smod_optab, SImode, "__modsi3");
532+ set_optab_libfunc (sdiv_optab, SImode, "__divsi3");
533+ set_optab_libfunc (smul_optab, SImode, "__mulsi3");
534+ set_optab_libfunc (umod_optab, SImode, "__umodsi3");
535+ set_optab_libfunc (udiv_optab, SImode, "__udivsi3");
536+
537+ if (TARGET_MB_64)
538+ {
539+ set_optab_libfunc (smod_optab, DImode, "__moddi3");
540+ set_optab_libfunc (sdiv_optab, DImode, "__divdi3");
541+ set_optab_libfunc (smul_optab, DImode, "__muldi3");
542+ set_optab_libfunc (umod_optab, DImode, "__umoddi3");
543+ set_optab_libfunc (udiv_optab, DImode, "__udivdi3");
544+ }
545+}
546 /* Insert instruction prefetch instruction at the fall
547 through path of the function call. */
548
549@@ -4267,6 +4351,17 @@ microblaze_starting_frame_offset (void)
550 #undef TARGET_LRA_P
551 #define TARGET_LRA_P hook_bool_void_false
552
553+#ifdef TARGET_MB_64
554+#undef TARGET_ASM_ALIGNED_DI_OP
555+#define TARGET_ASM_ALIGNED_DI_OP "\t.dword\t"
556+
557+#undef TARGET_ASM_ALIGNED_HI_OP
558+#define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t"
559+
560+#undef TARGET_ASM_ALIGNED_SI_OP
561+#define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
562+#endif
563+
564 #undef TARGET_FRAME_POINTER_REQUIRED
565 #define TARGET_FRAME_POINTER_REQUIRED microblaze_frame_pointer_required
566
567@@ -4276,6 +4371,9 @@ microblaze_starting_frame_offset (void)
568 #undef TARGET_TRAMPOLINE_INIT
569 #define TARGET_TRAMPOLINE_INIT microblaze_trampoline_init
570
571+#undef TARGET_INIT_LIBFUNCS
572+#define TARGET_INIT_LIBFUNCS microblaze_init_libfuncs
573+
574 #undef TARGET_PROMOTE_FUNCTION_MODE
575 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
576
577diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
578index 2ca44f5..a23fd4e 100644
579--- a/gcc/config/microblaze/microblaze.h
580+++ b/gcc/config/microblaze/microblaze.h
581@@ -173,7 +173,6 @@ extern enum pipeline_type microblaze_pipe;
582
583 /* Generate DWARF exception handling info. */
584 #define DWARF2_UNWIND_INFO 1
585-
586 /* Don't generate .loc operations. */
587 #define DWARF2_ASM_LINE_DEBUG_INFO 0
588
589@@ -206,38 +205,51 @@ extern enum pipeline_type microblaze_pipe;
590 ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr)
591
592 /* Use DWARF 2 debugging information by default. */
593-#define DWARF2_DEBUGGING_INFO
594+#define DWARF2_DEBUGGING_INFO 1
595 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
596+#define DWARF2_ADDR_SIZE 4
597
598 /* Target machine storage layout */
599
600 #define BITS_BIG_ENDIAN 0
601 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0)
602 #define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN)
603-#define BITS_PER_WORD 32
604-#define UNITS_PER_WORD 4
605+//#define BITS_PER_WORD 64
606+//Revisit
607+#define MAX_BITS_PER_WORD 64
608+#define UNITS_PER_WORD (TARGET_MB_64 ? 8 : 4)
609+//#define MIN_UNITS_PER_WORD (TARGET_MB_64 ? 8 : 4)
610+//#define UNITS_PER_WORD 4
611 #define MIN_UNITS_PER_WORD 4
612 #define INT_TYPE_SIZE 32
613 #define SHORT_TYPE_SIZE 16
614-#define LONG_TYPE_SIZE 64
615+#define LONG_TYPE_SIZE (TARGET_MB_64 ? 64 : 32)
616 #define LONG_LONG_TYPE_SIZE 64
617 #define FLOAT_TYPE_SIZE 32
618 #define DOUBLE_TYPE_SIZE 64
619 #define LONG_DOUBLE_TYPE_SIZE 64
620-#define POINTER_SIZE 32
621-#define PARM_BOUNDARY 32
622-#define FUNCTION_BOUNDARY 32
623-#define EMPTY_FIELD_BOUNDARY 32
624+#define POINTER_SIZE (TARGET_MB_64 ? 64 : 32)
625+//#define WIDEST_HARDWARE_FP_SIZE 64
626+//#define POINTERS_EXTEND_UNSIGNED 1
627+#define PARM_BOUNDARY (TARGET_MB_64 ? 64 : 32)
628+#define FUNCTION_BOUNDARY (TARGET_MB_64 ? 64 : 32)
629+#define EMPTY_FIELD_BOUNDARY (TARGET_MB_64 ? 64 : 32)
630 #define STRUCTURE_SIZE_BOUNDARY 8
631-#define BIGGEST_ALIGNMENT 32
632+#define BIGGEST_ALIGNMENT (TARGET_MB_64 ? 64 : 32)
633 #define STRICT_ALIGNMENT 1
634 #define PCC_BITFIELD_TYPE_MATTERS 1
635
636+//#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_MB_64 ? TImode : DImode)
637 #undef SIZE_TYPE
638-#define SIZE_TYPE "unsigned int"
639+#define SIZE_TYPE (TARGET_MB_64 ? "long unsigned int" : "unsigned int")
640
641 #undef PTRDIFF_TYPE
642-#define PTRDIFF_TYPE "int"
643+#define PTRDIFF_TYPE (TARGET_MB_64 ? "long int" : "int")
644+
645+/*#undef INTPTR_TYPE
646+#define INTPTR_TYPE (TARGET_MB_64 ? "long int" : "int")*/
647+#undef UINTPTR_TYPE
648+#define UINTPTR_TYPE (TARGET_MB_64 ? "long unsigned int" : "unsigned int")
649
650 #define DATA_ALIGNMENT(TYPE, ALIGN) \
651 ((((ALIGN) < BITS_PER_WORD) \
652@@ -253,12 +265,12 @@ extern enum pipeline_type microblaze_pipe;
653 #define WORD_REGISTER_OPERATIONS 1
654
655 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
656-
657+/*
658 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
659 if (GET_MODE_CLASS (MODE) == MODE_INT \
660- && GET_MODE_SIZE (MODE) < 4) \
661- (MODE) = SImode;
662-
663+ && GET_MODE_SIZE (MODE) < (TARGET_MB_64 ? 8 : 4)) \
664+ (MODE) = TARGET_MB_64 ? DImode : SImode;
665+*/
666 /* Standard register usage. */
667
668 /* On the MicroBlaze, we have 32 integer registers */
669@@ -438,13 +450,16 @@ extern struct microblaze_frame_info current_frame_info;
670 #define FIRST_PARM_OFFSET(FNDECL) (UNITS_PER_WORD)
671
672 #define ARG_POINTER_CFA_OFFSET(FNDECL) 0
673+#define DWARF_CIE_DATA_ALIGNMENT -1
674
675 #define REG_PARM_STACK_SPACE(FNDECL) microblaze_reg_parm_stack_space(FNDECL)
676
677 #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
678
679-#define STACK_BOUNDARY 32
680+#define STACK_BOUNDARY (TARGET_MB_64 ? 64 : 32)
681
682+#define PREFERRED_STACK_BOUNDARY (TARGET_MB_64 ? 64 : 32)
683+
684 #define NUM_OF_ARGS 6
685
686 #define GP_RETURN (GP_REG_FIRST + MB_ABI_INT_RETURN_VAL_REGNUM)
687@@ -455,12 +470,15 @@ extern struct microblaze_frame_info current_frame_info;
688 #define MAX_ARGS_IN_REGISTERS MB_ABI_MAX_ARG_REGS
689
690 #define LIBCALL_VALUE(MODE) \
691+ gen_rtx_REG (MODE,GP_RETURN)
692+
693+/*#define LIBCALL_VALUE(MODE) \
694 gen_rtx_REG ( \
695 ((GET_MODE_CLASS (MODE) != MODE_INT \
696 || GET_MODE_SIZE (MODE) >= 4) \
697 ? (MODE) \
698 : SImode), GP_RETURN)
699-
700+*/
701 /* 1 if N is a possible register number for a function value.
702 On the MicroBlaze, R2 R3 are the only register thus used.
703 Currently, R2 are only implemented here (C has no complex type) */
704@@ -500,7 +518,7 @@ typedef struct microblaze_args
705 /* 4 insns + 2 words of data. */
706 #define TRAMPOLINE_SIZE (6 * 4)
707
708-#define TRAMPOLINE_ALIGNMENT 32
709+#define TRAMPOLINE_ALIGNMENT 64
710
711 #define REGNO_OK_FOR_BASE_P(regno) microblaze_regno_ok_for_base_p ((regno), 1)
712
713@@ -529,13 +547,13 @@ typedef struct microblaze_args
714 addresses which require two reload registers. */
715 #define LEGITIMATE_PIC_OPERAND_P(X) microblaze_legitimate_pic_operand (X)
716
717-#define CASE_VECTOR_MODE (SImode)
718+#define CASE_VECTOR_MODE (TARGET_MB_64? DImode:SImode)
719
720 #ifndef DEFAULT_SIGNED_CHAR
721 #define DEFAULT_SIGNED_CHAR 1
722 #endif
723
724-#define MOVE_MAX 4
725+#define MOVE_MAX (TARGET_MB_64 ? 8 : 4)
726 #define MAX_MOVE_MAX 8
727
728 #define SLOW_BYTE_ACCESS 1
729@@ -545,7 +563,7 @@ typedef struct microblaze_args
730
731 #define SHIFT_COUNT_TRUNCATED 1
732
733-#define Pmode SImode
734+#define Pmode (TARGET_MB_64? DImode:SImode)
735
736 #define FUNCTION_MODE SImode
737
738@@ -707,6 +725,7 @@ do { \
739
740 #undef TARGET_ASM_OUTPUT_IDENT
741 #define TARGET_ASM_OUTPUT_IDENT microblaze_asm_output_ident
742+//#define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
743
744 /* Default to -G 8 */
745 #ifndef MICROBLAZE_DEFAULT_GVALUE
746diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
747index eb52957..77627a7 100644
748--- a/gcc/config/microblaze/microblaze.md
749+++ b/gcc/config/microblaze/microblaze.md
750@@ -26,6 +26,7 @@
751 ;; Constants
752 ;;----------------------------------------------------
753 (define_constants [
754+ (R_Z 0) ;; For reg r0
755 (R_SP 1) ;; Stack pointer reg
756 (R_SR 15) ;; Sub-routine return addr reg
757 (R_IR 14) ;; Interrupt return addr reg
758@@ -541,6 +542,7 @@
759
760 ;; Add 2 SImode integers [ src1 = reg ; src2 = arith ; dest = reg ]
761 ;; Leave carry as is
762+
763 (define_insn "addsi3"
764 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
765 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%dJ,dJ,dJ")
766@@ -562,23 +564,38 @@
767
768 ;; Adding 2 DI operands in register or reg/imm
769
770-(define_insn "adddi3_long"
771+(define_expand "adddi3"
772+ [(set (match_operand:DI 0 "register_operand" "")
773+ (plus:DI (match_operand:DI 1 "register_operand" "")
774+ (match_operand:DI 2 "arith_plus_operand" "")))]
775+""
776+{
777+ if (TARGET_MB_64)
778+ {
779+ if (GET_CODE (operands[2]) == CONST_INT &&
780+ INTVAL(operands[2]) < (long)-549755813888 &&
781+ INTVAL(operands[2]) > (long)549755813887)
782+ FAIL;
783+ }
784+})
785+
786+(define_insn "*adddi3_long"
787 [(set (match_operand:DI 0 "register_operand" "=d,d")
788- (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%dJ,dJ")
789+ (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
790 (match_operand:DI 2 "arith_plus_operand" "d,K")))]
791 "TARGET_MB_64"
792 "@
793- addlk\t%0,%z1,%2
794- addlik\t%0,%z1,%2"
795- [(set_attr "type" "arith,arith")
796- (set_attr "mode" "DI,DI")
797+ addlk\t%0,%1,%2
798+ addlik\t%0,%1,%2 #N10"
799+ [(set_attr "type" "darith,no_delay_arith")
800+ (set_attr "mode" "DI")
801 (set_attr "length" "4,4")])
802
803-(define_insn "adddi3"
804+(define_insn "*adddi3_all"
805 [(set (match_operand:DI 0 "register_operand" "=d,d")
806 (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
807 (match_operand:DI 2 "arith_operand" "d,i")))]
808- ""
809+ "!TARGET_MB_64"
810 "@
811 add\t%L0,%L1,%L2\;addc\t%M0,%M1,%M2
812 addi\t%L0,%L1,%j2\;addic\t%M0,%M1,%h2"
813@@ -605,7 +622,7 @@
814 (define_insn "iprefetch"
815 [(unspec [(match_operand:SI 0 "const_int_operand" "n")] UNSPEC_IPREFETCH)
816 (clobber (mem:BLK (scratch)))]
817- "TARGET_PREFETCH"
818+ "TARGET_PREFETCH && !TARGET_MB_64"
819 {
820 operands[2] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
821 return "mfs\t%2,rpc\n\twic\t%2,r0";
822@@ -618,23 +635,33 @@
823 ;; Double Precision Subtraction
824 ;;----------------------------------------------------------------
825
826-(define_insn "subdi3_long"
827- [(set (match_operand:DI 0 "register_operand" "=d,d")
828- (minus:DI (match_operand:DI 1 "register_operand" "d,d")
829- (match_operand:DI 2 "register_operand" "d,n")))]
830+(define_expand "subdi3"
831+ [(set (match_operand:DI 0 "register_operand" "")
832+ (minus:DI (match_operand:DI 1 "register_operand" "")
833+ (match_operand:DI 2 "arith_operand" "")))]
834+""
835+"
836+{
837+}")
838+
839+(define_insn "subsidi3"
840+ [(set (match_operand:DI 0 "register_operand" "=d,d,d")
841+ (minus:DI (match_operand:DI 1 "register_operand" "d,d,d")
842+ (match_operand:DI 2 "arith_operand" "d,K,n")))]
843 "TARGET_MB_64"
844 "@
845 rsubl\t%0,%2,%1
846- addlik\t%0,%z1,-%2"
847- [(set_attr "type" "darith")
848- (set_attr "mode" "DI,DI")
849- (set_attr "length" "4,4")])
850+ addik\t%0,%z1,-%2
851+ addik\t%0,%z1,-%2"
852+ [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
853+ (set_attr "mode" "DI")
854+ (set_attr "length" "4,4,4")])
855
856-(define_insn "subdi3"
857+(define_insn "subdi3_small"
858 [(set (match_operand:DI 0 "register_operand" "=&d")
859 (minus:DI (match_operand:DI 1 "register_operand" "d")
860 (match_operand:DI 2 "register_operand" "d")))]
861- ""
862+ "!TARGET_MB_64"
863 "rsub\t%L0,%L2,%L1\;rsubc\t%M0,%M2,%M1"
864 [(set_attr "type" "darith")
865 (set_attr "mode" "DI")
866@@ -663,7 +690,7 @@
867 (mult:DI
868 (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))
869 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
870- "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH"
871+ "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH && !TARGET_MB_64"
872 "mul\t%L0,%1,%2\;mulh\t%M0,%1,%2"
873 [(set_attr "type" "no_delay_arith")
874 (set_attr "mode" "DI")
875@@ -674,7 +701,7 @@
876 (mult:DI
877 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
878 (zero_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
879- "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH"
880+ "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH && !TARGET_MB_64"
881 "mul\t%L0,%1,%2\;mulhu\t%M0,%1,%2"
882 [(set_attr "type" "no_delay_arith")
883 (set_attr "mode" "DI")
884@@ -685,7 +712,7 @@
885 (mult:DI
886 (zero_extend:DI (match_operand:SI 1 "register_operand" "d"))
887 (sign_extend:DI (match_operand:SI 2 "register_operand" "d"))))]
888- "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH"
889+ "!TARGET_SOFT_MUL && TARGET_MULTIPLY_HIGH && !TARGET_MB_64"
890 "mul\t%L0,%1,%2\;mulhsu\t%M0,%2,%1"
891 [(set_attr "type" "no_delay_arith")
892 (set_attr "mode" "DI")
893@@ -789,7 +816,7 @@
894 (match_operand:SI 4 "arith_operand")])
895 (label_ref (match_operand 5))
896 (pc)))]
897- "TARGET_HARD_FLOAT"
898+ "TARGET_HARD_FLOAT && !TARGET_MB_64"
899 [(set (match_dup 1) (match_dup 3))]
900
901 {
902@@ -819,6 +846,15 @@
903 (set_attr "mode" "SI")
904 (set_attr "length" "4")])
905
906+(define_insn "negsi_long"
907+ [(set (match_operand:SI 0 "register_operand" "=d")
908+ (neg:SI (match_operand:DI 1 "register_operand" "d")))]
909+ ""
910+ "rsubk\t%0,%1,r0"
911+ [(set_attr "type" "arith")
912+ (set_attr "mode" "SI")
913+ (set_attr "length" "4")])
914+
915 (define_insn "negdi2_long"
916 [(set (match_operand:DI 0 "register_operand" "=d")
917 (neg:DI (match_operand:DI 1 "register_operand" "d")))]
918@@ -847,16 +883,24 @@
919 (set_attr "mode" "SI")
920 (set_attr "length" "4")])
921
922-(define_insn "one_cmpldi2_long"
923+(define_expand "one_cmpldi2"
924+ [(set (match_operand:DI 0 "register_operand" "")
925+ (not:DI (match_operand:DI 1 "register_operand" "")))]
926+ ""
927+ "
928+{
929+}")
930+
931+(define_insn ""
932 [(set (match_operand:DI 0 "register_operand" "=d")
933- (not:DI (match_operand:DI 1 "register_operand" "d")))]
934+ (not:DI (match_operand:DI 1 "arith_operand" "d")))]
935 "TARGET_MB_64"
936 "xorli\t%0,%1,-1"
937- [(set_attr "type" "arith")
938+ [(set_attr "type" "no_delay_arith")
939 (set_attr "mode" "DI")
940 (set_attr "length" "4")])
941
942-(define_insn "*one_cmpldi2"
943+(define_insn ""
944 [(set (match_operand:DI 0 "register_operand" "=d")
945 (not:DI (match_operand:DI 1 "register_operand" "d")))]
946 ""
947@@ -871,7 +915,8 @@
948 (not:DI (match_operand:DI 1 "register_operand" "")))]
949 "reload_completed
950 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
951- && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))"
952+ && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
953+ && !TARGET_MB_64"
954
955 [(set (subreg:SI (match_dup 0) 0) (not:SI (subreg:SI (match_dup 1) 0)))
956 (set (subreg:SI (match_dup 0) 4) (not:SI (subreg:SI (match_dup 1) 4)))]
957@@ -883,18 +928,17 @@
958 ;;----------------------------------------------------------------
959
960 (define_insn "anddi3"
961- [(set (match_operand:DI 0 "register_operand" "=d,d")
962- (and:DI (match_operand:DI 1 "arith_operand" "d,d")
963- (match_operand:DI 2 "arith_operand" "d,K")))]
964+ [(set (match_operand:DI 0 "register_operand" "=d,d,d")
965+ (and:DI (match_operand:DI 1 "arith_operand" "d,d,d")
966+ (match_operand:DI 2 "arith_operand" "d,K,I")))]
967 "TARGET_MB_64"
968 "@
969 andl\t%0,%1,%2
970- andli\t%0,%1,%2 #andl1"
971- ;; andli\t%0,%1,%2 #andl3
972- ;; andli\t%0,%1,%2 #andl2
973- [(set_attr "type" "arith,arith")
974- (set_attr "mode" "DI,DI")
975- (set_attr "length" "4,4")])
976+ andli\t%0,%1,%2 #andl2
977+ andli\t%0,%1,%2 #andl3"
978+ [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
979+ (set_attr "mode" "DI,DI,DI")
980+ (set_attr "length" "4,4,4")])
981
982 (define_insn "andsi3"
983 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
984@@ -919,7 +963,7 @@
985 "@
986 orl\t%0,%1,%2
987 orli\t%0,%1,%2 #andl1"
988- [(set_attr "type" "arith,arith")
989+ [(set_attr "type" "arith,no_delay_arith")
990 (set_attr "mode" "DI,DI")
991 (set_attr "length" "4,4")])
992
993@@ -945,7 +989,7 @@
994 "@
995 xorl\t%0,%1,%2
996 xorli\t%0,%1,%2 #andl1"
997- [(set_attr "type" "arith,arith")
998+ [(set_attr "type" "arith,no_delay_arith")
999 (set_attr "mode" "DI,DI")
1000 (set_attr "length" "4,4")])
1001
1002@@ -1018,26 +1062,6 @@
1003 (set_attr "mode" "SI")
1004 (set_attr "length" "4")])
1005
1006-;;(define_expand "extendqidi2"
1007-;; [(set (match_operand:DI 0 "register_operand" "=d")
1008-;; (sign_extend:DI (match_operand:QI 1 "general_operand" "d")))]
1009-;; "TARGET_MB_64"
1010-;; {
1011-;; if (GET_CODE (operands[1]) != REG)
1012-;; FAIL;
1013-;; }
1014-;;)
1015-
1016-
1017-;;(define_insn "extendqidi2"
1018-;; [(set (match_operand:DI 0 "register_operand" "=d")
1019-;; (sign_extend:DI (match_operand:QI 1 "register_operand" "d")))]
1020-;; "TARGET_MB_64"
1021-;; "sextl8\t%0,%1"
1022-;; [(set_attr "type" "arith")
1023-;; (set_attr "mode" "DI")
1024-;; (set_attr "length" "4")])
1025-
1026 (define_insn "extendhisi2"
1027 [(set (match_operand:SI 0 "register_operand" "=d")
1028 (sign_extend:SI (match_operand:HI 1 "register_operand" "d")))]
1029@@ -1060,6 +1084,27 @@
1030 ;; Those for integer source operand are ordered
1031 ;; widest source type first.
1032
1033+(define_insn "extendsidi2_long"
1034+ [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1035+ (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))]
1036+ "TARGET_MB_64"
1037+ {
1038+ switch (which_alternative)
1039+ {
1040+ case 0:
1041+ return "sextl32\t%0,%1";
1042+ case 1:
1043+ case 2:
1044+ {
1045+ output_asm_insn ("ll%i1\t%0,%1", operands);
1046+ return "sextl32\t%0,%0";
1047+ }
1048+ }
1049+ }
1050+ [(set_attr "type" "multi,multi,multi")
1051+ (set_attr "mode" "DI")
1052+ (set_attr "length" "4,8,8")])
1053+
1054 (define_insn "extendsidi2"
1055 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
1056 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,R,m")))]
1057@@ -1090,68 +1135,117 @@
1058 ;; Unlike most other insns, the move insns can't be split with
1059 ;; different predicates, because register spilling and other parts of
1060 ;; the compiler, have memoized the insn number already.
1061+;; //}
1062
1063 (define_expand "movdi"
1064 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1065 (match_operand:DI 1 "general_operand" ""))]
1066 ""
1067 {
1068- /* If operands[1] is a constant address illegal for pic, then we need to
1069- handle it just like microblaze_legitimize_address does. */
1070- if (flag_pic && pic_address_needs_scratch (operands[1]))
1071+ if (TARGET_MB_64)
1072+ {
1073+ if (microblaze_expand_move (DImode, operands)) DONE;
1074+ }
1075+ else
1076 {
1077+ /* If operands[1] is a constant address illegal for pic, then we need to
1078+ handle it just like microblaze_legitimize_address does. */
1079+ if (flag_pic && pic_address_needs_scratch (operands[1]))
1080+ {
1081 rtx temp = force_reg (DImode, XEXP (XEXP (operands[1], 0), 0));
1082 rtx temp2 = XEXP (XEXP (operands[1], 0), 1);
1083 emit_move_insn (operands[0], gen_rtx_PLUS (DImode, temp, temp2));
1084 DONE;
1085- }
1086-
1087-
1088- if ((reload_in_progress | reload_completed) == 0
1089- && !register_operand (operands[0], DImode)
1090- && !register_operand (operands[1], DImode)
1091- && (((GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
1092- && operands[1] != CONST0_RTX (DImode))))
1093- {
1094+ }
1095
1096- rtx temp = force_reg (DImode, operands[1]);
1097- emit_move_insn (operands[0], temp);
1098- DONE;
1099+ if ((reload_in_progress | reload_completed) == 0
1100+ && !register_operand (operands[0], DImode)
1101+ && !register_operand (operands[1], DImode)
1102+ && (((GET_CODE (operands[1]) != CONST_INT || INTVAL (operands[1]) != 0)
1103+ && operands[1] != CONST0_RTX (DImode))))
1104+ {
1105+ rtx temp = force_reg (DImode, operands[1]);
1106+ emit_move_insn (operands[0], temp);
1107+ DONE;
1108+ }
1109 }
1110 }
1111 )
1112
1113+;; Added for status registers
1114+(define_insn "movdi_status"
1115+ [(set (match_operand:DI 0 "register_operand" "=d,d,z")
1116+ (match_operand:DI 1 "register_operand" "z,d,d"))]
1117+ "microblaze_is_interrupt_variant () && TARGET_MB_64"
1118+ "@
1119+ mfs\t%0,%1 #mfs
1120+ addlk\t%0,%1,r0 #add movdi
1121+ mts\t%0,%1 #mts"
1122+ [(set_attr "type" "move")
1123+ (set_attr "mode" "DI")
1124+ (set_attr "length" "12")])
1125
1126-(define_insn "*movdi_internal_64"
1127- [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
1128- (match_operand:DI 1 "general_operand" " d,K,J,R,o,d,d"))]
1129- "TARGET_MB_64 && (INTVAL(operands[1]) < 0x7fffffffff) && (INTVAL(operands[1]) > 0xffffff8000000000)"
1130+;; This move will be not be moved to delay slot.
1131+(define_insn "*movdi_internal3"
1132+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d")
1133+ (match_operand:DI 1 "immediate_operand" "J,I,Mnis"))]
1134+ "TARGET_MB_64 && (register_operand (operands[0], DImode) &&
1135+ (GET_CODE (operands[1]) == CONST_INT &&
1136+ (INTVAL (operands[1]) <= (long)549755813887 && INTVAL (operands[1]) >= (long)-549755813888)))"
1137+ "@
1138+ addlk\t%0,r0,r0\t
1139+ addlik\t%0,r0,%1\t #N1 %X1
1140+ addlik\t%0,r0,%1\t #N2 %X1"
1141+ [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
1142+ (set_attr "mode" "DI")
1143+ (set_attr "length" "4")])
1144+
1145+;; This move may be used for PLT label operand
1146+(define_insn "*movdi_internal5_pltop"
1147+ [(set (match_operand:DI 0 "register_operand" "=d,d")
1148+ (match_operand:DI 1 "call_insn_operand" ""))]
1149+ "TARGET_MB_64 && (register_operand (operands[0], Pmode) &&
1150+ PLT_ADDR_P (operands[1]))"
1151+ {
1152+ gcc_unreachable ();
1153+ }
1154+ [(set_attr "type" "load")
1155+ (set_attr "mode" "DI")
1156+ (set_attr "length" "4")])
1157+
1158+(define_insn "*movdi_internal2"
1159+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
1160+ (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
1161+ "TARGET_MB_64"
1162 {
1163 switch (which_alternative)
1164 {
1165 case 0:
1166- return "addlk\t%0,%1";
1167- case 1:
1168- return "addlik\t%0,r0,%1";
1169- case 2:
1170- return "addlk\t%0,r0,r0";
1171- case 3:
1172- case 4:
1173- return "lli\t%0,%1";
1174- case 5:
1175- case 6:
1176- return "sli\t%1,%0";
1177- }
1178- return "unreachable";
1179- }
1180- [(set_attr "type" "no_delay_move,no_delay_arith,no_delay_arith,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
1181+ return "addlk\t%0,%1,r0";
1182+ case 1:
1183+ case 2:
1184+ if (GET_CODE (operands[1]) == CONST_INT &&
1185+ (INTVAL (operands[1]) > (long)549755813887 || INTVAL (operands[1]) < (long)-549755813888))
1186+ return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
1187+ else
1188+ return "addlik\t%0,r0,%1";
1189+ case 3:
1190+ case 4:
1191+ return "ll%i1\t%0,%1";
1192+ case 5:
1193+ case 6:
1194+ return "sl%i0\t%z1,%0";
1195+ }
1196+ }
1197+ [(set_attr "type" "load,no_delay_load,no_delay_load,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
1198 (set_attr "mode" "DI")
1199- (set_attr "length" "8,8,8,8,12,8,12")])
1200+ (set_attr "length" "4,4,12,4,8,4,8")])
1201+
1202
1203 (define_insn "*movdi_internal"
1204 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
1205 (match_operand:DI 1 "general_operand" " d,i,J,R,o,d,d"))]
1206- ""
1207+ "!TARGET_MB_64"
1208 {
1209 switch (which_alternative)
1210 {
1211@@ -1183,7 +1277,8 @@
1212 "reload_completed
1213 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1214 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1215- && (REGNO(operands[0]) == (REGNO(operands[1]) + 1))"
1216+ && (REGNO(operands[0]) == (REGNO(operands[1]) + 1))
1217+ && !(TARGET_MB_64)"
1218
1219 [(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))
1220 (set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))]
1221@@ -1195,12 +1290,22 @@
1222 "reload_completed
1223 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1224 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1225- && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))"
1226+ && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))
1227+ && !(TARGET_MB_64)"
1228
1229 [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
1230 (set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))]
1231 "")
1232
1233+(define_insn "movdi_long_int"
1234+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1235+ (match_operand:DI 1 "general_operand" "i"))]
1236+ ""
1237+ "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
1238+ [(set_attr "type" "no_delay_arith")
1239+ (set_attr "mode" "DI")
1240+ (set_attr "length" "12")])
1241+
1242 ;; Unlike most other insns, the move insns can't be split with
1243 ;; different predicates, because register spilling and other parts of
1244 ;; the compiler, have memoized the insn number already.
1245@@ -1272,6 +1377,8 @@
1246 (set_attr "length" "4,4,8,4,8,4,8")])
1247
1248
1249+
1250+
1251 ;; 16-bit Integer moves
1252
1253 ;; Unlike most other insns, the move insns can't be split with
1254@@ -1304,8 +1411,8 @@
1255 "@
1256 addik\t%0,r0,%1\t# %X1
1257 addk\t%0,%1,r0
1258- lhui\t%0,%1
1259- lhui\t%0,%1
1260+ lhu%i1\t%0,%1
1261+ lhu%i1\t%0,%1
1262 sh%i0\t%z1,%0
1263 sh%i0\t%z1,%0"
1264 [(set_attr "type" "arith,move,load,no_delay_load,store,no_delay_store")
1265@@ -1348,7 +1455,7 @@
1266 lbu%i1\t%0,%1
1267 lbu%i1\t%0,%1
1268 sb%i0\t%z1,%0
1269- sbi\t%z1,%0"
1270+ sb%i0\t%z1,%0"
1271 [(set_attr "type" "arith,arith,move,load,no_delay_load,store,no_delay_store")
1272 (set_attr "mode" "QI")
1273 (set_attr "length" "4,4,8,4,8,4,8")])
1274@@ -1421,7 +1528,7 @@
1275 addik\t%0,r0,%F1
1276 lw%i1\t%0,%1
1277 sw%i0\t%z1,%0
1278- swi\t%z1,%0"
1279+ sw%i0\t%z1,%0"
1280 [(set_attr "type" "move,no_delay_load,load,no_delay_load,no_delay_load,store,no_delay_store")
1281 (set_attr "mode" "SF")
1282 (set_attr "length" "4,4,4,4,4,4,4")])
1283@@ -1460,6 +1567,33 @@
1284 ;; movdf_internal
1285 ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
1286 ;;
1287+(define_insn "*movdf_internal_64"
1288+ [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
1289+ (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
1290+ "TARGET_MB_64"
1291+ {
1292+ switch (which_alternative)
1293+ {
1294+ case 0:
1295+ return "addlk\t%0,%1,r0";
1296+ case 1:
1297+ return "addlk\t%0,r0,r0";
1298+ case 2:
1299+ case 4:
1300+ return "ll%i1\t%0,%1";
1301+ case 3:
1302+ {
1303+ return "addlik\t%0,r0,%h1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #Xfer Lo";
1304+ }
1305+ case 5:
1306+ return "sl%i0\t%1,%0";
1307+ }
1308+ gcc_unreachable ();
1309+ }
1310+ [(set_attr "type" "no_delay_move,no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store")
1311+ (set_attr "mode" "DF")
1312+ (set_attr "length" "4,4,4,16,4,4")])
1313+
1314 (define_insn "*movdf_internal"
1315 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,o")
1316 (match_operand:DF 1 "general_operand" "dG,o,F,T,d"))]
1317@@ -1494,7 +1628,8 @@
1318 "reload_completed
1319 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1320 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1321- && (REGNO (operands[0]) == (REGNO (operands[1]) + 1))"
1322+ && (REGNO (operands[0]) == (REGNO (operands[1]) + 1))
1323+ && !TARGET_MB_64"
1324 [(set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))
1325 (set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))]
1326 "")
1327@@ -1505,7 +1640,8 @@
1328 "reload_completed
1329 && GET_CODE (operands[0]) == REG && GP_REG_P (REGNO (operands[0]))
1330 && GET_CODE (operands[1]) == REG && GP_REG_P (REGNO (operands[1]))
1331- && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))"
1332+ && (REGNO (operands[0]) != (REGNO (operands[1]) + 1))
1333+ && !TARGET_MB_64"
1334 [(set (subreg:SI (match_dup 0) 0) (subreg:SI (match_dup 1) 0))
1335 (set (subreg:SI (match_dup 0) 4) (subreg:SI (match_dup 1) 4))]
1336 "")
1337@@ -2005,6 +2141,31 @@ else
1338 "
1339 )
1340
1341+
1342+(define_insn "seq_internal_pat_long"
1343+ [(set (match_operand:DI 0 "register_operand" "=d")
1344+ (eq:DI
1345+ (match_operand:DI 1 "register_operand" "d")
1346+ (match_operand:DI 2 "register_operand" "d")))]
1347+ "TARGET_MB_64"
1348+ "pcmpleq\t%0,%1,%2"
1349+ [(set_attr "type" "arith")
1350+ (set_attr "mode" "DI")
1351+ (set_attr "length" "4")]
1352+)
1353+
1354+(define_insn "sne_internal_pat_long"
1355+ [(set (match_operand:DI 0 "register_operand" "=d")
1356+ (ne:DI
1357+ (match_operand:DI 1 "register_operand" "d")
1358+ (match_operand:DI 2 "register_operand" "d")))]
1359+ "TARGET_MB_64"
1360+ "pcmplne\t%0,%1,%2"
1361+ [(set_attr "type" "arith")
1362+ (set_attr "mode" "DI")
1363+ (set_attr "length" "4")]
1364+)
1365+
1366 (define_insn "seq_internal_pat"
1367 [(set (match_operand:SI 0 "register_operand" "=d")
1368 (eq:SI
1369@@ -2065,8 +2226,8 @@ else
1370 (define_expand "cbranchsi4"
1371 [(set (pc)
1372 (if_then_else (match_operator 0 "ordered_comparison_operator"
1373- [(match_operand:SI 1 "register_operand")
1374- (match_operand:SI 2 "arith_operand" "I,i")])
1375+ [(match_operand 1 "register_operand")
1376+ (match_operand 2 "arith_operand" "I,i")])
1377 (label_ref (match_operand 3 ""))
1378 (pc)))]
1379 ""
1380@@ -2078,13 +2239,13 @@ else
1381 (define_expand "cbranchsi4_reg"
1382 [(set (pc)
1383 (if_then_else (match_operator 0 "ordered_comparison_operator"
1384- [(match_operand:SI 1 "register_operand")
1385- (match_operand:SI 2 "register_operand")])
1386+ [(match_operand 1 "register_operand")
1387+ (match_operand 2 "register_operand")])
1388 (label_ref (match_operand 3 ""))
1389 (pc)))]
1390 ""
1391 {
1392- microblaze_expand_conditional_branch_reg (SImode, operands);
1393+ microblaze_expand_conditional_branch_reg (Pmode, operands);
1394 DONE;
1395 })
1396
1397@@ -2109,6 +2270,26 @@ else
1398 (label_ref (match_operand 1))
1399 (pc)))])
1400
1401+(define_insn "branch_zero64"
1402+ [(set (pc)
1403+ (if_then_else (match_operator 0 "ordered_comparison_operator"
1404+ [(match_operand 1 "register_operand" "d")
1405+ (const_int 0)])
1406+ (match_operand 2 "pc_or_label_operand" "")
1407+ (match_operand 3 "pc_or_label_operand" "")))
1408+ ]
1409+ "TARGET_MB_64"
1410+ {
1411+ if (operands[3] == pc_rtx)
1412+ return "bea%C0i%?\t%z1,%2";
1413+ else
1414+ return "bea%N0i%?\t%z1,%3";
1415+ }
1416+ [(set_attr "type" "branch")
1417+ (set_attr "mode" "none")
1418+ (set_attr "length" "4")]
1419+)
1420+
1421 (define_insn "branch_zero"
1422 [(set (pc)
1423 (if_then_else (match_operator:SI 0 "ordered_comparison_operator"
1424@@ -2129,6 +2310,47 @@ else
1425 (set_attr "length" "4")]
1426 )
1427
1428+(define_insn "branch_compare64"
1429+ [(set (pc)
1430+ (if_then_else (match_operator 0 "cmp_op"
1431+ [(match_operand 1 "register_operand" "d")
1432+ (match_operand 2 "register_operand" "d")
1433+ ])
1434+ (label_ref (match_operand 3))
1435+ (pc)))
1436+ (clobber(reg:SI R_TMP))]
1437+ "TARGET_MB_64"
1438+ {
1439+ operands[4] = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
1440+ enum rtx_code code = GET_CODE (operands[0]);
1441+
1442+ if (code == GT || code == LE)
1443+ {
1444+ output_asm_insn ("cmp\tr18,%z1,%z2", operands);
1445+ code = swap_condition (code);
1446+ }
1447+ else if (code == GTU || code == LEU)
1448+ {
1449+ output_asm_insn ("cmpu\tr18,%z1,%z2", operands);
1450+ code = swap_condition (code);
1451+ }
1452+ else if (code == GE || code == LT)
1453+ {
1454+ output_asm_insn ("cmp\tr18,%z2,%z1", operands);
1455+ }
1456+ else if (code == GEU || code == LTU)
1457+ {
1458+ output_asm_insn ("cmpu\tr18,%z2,%z1", operands);
1459+ }
1460+
1461+ operands[0] = gen_rtx_fmt_ee (signed_condition (code), SImode, operands[4], const0_rtx);
1462+ return "bea%C0i%?\tr18,%3";
1463+ }
1464+ [(set_attr "type" "branch")
1465+ (set_attr "mode" "none")
1466+ (set_attr "length" "12")]
1467+)
1468+
1469 (define_insn "branch_compare"
1470 [(set (pc)
1471 (if_then_else (match_operator:SI 0 "cmp_op"
1472@@ -2312,7 +2534,7 @@ else
1473 ;; Indirect jumps. Jump to register values. Assuming absolute jumps
1474
1475 (define_insn "indirect_jump_internal1"
1476- [(set (pc) (match_operand:SI 0 "register_operand" "d"))]
1477+ [(set (pc) (match_operand 0 "register_operand" "d"))]
1478 ""
1479 "bra%?\t%0"
1480 [(set_attr "type" "jump")
1481@@ -2325,7 +2547,7 @@ else
1482 (use (label_ref (match_operand 1 "" "")))]
1483 ""
1484 {
1485- gcc_assert (GET_MODE (operands[0]) == Pmode);
1486+ //gcc_assert (GET_MODE (operands[0]) == Pmode);
1487
1488 if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)
1489 emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
1490@@ -2337,7 +2559,7 @@ else
1491
1492 (define_insn "tablejump_internal1"
1493 [(set (pc)
1494- (match_operand:SI 0 "register_operand" "d"))
1495+ (match_operand 0 "register_operand" "d"))
1496 (use (label_ref (match_operand 1 "" "")))]
1497 ""
1498 "bra%?\t%0 "
1499@@ -2347,9 +2569,9 @@ else
1500
1501 (define_expand "tablejump_internal3"
1502 [(parallel [(set (pc)
1503- (plus:SI (match_operand:SI 0 "register_operand" "d")
1504- (label_ref:SI (match_operand:SI 1 "" ""))))
1505- (use (label_ref:SI (match_dup 1)))])]
1506+ (plus (match_operand 0 "register_operand" "d")
1507+ (label_ref (match_operand:SI 1 "" ""))))
1508+ (use (label_ref (match_dup 1)))])]
1509 ""
1510 ""
1511 )
1512@@ -2410,7 +2632,7 @@ else
1513 (minus (reg 1) (match_operand 1 "register_operand" "")))
1514 (set (reg 1)
1515 (minus (reg 1) (match_dup 1)))]
1516- ""
1517+ "!TARGET_MB_64"
1518 {
1519 rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1520 rtx reg = gen_reg_rtx (Pmode);
1521@@ -2435,7 +2657,7 @@ else
1522 (define_expand "save_stack_block"
1523 [(match_operand 0 "register_operand" "")
1524 (match_operand 1 "register_operand" "")]
1525- ""
1526+ "!TARGET_MB_64"
1527 {
1528 emit_move_insn (operands[0], operands[1]);
1529 DONE;
1530@@ -2445,7 +2667,7 @@ else
1531 (define_expand "restore_stack_block"
1532 [(match_operand 0 "register_operand" "")
1533 (match_operand 1 "register_operand" "")]
1534- ""
1535+ "!TARGET_MB_64"
1536 {
1537 rtx retaddr = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1538 rtx rtmp = gen_rtx_REG (SImode, R_TMP);
1539@@ -2492,7 +2714,7 @@ else
1540
1541 (define_insn "<optab>_internal"
1542 [(any_return)
1543- (use (match_operand:SI 0 "register_operand" ""))]
1544+ (use (match_operand 0 "register_operand" ""))]
1545 ""
1546 {
1547 if (microblaze_is_break_handler ())
1548@@ -2525,7 +2747,7 @@ else
1549 (define_expand "call"
1550 [(parallel [(call (match_operand 0 "memory_operand" "m")
1551 (match_operand 1 "" "i"))
1552- (clobber (reg:SI R_SR))
1553+ (clobber (reg R_SR))
1554 (use (match_operand 2 "" ""))
1555 (use (match_operand 3 "" ""))])]
1556 ""
1557@@ -2546,12 +2768,12 @@ else
1558
1559 if (GET_CODE (XEXP (operands[0], 0)) == UNSPEC)
1560 emit_call_insn (gen_call_internal_plt0 (operands[0], operands[1],
1561- gen_rtx_REG (SImode,
1562+ gen_rtx_REG (Pmode,
1563 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM),
1564 pic_offset_table_rtx));
1565 else
1566 emit_call_insn (gen_call_internal0 (operands[0], operands[1],
1567- gen_rtx_REG (SImode,
1568+ gen_rtx_REG (Pmode,
1569 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM)));
1570
1571 DONE;
1572@@ -2561,7 +2783,7 @@ else
1573 (define_expand "call_internal0"
1574 [(parallel [(call (match_operand 0 "" "")
1575 (match_operand 1 "" ""))
1576- (clobber (match_operand:SI 2 "" ""))])]
1577+ (clobber (match_operand 2 "" ""))])]
1578 ""
1579 {
1580 }
1581@@ -2570,18 +2792,34 @@ else
1582 (define_expand "call_internal_plt0"
1583 [(parallel [(call (match_operand 0 "" "")
1584 (match_operand 1 "" ""))
1585- (clobber (match_operand:SI 2 "" ""))
1586- (use (match_operand:SI 3 "" ""))])]
1587+ (clobber (match_operand 2 "" ""))
1588+ (use (match_operand 3 "" ""))])]
1589 ""
1590 {
1591 }
1592 )
1593
1594+(define_insn "call_internal_plt_64"
1595+ [(call (mem (match_operand 0 "call_insn_plt_operand" ""))
1596+ (match_operand 1 "" "i"))
1597+ (clobber (reg R_SR))
1598+ (use (reg R_GOT))]
1599+ "flag_pic && TARGET_MB_64"
1600+ {
1601+ register rtx target2 = gen_rtx_REG (Pmode,
1602+ GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1603+ gen_rtx_CLOBBER (VOIDmode, target2);
1604+ return "brealid\tr15,%0\;%#";
1605+ }
1606+ [(set_attr "type" "call")
1607+ (set_attr "mode" "none")
1608+ (set_attr "length" "4")])
1609+
1610 (define_insn "call_internal_plt"
1611- [(call (mem (match_operand:SI 0 "call_insn_plt_operand" ""))
1612- (match_operand:SI 1 "" "i"))
1613- (clobber (reg:SI R_SR))
1614- (use (reg:SI R_GOT))]
1615+ [(call (mem (match_operand 0 "call_insn_plt_operand" ""))
1616+ (match_operand 1 "" "i"))
1617+ (clobber (reg R_SR))
1618+ (use (reg R_GOT))]
1619 "flag_pic"
1620 {
1621 register rtx target2 = gen_rtx_REG (Pmode,
1622@@ -2593,10 +2831,41 @@ else
1623 (set_attr "mode" "none")
1624 (set_attr "length" "4")])
1625
1626+(define_insn "call_internal1_64"
1627+ [(call (mem (match_operand:VOID 0 "call_insn_simple_operand" "ri"))
1628+ (match_operand 1 "" "i"))
1629+ (clobber (reg R_SR))]
1630+ "TARGET_MB_64"
1631+ {
1632+ register rtx target = operands[0];
1633+ register rtx target2 = gen_rtx_REG (Pmode,
1634+ GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1635+ if (GET_CODE (target) == SYMBOL_REF) {
1636+ if (microblaze_break_function_p (SYMBOL_REF_DECL (target))) {
1637+ gen_rtx_CLOBBER (VOIDmode, target2);
1638+ return "breaki\tr16,%0\;%#";
1639+ }
1640+ else {
1641+ gen_rtx_CLOBBER (VOIDmode, target2);
1642+ return "brealid\tr15,%0\;%#";
1643+ }
1644+ } else if (GET_CODE (target) == CONST_INT)
1645+ return "la\t%@,r0,%0\;brald\tr15,%@\;%#";
1646+ else if (GET_CODE (target) == REG)
1647+ return "brald\tr15,%0\;%#";
1648+ else {
1649+ fprintf (stderr,"Unsupported call insn\n");
1650+ return NULL;
1651+ }
1652+ }
1653+ [(set_attr "type" "call")
1654+ (set_attr "mode" "none")
1655+ (set_attr "length" "4")])
1656+
1657 (define_insn "call_internal1"
1658 [(call (mem (match_operand:VOID 0 "call_insn_simple_operand" "ri"))
1659- (match_operand:SI 1 "" "i"))
1660- (clobber (reg:SI R_SR))]
1661+ (match_operand 1 "" "i"))
1662+ (clobber (reg R_SR))]
1663 ""
1664 {
1665 register rtx target = operands[0];
1666@@ -2630,7 +2899,7 @@ else
1667 [(parallel [(set (match_operand 0 "register_operand" "=d")
1668 (call (match_operand 1 "memory_operand" "m")
1669 (match_operand 2 "" "i")))
1670- (clobber (reg:SI R_SR))
1671+ (clobber (reg R_SR))
1672 (use (match_operand 3 "" ""))])] ;; next_arg_reg
1673 ""
1674 {
1675@@ -2651,13 +2920,13 @@ else
1676 if (GET_CODE (XEXP (operands[1], 0)) == UNSPEC)
1677 emit_call_insn (gen_call_value_intern_plt0 (operands[0], operands[1],
1678 operands[2],
1679- gen_rtx_REG (SImode,
1680+ gen_rtx_REG (Pmode,
1681 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM),
1682 pic_offset_table_rtx));
1683 else
1684 emit_call_insn (gen_call_value_internal (operands[0], operands[1],
1685 operands[2],
1686- gen_rtx_REG (SImode,
1687+ gen_rtx_REG (Pmode,
1688 GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM)));
1689
1690 DONE;
1691@@ -2669,7 +2938,7 @@ else
1692 [(parallel [(set (match_operand 0 "" "")
1693 (call (match_operand 1 "" "")
1694 (match_operand 2 "" "")))
1695- (clobber (match_operand:SI 3 "" ""))
1696+ (clobber (match_operand 3 "" ""))
1697 ])]
1698 ""
1699 {}
1700@@ -2679,18 +2948,35 @@ else
1701 [(parallel[(set (match_operand 0 "" "")
1702 (call (match_operand 1 "" "")
1703 (match_operand 2 "" "")))
1704- (clobber (match_operand:SI 3 "" ""))
1705- (use (match_operand:SI 4 "" ""))])]
1706+ (clobber (match_operand 3 "" ""))
1707+ (use (match_operand 4 "" ""))])]
1708 "flag_pic"
1709 {}
1710 )
1711
1712+(define_insn "call_value_intern_plt_64"
1713+ [(set (match_operand:VOID 0 "register_operand" "=d")
1714+ (call (mem (match_operand 1 "call_insn_plt_operand" ""))
1715+ (match_operand 2 "" "i")))
1716+ (clobber (match_operand 3 "register_operand" "=d"))
1717+ (use (match_operand 4 "register_operand"))]
1718+ "flag_pic && TARGET_MB_64"
1719+ {
1720+ register rtx target2=gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1721+
1722+ gen_rtx_CLOBBER (VOIDmode,target2);
1723+ return "brealid\tr15,%1\;%#";
1724+ }
1725+ [(set_attr "type" "call")
1726+ (set_attr "mode" "none")
1727+ (set_attr "length" "4")])
1728+
1729 (define_insn "call_value_intern_plt"
1730 [(set (match_operand:VOID 0 "register_operand" "=d")
1731- (call (mem (match_operand:SI 1 "call_insn_plt_operand" ""))
1732- (match_operand:SI 2 "" "i")))
1733- (clobber (match_operand:SI 3 "register_operand" "=d"))
1734- (use (match_operand:SI 4 "register_operand"))]
1735+ (call (mem (match_operand 1 "call_insn_plt_operand" ""))
1736+ (match_operand 2 "" "i")))
1737+ (clobber (match_operand 3 "register_operand" "=d"))
1738+ (use (match_operand 4 "register_operand"))]
1739 "flag_pic"
1740 {
1741 register rtx target2=gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1742@@ -2702,11 +2988,46 @@ else
1743 (set_attr "mode" "none")
1744 (set_attr "length" "4")])
1745
1746+(define_insn "call_value_intern_64"
1747+ [(set (match_operand:VOID 0 "register_operand" "=d")
1748+ (call (mem (match_operand:VOID 1 "call_insn_operand" "ri"))
1749+ (match_operand 2 "" "i")))
1750+ (clobber (match_operand 3 "register_operand" "=d"))]
1751+ "TARGET_MB_64"
1752+ {
1753+ register rtx target = operands[1];
1754+ register rtx target2=gen_rtx_REG (Pmode,GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM);
1755+
1756+ if (GET_CODE (target) == SYMBOL_REF)
1757+ {
1758+ gen_rtx_CLOBBER (VOIDmode,target2);
1759+ if (microblaze_break_function_p (SYMBOL_REF_DECL (target)))
1760+ return "breaki\tr16,%1\;%#";
1761+ else if (SYMBOL_REF_FLAGS (target) & SYMBOL_FLAG_FUNCTION)
1762+ {
1763+ return "brealid\tr15,%1\;%#";
1764+ }
1765+ else
1766+ {
1767+ return "bralid\tr15,%1\;%#";
1768+ }
1769+ }
1770+ else if (GET_CODE (target) == CONST_INT)
1771+ return "la\t%@,r0,%1\;brald\tr15,%@\;%#";
1772+ else if (GET_CODE (target) == REG)
1773+ return "brald\tr15,%1\;%#";
1774+ else
1775+ return "Unsupported call insn\n";
1776+ }
1777+ [(set_attr "type" "call")
1778+ (set_attr "mode" "none")
1779+ (set_attr "length" "4")])
1780+
1781 (define_insn "call_value_intern"
1782 [(set (match_operand:VOID 0 "register_operand" "=d")
1783 (call (mem (match_operand:VOID 1 "call_insn_operand" "ri"))
1784- (match_operand:SI 2 "" "i")))
1785- (clobber (match_operand:SI 3 "register_operand" "=d"))]
1786+ (match_operand 2 "" "i")))
1787+ (clobber (match_operand 3 "register_operand" "=d"))]
1788 ""
1789 {
1790 register rtx target = operands[1];
1791@@ -2880,7 +3201,6 @@ else
1792
1793 ;;if (!register_operand (operands[0], VOIDmode))
1794 ;; FAIL;
1795-
1796 emit_insn (gen_insv_32 (operands[0], operands[1],
1797 operands[2], operands[3]));
1798 DONE;
1799diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
1800index 7671f63..9fc80b1 100644
1801--- a/gcc/config/microblaze/t-microblaze
1802+++ b/gcc/config/microblaze/t-microblaze
1803@@ -2,10 +2,11 @@ MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-en
1804 MULTILIB_DIRNAMES = bs m mh le m64
1805 MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
1806 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
1807-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64
1808+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian/m64
1809+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64 mxl-multiply-high
1810 MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
1811-#MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
1812-#MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
1813+MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
1814+MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
1815
1816 # Extra files
1817 microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.c \
1818diff --git a/libgcc/config/microblaze/crti.S b/libgcc/config/microblaze/crti.S
1819index ee380ee..1811327 100644
1820--- a/libgcc/config/microblaze/crti.S
1821+++ b/libgcc/config/microblaze/crti.S
1822@@ -40,7 +40,7 @@
1823
1824 .align 2
1825 __init:
1826- addik r1, r1, -8
1827+ addik r1, r1, -16
1828 sw r15, r0, r1
1829 la r11, r0, _stack
1830 mts rshr, r11
1831@@ -51,5 +51,5 @@ __init:
1832 .global __fini
1833 .align 2
1834 __fini:
1835- addik r1, r1, -8
1836+ addik r1, r1, -16
1837 sw r15, r0, r1
1838diff --git a/libgcc/config/microblaze/crtn.S b/libgcc/config/microblaze/crtn.S
1839index 00d398a..60a4648 100644
1840--- a/libgcc/config/microblaze/crtn.S
1841+++ b/libgcc/config/microblaze/crtn.S
1842@@ -33,9 +33,9 @@
1843 .section .init, "ax"
1844 lw r15, r0, r1
1845 rtsd r15, 8
1846- addik r1, r1, 8
1847+ addik r1, r1, 16
1848
1849 .section .fini, "ax"
1850 lw r15, r0, r1
1851 rtsd r15, 8
1852- addik r1, r1, 8
1853+ addik r1, r1, 16
1854diff --git a/libgcc/config/microblaze/divdi3.S b/libgcc/config/microblaze/divdi3.S
1855new file mode 100644
1856index 0000000..d37bf51
1857--- /dev/null
1858+++ b/libgcc/config/microblaze/divdi3.S
1859@@ -0,0 +1,98 @@
1860+###################################-
1861+#
1862+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
1863+#
1864+# Contributed by Michael Eager <eager@eagercon.com>.
1865+#
1866+# This file is free software; you can redistribute it and/or modify it
1867+# under the terms of the GNU General Public License as published by the
1868+# Free Software Foundation; either version 3, or (at your option) any
1869+# later version.
1870+#
1871+# GCC is distributed in the hope that it will be useful, but WITHOUT
1872+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1873+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1874+# License for more details.
1875+#
1876+# Under Section 7 of GPL version 3, you are granted additional
1877+# permissions described in the GCC Runtime Library Exception, version
1878+# 3.1, as published by the Free Software Foundation.
1879+#
1880+# You should have received a copy of the GNU General Public License and
1881+# a copy of the GCC Runtime Library Exception along with this program;
1882+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
1883+# <http://www.gnu.org/licenses/>.
1884+#
1885+# divdi3.S
1886+#
1887+# Divide operation for 32 bit integers.
1888+# Input : Dividend in Reg r5
1889+# Divisor in Reg r6
1890+# Output: Result in Reg r3
1891+#
1892+#######################################
1893+
1894+#ifdef __arch64__
1895+ .globl __divdi3
1896+ .ent __divdi3
1897+ .type __divdi3,@function
1898+__divdi3:
1899+ .frame r1,0,r15
1900+
1901+ ADDLIK r1,r1,-32
1902+ SLI r28,r1,0
1903+ SLI r29,r1,8
1904+ SLI r30,r1,16
1905+ SLI r31,r1,24
1906+
1907+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
1908+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
1909+ XORL r28,r5,r6 # Get the sign of the result
1910+ BEALGEI r5,$LaR5_Pos
1911+ RSUBLI r5,r5,0 # Make r5 positive
1912+$LaR5_Pos:
1913+ BEALGEI r6,$LaR6_Pos
1914+ RSUBLI r6,r6,0 # Make r6 positive
1915+$LaR6_Pos:
1916+ ADDLIK r30,r0,0 # Clear mod
1917+ ADDLIK r3,r0,0 # clear div
1918+ ADDLIK r29,r0,64 # Initialize the loop count
1919+
1920+ # First part try to find the first '1' in the r5
1921+$LaDIV0:
1922+ BEALLTI r5,$LaDIV2 # This traps r5 == 0x80000000
1923+$LaDIV1:
1924+ ADDL r5,r5,r5 # left shift logical r5
1925+ ADDLIK r29,r29,-1
1926+ BEALGTI r5,$LaDIV1
1927+$LaDIV2:
1928+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
1929+ ADDLC r30,r30,r30 # Move that bit into the Mod register
1930+ RSUBL r31,r6,r30 # Try to subtract (r30 a r6)
1931+ BEALLTI r31,$LaMOD_TOO_SMALL
1932+ ORL r30,r0,r31 # Move the r31 to mod since the result was positive
1933+ ADDLIK r3,r3,1
1934+$LaMOD_TOO_SMALL:
1935+ ADDLIK r29,r29,-1
1936+ BEALEQi r29,$LaLOOP_END
1937+ ADDL r3,r3,r3 # Shift in the '1' into div
1938+ BREAI $LaDIV2 # Div2
1939+$LaLOOP_END:
1940+ BEALGEI r28,$LaRETURN_HERE
1941+ RSUBLI r3,r3,0 # Negate the result
1942+ BREAI $LaRETURN_HERE
1943+$LaDiv_By_Zero:
1944+$LaResult_Is_Zero:
1945+ ORL r3,r0,r0 # set result to 0
1946+$LaRETURN_HERE:
1947+# Restore values of CSRs and that of r3 and the divisor and the dividend
1948+ LLI r28,r1,0
1949+ LLI r29,r1,8
1950+ LLI r30,r1,16
1951+ LLI r31,r1,24
1952+ ADDLIK r1,r1,32
1953+ RTSD r15,8
1954+ nop
1955+.end __divdi3
1956+ .size __divdi3, . - __divdi3
1957+#endif
1958diff --git a/libgcc/config/microblaze/divdi3_table.c b/libgcc/config/microblaze/divdi3_table.c
1959new file mode 100644
1960index 0000000..8096259
1961--- /dev/null
1962+++ b/libgcc/config/microblaze/divdi3_table.c
1963@@ -0,0 +1,62 @@
1964+/* Table for software lookup divide for Xilinx MicroBlaze.
1965+
1966+ Copyright (C) 2009-2017 Free Software Foundation, Inc.
1967+
1968+ Contributed by Michael Eager <eager@eagercon.com>.
1969+
1970+ This file is free software; you can redistribute it and/or modify it
1971+ under the terms of the GNU General Public License as published by the
1972+ Free Software Foundation; either version 3, or (at your option) any
1973+ later version.
1974+
1975+ GCC is distributed in the hope that it will be useful, but WITHOUT
1976+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1977+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
1978+ License for more details.
1979+
1980+ Under Section 7 of GPL version 3, you are granted additional
1981+ permissions described in the GCC Runtime Library Exception, version
1982+ 3.1, as published by the Free Software Foundation.
1983+
1984+ You should have received a copy of the GNU General Public License and
1985+ a copy of the GCC Runtime Library Exception along with this program;
1986+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
1987+ <http://www.gnu.org/licenses/>. */
1988+
1989+
1990+unsigned char _divdi3_table[] =
1991+{
1992+ 0, 0/1, 0/2, 0/3, 0/4, 0/5, 0/6, 0/7,
1993+ 0/8, 0/9, 0/10, 0/11, 0/12, 0/13, 0/14, 0/15,
1994+ 0, 1/1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7,
1995+ 1/8, 1/9, 1/10, 1/11, 1/12, 1/13, 1/14, 1/15,
1996+ 0, 2/1, 2/2, 2/3, 2/4, 2/5, 2/6, 2/7,
1997+ 2/8, 2/9, 2/10, 2/11, 2/12, 2/13, 2/14, 2/15,
1998+ 0, 3/1, 3/2, 3/3, 3/4, 3/5, 3/6, 3/7,
1999+ 3/8, 3/9, 3/10, 3/11, 3/12, 3/13, 3/14, 3/15,
2000+ 0, 4/1, 4/2, 4/3, 4/4, 4/5, 4/6, 4/7,
2001+ 4/8, 4/9, 4/10, 4/11, 4/12, 4/13, 4/14, 4/15,
2002+ 0, 5/1, 5/2, 5/3, 5/4, 5/5, 5/6, 5/7,
2003+ 5/8, 5/9, 5/10, 5/11, 5/12, 5/13, 5/14, 5/15,
2004+ 0, 6/1, 6/2, 6/3, 6/4, 6/5, 6/6, 6/7,
2005+ 6/8, 6/9, 6/10, 6/11, 6/12, 6/13, 6/14, 6/15,
2006+ 0, 7/1, 7/2, 7/3, 7/4, 7/5, 7/6, 7/7,
2007+ 7/8, 7/9, 7/10, 7/11, 7/12, 7/13, 7/14, 7/15,
2008+ 0, 8/1, 8/2, 8/3, 8/4, 8/5, 8/6, 8/7,
2009+ 8/8, 8/9, 8/10, 8/11, 8/12, 8/13, 8/14, 8/15,
2010+ 0, 9/1, 9/2, 9/3, 9/4, 9/5, 9/6, 9/7,
2011+ 9/8, 9/9, 9/10, 9/11, 9/12, 9/13, 9/14, 9/15,
2012+ 0, 10/1, 10/2, 10/3, 10/4, 10/5, 10/6, 10/7,
2013+ 10/8, 10/9, 10/10, 10/11, 10/12, 10/13, 10/14, 10/15,
2014+ 0, 11/1, 11/2, 11/3, 11/4, 11/5, 11/6, 11/7,
2015+ 11/8, 11/9, 11/10, 11/11, 11/12, 11/13, 11/14, 11/15,
2016+ 0, 12/1, 12/2, 12/3, 12/4, 12/5, 12/6, 12/7,
2017+ 12/8, 12/9, 12/10, 12/11, 12/12, 12/13, 12/14, 12/15,
2018+ 0, 13/1, 13/2, 13/3, 13/4, 13/5, 13/6, 13/7,
2019+ 13/8, 13/9, 13/10, 13/11, 13/12, 13/13, 13/14, 13/15,
2020+ 0, 14/1, 14/2, 14/3, 14/4, 14/5, 14/6, 14/7,
2021+ 14/8, 14/9, 14/10, 14/11, 14/12, 14/13, 14/14, 14/15,
2022+ 0, 15/1, 15/2, 15/3, 15/4, 15/5, 15/6, 15/7,
2023+ 15/8, 15/9, 15/10, 15/11, 15/12, 15/13, 15/14, 15/15,
2024+};
2025+
2026diff --git a/libgcc/config/microblaze/moddi3.S b/libgcc/config/microblaze/moddi3.S
2027new file mode 100644
2028index 0000000..5d3f7c0
2029--- /dev/null
2030+++ b/libgcc/config/microblaze/moddi3.S
2031@@ -0,0 +1,97 @@
2032+###################################
2033+#
2034+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2035+#
2036+# Contributed by Michael Eager <eager@eagercon.com>.
2037+#
2038+# This file is free software; you can redistribute it and/or modify it
2039+# under the terms of the GNU General Public License as published by the
2040+# Free Software Foundation; either version 3, or (at your option) any
2041+# later version.
2042+#
2043+# GCC is distributed in the hope that it will be useful, but WITHOUT
2044+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2045+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2046+# License for more details.
2047+#
2048+# Under Section 7 of GPL version 3, you are granted additional
2049+# permissions described in the GCC Runtime Library Exception, version
2050+# 3.1, as published by the Free Software Foundation.
2051+#
2052+# You should have received a copy of the GNU General Public License and
2053+# a copy of the GCC Runtime Library Exception along with this program;
2054+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2055+# <http://www.gnu.org/licenses/>.
2056+#
2057+# moddi3.S
2058+#
2059+# modulo operation for 32 bit integers.
2060+# Input : op1 in Reg r5
2061+# op2 in Reg r6
2062+# Output: op1 mod op2 in Reg r3
2063+#
2064+#######################################
2065+
2066+#ifdef __arch64__
2067+ .globl __moddi3
2068+ .ent __moddi3
2069+ .type __moddi3,@function
2070+__moddi3:
2071+ .frame r1,0,r15
2072+
2073+ addlik r1,r1,-32
2074+ sli r28,r1,0
2075+ sli r29,r1,8
2076+ sli r30,r1,16
2077+ sli r31,r1,32
2078+
2079+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
2080+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
2081+ ADDL r28,r5,r0 # Get the sign of the result [ Depends only on the first arg]
2082+ BEALGEI r5,$LaR5_Pos
2083+ RSUBLI r5,r5,0 # Make r5 positive
2084+$LaR5_Pos:
2085+ BEALGEI r6,$LaR6_Pos
2086+ RSUBLI r6,r6,0 # Make r6 positive
2087+$LaR6_Pos:
2088+ ADDLIK r3,r0,0 # Clear mod
2089+ ADDLIK r30,r0,0 # clear div
2090+ ADDLIK r29,r0,64 # Initialize the loop count
2091+ BEALLTI r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
2092+ # the first bit search.
2093+ # First part try to find the first '1' in the r5
2094+$LaDIV1:
2095+ ADDL r5,r5,r5 # left shift logical r5
2096+ ADDLIK r29,r29,-1
2097+ BEALGEI r5,$LaDIV1 #
2098+$LaDIV2:
2099+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
2100+ ADDLC r3,r3,r3 # Move that bit into the Mod register
2101+ rSUBL r31,r6,r3 # Try to subtract (r30 a r6)
2102+ BEALLTi r31,$LaMOD_TOO_SMALL
2103+ ORL r3,r0,r31 # Move the r31 to mod since the result was positive
2104+ ADDLIK r30,r30,1
2105+$LaMOD_TOO_SMALL:
2106+ ADDLIK r29,r29,-1
2107+ BEALEQi r29,$LaLOOP_END
2108+ ADDL r30,r30,r30 # Shift in the '1' into div
2109+ BREAI $LaDIV2 # Div2
2110+$LaLOOP_END:
2111+ BEALGEI r28,$LaRETURN_HERE
2112+ rsubli r3,r3,0 # Negate the result
2113+ BREAI $LaRETURN_HERE
2114+$LaDiv_By_Zero:
2115+$LaResult_Is_Zero:
2116+ orl r3,r0,r0 # set result to 0 [Both mod as well as div are 0]
2117+$LaRETURN_HERE:
2118+# Restore values of CSRs and that of r3 and the divisor and the dividend
2119+ lli r28,r1,0
2120+ lli r29,r1,8
2121+ lli r30,r1,16
2122+ lli r31,r1,24
2123+ addlik r1,r1,32
2124+ rtsd r15,8
2125+ nop
2126+ .end __moddi3
2127+ .size __moddi3, . - __moddi3
2128+#endif
2129diff --git a/libgcc/config/microblaze/muldi3.S b/libgcc/config/microblaze/muldi3.S
2130new file mode 100644
2131index 0000000..5677841
2132--- /dev/null
2133+++ b/libgcc/config/microblaze/muldi3.S
2134@@ -0,0 +1,73 @@
2135+/*###################################-*-asm*-
2136+#
2137+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2138+#
2139+# Contributed by Michael Eager <eager@eagercon.com>.
2140+#
2141+# This file is free software; you can redistribute it and/or modify it
2142+# under the terms of the GNU General Public License as published by the
2143+# Free Software Foundation; either version 3, or (at your option) any
2144+# later version.
2145+#
2146+# GCC is distributed in the hope that it will be useful, but WITHOUT
2147+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2148+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2149+# License for more details.
2150+#
2151+# Under Section 7 of GPL version 3, you are granted additional
2152+# permissions described in the GCC Runtime Library Exception, version
2153+# 3.1, as published by the Free Software Foundation.
2154+#
2155+# You should have received a copy of the GNU General Public License and
2156+# a copy of the GCC Runtime Library Exception along with this program;
2157+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2158+# <http://www.gnu.org/licenses/>.
2159+#
2160+# muldi3.S
2161+#
2162+# Multiply operation for 32 bit integers.
2163+# Input : Operand1 in Reg r5
2164+# Operand2 in Reg r6
2165+# Output: Result [op1 * op2] in Reg r3
2166+#
2167+#######################################*/
2168+
2169+#ifdef __arch64__
2170+ .globl __muldi3
2171+ .ent __muldi3
2172+ .type __muldi3,@function
2173+__muldi3:
2174+ .frame r1,0,r15
2175+ addl r3,r0,r0
2176+ BEALEQI r5,$L_Result_Is_Zero # Multiply by Zero
2177+ BEALEQI r6,$L_Result_Is_Zero # Multiply by Zero
2178+ XORL r4,r5,r6 # Get the sign of the result
2179+ BEALGEI r5,$L_R5_Pos
2180+ RSUBLI r5,r5,0 # Make r5 positive
2181+$L_R5_Pos:
2182+ BEALGEI r6,$L_R6_Pos
2183+ RSUBLI r6,r6,0 # Make r6 positive
2184+$L_R6_Pos:
2185+ breai $L1
2186+$L2:
2187+ addl r5,r5,r5
2188+$L1:
2189+ srll r6,r6
2190+ addlc r7,r0,r0
2191+ bealeqi r7,$L2
2192+ addl r3,r3,r5
2193+ bealnei r6,$L2
2194+ beallti r4,$L_NegateResult
2195+ rtsd r15,8
2196+ nop
2197+$L_NegateResult:
2198+ rsubl r3,r3,r0
2199+ rtsd r15,8
2200+ nop
2201+$L_Result_Is_Zero:
2202+ addli r3,r0,0
2203+ rtsd r15,8
2204+ nop
2205+ .end __muldi3
2206+ .size __muldi3, . - __muldi3
2207+#endif
2208diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
2209index 8d954a4..35021b2 100644
2210--- a/libgcc/config/microblaze/t-microblaze
2211+++ b/libgcc/config/microblaze/t-microblaze
2212@@ -1,11 +1,16 @@
2213-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
2214+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3 \
2215+ _divdi3 _moddi3 _muldi3 _udivdi3 _umoddi3
2216
2217 LIB2ADD += \
2218 $(srcdir)/config/microblaze/divsi3.S \
2219+ $(srcdir)/config/microblaze/divdi3.S \
2220 $(srcdir)/config/microblaze/modsi3.S \
2221- $(srcdir)/config/microblaze/muldi3_hard.S \
2222+ $(srcdir)/config/microblaze/moddi3.S \
2223 $(srcdir)/config/microblaze/mulsi3.S \
2224+ $(srcdir)/config/microblaze/muldi3.S \
2225 $(srcdir)/config/microblaze/stack_overflow_exit.S \
2226 $(srcdir)/config/microblaze/udivsi3.S \
2227+ $(srcdir)/config/microblaze/udivdi3.S \
2228 $(srcdir)/config/microblaze/umodsi3.S \
2229- $(srcdir)/config/microblaze/divsi3_table.c
2230+ $(srcdir)/config/microblaze/umoddi3.S \
2231+ $(srcdir)/config/microblaze/divsi3_table.c \
2232diff --git a/libgcc/config/microblaze/udivdi3.S b/libgcc/config/microblaze/udivdi3.S
2233new file mode 100644
2234index 0000000..c210fbc
2235--- /dev/null
2236+++ b/libgcc/config/microblaze/udivdi3.S
2237@@ -0,0 +1,107 @@
2238+###################################-
2239+#
2240+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2241+#
2242+# Contributed by Michael Eager <eager@eagercon.com>.
2243+#
2244+# This file is free software; you can redistribute it and/or modify it
2245+# under the terms of the GNU General Public License as published by the
2246+# Free Software Foundation; either version 3, or (at your option) any
2247+# later version.
2248+#
2249+# GCC is distributed in the hope that it will be useful, but WITHOUT
2250+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2251+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2252+# License for more details.
2253+#
2254+# Under Section 7 of GPL version 3, you are granted additional
2255+# permissions described in the GCC Runtime Library Exception, version
2256+# 3.1, as published by the Free Software Foundation.
2257+#
2258+# You should have received a copy of the GNU General Public License and
2259+# a copy of the GCC Runtime Library Exception along with this program;
2260+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2261+# <http://www.gnu.org/licenses/>.
2262+#
2263+# udivdi3.S
2264+#
2265+# Unsigned divide operation.
2266+# Input : Divisor in Reg r5
2267+# Dividend in Reg r6
2268+# Output: Result in Reg r3
2269+#
2270+#######################################
2271+
2272+#ifdef __arch64__
2273+ .globl __udivdi3
2274+ .ent __udivdi3
2275+ .type __udivdi3,@function
2276+__udivdi3:
2277+ .frame r1,0,r15
2278+
2279+ ADDlIK r1,r1,-24
2280+ SLI r29,r1,0
2281+ SLI r30,r1,8
2282+ SLI r31,r1,16
2283+
2284+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
2285+ ADDLIK r30,r0,0 # Clear mod
2286+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
2287+ ADDLIK r29,r0,64 # Initialize the loop count
2288+
2289+ # Check if r6 and r5 are equal # if yes, return 1
2290+ RSUBL r18,r5,r6
2291+ ADDLIK r3,r0,1
2292+ BEALEQI r18,$LaRETURN_HERE
2293+
2294+ # Check if (uns)r6 is greater than (uns)r5. In that case, just return 0
2295+ XORL r18,r5,r6
2296+ ADDL r3,r0,r0 # We would anyways clear r3
2297+ BEALGEI r18,$LRSUBL
2298+ BEALLTI r6,$LaRETURN_HERE # r6[bit 31 = 1] hence is greater
2299+ BREAI $LCheckr6
2300+$LRSUBL:
2301+ RSUBL r18,r6,r5 # MICROBLAZEcmp
2302+ BEALLTI r18,$LaRETURN_HERE
2303+
2304+ # If r6 [bit 31] is set, then return result as 1
2305+$LCheckr6:
2306+ BEALGTI r6,$LaDIV0
2307+ ADDLIK r3,r0,1
2308+ BREAI $LaRETURN_HERE
2309+
2310+ # First part try to find the first '1' in the r5
2311+$LaDIV0:
2312+ BEALLTI r5,$LaDIV2
2313+$LaDIV1:
2314+ ADDL r5,r5,r5 # left shift logical r5
2315+ ADDLIK r29,r29,-1
2316+ BEALGTI r5,$LaDIV1
2317+$LaDIV2:
2318+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
2319+ ADDLC r30,r30,r30 # Move that bit into the Mod register
2320+ RSUBL r31,r6,r30 # Try to subtract (r30 a r6)
2321+ BEALLTI r31,$LaMOD_TOO_SMALL
2322+ ORL r30,r0,r31 # Move the r31 to mod since the result was positive
2323+ ADDLIK r3,r3,1
2324+$LaMOD_TOO_SMALL:
2325+ ADDLIK r29,r29,-1
2326+ BEALEQi r29,$LaLOOP_END
2327+ ADDL r3,r3,r3 # Shift in the '1' into div
2328+ BREAI $LaDIV2 # Div2
2329+$LaLOOP_END:
2330+ BREAI $LaRETURN_HERE
2331+$LaDiv_By_Zero:
2332+$LaResult_Is_Zero:
2333+ ORL r3,r0,r0 # set result to 0
2334+$LaRETURN_HERE:
2335+ # Restore values of CSRs and that of r3 and the divisor and the dividend
2336+ LLI r29,r1,0
2337+ LLI r30,r1,8
2338+ LLI r31,r1,16
2339+ ADDLIK r1,r1,24
2340+ RTSD r15,8
2341+ NOP
2342+ .end __udivdi3
2343+ .size __udivdi3, . - __udivdi3
2344+#endif
2345diff --git a/libgcc/config/microblaze/umoddi3.S b/libgcc/config/microblaze/umoddi3.S
2346new file mode 100644
2347index 0000000..7f5cd23
2348--- /dev/null
2349+++ b/libgcc/config/microblaze/umoddi3.S
2350@@ -0,0 +1,110 @@
2351+###################################
2352+#
2353+# Copyright (C) 2009-2017 Free Software Foundation, Inc.
2354+#
2355+# Contributed by Michael Eager <eager@eagercon.com>.
2356+#
2357+# This file is free software; you can redistribute it and/or modify it
2358+# under the terms of the GNU General Public License as published by the
2359+# Free Software Foundation; either version 3, or (at your option) any
2360+# later version.
2361+#
2362+# GCC is distributed in the hope that it will be useful, but WITHOUT
2363+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2364+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2365+# License for more details.
2366+#
2367+# Under Section 7 of GPL version 3, you are granted additional
2368+# permissions described in the GCC Runtime Library Exception, version
2369+# 3.1, as published by the Free Software Foundation.
2370+#
2371+# You should have received a copy of the GNU General Public License and
2372+# a copy of the GCC Runtime Library Exception along with this program;
2373+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2374+# <http://www.gnu.org/licenses/>.
2375+#
2376+# umoddi3.S
2377+#
2378+# Unsigned modulo operation for 32 bit integers.
2379+# Input : op1 in Reg r5
2380+# op2 in Reg r6
2381+# Output: op1 mod op2 in Reg r3
2382+#
2383+#######################################
2384+
2385+#ifdef __arch64__
2386+ .globl __umoddi3
2387+ .ent __umoddi3
2388+ .type __umoddi3,@function
2389+__umoddi3:
2390+ .frame r1,0,r15
2391+
2392+ addlik r1,r1,-24
2393+ sli r29,r1,0
2394+ sli r30,r1,8
2395+ sli r31,r1,16
2396+
2397+ BEALEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
2398+ ADDLIK r3,r0,0 # Clear div
2399+ BEALEQI r5,$LaResult_Is_Zero # Result is Zero
2400+ ADDLIK r30,r0,0 # clear mod
2401+ ADDLIK r29,r0,64 # Initialize the loop count
2402+
2403+# Check if r6 and r5 are equal # if yes, return 0
2404+ rsubl r18,r5,r6
2405+ bealeqi r18,$LaRETURN_HERE
2406+
2407+# Check if (uns)r6 is greater than (uns)r5. In that case, just return r5
2408+ xorl r18,r5,r6
2409+ addlik r3,r5,0
2410+ bealgei r18,$LRSUB
2411+ beallti r6,$LaRETURN_HERE
2412+ breai $LCheckr6
2413+$LRSUB:
2414+ rsubl r18,r5,r6 # MICROBLAZEcmp
2415+ bealgti r18,$LaRETURN_HERE
2416+
2417+# If r6 [bit 31] is set, then return result as r5-r6
2418+$LCheckr6:
2419+ addlik r3,r0,0
2420+ bealgti r6,$LaDIV0
2421+ addlik r18,r0,0x7fffffff
2422+ andl r5,r5,r18
2423+ andl r6,r6,r18
2424+ breaid $LaRETURN_HERE
2425+ rsubl r3,r6,r5
2426+# First part: try to find the first '1' in the r5
2427+$LaDIV0:
2428+ BEALLTI r5,$LaDIV2
2429+$LaDIV1:
2430+ ADDL r5,r5,r5 # left shift logical r5
2431+ ADDLIK r29,r29,-1
2432+ BEALGEI r5,$LaDIV1 #
2433+$LaDIV2:
2434+ ADDL r5,r5,r5 # left shift logical r5 get the '1' into the Carry
2435+ ADDLC r3,r3,r3 # Move that bit into the Mod register
2436+ rSUBL r31,r6,r3 # Try to subtract (r3 a r6)
2437+ BEALLTi r31,$LaMOD_TOO_SMALL
2438+ ORL r3,r0,r31 # Move the r31 to mod since the result was positive
2439+ ADDLIK r30,r30,1
2440+$LaMOD_TOO_SMALL:
2441+ ADDLIK r29,r29,-1
2442+ BEALEQi r29,$LaLOOP_END
2443+ ADDL r30,r30,r30 # Shift in the '1' into div
2444+ BREAI $LaDIV2 # Div2
2445+$LaLOOP_END:
2446+ BREAI $LaRETURN_HERE
2447+$LaDiv_By_Zero:
2448+$LaResult_Is_Zero:
2449+ orl r3,r0,r0 # set result to 0
2450+$LaRETURN_HERE:
2451+# Restore values of CSRs and that of r3 and the divisor and the dividend
2452+ lli r29,r1,0
2453+ lli r30,r1,8
2454+ lli r31,r1,16
2455+ addlik r1,r1,24
2456+ rtsd r15,8
2457+ nop
2458+.end __umoddi3
2459+ .size __umoddi3, . - __umoddi3
2460+#endif
2461--
24622.7.4
2463
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0042-re-arrangement-of-the-compare-branches.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0042-re-arrangement-of-the-compare-branches.patch
new file mode 100644
index 00000000..3afb7629
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0042-re-arrangement-of-the-compare-branches.patch
@@ -0,0 +1,268 @@
1From 31062878a2c1773a1fc94242ad29e6d03e4828b1 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 3 Aug 2018 15:41:39 +0530
4Subject: [PATCH 42/63] re-arrangement of the compare branches
5
6---
7 gcc/config/microblaze/microblaze.c | 28 ++-----
8 gcc/config/microblaze/microblaze.md | 141 +++++++++++++++++-------------------
9 2 files changed, 73 insertions(+), 96 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
12index d5ff7af..dd46d93 100644
13--- a/gcc/config/microblaze/microblaze.c
14+++ b/gcc/config/microblaze/microblaze.c
15@@ -3835,11 +3835,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
16 {
17 comp_reg = cmp_op0;
18 condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
19- if (mode == Pmode)
20- emit_jump_insn (gen_condjump (condition, label1));
21- else
22- emit_jump_insn (gen_long_condjump (condition, label1));
23-
24+ emit_jump_insn (gen_condjump (condition, label1));
25 }
26
27 else if (code == EQ || code == NE)
28@@ -3850,10 +3846,7 @@ microblaze_expand_conditional_branch (machine_mode mode, rtx operands[])
29 else
30 emit_insn (gen_xordi3 (comp_reg, cmp_op0, cmp_op1));
31 condition = gen_rtx_fmt_ee (signed_condition (code), mode, comp_reg, const0_rtx);
32- if (mode == SImode)
33- emit_jump_insn (gen_condjump (condition, label1));
34- else
35- emit_jump_insn (gen_long_condjump (condition, label1));
36+ emit_jump_insn (gen_condjump (condition, label1));
37 }
38 else
39 {
40@@ -3886,10 +3879,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
41 comp_reg = cmp_op0;
42 condition = gen_rtx_fmt_ee (signed_condition (code),
43 mode, comp_reg, const0_rtx);
44- if (mode == SImode)
45- emit_jump_insn (gen_condjump (condition, label1));
46- else
47- emit_jump_insn (gen_long_condjump (condition, label1));
48+ emit_jump_insn (gen_condjump (condition, label1));
49 }
50 else if (code == EQ)
51 {
52@@ -3904,10 +3894,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
53 cmp_op1));
54 }
55 condition = gen_rtx_EQ (mode, comp_reg, const0_rtx);
56- if (mode == SImode)
57- emit_jump_insn (gen_condjump (condition, label1));
58- else
59- emit_jump_insn (gen_long_condjump (condition, label1));
60+ emit_jump_insn (gen_condjump (condition, label1));
61
62 }
63 else if (code == NE)
64@@ -3923,10 +3910,7 @@ microblaze_expand_conditional_branch_reg (machine_mode mode, rtx operands[])
65 cmp_op1));
66 }
67 condition = gen_rtx_NE (mode, comp_reg, const0_rtx);
68- if (mode == SImode)
69- emit_jump_insn (gen_condjump (condition, label1));
70- else
71- emit_jump_insn (gen_long_condjump (condition, label1));
72+ emit_jump_insn (gen_condjump (condition, label1));
73 }
74 else
75 {
76@@ -3968,7 +3952,7 @@ microblaze_expand_conditional_branch_df (rtx operands[])
77
78 emit_insn (gen_cstoredf4 (comp_reg, operands[0], cmp_op0, cmp_op1));
79 condition = gen_rtx_NE (Pmode, comp_reg, const0_rtx);
80- emit_jump_insn (gen_long_condjump (condition, operands[3]));
81+ emit_jump_insn (gen_condjump (condition, operands[3]));
82 }
83
84 /* Implement TARGET_FRAME_POINTER_REQUIRED. */
85diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
86index 77627a7..edb7aab 100644
87--- a/gcc/config/microblaze/microblaze.md
88+++ b/gcc/config/microblaze/microblaze.md
89@@ -2270,7 +2270,27 @@ else
90 (label_ref (match_operand 1))
91 (pc)))])
92
93-(define_insn "branch_zero64"
94+(define_insn "branch_zero_64"
95+ [(set (pc)
96+ (if_then_else (match_operator:SI 0 "ordered_comparison_operator"
97+ [(match_operand:SI 1 "register_operand" "d")
98+ (const_int 0)])
99+ (match_operand:SI 2 "pc_or_label_operand" "")
100+ (match_operand:SI 3 "pc_or_label_operand" "")))
101+ ]
102+ "TARGET_MB_64"
103+ {
104+ if (operands[3] == pc_rtx)
105+ return "bea%C0i%?\t%z1,%2";
106+ else
107+ return "bea%N0i%?\t%z1,%3";
108+ }
109+ [(set_attr "type" "branch")
110+ (set_attr "mode" "none")
111+ (set_attr "length" "4")]
112+)
113+
114+(define_insn "long_branch_zero"
115 [(set (pc)
116 (if_then_else (match_operator 0 "ordered_comparison_operator"
117 [(match_operand 1 "register_operand" "d")
118@@ -2281,9 +2301,9 @@ else
119 "TARGET_MB_64"
120 {
121 if (operands[3] == pc_rtx)
122- return "bea%C0i%?\t%z1,%2";
123+ return "beal%C0i%?\t%z1,%2";
124 else
125- return "bea%N0i%?\t%z1,%3";
126+ return "beal%N0i%?\t%z1,%3";
127 }
128 [(set_attr "type" "branch")
129 (set_attr "mode" "none")
130@@ -2312,9 +2332,9 @@ else
131
132 (define_insn "branch_compare64"
133 [(set (pc)
134- (if_then_else (match_operator 0 "cmp_op"
135- [(match_operand 1 "register_operand" "d")
136- (match_operand 2 "register_operand" "d")
137+ (if_then_else (match_operator:SI 0 "cmp_op"
138+ [(match_operand:SI 1 "register_operand" "d")
139+ (match_operand:SI 2 "register_operand" "d")
140 ])
141 (label_ref (match_operand 3))
142 (pc)))
143@@ -2351,6 +2371,47 @@ else
144 (set_attr "length" "12")]
145 )
146
147+(define_insn "long_branch_compare"
148+ [(set (pc)
149+ (if_then_else (match_operator 0 "cmp_op"
150+ [(match_operand 1 "register_operand" "d")
151+ (match_operand 2 "register_operand" "d")
152+ ])
153+ (label_ref (match_operand 3))
154+ (pc)))
155+ (clobber(reg:DI R_TMP))]
156+ "TARGET_MB_64"
157+ {
158+ operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
159+ enum rtx_code code = GET_CODE (operands[0]);
160+
161+ if (code == GT || code == LE)
162+ {
163+ output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
164+ code = swap_condition (code);
165+ }
166+ else if (code == GTU || code == LEU)
167+ {
168+ output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
169+ code = swap_condition (code);
170+ }
171+ else if (code == GE || code == LT)
172+ {
173+ output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
174+ }
175+ else if (code == GEU || code == LTU)
176+ {
177+ output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
178+ }
179+
180+ operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
181+ return "beal%C0i%?\tr18,%3";
182+ }
183+ [(set_attr "type" "branch")
184+ (set_attr "mode" "none")
185+ (set_attr "length" "12")]
186+)
187+
188 (define_insn "branch_compare"
189 [(set (pc)
190 (if_then_else (match_operator:SI 0 "cmp_op"
191@@ -2433,74 +2494,6 @@ else
192
193 })
194
195-;; Used to implement comparison instructions
196-(define_expand "long_condjump"
197- [(set (pc)
198- (if_then_else (match_operand 0)
199- (label_ref (match_operand 1))
200- (pc)))])
201-
202-(define_insn "long_branch_zero"
203- [(set (pc)
204- (if_then_else (match_operator:DI 0 "ordered_comparison_operator"
205- [(match_operand:DI 1 "register_operand" "d")
206- (const_int 0)])
207- (match_operand:DI 2 "pc_or_label_operand" "")
208- (match_operand:DI 3 "pc_or_label_operand" "")))
209- ]
210- "TARGET_MB_64"
211- {
212- if (operands[3] == pc_rtx)
213- return "beal%C0i%?\t%z1,%2";
214- else
215- return "beal%N0i%?\t%z1,%3";
216- }
217- [(set_attr "type" "branch")
218- (set_attr "mode" "none")
219- (set_attr "length" "4")]
220-)
221-
222-(define_insn "long_branch_compare"
223- [(set (pc)
224- (if_then_else (match_operator:DI 0 "cmp_op"
225- [(match_operand:DI 1 "register_operand" "d")
226- (match_operand:DI 2 "register_operand" "d")
227- ])
228- (label_ref (match_operand 3))
229- (pc)))
230- (clobber(reg:DI R_TMP))]
231- "TARGET_MB_64"
232- {
233- operands[4] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
234- enum rtx_code code = GET_CODE (operands[0]);
235-
236- if (code == GT || code == LE)
237- {
238- output_asm_insn ("cmpl\tr18,%z1,%z2", operands);
239- code = swap_condition (code);
240- }
241- else if (code == GTU || code == LEU)
242- {
243- output_asm_insn ("cmplu\tr18,%z1,%z2", operands);
244- code = swap_condition (code);
245- }
246- else if (code == GE || code == LT)
247- {
248- output_asm_insn ("cmpl\tr18,%z2,%z1", operands);
249- }
250- else if (code == GEU || code == LTU)
251- {
252- output_asm_insn ("cmplu\tr18,%z2,%z1", operands);
253- }
254-
255- operands[0] = gen_rtx_fmt_ee (signed_condition (code), DImode, operands[4], const0_rtx);
256- return "beal%C0i%?\tr18,%3";
257- }
258- [(set_attr "type" "branch")
259- (set_attr "mode" "none")
260- (set_attr "length" "12")]
261-)
262-
263 ;;----------------------------------------------------------------
264 ;; Unconditional branches
265 ;;----------------------------------------------------------------
266--
2672.7.4
268
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0043-Patch-Microblaze-previous-commit-broke-the-handling-.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0043-Patch-Microblaze-previous-commit-broke-the-handling-.patch
new file mode 100644
index 00000000..f4074899
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0043-Patch-Microblaze-previous-commit-broke-the-handling-.patch
@@ -0,0 +1,28 @@
1From 7ab47599c2bec80d622883b3e220827dce89c598 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 8 Aug 2018 17:37:26 +0530
4Subject: [PATCH 43/63] [Patch,Microblaze] : previous commit broke the
5 handling of SI Branch compare for Microblaze 32-bit..
6
7---
8 gcc/config/microblaze/microblaze.md | 4 ++--
9 1 file changed, 2 insertions(+), 2 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index edb7aab..fb22edb 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -2226,8 +2226,8 @@ else
16 (define_expand "cbranchsi4"
17 [(set (pc)
18 (if_then_else (match_operator 0 "ordered_comparison_operator"
19- [(match_operand 1 "register_operand")
20- (match_operand 2 "arith_operand" "I,i")])
21+ [(match_operand:SI 1 "register_operand")
22+ (match_operand:SI 2 "arith_operand" "I,i")])
23 (label_ref (match_operand 3 ""))
24 (pc)))]
25 ""
26--
272.7.4
28
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0044-Patch-Microblaze-Support-of-multilibs-with-m64.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0044-Patch-Microblaze-Support-of-multilibs-with-m64.patch
new file mode 100644
index 00000000..ad287e57
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0044-Patch-Microblaze-Support-of-multilibs-with-m64.patch
@@ -0,0 +1,73 @@
1From 23622921a153258de469ff10db4926b83ff0c432 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 11 Sep 2018 13:43:48 +0530
4Subject: [PATCH 44/63] [Patch, Microblaze] : Support of multilibs with m64 ...
5
6---
7 gcc/config/microblaze/microblaze-c.c | 1 +
8 gcc/config/microblaze/t-microblaze | 15 ++++++---------
9 libgcc/config/microblaze/t-microblaze | 11 +++--------
10 3 files changed, 10 insertions(+), 17 deletions(-)
11
12diff --git a/gcc/config/microblaze/microblaze-c.c b/gcc/config/microblaze/microblaze-c.c
13index d2b0c76..6670091 100644
14--- a/gcc/config/microblaze/microblaze-c.c
15+++ b/gcc/config/microblaze/microblaze-c.c
16@@ -102,6 +102,7 @@ microblaze_cpp_define (cpp_reader *pfile)
17 }
18 if (TARGET_MB_64)
19 {
20+ builtin_define ("__microblaze64");
21 builtin_define ("__arch64__");
22 builtin_define ("__microblaze64__");
23 builtin_define ("__MICROBLAZE64__");
24diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
25index 9fc80b1..35ab9654 100644
26--- a/gcc/config/microblaze/t-microblaze
27+++ b/gcc/config/microblaze/t-microblaze
28@@ -1,12 +1,9 @@
29-MULTILIB_OPTIONS = mxl-barrel-shift mno-xl-soft-mul mxl-multiply-high mlittle-endian m64
30-MULTILIB_DIRNAMES = bs m mh le m64
31-MULTILIB_EXCEPTIONS = *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
32-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian
33-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/mlittle-endian/m64
34-MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high/m64 mxl-multiply-high
35-MULTILIB_EXCEPTIONS += mxl-multiply-high/mlittle-endian
36-MULTILIB_EXCEPTIONS += mxl-multiply-high/m64
37-MULTILIB_EXCEPTIONS += *mxl-multiply-high/mlittle-endian/m64
38+MULTILIB_OPTIONS = m64 mxl-barrel-shift mlittle-endian mno-xl-soft-mul mxl-multiply-high
39+MULTILIB_DIRNAMES = m64 bs le m mh
40+MULTILIB_EXCEPTIONS = *m64/mxl-multiply-high mxl-multiply-high
41+MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
42+MULTILIB_EXCEPTIONS += *mlittle-endian/mxl-multiply-high mxl-multiply-high
43+MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift/mlittle-endian/mxl-multiply-high
44
45 # Extra files
46 microblaze-c.o: $(srcdir)/config/microblaze/microblaze-c.c \
47diff --git a/libgcc/config/microblaze/t-microblaze b/libgcc/config/microblaze/t-microblaze
48index 35021b2..8d954a4 100644
49--- a/libgcc/config/microblaze/t-microblaze
50+++ b/libgcc/config/microblaze/t-microblaze
51@@ -1,16 +1,11 @@
52-LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3 \
53- _divdi3 _moddi3 _muldi3 _udivdi3 _umoddi3
54+LIB2FUNCS_EXCLUDE += _divsi3 _modsi3 _mulsi3 _udivsi3 _umodsi3
55
56 LIB2ADD += \
57 $(srcdir)/config/microblaze/divsi3.S \
58- $(srcdir)/config/microblaze/divdi3.S \
59 $(srcdir)/config/microblaze/modsi3.S \
60- $(srcdir)/config/microblaze/moddi3.S \
61+ $(srcdir)/config/microblaze/muldi3_hard.S \
62 $(srcdir)/config/microblaze/mulsi3.S \
63- $(srcdir)/config/microblaze/muldi3.S \
64 $(srcdir)/config/microblaze/stack_overflow_exit.S \
65 $(srcdir)/config/microblaze/udivsi3.S \
66- $(srcdir)/config/microblaze/udivdi3.S \
67 $(srcdir)/config/microblaze/umodsi3.S \
68- $(srcdir)/config/microblaze/umoddi3.S \
69- $(srcdir)/config/microblaze/divsi3_table.c \
70+ $(srcdir)/config/microblaze/divsi3_table.c
71--
722.7.4
73
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0045-Fixed-issues-like.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0045-Fixed-issues-like.patch
new file mode 100644
index 00000000..3f5f7827
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0045-Fixed-issues-like.patch
@@ -0,0 +1,70 @@
1From 6e6fcbe5fafcbebaf63ff071ad947966af0c1559 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 11 Sep 2018 14:58:00 +0530
4Subject: [PATCH 45/63] Fixed issues like: 1 Interrupt alignment issue 2 Sign
5 extension issue
6
7---
8 gcc/config/microblaze/microblaze.c | 16 ++++++++++------
9 gcc/config/microblaze/microblaze.md | 2 +-
10 2 files changed, 11 insertions(+), 7 deletions(-)
11
12diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
13index dd46d93..bfa667b 100644
14--- a/gcc/config/microblaze/microblaze.c
15+++ b/gcc/config/microblaze/microblaze.c
16@@ -2317,9 +2317,14 @@ compute_frame_size (HOST_WIDE_INT size)
17
18 total_size += gp_reg_size;
19
20- /* Add 4 bytes for MSR. */
21+ /* Add 4/8 bytes for MSR. */
22 if (microblaze_is_interrupt_variant ())
23- total_size += 4;
24+ {
25+ if (TARGET_MB_64)
26+ total_size += 8;
27+ else
28+ total_size += 4;
29+ }
30
31 /* No space to be allocated for link register in leaf functions with no other
32 stack requirements. */
33@@ -2604,7 +2609,6 @@ print_operand (FILE * file, rtx op, int letter)
34 else if (letter == 'h' || letter == 'j')
35 {
36 long val[2];
37- int val1[2];
38 long l[2];
39 if (code == CONST_DOUBLE)
40 {
41@@ -2619,10 +2623,10 @@ print_operand (FILE * file, rtx op, int letter)
42 }
43 else if (code == CONST_INT || code == CONST)// || code == SYMBOL_REF ||code == LABEL_REF)
44 {
45- val1[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
46- val1[1] = INTVAL (op) & 0x00000000ffffffffLL;
47+ val[0] = (INTVAL (op) & 0xffffffff00000000LL) >> 32;
48+ val[1] = INTVAL (op) & 0x00000000ffffffffLL;
49 }
50- fprintf (file, "0x%8.8lx", (letter == 'h') ? val1[0] : val1[1]);
51+ fprintf (file, "0x%8.8lx", (letter == 'h') ? val[0] : val[1]);
52 }
53 else if (code == CONST_DOUBLE)
54 {
55diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
56index fb22edb..4a8fbab 100644
57--- a/gcc/config/microblaze/microblaze.md
58+++ b/gcc/config/microblaze/microblaze.md
59@@ -1096,7 +1096,7 @@
60 case 1:
61 case 2:
62 {
63- output_asm_insn ("ll%i1\t%0,%1", operands);
64+ output_asm_insn ("lw%i1\t%0,%1", operands);
65 return "sextl32\t%0,%0";
66 }
67 }
68--
692.7.4
70
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0046-Fixed-below-issues.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0046-Fixed-below-issues.patch
new file mode 100644
index 00000000..fc2fe3b5
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0046-Fixed-below-issues.patch
@@ -0,0 +1,307 @@
1From 7c911a5ae8cf4a7496c059374f170f1919c00f6d Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 26 Nov 2019 17:26:15 +0530
4Subject: [PATCH 46/63] Fixed below issues:
5
6- Floating point print issues in 64bit mode
7- Dejagnu Jump related issues
8- Added dbl instruction
9
10Conflicts:
11 gcc/config/microblaze/microblaze.md
12---
13 gcc/config/microblaze/microblaze.c | 12 +++++-
14 gcc/config/microblaze/microblaze.h | 7 +++
15 gcc/config/microblaze/microblaze.md | 86 +++++++++++++++++++++++++++++++------
16 libgcc/config/microblaze/crti.S | 24 ++++++++++-
17 libgcc/config/microblaze/crtn.S | 13 ++++++
18 5 files changed, 125 insertions(+), 17 deletions(-)
19
20diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
21index bfa667b..220e03d 100644
22--- a/gcc/config/microblaze/microblaze.c
23+++ b/gcc/config/microblaze/microblaze.c
24@@ -2613,7 +2613,12 @@ print_operand (FILE * file, rtx op, int letter)
25 if (code == CONST_DOUBLE)
26 {
27 if (GET_MODE (op) == DFmode)
28- REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
29+ {
30+ if (TARGET_MB_64)
31+ REAL_VALUE_TO_TARGET_LONG_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
32+ else
33+ REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
34+ }
35 else
36 {
37 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), l);
38@@ -4014,7 +4019,10 @@ microblaze_expand_divide (rtx operands[])
39 gen_rtx_PLUS (QImode, regt1, div_table_rtx));
40
41 insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
42- jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
43+ if (TARGET_MB_64)
44+ jump = emit_jump_insn_after (gen_jump_64 (div_end_label), insn);
45+ else
46+ jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
47 JUMP_LABEL (jump) = div_end_label;
48 LABEL_NUSES (div_end_label) = 1;
49 emit_barrier ();
50diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
51index a23fd4e..7497cfb 100644
52--- a/gcc/config/microblaze/microblaze.h
53+++ b/gcc/config/microblaze/microblaze.h
54@@ -888,10 +888,17 @@ do { \
55 /* We do this to save a few 10s of code space that would be taken up
56 by the call_FUNC () wrappers, used by the generic CRT_CALL_STATIC_FUNCTION
57 definition in crtstuff.c. */
58+#ifdef __arch64__
59+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
60+ asm ( SECTION_OP "\n" \
61+ "\tbrealid r15, " #FUNC "\n\t nop\n" \
62+ TEXT_SECTION_ASM_OP);
63+#else
64 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
65 asm ( SECTION_OP "\n" \
66 "\tbrlid r15, " #FUNC "\n\t nop\n" \
67 TEXT_SECTION_ASM_OP);
68+#endif
69
70 /* We need to group -lm as well, since some Newlib math functions
71 reference __errno! */
72diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
73index 4a8fbab..65ec32c 100644
74--- a/gcc/config/microblaze/microblaze.md
75+++ b/gcc/config/microblaze/microblaze.md
76@@ -527,6 +527,15 @@
77 (set_attr "mode" "SF")
78 (set_attr "length" "4")])
79
80+(define_insn "floatdidf2"
81+ [(set (match_operand:DF 0 "register_operand" "=d")
82+ (float:DF (match_operand:DI 1 "register_operand" "d")))]
83+ "TARGET_MB_64"
84+ "dbl\t%0,%1"
85+ [(set_attr "type" "fcvt")
86+ (set_attr "mode" "DF")
87+ (set_attr "length" "4")])
88+
89 (define_insn "fix_truncsfsi2"
90 [(set (match_operand:SI 0 "register_operand" "=d")
91 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
92@@ -1300,7 +1309,7 @@
93 (define_insn "movdi_long_int"
94 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
95 (match_operand:DI 1 "general_operand" "i"))]
96- ""
97+ "TARGET_MB_64"
98 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
99 [(set_attr "type" "no_delay_arith")
100 (set_attr "mode" "DI")
101@@ -1583,7 +1592,7 @@
102 return "ll%i1\t%0,%1";
103 case 3:
104 {
105- return "addlik\t%0,r0,%h1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #Xfer Lo";
106+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
107 }
108 case 5:
109 return "sl%i0\t%1,%0";
110@@ -2373,9 +2382,9 @@ else
111
112 (define_insn "long_branch_compare"
113 [(set (pc)
114- (if_then_else (match_operator 0 "cmp_op"
115- [(match_operand 1 "register_operand" "d")
116- (match_operand 2 "register_operand" "d")
117+ (if_then_else (match_operator:DI 0 "cmp_op"
118+ [(match_operand:DI 1 "register_operand" "d")
119+ (match_operand:DI 2 "register_operand" "d")
120 ])
121 (label_ref (match_operand 3))
122 (pc)))
123@@ -2497,6 +2506,20 @@ else
124 ;;----------------------------------------------------------------
125 ;; Unconditional branches
126 ;;----------------------------------------------------------------
127+(define_insn "jump_64"
128+ [(set (pc)
129+ (label_ref (match_operand 0 "" "")))]
130+ "TARGET_MB_64"
131+ {
132+ if (GET_CODE (operands[0]) == REG)
133+ return "brea%?\t%0";
134+ else
135+ return "breai%?\t%l0";
136+ }
137+ [(set_attr "type" "jump")
138+ (set_attr "mode" "none")
139+ (set_attr "length" "4")])
140+
141 (define_insn "jump"
142 [(set (pc)
143 (label_ref (match_operand 0 "" "")))]
144@@ -2542,17 +2565,25 @@ else
145 {
146 //gcc_assert (GET_MODE (operands[0]) == Pmode);
147
148- if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)
149- emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
150- else
151- emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
152+ if (!flag_pic || TARGET_PIC_DATA_TEXT_REL) {
153+ if (!TARGET_MB_64)
154+ emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
155+ else
156+ emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
157+ }
158+ else {
159+ if (!TARGET_MB_64)
160+ emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
161+ else
162+ emit_jump_insn (gen_tablejump_internal4 (operands[0], operands[1]));
163+ }
164 DONE;
165 }
166 )
167
168 (define_insn "tablejump_internal1"
169 [(set (pc)
170- (match_operand 0 "register_operand" "d"))
171+ (match_operand:SI 0 "register_operand" "d"))
172 (use (label_ref (match_operand 1 "" "")))]
173 ""
174 "bra%?\t%0 "
175@@ -2560,11 +2591,21 @@ else
176 (set_attr "mode" "none")
177 (set_attr "length" "4")])
178
179+(define_insn "tablejump_internal2"
180+ [(set (pc)
181+ (match_operand:DI 0 "register_operand" "d"))
182+ (use (label_ref (match_operand 1 "" "")))]
183+ "TARGET_MB_64"
184+ "bra%?\t%0 "
185+ [(set_attr "type" "jump")
186+ (set_attr "mode" "none")
187+ (set_attr "length" "4")])
188+
189 (define_expand "tablejump_internal3"
190 [(parallel [(set (pc)
191- (plus (match_operand 0 "register_operand" "d")
192- (label_ref (match_operand:SI 1 "" ""))))
193- (use (label_ref (match_dup 1)))])]
194+ (plus:SI (match_operand:SI 0 "register_operand" "d")
195+ (label_ref:SI (match_operand:SI 1 "" ""))))
196+ (use (label_ref:SI (match_dup 1)))])]
197 ""
198 ""
199 )
200@@ -2595,6 +2636,23 @@ else
201 ""
202 )
203
204+(define_insn ""
205+ [(set (pc)
206+ (plus:DI (match_operand:DI 0 "register_operand" "d")
207+ (label_ref:DI (match_operand 1 "" ""))))
208+ (use (label_ref:DI (match_dup 1)))]
209+ "TARGET_MB_64 && NEXT_INSN (as_a <rtx_insn *> (operands[1])) != 0
210+ && GET_CODE (PATTERN (NEXT_INSN (as_a <rtx_insn *> (operands[1])))) == ADDR_DIFF_VEC
211+ && flag_pic"
212+ {
213+ output_asm_insn ("addlk\t%0,%0,r20",operands);
214+ return "bra%?\t%0";
215+}
216+ [(set_attr "type" "jump")
217+ (set_attr "mode" "none")
218+ (set_attr "length" "4")])
219+
220+
221 ;;----------------------------------------------------------------
222 ;; Function prologue/epilogue and stack allocation
223 ;;----------------------------------------------------------------
224@@ -3101,7 +3159,7 @@ else
225 ;; The insn to set GOT. The hardcoded number "8" accounts for $pc difference
226 ;; between "mfs" and "addik" instructions.
227 (define_insn "set_got"
228- [(set (match_operand:SI 0 "register_operand" "=r")
229+ [(set (match_operand 0 "register_operand" "=r")
230 (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))]
231 ""
232 "mfs\t%0,rpc\n\taddik\t%0,%0,_GLOBAL_OFFSET_TABLE_+8"
233diff --git a/libgcc/config/microblaze/crti.S b/libgcc/config/microblaze/crti.S
234index 1811327..a661319 100644
235--- a/libgcc/config/microblaze/crti.S
236+++ b/libgcc/config/microblaze/crti.S
237@@ -33,11 +33,32 @@
238 .section .init, "ax"
239 .global __init
240
241+#ifdef __arch64__
242 .weak _stack
243- .set _stack, 0xffffffff
244+ .set _stack, 0xffffffffffffffff
245 .weak _stack_end
246 .set _stack_end, 0
247
248+ .align 3
249+__init:
250+ addlik r1, r1, -32
251+ sl r15, r0, r1
252+ addlik r11, r0, _stack
253+ mts rshr, r11
254+ addlik r11, r0, _stack_end
255+ mts rslr, r11
256+
257+ .section .fini, "ax"
258+ .global __fini
259+ .align 3
260+__fini:
261+ addlik r1, r1, -32
262+ sl r15, r0, r1
263+#else
264+ .weak _stack
265+ .set _stack, 0xffffffff
266+ .weak _stack_end
267+ .set _stack_end, 0
268 .align 2
269 __init:
270 addik r1, r1, -16
271@@ -53,3 +74,4 @@ __init:
272 __fini:
273 addik r1, r1, -16
274 sw r15, r0, r1
275+#endif
276diff --git a/libgcc/config/microblaze/crtn.S b/libgcc/config/microblaze/crtn.S
277index 60a4648..d72507b 100644
278--- a/libgcc/config/microblaze/crtn.S
279+++ b/libgcc/config/microblaze/crtn.S
280@@ -29,7 +29,19 @@
281 .section .note.GNU-stack,"",%progbits
282 .previous
283 #endif
284+#ifdef __arch64__
285+ .section .init, "ax"
286+ ll r15, r0, r1
287+ addlik r1, r1, 32
288+ rtsd r15, 8
289+ nop
290
291+ .section .fini, "ax"
292+ ll r15, r0, r1
293+ addlik r1, r1, 32
294+ rtsd r15, 8
295+ nop
296+#else
297 .section .init, "ax"
298 lw r15, r0, r1
299 rtsd r15, 8
300@@ -39,3 +51,4 @@
301 lw r15, r0, r1
302 rtsd r15, 8
303 addik r1, r1, 16
304+#endif
305--
3062.7.4
307
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0047-Added-double-arith-instructions.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0047-Added-double-arith-instructions.patch
new file mode 100644
index 00000000..1b7ac28b
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0047-Added-double-arith-instructions.patch
@@ -0,0 +1,135 @@
1From 0f310964ff1c19cbc3404ec7ceba286d6de315c0 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 9 Oct 2018 10:07:08 +0530
4Subject: [PATCH 47/63] -Added double arith instructions -Fixed prologue stack
5 pointer decrement issue
6
7---
8 gcc/config/microblaze/microblaze.md | 78 ++++++++++++++++++++++++++++++++-----
9 gcc/config/microblaze/t-microblaze | 7 ++++
10 2 files changed, 76 insertions(+), 9 deletions(-)
11
12diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
13index 65ec32c..c199b27 100644
14--- a/gcc/config/microblaze/microblaze.md
15+++ b/gcc/config/microblaze/microblaze.md
16@@ -527,6 +527,66 @@
17 (set_attr "mode" "SF")
18 (set_attr "length" "4")])
19
20+(define_insn "fix_truncsfsi2"
21+ [(set (match_operand:SI 0 "register_operand" "=d")
22+ (fix:SI (match_operand:SF 1 "register_operand" "d")))]
23+ "TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
24+ "fint\t%0,%1"
25+ [(set_attr "type" "fint")
26+ (set_attr "mode" "SF")
27+ (set_attr "length" "4")])
28+
29+
30+(define_insn "adddf3"
31+ [(set (match_operand:DF 0 "register_operand" "=d")
32+ (plus:DF (match_operand:DF 1 "register_operand" "d")
33+ (match_operand:DF 2 "register_operand" "d")))]
34+ "TARGET_MB_64"
35+ "dadd\t%0,%1,%2"
36+ [(set_attr "type" "fadd")
37+ (set_attr "mode" "DF")
38+ (set_attr "length" "4")])
39+
40+(define_insn "subdf3"
41+ [(set (match_operand:DF 0 "register_operand" "=d")
42+ (minus:DF (match_operand:DF 1 "register_operand" "d")
43+ (match_operand:DF 2 "register_operand" "d")))]
44+ "TARGET_MB_64"
45+ "drsub\t%0,%2,%1"
46+ [(set_attr "type" "frsub")
47+ (set_attr "mode" "DF")
48+ (set_attr "length" "4")])
49+
50+(define_insn "muldf3"
51+ [(set (match_operand:DF 0 "register_operand" "=d")
52+ (mult:DF (match_operand:DF 1 "register_operand" "d")
53+ (match_operand:DF 2 "register_operand" "d")))]
54+ "TARGET_MB_64"
55+ "dmul\t%0,%1,%2"
56+ [(set_attr "type" "fmul")
57+ (set_attr "mode" "DF")
58+ (set_attr "length" "4")])
59+
60+(define_insn "divdf3"
61+ [(set (match_operand:DF 0 "register_operand" "=d")
62+ (div:DF (match_operand:DF 1 "register_operand" "d")
63+ (match_operand:DF 2 "register_operand" "d")))]
64+ "TARGET_MB_64"
65+ "ddiv\t%0,%2,%1"
66+ [(set_attr "type" "fdiv")
67+ (set_attr "mode" "DF")
68+ (set_attr "length" "4")])
69+
70+
71+(define_insn "sqrtdf2"
72+ [(set (match_operand:DF 0 "register_operand" "=d")
73+ (sqrt:DF (match_operand:DF 1 "register_operand" "d")))]
74+ "TARGET_MB_64"
75+ "dsqrt\t%0,%1"
76+ [(set_attr "type" "fsqrt")
77+ (set_attr "mode" "DF")
78+ (set_attr "length" "4")])
79+
80 (define_insn "floatdidf2"
81 [(set (match_operand:DF 0 "register_operand" "=d")
82 (float:DF (match_operand:DI 1 "register_operand" "d")))]
83@@ -536,13 +596,13 @@
84 (set_attr "mode" "DF")
85 (set_attr "length" "4")])
86
87-(define_insn "fix_truncsfsi2"
88- [(set (match_operand:SI 0 "register_operand" "=d")
89- (fix:SI (match_operand:SF 1 "register_operand" "d")))]
90- "TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
91- "fint\t%0,%1"
92- [(set_attr "type" "fint")
93- (set_attr "mode" "SF")
94+(define_insn "floatdfdi2"
95+ [(set (match_operand:DI 0 "register_operand" "=d")
96+ (float:DI (match_operand:DF 1 "register_operand" "d")))]
97+ "TARGET_MB_64"
98+ "dlong\t%0,%1"
99+ [(set_attr "type" "fcvt")
100+ (set_attr "mode" "DI")
101 (set_attr "length" "4")])
102
103 ;;----------------------------------------------------------------
104@@ -660,8 +720,8 @@
105 "TARGET_MB_64"
106 "@
107 rsubl\t%0,%2,%1
108- addik\t%0,%z1,-%2
109- addik\t%0,%z1,-%2"
110+ addlik\t%0,%z1,-%2
111+ addlik\t%0,%z1,-%2"
112 [(set_attr "type" "arith,no_delay_arith,no_delay_arith")
113 (set_attr "mode" "DI")
114 (set_attr "length" "4,4,4")])
115diff --git a/gcc/config/microblaze/t-microblaze b/gcc/config/microblaze/t-microblaze
116index 35ab9654..dfef45c 100644
117--- a/gcc/config/microblaze/t-microblaze
118+++ b/gcc/config/microblaze/t-microblaze
119@@ -1,6 +1,13 @@
120 MULTILIB_OPTIONS = m64 mxl-barrel-shift mlittle-endian mno-xl-soft-mul mxl-multiply-high
121 MULTILIB_DIRNAMES = m64 bs le m mh
122 MULTILIB_EXCEPTIONS = *m64/mxl-multiply-high mxl-multiply-high
123+MULTILIB_EXCEPTIONS += *m64
124+MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift
125+MULTILIB_EXCEPTIONS += *m64/mno-xl-soft-mul
126+MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift/mno-xl-soft-mul
127+MULTILIB_EXCEPTIONS += *m64/mno-xl-soft-mul
128+MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift/mno-xl-soft-mul/mxl-multiply-high
129+MULTILIB_EXCEPTIONS += *m64/mno-xl-soft-mul/mxl-multiply-high
130 MULTILIB_EXCEPTIONS += *mxl-barrel-shift/mxl-multiply-high mxl-multiply-high
131 MULTILIB_EXCEPTIONS += *mlittle-endian/mxl-multiply-high mxl-multiply-high
132 MULTILIB_EXCEPTIONS += *m64/mxl-barrel-shift/mlittle-endian/mxl-multiply-high
133--
1342.7.4
135
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0048-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0048-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch
new file mode 100644
index 00000000..c00b0a2b
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0048-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch
@@ -0,0 +1,37 @@
1From b63cd2a410b9350fa67ed3ca348dcca349da4e44 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 12 Oct 2018 16:07:36 +0530
4Subject: [PATCH 48/63] Fixed the issue in the delay slot with swap
5 instructions
6
7---
8 gcc/config/microblaze/microblaze.md | 6 ++++++
9 1 file changed, 6 insertions(+)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index c199b27..d6370d8 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -443,6 +443,9 @@
16 (bswap:SI (match_operand:SI 1 "register_operand" "r")))]
17 "TARGET_REORDER"
18 "swapb %0, %1"
19+ [(set_attr "type" "no_delay_arith")
20+ (set_attr "mode" "SI")
21+ (set_attr "length" "4")]
22 )
23
24 (define_insn "bswaphi2"
25@@ -451,6 +454,9 @@
26 "TARGET_REORDER"
27 "swapb %0, %1
28 swaph %0, %0"
29+ [(set_attr "type" "no_delay_arith")
30+ (set_attr "mode" "SI")
31+ (set_attr "length" "8")]
32 )
33
34 ;;----------------------------------------------------------------
35--
362.7.4
37
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0049-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0049-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch
new file mode 100644
index 00000000..7e92df2e
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0049-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch
@@ -0,0 +1,256 @@
1From f39f36cb0f0466343ef4ead50261b58595af708c Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Sat, 13 Oct 2018 21:12:43 +0530
4Subject: [PATCH 49/63] Fixed the load store issue with the 32bit arith
5 libraries
6
7---
8 libgcc/config/microblaze/divsi3.S | 25 ++++++++++++++++++++++++-
9 libgcc/config/microblaze/modsi3.S | 26 +++++++++++++++++++++++++-
10 libgcc/config/microblaze/mulsi3.S | 3 +++
11 libgcc/config/microblaze/udivsi3.S | 24 +++++++++++++++++++++++-
12 libgcc/config/microblaze/umodsi3.S | 24 +++++++++++++++++++++++-
13 5 files changed, 98 insertions(+), 4 deletions(-)
14
15diff --git a/libgcc/config/microblaze/divsi3.S b/libgcc/config/microblaze/divsi3.S
16index 24b94b9..2765e42 100644
17--- a/libgcc/config/microblaze/divsi3.S
18+++ b/libgcc/config/microblaze/divsi3.S
19@@ -41,6 +41,17 @@
20 .globl __divsi3
21 .ent __divsi3
22 .type __divsi3,@function
23+#ifdef __arch64__
24+ .align 3
25+__divsi3:
26+ .frame r1,0,r15
27+
28+ ADDIK r1,r1,-32
29+ SLI r28,r1,0
30+ SLI r29,r1,8
31+ SLI r30,r1,16
32+ SLI r31,r1,24
33+#else
34 __divsi3:
35 .frame r1,0,r15
36
37@@ -49,7 +60,7 @@ __divsi3:
38 SWI r29,r1,4
39 SWI r30,r1,8
40 SWI r31,r1,12
41-
42+#endif
43 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
44 BEQI r5,$LaResult_Is_Zero # Result is Zero
45 BGEID r5,$LaR5_Pos
46@@ -89,6 +100,17 @@ $LaLOOP_END:
47 $LaDiv_By_Zero:
48 $LaResult_Is_Zero:
49 OR r3,r0,r0 # set result to 0
50+#ifdef __arch64__
51+$LaRETURN_HERE:
52+# Restore values of CSRs and that of r3 and the divisor and the dividend
53+ LLI r28,r1,0
54+ LLI r29,r1,8
55+ LLI r30,r1,16
56+ LLI r31,r1,24
57+ ADDLIK r1,r1,32
58+ RTSD r15,8
59+ NOP
60+#else
61 $LaRETURN_HERE:
62 # Restore values of CSRs and that of r3 and the divisor and the dividend
63 LWI r28,r1,0
64@@ -97,6 +119,7 @@ $LaRETURN_HERE:
65 LWI r31,r1,12
66 RTSD r15,8
67 ADDIK r1,r1,16
68+#endif
69 .end __divsi3
70 .size __divsi3, . - __divsi3
71
72diff --git a/libgcc/config/microblaze/modsi3.S b/libgcc/config/microblaze/modsi3.S
73index 87372f5..7e61453 100644
74--- a/libgcc/config/microblaze/modsi3.S
75+++ b/libgcc/config/microblaze/modsi3.S
76@@ -41,6 +41,17 @@
77 .globl __modsi3
78 .ent __modsi3
79 .type __modsi3,@function
80+#ifdef __arch64__
81+ .align 3
82+__modsi3:
83+ .frame r1,0,r15
84+
85+ addlik r1,r1,-32
86+ sli r28,r1,0
87+ sli r29,r1,8
88+ sli r30,r1,16
89+ sli r31,r1,24
90+#else
91 __modsi3:
92 .frame r1,0,r15
93
94@@ -49,6 +60,7 @@ __modsi3:
95 swi r29,r1,4
96 swi r30,r1,8
97 swi r31,r1,12
98+#endif
99
100 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
101 BEQI r5,$LaResult_Is_Zero # Result is Zero
102@@ -88,6 +100,18 @@ $LaLOOP_END:
103 $LaDiv_By_Zero:
104 $LaResult_Is_Zero:
105 or r3,r0,r0 # set result to 0 [Both mod as well as div are 0]
106+
107+#ifdef __arch64__
108+$LaRETURN_HERE:
109+# Restore values of CSRs and that of r3 and the divisor and the dividend
110+ lli r28,r1,0
111+ lli r29,r1,8
112+ lli r30,r1,16
113+ lli r31,r1,24
114+ addik r1,r1,32
115+ rtsd r15,8
116+ nop
117+#else
118 $LaRETURN_HERE:
119 # Restore values of CSRs and that of r3 and the divisor and the dividend
120 lwi r28,r1,0
121@@ -95,7 +119,7 @@ $LaRETURN_HERE:
122 lwi r30,r1,8
123 lwi r31,r1,12
124 rtsd r15,8
125- addik r1,r1,16
126+#endif
127 .end __modsi3
128 .size __modsi3, . - __modsi3
129
130diff --git a/libgcc/config/microblaze/mulsi3.S b/libgcc/config/microblaze/mulsi3.S
131index 8c3f788..e28c69a 100644
132--- a/libgcc/config/microblaze/mulsi3.S
133+++ b/libgcc/config/microblaze/mulsi3.S
134@@ -41,6 +41,9 @@
135 .globl __mulsi3
136 .ent __mulsi3
137 .type __mulsi3,@function
138+#ifdef __arch64__
139+ .align 3
140+#endif
141 __mulsi3:
142 .frame r1,0,r15
143 add r3,r0,r0
144diff --git a/libgcc/config/microblaze/udivsi3.S b/libgcc/config/microblaze/udivsi3.S
145index 5d726ad..b1e44b6 100644
146--- a/libgcc/config/microblaze/udivsi3.S
147+++ b/libgcc/config/microblaze/udivsi3.S
148@@ -41,6 +41,16 @@
149 .globl __udivsi3
150 .ent __udivsi3
151 .type __udivsi3,@function
152+#ifdef __arch64__
153+ .align 3
154+__udivsi3:
155+ .frame r1,0,r15
156+
157+ ADDLIK r1,r1,-24
158+ SLI r29,r1,0
159+ SLI r30,r1,8
160+ SLI r31,r1,16
161+#else
162 __udivsi3:
163 .frame r1,0,r15
164
165@@ -48,7 +58,7 @@ __udivsi3:
166 SWI r29,r1,0
167 SWI r30,r1,4
168 SWI r31,r1,8
169-
170+#endif
171 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
172 BEQID r5,$LaResult_Is_Zero # Result is Zero
173 ADDIK r30,r0,0 # Clear mod
174@@ -98,6 +108,17 @@ $LaLOOP_END:
175 $LaDiv_By_Zero:
176 $LaResult_Is_Zero:
177 OR r3,r0,r0 # set result to 0
178+
179+#ifdef __arch64__
180+$LaRETURN_HERE:
181+ # Restore values of CSRs and that of r3 and the divisor and the dividend
182+ LLI r29,r1,0
183+ LLI r30,r1,8
184+ LLI r31,r1,16
185+ ADDIK r1,r1,24
186+ RTSD r15,8
187+ NOP
188+#else
189 $LaRETURN_HERE:
190 # Restore values of CSRs and that of r3 and the divisor and the dividend
191 LWI r29,r1,0
192@@ -105,5 +126,6 @@ $LaRETURN_HERE:
193 LWI r31,r1,8
194 RTSD r15,8
195 ADDIK r1,r1,12
196+#endif
197 .end __udivsi3
198 .size __udivsi3, . - __udivsi3
199diff --git a/libgcc/config/microblaze/umodsi3.S b/libgcc/config/microblaze/umodsi3.S
200index b29d7e1..8804b99 100644
201--- a/libgcc/config/microblaze/umodsi3.S
202+++ b/libgcc/config/microblaze/umodsi3.S
203@@ -41,6 +41,16 @@
204 .globl __umodsi3
205 .ent __umodsi3
206 .type __umodsi3,@function
207+#ifdef __arch64__
208+ .align 3
209+__umodsi3:
210+ .frame r1,0,r15
211+
212+ addik r1,r1,-24
213+ swi r29,r1,0
214+ swi r30,r1,8
215+ swi r31,r1,16
216+#else
217 __umodsi3:
218 .frame r1,0,r15
219
220@@ -48,7 +58,7 @@ __umodsi3:
221 swi r29,r1,0
222 swi r30,r1,4
223 swi r31,r1,8
224-
225+#endif
226 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
227 BEQId r5,$LaResult_Is_Zero # Result is Zero
228 ADDIK r3,r0,0 # Clear div
229@@ -101,6 +111,17 @@ $LaLOOP_END:
230 $LaDiv_By_Zero:
231 $LaResult_Is_Zero:
232 or r3,r0,r0 # set result to 0
233+
234+#ifdef __arch64__
235+$LaRETURN_HERE:
236+# Restore values of CSRs and that of r3 and the divisor and the dividend
237+ lli r29,r1,0
238+ lli r30,r1,8
239+ lli r31,r1,16
240+ addlik r1,r1,24
241+ rtsd r15,8
242+ nop
243+#else
244 $LaRETURN_HERE:
245 # Restore values of CSRs and that of r3 and the divisor and the dividend
246 lwi r29,r1,0
247@@ -108,5 +129,6 @@ $LaRETURN_HERE:
248 lwi r31,r1,8
249 rtsd r15,8
250 addik r1,r1,12
251+#endif
252 .end __umodsi3
253 .size __umodsi3, . - __umodsi3
254--
2552.7.4
256
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0050-extending-the-Dwarf-support-to-64bit-Microblaze.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0050-extending-the-Dwarf-support-to-64bit-Microblaze.patch
new file mode 100644
index 00000000..ba717327
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0050-extending-the-Dwarf-support-to-64bit-Microblaze.patch
@@ -0,0 +1,25 @@
1From 51886f40b6bccea22277f8dcc971706d7c24bdd0 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 15 Oct 2018 12:00:10 +0530
4Subject: [PATCH 50/63] extending the Dwarf support to 64bit Microblaze
5
6---
7 gcc/config/microblaze/microblaze.h | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-)
9
10diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
11index 7497cfb..bd5e216 100644
12--- a/gcc/config/microblaze/microblaze.h
13+++ b/gcc/config/microblaze/microblaze.h
14@@ -207,7 +207,7 @@ extern enum pipeline_type microblaze_pipe;
15 /* Use DWARF 2 debugging information by default. */
16 #define DWARF2_DEBUGGING_INFO 1
17 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
18-#define DWARF2_ADDR_SIZE 4
19+#define DWARF2_ADDR_SIZE (TARGET_MB_64 ? 8 : 4)
20
21 /* Target machine storage layout */
22
23--
242.7.4
25
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0051-fixing-the-typo-errors-in-umodsi3-file.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0051-fixing-the-typo-errors-in-umodsi3-file.patch
new file mode 100644
index 00000000..a0758b31
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0051-fixing-the-typo-errors-in-umodsi3-file.patch
@@ -0,0 +1,29 @@
1From a8978d71c8b5adfa59430443611bd785a4d54ef9 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Tue, 16 Oct 2018 07:55:46 +0530
4Subject: [PATCH 51/63] fixing the typo errors in umodsi3 file
5
6---
7 libgcc/config/microblaze/umodsi3.S | 6 +++---
8 1 file changed, 3 insertions(+), 3 deletions(-)
9
10diff --git a/libgcc/config/microblaze/umodsi3.S b/libgcc/config/microblaze/umodsi3.S
11index 8804b99..1b3070e 100644
12--- a/libgcc/config/microblaze/umodsi3.S
13+++ b/libgcc/config/microblaze/umodsi3.S
14@@ -47,9 +47,9 @@ __umodsi3:
15 .frame r1,0,r15
16
17 addik r1,r1,-24
18- swi r29,r1,0
19- swi r30,r1,8
20- swi r31,r1,16
21+ sli r29,r1,0
22+ sli r30,r1,8
23+ sli r31,r1,16
24 #else
25 __umodsi3:
26 .frame r1,0,r15
27--
282.7.4
29
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0052-fixing-the-32bit-LTO-related-issue9-1014024.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0052-fixing-the-32bit-LTO-related-issue9-1014024.patch
new file mode 100644
index 00000000..d0b534bc
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0052-fixing-the-32bit-LTO-related-issue9-1014024.patch
@@ -0,0 +1,68 @@
1From 328bd339c292b63d2068a132a245bdc037815d6b Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Wed, 17 Oct 2018 16:56:14 +0530
4Subject: [PATCH 52/63] fixing the 32bit LTO related issue9(1014024)
5
6---
7 gcc/config/microblaze/microblaze.h | 24 ++++++++++++++----------
8 1 file changed, 14 insertions(+), 10 deletions(-)
9
10diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
11index bd5e216..ab541f7 100644
12--- a/gcc/config/microblaze/microblaze.h
13+++ b/gcc/config/microblaze/microblaze.h
14@@ -265,12 +265,14 @@ extern enum pipeline_type microblaze_pipe;
15 #define WORD_REGISTER_OPERATIONS 1
16
17 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
18-/*
19-#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
20- if (GET_MODE_CLASS (MODE) == MODE_INT \
21- && GET_MODE_SIZE (MODE) < (TARGET_MB_64 ? 8 : 4)) \
22- (MODE) = TARGET_MB_64 ? DImode : SImode;
23-*/
24+
25+#ifndef __arch64__
26+#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
27+ if (GET_MODE_CLASS (MODE) == MODE_INT \
28+ && GET_MODE_SIZE (MODE) < 4) \
29+ (MODE) = SImode;
30+#endif
31+
32 /* Standard register usage. */
33
34 /* On the MicroBlaze, we have 32 integer registers */
35@@ -469,16 +471,18 @@ extern struct microblaze_frame_info current_frame_info;
36
37 #define MAX_ARGS_IN_REGISTERS MB_ABI_MAX_ARG_REGS
38
39+#ifdef __aarch64__
40 #define LIBCALL_VALUE(MODE) \
41 gen_rtx_REG (MODE,GP_RETURN)
42-
43-/*#define LIBCALL_VALUE(MODE) \
44+#else
45+#define LIBCALL_VALUE(MODE) \
46 gen_rtx_REG ( \
47 ((GET_MODE_CLASS (MODE) != MODE_INT \
48 || GET_MODE_SIZE (MODE) >= 4) \
49 ? (MODE) \
50 : SImode), GP_RETURN)
51-*/
52+#endif
53+
54 /* 1 if N is a possible register number for a function value.
55 On the MicroBlaze, R2 R3 are the only register thus used.
56 Currently, R2 are only implemented here (C has no complex type) */
57@@ -518,7 +522,7 @@ typedef struct microblaze_args
58 /* 4 insns + 2 words of data. */
59 #define TRAMPOLINE_SIZE (6 * 4)
60
61-#define TRAMPOLINE_ALIGNMENT 64
62+#define TRAMPOLINE_ALIGNMENT (TARGET_MB_64 ? 64 : 32)
63
64 #define REGNO_OK_FOR_BASE_P(regno) microblaze_regno_ok_for_base_p ((regno), 1)
65
66--
672.7.4
68
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0053-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0053-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch
new file mode 100644
index 00000000..f8ac364c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0053-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch
@@ -0,0 +1,25 @@
1From 3f65f0432d42f4d469fbb10828f1683cd30a5d84 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 19 Oct 2018 14:26:25 +0530
4Subject: [PATCH 53/63] Fixed the missing stack adjustment in prologue of
5 modsi3 function
6
7---
8 libgcc/config/microblaze/modsi3.S | 1 +
9 1 file changed, 1 insertion(+)
10
11diff --git a/libgcc/config/microblaze/modsi3.S b/libgcc/config/microblaze/modsi3.S
12index 7e61453..b0e6cad 100644
13--- a/libgcc/config/microblaze/modsi3.S
14+++ b/libgcc/config/microblaze/modsi3.S
15@@ -119,6 +119,7 @@ $LaRETURN_HERE:
16 lwi r30,r1,8
17 lwi r31,r1,12
18 rtsd r15,8
19+ addik r1,r1,16
20 #endif
21 .end __modsi3
22 .size __modsi3, . - __modsi3
23--
242.7.4
25
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0054-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0054-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch
new file mode 100644
index 00000000..0e704506
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0054-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch
@@ -0,0 +1,29 @@
1From 0dbb2b7bfe466c18d54aec680208fd1459619bc1 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 24 Oct 2018 18:31:04 +0530
4Subject: [PATCH 54/63] [Patch,Microblaze] : corrected SPN for dlong
5 instruction mapping.
6
7---
8 gcc/config/microblaze/microblaze.md | 4 ++--
9 1 file changed, 2 insertions(+), 2 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index d6370d8..6b6b7c6 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -602,9 +602,9 @@
16 (set_attr "mode" "DF")
17 (set_attr "length" "4")])
18
19-(define_insn "floatdfdi2"
20+(define_insn "fix_truncdfdi2"
21 [(set (match_operand:DI 0 "register_operand" "=d")
22- (float:DI (match_operand:DF 1 "register_operand" "d")))]
23+ (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
24 "TARGET_MB_64"
25 "dlong\t%0,%1"
26 [(set_attr "type" "fcvt")
27--
282.7.4
29
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0055-fixing-the-long-long-long-mingw-toolchain-issue.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0055-fixing-the-long-long-long-mingw-toolchain-issue.patch
new file mode 100644
index 00000000..28554722
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0055-fixing-the-long-long-long-mingw-toolchain-issue.patch
@@ -0,0 +1,59 @@
1From a56b23ae244eee1da6d6595d3a6477085d77271e Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 29 Nov 2018 17:55:08 +0530
4Subject: [PATCH 55/63] fixing the long & long long mingw toolchain issue
5
6---
7 gcc/config/microblaze/constraints.md | 2 +-
8 gcc/config/microblaze/microblaze.md | 8 ++++----
9 2 files changed, 5 insertions(+), 5 deletions(-)
10
11diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md
12index 2fce91e..9a5aa6b 100644
13--- a/gcc/config/microblaze/constraints.md
14+++ b/gcc/config/microblaze/constraints.md
15@@ -55,7 +55,7 @@
16 (define_constraint "K"
17 "A constant in the range 0xffffff8000000000L to 0x0000007fffffffffL (inclusive)."
18 (and (match_code "const_int")
19- (match_test "ival > (long)-549755813888 && ival < (long)549755813887")))
20+ (match_test "ival > (long long)-549755813888 && ival < (long long)549755813887")))
21
22 ;; Define floating point constraints
23
24diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
25index 6b6b7c6..a1dc41f 100644
26--- a/gcc/config/microblaze/microblaze.md
27+++ b/gcc/config/microblaze/microblaze.md
28@@ -648,8 +648,8 @@
29 if (TARGET_MB_64)
30 {
31 if (GET_CODE (operands[2]) == CONST_INT &&
32- INTVAL(operands[2]) < (long)-549755813888 &&
33- INTVAL(operands[2]) > (long)549755813887)
34+ INTVAL(operands[2]) < (long long)-549755813888 &&
35+ INTVAL(operands[2]) > (long long)549755813887)
36 FAIL;
37 }
38 })
39@@ -1266,7 +1266,7 @@
40 (match_operand:DI 1 "immediate_operand" "J,I,Mnis"))]
41 "TARGET_MB_64 && (register_operand (operands[0], DImode) &&
42 (GET_CODE (operands[1]) == CONST_INT &&
43- (INTVAL (operands[1]) <= (long)549755813887 && INTVAL (operands[1]) >= (long)-549755813888)))"
44+ (INTVAL (operands[1]) <= (long long)549755813887 && INTVAL (operands[1]) >= (long long)-549755813888)))"
45 "@
46 addlk\t%0,r0,r0\t
47 addlik\t%0,r0,%1\t #N1 %X1
48@@ -1300,7 +1300,7 @@
49 case 1:
50 case 2:
51 if (GET_CODE (operands[1]) == CONST_INT &&
52- (INTVAL (operands[1]) > (long)549755813887 || INTVAL (operands[1]) < (long)-549755813888))
53+ (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
54 return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
55 else
56 return "addlik\t%0,r0,%1";
57--
582.7.4
59
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0055-microblaze_linker_script_xilinx_ld.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0055-microblaze_linker_script_xilinx_ld.patch
new file mode 100644
index 00000000..c009c92d
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0055-microblaze_linker_script_xilinx_ld.patch
@@ -0,0 +1,16 @@
1diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
2index 740b8d9..4bda9c2 100644
3--- a/gcc/config/microblaze/microblaze.h
4+++ b/gcc/config/microblaze/microblaze.h
5@@ -114,8 +114,9 @@ extern enum pipeline_type microblaze_pipe;
6 %{m64:-EL --oformat=elf64-microblazeel} \
7 %{Zxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
8 %{mxl-mode-xmdstub:-defsym _TEXT_START_ADDR=0x800} \
9- %{mxl-gp-opt:%{G*}} %{!mxl-gp-opt: -G 0} \
10- %{!T*: -dT xilinx.ld%s}"
11+ %{mxl-gp-opt:%{G*}} %{!mxl-gp-opt: -G 0}"
12+
13+// %{!T*: -dT xilinx.ld%s}"
14
15 /* Specs for the compiler proper */
16
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0056-Fix-the-MB-64-bug-of-handling-QI-objects.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0056-Fix-the-MB-64-bug-of-handling-QI-objects.patch
new file mode 100644
index 00000000..a419216c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0056-Fix-the-MB-64-bug-of-handling-QI-objects.patch
@@ -0,0 +1,47 @@
1From e13b1b70972511a642512cbc7093ed21e5a9e141 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 14 Mar 2019 18:11:04 +0530
4Subject: [PATCH 56/63] Fix the MB-64 bug of handling QI objects
5
6---
7 gcc/config/microblaze/microblaze.md | 14 +++++++-------
8 1 file changed, 7 insertions(+), 7 deletions(-)
9
10diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
11index a1dc41f..bb96e2d 100644
12--- a/gcc/config/microblaze/microblaze.md
13+++ b/gcc/config/microblaze/microblaze.md
14@@ -2347,11 +2347,11 @@ else
15
16 (define_insn "branch_zero_64"
17 [(set (pc)
18- (if_then_else (match_operator:SI 0 "ordered_comparison_operator"
19+ (if_then_else (match_operator 0 "ordered_comparison_operator"
20 [(match_operand:SI 1 "register_operand" "d")
21 (const_int 0)])
22- (match_operand:SI 2 "pc_or_label_operand" "")
23- (match_operand:SI 3 "pc_or_label_operand" "")))
24+ (match_operand 2 "pc_or_label_operand" "")
25+ (match_operand 3 "pc_or_label_operand" "")))
26 ]
27 "TARGET_MB_64"
28 {
29@@ -2367,11 +2367,11 @@ else
30
31 (define_insn "long_branch_zero"
32 [(set (pc)
33- (if_then_else (match_operator 0 "ordered_comparison_operator"
34- [(match_operand 1 "register_operand" "d")
35+ (if_then_else (match_operator:DI 0 "ordered_comparison_operator"
36+ [(match_operand:DI 1 "register_operand" "d")
37 (const_int 0)])
38- (match_operand 2 "pc_or_label_operand" "")
39- (match_operand 3 "pc_or_label_operand" "")))
40+ (match_operand:DI 2 "pc_or_label_operand" "")
41+ (match_operand:DI 3 "pc_or_label_operand" "")))
42 ]
43 "TARGET_MB_64"
44 {
45--
462.7.4
47
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0056-fix-the-lto-wrapper-issue-on-windows.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0056-fix-the-lto-wrapper-issue-on-windows.patch
new file mode 100644
index 00000000..ff524770
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0056-fix-the-lto-wrapper-issue-on-windows.patch
@@ -0,0 +1,36 @@
1From f30b99b5b8d3f2a8d8e4973cd155a4b9f1849039 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 14 Mar 2019 18:08:06 +0530
4Subject: [PATCH 56/57] fix the lto-wrapper issue on windows
5
6---
7 libiberty/simple-object.c | 6 +++++-
8 1 file changed, 5 insertions(+), 1 deletion(-)
9
10diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c
11index 42aa6ac..d2465c6 100644
12--- a/libiberty/simple-object.c
13+++ b/libiberty/simple-object.c
14@@ -44,6 +44,10 @@ Boston, MA 02110-1301, USA. */
15 #define SEEK_SET 0
16 #endif
17
18+#ifndef O_BINARY
19+#define O_BINARY 0
20+#endif
21+
22 #include "simple-object-common.h"
23
24 /* The known object file formats. */
25@@ -326,7 +330,7 @@ simple_object_copy_lto_debug_sections (simple_object_read *sobj,
26 return errmsg;
27 }
28
29- outfd = creat (dest, 00777);
30+ outfd = open (dest, O_CREAT|O_WRONLY|O_TRUNC|O_BINARY, 00777);
31 if (outfd == -1)
32 {
33 *err = errno;
34--
352.7.4
36
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0057-Fix-the-MB-64-bug-of-handling-QI-objects.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0057-Fix-the-MB-64-bug-of-handling-QI-objects.patch
new file mode 100644
index 00000000..a5a2039d
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0057-Fix-the-MB-64-bug-of-handling-QI-objects.patch
@@ -0,0 +1,47 @@
1From 6c58973f1cc1e37773aeab583aa3ac6331489106 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 14 Mar 2019 18:11:04 +0530
4Subject: [PATCH 57/57] Fix the MB-64 bug of handling QI objects
5
6---
7 gcc/config/microblaze/microblaze.md | 14 +++++++-------
8 1 file changed, 7 insertions(+), 7 deletions(-)
9
10diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
11index e03b835..88aee9e 100644
12--- a/gcc/config/microblaze/microblaze.md
13+++ b/gcc/config/microblaze/microblaze.md
14@@ -2345,11 +2345,11 @@ else
15
16 (define_insn "branch_zero_64"
17 [(set (pc)
18- (if_then_else (match_operator:SI 0 "ordered_comparison_operator"
19+ (if_then_else (match_operator 0 "ordered_comparison_operator"
20 [(match_operand:SI 1 "register_operand" "d")
21 (const_int 0)])
22- (match_operand:SI 2 "pc_or_label_operand" "")
23- (match_operand:SI 3 "pc_or_label_operand" "")))
24+ (match_operand 2 "pc_or_label_operand" "")
25+ (match_operand 3 "pc_or_label_operand" "")))
26 ]
27 "TARGET_MB_64"
28 {
29@@ -2365,11 +2365,11 @@ else
30
31 (define_insn "long_branch_zero"
32 [(set (pc)
33- (if_then_else (match_operator 0 "ordered_comparison_operator"
34- [(match_operand 1 "register_operand" "d")
35+ (if_then_else (match_operator:DI 0 "ordered_comparison_operator"
36+ [(match_operand:DI 1 "register_operand" "d")
37 (const_int 0)])
38- (match_operand 2 "pc_or_label_operand" "")
39- (match_operand 3 "pc_or_label_operand" "")))
40+ (match_operand:DI 2 "pc_or_label_operand" "")
41+ (match_operand:DI 3 "pc_or_label_operand" "")))
42 ]
43 "TARGET_MB_64"
44 {
45--
462.7.4
47
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0057-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0057-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch
new file mode 100644
index 00000000..940009de
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0057-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch
@@ -0,0 +1,87 @@
1From 1387d4fedb397f78b08ad33204a3fcf2bd63f183 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Fri, 29 Mar 2019 12:08:39 +0530
4Subject: [PATCH 57/63] [Patch,Microblaze] : We will check the possibility of
5 peephole2 optimization,if we can then we will fix the compiler issue.
6
7---
8 gcc/config/microblaze/microblaze.md | 63 ++++++++++++++++++++++---------------
9 1 file changed, 38 insertions(+), 25 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index bb96e2d..830ef77 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -882,31 +882,44 @@
16 (set_attr "mode" "SI")
17 (set_attr "length" "4")])
18
19-(define_peephole2
20- [(set (match_operand:SI 0 "register_operand")
21- (fix:SI (match_operand:SF 1 "register_operand")))
22- (set (pc)
23- (if_then_else (match_operator 2 "ordered_comparison_operator"
24- [(match_operand:SI 3 "register_operand")
25- (match_operand:SI 4 "arith_operand")])
26- (label_ref (match_operand 5))
27- (pc)))]
28- "TARGET_HARD_FLOAT && !TARGET_MB_64"
29- [(set (match_dup 1) (match_dup 3))]
30-
31- {
32- rtx condition;
33- rtx cmp_op0 = operands[3];
34- rtx cmp_op1 = operands[4];
35- rtx comp_reg = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
36-
37- emit_insn (gen_cstoresf4 (comp_reg, operands[2],
38- gen_rtx_REG (SFmode, REGNO (cmp_op0)),
39- gen_rtx_REG (SFmode, REGNO (cmp_op1))));
40- condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
41- emit_jump_insn (gen_condjump (condition, operands[5]));
42- }
43-)
44+;; peephole2 optimization will be done only if fint and if-then-else
45+;; are dependent.added condition for the same.
46+;; if they are dependent then gcc is giving "flow control insn inside a basic block"
47+;; testcase:
48+;; volatile float vec = 1.0;
49+;; volatile int ci = 2;
50+;; register int cj = (int)(vec);
51+;;// ci=cj;
52+;;// if (ci <0) {
53+;; if (cj < 0) {
54+;; ci = 0;
55+;; }
56+;; commenting for now.we will check the possibility of this optimization later
57+
58+;;(define_peephole2
59+;; [(set (match_operand:SI 0 "register_operand")
60+;; (fix:SI (match_operand:SF 1 "register_operand")))
61+;; (set (pc)
62+;; (if_then_else (match_operator 2 "ordered_comparison_operator"
63+;; [(match_operand:SI 3 "register_operand")
64+;; (match_operand:SI 4 "arith_operand")])
65+;; (label_ref (match_operand 5))
66+;; (pc)))]
67+;; "TARGET_HARD_FLOAT && !TARGET_MB_64 && ((REGNO (operands[0])) == (REGNO (operands[3])))"
68+;; [(set (match_dup 1) (match_dup 3))]
69+;; {
70+;; rtx condition;
71+;; rtx cmp_op0 = operands[3];
72+;; rtx cmp_op1 = operands[4];
73+;; rtx comp_reg = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
74+;;
75+;; emit_insn (gen_cstoresf4 (comp_reg, operands[2],
76+;; gen_rtx_REG (SFmode, REGNO (cmp_op0)),
77+;; gen_rtx_REG (SFmode, REGNO (cmp_op1))));
78+;; condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
79+;; emit_jump_insn (gen_condjump (condition, operands[5]));
80+;; }
81+;;)
82
83 ;;----------------------------------------------------------------
84 ;; Negation and one's complement
85--
862.7.4
87
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0058-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0058-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch
new file mode 100644
index 00000000..8bc47a43
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0058-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch
@@ -0,0 +1,87 @@
1From bcbfd9f69d858306a080aa7213e96ca6eca66106 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Fri, 29 Mar 2019 12:08:39 +0530
4Subject: [PATCH 58/61] [Patch,Microblaze] : We will check the possibility of
5 peephole2 optimization,if we can then we will fix the compiler issue.
6
7---
8 gcc/config/microblaze/microblaze.md | 63 ++++++++++++++++++++++---------------
9 1 file changed, 38 insertions(+), 25 deletions(-)
10
11diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
12index 88aee9e..8bd175f 100644
13--- a/gcc/config/microblaze/microblaze.md
14+++ b/gcc/config/microblaze/microblaze.md
15@@ -880,31 +880,44 @@
16 (set_attr "mode" "SI")
17 (set_attr "length" "4")])
18
19-(define_peephole2
20- [(set (match_operand:SI 0 "register_operand")
21- (fix:SI (match_operand:SF 1 "register_operand")))
22- (set (pc)
23- (if_then_else (match_operator 2 "ordered_comparison_operator"
24- [(match_operand:SI 3 "register_operand")
25- (match_operand:SI 4 "arith_operand")])
26- (label_ref (match_operand 5))
27- (pc)))]
28- "TARGET_HARD_FLOAT && !TARGET_MB_64"
29- [(set (match_dup 1) (match_dup 3))]
30-
31- {
32- rtx condition;
33- rtx cmp_op0 = operands[3];
34- rtx cmp_op1 = operands[4];
35- rtx comp_reg = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
36-
37- emit_insn (gen_cstoresf4 (comp_reg, operands[2],
38- gen_rtx_REG (SFmode, REGNO (cmp_op0)),
39- gen_rtx_REG (SFmode, REGNO (cmp_op1))));
40- condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
41- emit_jump_insn (gen_condjump (condition, operands[5]));
42- }
43-)
44+;; peephole2 optimization will be done only if fint and if-then-else
45+;; are dependent.added condition for the same.
46+;; if they are dependent then gcc is giving "flow control insn inside a basic block"
47+;; testcase:
48+;; volatile float vec = 1.0;
49+;; volatile int ci = 2;
50+;; register int cj = (int)(vec);
51+;;// ci=cj;
52+;;// if (ci <0) {
53+;; if (cj < 0) {
54+;; ci = 0;
55+;; }
56+;; commenting for now.we will check the possibility of this optimization later
57+
58+;;(define_peephole2
59+;; [(set (match_operand:SI 0 "register_operand")
60+;; (fix:SI (match_operand:SF 1 "register_operand")))
61+;; (set (pc)
62+;; (if_then_else (match_operator 2 "ordered_comparison_operator"
63+;; [(match_operand:SI 3 "register_operand")
64+;; (match_operand:SI 4 "arith_operand")])
65+;; (label_ref (match_operand 5))
66+;; (pc)))]
67+;; "TARGET_HARD_FLOAT && !TARGET_MB_64 && ((REGNO (operands[0])) == (REGNO (operands[3])))"
68+;; [(set (match_dup 1) (match_dup 3))]
69+;; {
70+;; rtx condition;
71+;; rtx cmp_op0 = operands[3];
72+;; rtx cmp_op1 = operands[4];
73+;; rtx comp_reg = gen_rtx_REG (SImode, MB_ABI_ASM_TEMP_REGNUM);
74+;;
75+;; emit_insn (gen_cstoresf4 (comp_reg, operands[2],
76+;; gen_rtx_REG (SFmode, REGNO (cmp_op0)),
77+;; gen_rtx_REG (SFmode, REGNO (cmp_op1))));
78+;; condition = gen_rtx_NE (SImode, comp_reg, const0_rtx);
79+;; emit_jump_insn (gen_condjump (condition, operands[5]));
80+;; }
81+;;)
82
83 ;;----------------------------------------------------------------
84 ;; Negation and one's complement
85--
862.7.4
87
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0058-Reverting-the-patch-as-kernel-boot-is-not-working-wi.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0058-Reverting-the-patch-as-kernel-boot-is-not-working-wi.patch
new file mode 100644
index 00000000..69b49898
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0058-Reverting-the-patch-as-kernel-boot-is-not-working-wi.patch
@@ -0,0 +1,51 @@
1From 8e7d7f3d2e103c34bbb28afe1338107b9fd824f0 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 16 Apr 2019 17:20:24 +0530
4Subject: [PATCH 58/63] Reverting the patch as kernel boot is not working with
5 this patch CR-1026413 Revert "[Patch,Microblaze]:reverting the cost check
6 before propagating constants."
7
8This reverts commit 7156e379a67fa47a5fb9ede1448c0d528dbda65b.
9---
10 gcc/cprop.c | 4 ----
11 1 file changed, 4 deletions(-)
12
13diff --git a/gcc/cprop.c b/gcc/cprop.c
14index 42bcc81..65c0130 100644
15--- a/gcc/cprop.c
16+++ b/gcc/cprop.c
17@@ -733,7 +733,6 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
18 int success = 0;
19 rtx set = single_set (insn);
20
21-#if 0
22 bool check_rtx_costs = true;
23 bool speed = optimize_bb_for_speed_p (BLOCK_FOR_INSN (insn));
24 int old_cost = set ? set_rtx_cost (set, speed) : 0;
25@@ -745,7 +744,6 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
26 && (GET_CODE (XEXP (note, 0)) == CONST
27 || CONSTANT_P (XEXP (note, 0)))))
28 check_rtx_costs = false;
29-#endif
30
31 /* Usually we substitute easy stuff, so we won't copy everything.
32 We however need to take care to not duplicate non-trivial CONST
33@@ -754,7 +752,6 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
34
35 validate_replace_src_group (from, to, insn);
36
37-#if 0
38 /* If TO is a constant, check the cost of the set after propagation
39 to the cost of the set before the propagation. If the cost is
40 higher, then do not replace FROM with TO. */
41@@ -767,7 +764,6 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
42 return false;
43 }
44
45-#endif
46
47 if (num_changes_pending () && apply_change_group ())
48 success = 1;
49--
502.7.4
51
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0059-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0059-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch
new file mode 100644
index 00000000..2e570330
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0059-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch
@@ -0,0 +1,466 @@
1From e1a10a708f209704a3921cf66dd3ff4d0814befc Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 17 Apr 2019 12:36:16 +0530
4Subject: [PATCH 59/63] [Patch,MicroBlaze]: fixed typos in mul,div and mod
5 assembly files.
6
7---
8 libgcc/config/microblaze/divsi3.S | 47 ++++++++++++++++++++++++++----
9 libgcc/config/microblaze/modsi3.S | 40 +++++++++++++++++++++++---
10 libgcc/config/microblaze/mulsi3.S | 33 +++++++++++++++++++++-
11 libgcc/config/microblaze/udivsi3.S | 54 +++++++++++++++++++++++++++++++----
12 libgcc/config/microblaze/umodsi3.S | 58 +++++++++++++++++++++++++++++++++++---
13 5 files changed, 212 insertions(+), 20 deletions(-)
14
15diff --git a/libgcc/config/microblaze/divsi3.S b/libgcc/config/microblaze/divsi3.S
16index 2765e42..bd56522 100644
17--- a/libgcc/config/microblaze/divsi3.S
18+++ b/libgcc/config/microblaze/divsi3.S
19@@ -46,7 +46,7 @@
20 __divsi3:
21 .frame r1,0,r15
22
23- ADDIK r1,r1,-32
24+ ADDLIK r1,r1,-32
25 SLI r28,r1,0
26 SLI r29,r1,8
27 SLI r30,r1,16
28@@ -61,13 +61,23 @@ __divsi3:
29 SWI r30,r1,8
30 SWI r31,r1,12
31 #endif
32- BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
33- BEQI r5,$LaResult_Is_Zero # Result is Zero
34- BGEID r5,$LaR5_Pos
35+#ifdef __arch64__
36+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
37+ BEAEQI r5,$LaResult_Is_Zero # Result is Zero
38+ BEAGEID r5,$LaR5_Pos
39+#else
40+ BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
41+ BEQI r5,$LaResult_Is_Zero # Result is Zero
42+ BGEID r5,$LaR5_Pos
43+#endif
44 XOR r28,r5,r6 # Get the sign of the result
45 RSUBI r5,r5,0 # Make r5 positive
46 $LaR5_Pos:
47- BGEI r6,$LaR6_Pos
48+#ifdef __arch64__
49+ BEAGEI r6,$LaR6_Pos
50+#else
51+ BGEI r6,$LaR6_Pos
52+#endif
53 RSUBI r6,r6,0 # Make r6 positive
54 $LaR6_Pos:
55 ADDIK r30,r0,0 # Clear mod
56@@ -76,26 +86,51 @@ $LaR6_Pos:
57
58 # First part try to find the first '1' in the r5
59 $LaDIV0:
60- BLTI r5,$LaDIV2 # This traps r5 == 0x80000000
61+#ifdef __arch64__
62+ BEALTI r5,$LaDIV2 # This traps r5 == 0x80000000
63+#else
64+ BLTI r5,$LaDIV2 # This traps r5 == 0x80000000
65+#endif
66 $LaDIV1:
67 ADD r5,r5,r5 # left shift logical r5
68+#ifdef __arch64__
69+ BEAGTID r5,$LaDIV1
70+#else
71 BGTID r5,$LaDIV1
72+#endif
73 ADDIK r29,r29,-1
74 $LaDIV2:
75 ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
76 ADDC r30,r30,r30 # Move that bit into the Mod register
77 RSUB r31,r6,r30 # Try to subtract (r30 a r6)
78+#ifdef __arch64__
79+ BEALTI r31,$LaMOD_TOO_SMALL
80+#else
81 BLTI r31,$LaMOD_TOO_SMALL
82+#endif
83 OR r30,r0,r31 # Move the r31 to mod since the result was positive
84 ADDIK r3,r3,1
85 $LaMOD_TOO_SMALL:
86 ADDIK r29,r29,-1
87+#ifdef __arch64__
88+ BEAEQi r29,$LaLOOP_END
89+#else
90 BEQi r29,$LaLOOP_END
91+#endif
92 ADD r3,r3,r3 # Shift in the '1' into div
93+#ifdef __arch64__
94+ BREAI $LaDIV2 # Div2
95+#else
96 BRI $LaDIV2 # Div2
97+#endif
98 $LaLOOP_END:
99+#ifdef __arch64__
100+ BEAGEI r28,$LaRETURN_HERE
101+ BREAID $LaRETURN_HERE
102+#else
103 BGEI r28,$LaRETURN_HERE
104 BRID $LaRETURN_HERE
105+#endif
106 RSUBI r3,r3,0 # Negate the result
107 $LaDiv_By_Zero:
108 $LaResult_Is_Zero:
109diff --git a/libgcc/config/microblaze/modsi3.S b/libgcc/config/microblaze/modsi3.S
110index b0e6cad..3632fad 100644
111--- a/libgcc/config/microblaze/modsi3.S
112+++ b/libgcc/config/microblaze/modsi3.S
113@@ -62,40 +62,72 @@ __modsi3:
114 swi r31,r1,12
115 #endif
116
117+#ifdef __arch64__
118+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
119+ BEAEQI r5,$LaResult_Is_Zero # Result is Zero
120+ BEAGEId r5,$LaR5_Pos
121+#else
122 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
123 BEQI r5,$LaResult_Is_Zero # Result is Zero
124 BGEId r5,$LaR5_Pos
125+#endif
126 ADD r28,r5,r0 # Get the sign of the result [ Depends only on the first arg]
127 RSUBI r5,r5,0 # Make r5 positive
128 $LaR5_Pos:
129- BGEI r6,$LaR6_Pos
130+#ifdef __arch64__
131+ BEAGEI r6,$LaR6_Pos
132+#else
133+ BGEI r6,$LaR6_Pos
134+#endif
135 RSUBI r6,r6,0 # Make r6 positive
136 $LaR6_Pos:
137 ADDIK r3,r0,0 # Clear mod
138 ADDIK r30,r0,0 # clear div
139- BLTId r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
140+#ifdef __arch64__
141+ BEALTId r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
142 # the first bit search.
143+#else
144+ BLTId r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
145+ # the first bit search.
146+#endif
147 ADDIK r29,r0,32 # Initialize the loop count
148 # First part try to find the first '1' in the r5
149 $LaDIV1:
150 ADD r5,r5,r5 # left shift logical r5
151- BGEID r5,$LaDIV1 #
152+#ifdef __arch64__
153+ BEAGEID r5,$LaDIV1 #
154+#else
155+ BGEID r5,$LaDIV1 #
156+#endif
157 ADDIK r29,r29,-1
158 $LaDIV2:
159 ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
160 ADDC r3,r3,r3 # Move that bit into the Mod register
161 rSUB r31,r6,r3 # Try to subtract (r30 a r6)
162+#ifdef __arch64__
163+ BEALTi r31,$LaMOD_TOO_SMALL
164+#else
165 BLTi r31,$LaMOD_TOO_SMALL
166+#endif
167 OR r3,r0,r31 # Move the r31 to mod since the result was positive
168 ADDIK r30,r30,1
169 $LaMOD_TOO_SMALL:
170 ADDIK r29,r29,-1
171+#ifdef __arch64__
172+ BEAEQi r29,$LaLOOP_END
173+ ADD r30,r30,r30 # Shift in the '1' into div
174+ BREAI $LaDIV2 # Div2
175+$LaLOOP_END:
176+ BEAGEI r28,$LaRETURN_HERE
177+ BREAId $LaRETURN_HERE
178+#else
179 BEQi r29,$LaLOOP_END
180 ADD r30,r30,r30 # Shift in the '1' into div
181 BRI $LaDIV2 # Div2
182 $LaLOOP_END:
183 BGEI r28,$LaRETURN_HERE
184 BRId $LaRETURN_HERE
185+#endif
186 rsubi r3,r3,0 # Negate the result
187 $LaDiv_By_Zero:
188 $LaResult_Is_Zero:
189@@ -108,7 +140,7 @@ $LaRETURN_HERE:
190 lli r29,r1,8
191 lli r30,r1,16
192 lli r31,r1,24
193- addik r1,r1,32
194+ addlik r1,r1,32
195 rtsd r15,8
196 nop
197 #else
198diff --git a/libgcc/config/microblaze/mulsi3.S b/libgcc/config/microblaze/mulsi3.S
199index e28c69a..991dbcd 100644
200--- a/libgcc/config/microblaze/mulsi3.S
201+++ b/libgcc/config/microblaze/mulsi3.S
202@@ -43,7 +43,37 @@
203 .type __mulsi3,@function
204 #ifdef __arch64__
205 .align 3
206-#endif
207+__mulsi3:
208+ .frame r1,0,r15
209+ add r3,r0,r0
210+ BEAEQI r5,$L_Result_Is_Zero # Multiply by Zero
211+ BEAEQI r6,$L_Result_Is_Zero # Multiply by Zero
212+ BEAGEId r5,$L_R5_Pos
213+ XOR r4,r5,r6 # Get the sign of the result
214+ RSUBI r5,r5,0 # Make r5 positive
215+$L_R5_Pos:
216+ BEAGEI r6,$L_R6_Pos
217+ RSUBI r6,r6,0 # Make r6 positive
218+$L_R6_Pos:
219+ breai $L1
220+$L2:
221+ add r5,r5,r5
222+$L1:
223+ srl r6,r6
224+ addc r7,r0,r0
225+ beaeqi r7,$L2
226+ beaneid r6,$L2
227+ add r3,r3,r5
228+ bealti r4,$L_NegateResult
229+ rtsd r15,8
230+ nop
231+$L_NegateResult:
232+ rtsd r15,8
233+ rsub r3,r3,r0
234+$L_Result_Is_Zero:
235+ rtsd r15,8
236+ addi r3,r0,0
237+#else
238 __mulsi3:
239 .frame r1,0,r15
240 add r3,r0,r0
241@@ -74,5 +104,6 @@ $L_NegateResult:
242 $L_Result_Is_Zero:
243 rtsd r15,8
244 addi r3,r0,0
245+#endif
246 .end __mulsi3
247 .size __mulsi3, . - __mulsi3
248diff --git a/libgcc/config/microblaze/udivsi3.S b/libgcc/config/microblaze/udivsi3.S
249index b1e44b6..42b086e 100644
250--- a/libgcc/config/microblaze/udivsi3.S
251+++ b/libgcc/config/microblaze/udivsi3.S
252@@ -59,52 +59,96 @@ __udivsi3:
253 SWI r30,r1,4
254 SWI r31,r1,8
255 #endif
256+#ifdef __arch64__
257+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
258+ BEAEQID r5,$LaResult_Is_Zero # Result is Zero
259+#else
260 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
261 BEQID r5,$LaResult_Is_Zero # Result is Zero
262+#endif
263 ADDIK r30,r0,0 # Clear mod
264 ADDIK r29,r0,32 # Initialize the loop count
265
266 # Check if r6 and r5 are equal # if yes, return 1
267 RSUB r18,r5,r6
268+#ifdef __arch64__
269+ BEAEQID r18,$LaRETURN_HERE
270+#else
271 BEQID r18,$LaRETURN_HERE
272+#endif
273 ADDIK r3,r0,1
274
275 # Check if (uns)r6 is greater than (uns)r5. In that case, just return 0
276 XOR r18,r5,r6
277- BGEID r18,16
278+#ifdef __arch64__
279+ BEAGEID r18,16
280+#else
281+ BGEID r18,16
282+#endif
283 ADD r3,r0,r0 # We would anyways clear r3
284+#ifdef __arch64__
285+ BEALTI r6,$LaRETURN_HERE # r6[bit 31 = 1] hence is greater
286+ BREAI $LCheckr6
287+ RSUB r18,r6,r5 # MICROBLAZEcmp
288+ BEALTI r18,$LaRETURN_HERE
289+#else
290 BLTI r6,$LaRETURN_HERE # r6[bit 31 = 1] hence is greater
291 BRI $LCheckr6
292 RSUB r18,r6,r5 # MICROBLAZEcmp
293 BLTI r18,$LaRETURN_HERE
294-
295+#endif
296 # If r6 [bit 31] is set, then return result as 1
297 $LCheckr6:
298- BGTI r6,$LaDIV0
299- BRID $LaRETURN_HERE
300+#ifdef __arch64__
301+ BEAGTI r6,$LaDIV0
302+ BREAID $LaRETURN_HERE
303+#else
304+ BGTI r6,$LaDIV0
305+ BRID $LaRETURN_HERE
306+#endif
307 ADDIK r3,r0,1
308
309 # First part try to find the first '1' in the r5
310 $LaDIV0:
311+#ifdef __arch64__
312+ BEALTI r5,$LaDIV2
313+#else
314 BLTI r5,$LaDIV2
315+#endif
316 $LaDIV1:
317 ADD r5,r5,r5 # left shift logical r5
318+#ifdef __arch64__
319+ BEAGTID r5,$LaDIV1
320+#else
321 BGTID r5,$LaDIV1
322+#endif
323 ADDIK r29,r29,-1
324 $LaDIV2:
325 ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
326 ADDC r30,r30,r30 # Move that bit into the Mod register
327 RSUB r31,r6,r30 # Try to subtract (r30 a r6)
328+#ifdef __arch64__
329+ BEALTI r31,$LaMOD_TOO_SMALL
330+#else
331 BLTI r31,$LaMOD_TOO_SMALL
332+#endif
333 OR r30,r0,r31 # Move the r31 to mod since the result was positive
334 ADDIK r3,r3,1
335 $LaMOD_TOO_SMALL:
336 ADDIK r29,r29,-1
337+#ifdef __arch64__
338+ BEAEQi r29,$LaLOOP_END
339+ ADD r3,r3,r3 # Shift in the '1' into div
340+ BREAI $LaDIV2 # Div2
341+$LaLOOP_END:
342+ BREAI $LaRETURN_HERE
343+#else
344 BEQi r29,$LaLOOP_END
345 ADD r3,r3,r3 # Shift in the '1' into div
346 BRI $LaDIV2 # Div2
347 $LaLOOP_END:
348 BRI $LaRETURN_HERE
349+#endif
350 $LaDiv_By_Zero:
351 $LaResult_Is_Zero:
352 OR r3,r0,r0 # set result to 0
353@@ -115,7 +159,7 @@ $LaRETURN_HERE:
354 LLI r29,r1,0
355 LLI r30,r1,8
356 LLI r31,r1,16
357- ADDIK r1,r1,24
358+ ADDLIK r1,r1,24
359 RTSD r15,8
360 NOP
361 #else
362diff --git a/libgcc/config/microblaze/umodsi3.S b/libgcc/config/microblaze/umodsi3.S
363index 1b3070e..91430a6 100644
364--- a/libgcc/config/microblaze/umodsi3.S
365+++ b/libgcc/config/microblaze/umodsi3.S
366@@ -46,7 +46,7 @@
367 __umodsi3:
368 .frame r1,0,r15
369
370- addik r1,r1,-24
371+ addlik r1,r1,-24
372 sli r29,r1,0
373 sli r30,r1,8
374 sli r31,r1,16
375@@ -59,27 +59,77 @@ __umodsi3:
376 swi r30,r1,4
377 swi r31,r1,8
378 #endif
379+#ifdef __arch64__
380+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
381+ BEAEQId r5,$LaResult_Is_Zero # Result is Zero
382+#else
383 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
384 BEQId r5,$LaResult_Is_Zero # Result is Zero
385+#endif
386 ADDIK r3,r0,0 # Clear div
387 ADDIK r30,r0,0 # clear mod
388 ADDIK r29,r0,32 # Initialize the loop count
389
390 # Check if r6 and r5 are equal # if yes, return 0
391 rsub r18,r5,r6
392- beqi r18,$LaRETURN_HERE
393
394+#ifdef __arch64__
395+ beaeqi r18,$LaRETURN_HERE
396+#else
397+ beqi r18,$LaRETURN_HERE
398+#endif
399 # Check if (uns)r6 is greater than (uns)r5. In that case, just return r5
400 xor r18,r5,r6
401+#ifdef __arch64__
402+ beageid r18,16
403+ addik r3,r5,0
404+ bealti r6,$LaRETURN_HERE
405+ breai $LCheckr6
406+ rsub r18,r5,r6 # MICROBLAZEcmp
407+ beagti r18,$LaRETURN_HERE
408+#else
409 bgeid r18,16
410 addik r3,r5,0
411 blti r6,$LaRETURN_HERE
412 bri $LCheckr6
413 rsub r18,r5,r6 # MICROBLAZEcmp
414 bgti r18,$LaRETURN_HERE
415-
416+#endif
417 # If r6 [bit 31] is set, then return result as r5-r6
418 $LCheckr6:
419+#ifdef __arch64__
420+ beagtid r6,$LaDIV0
421+ addik r3,r0,0
422+ addik r18,r0,0x7fffffff
423+ and r5,r5,r18
424+ and r6,r6,r18
425+ breaid $LaRETURN_HERE
426+ rsub r3,r6,r5
427+# First part: try to find the first '1' in the r5
428+$LaDIV0:
429+ BEALTI r5,$LaDIV2
430+$LaDIV1:
431+ ADD r5,r5,r5 # left shift logical r5
432+ BEAGEID r5,$LaDIV1 #
433+ ADDIK r29,r29,-1
434+$LaDIV2:
435+ ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
436+ ADDC r3,r3,r3 # Move that bit into the Mod register
437+ rSUB r31,r6,r3 # Try to subtract (r3 a r6)
438+ BEALTi r31,$LaMOD_TOO_SMALL
439+ OR r3,r0,r31 # Move the r31 to mod since the result was positive
440+ ADDIK r30,r30,1
441+$LaMOD_TOO_SMALL:
442+ ADDIK r29,r29,-1
443+ BEAEQi r29,$LaLOOP_END
444+ ADD r30,r30,r30 # Shift in the '1' into div
445+ BREAI $LaDIV2 # Div2
446+$LaLOOP_END:
447+ BREAI $LaRETURN_HERE
448+$LaDiv_By_Zero:
449+$LaResult_Is_Zero:
450+ or r3,r0,r0 # set result to 0
451+#else
452 bgtid r6,$LaDIV0
453 addik r3,r0,0
454 addik r18,r0,0x7fffffff
455@@ -111,7 +161,7 @@ $LaLOOP_END:
456 $LaDiv_By_Zero:
457 $LaResult_Is_Zero:
458 or r3,r0,r0 # set result to 0
459-
460+#endif
461 #ifdef __arch64__
462 $LaRETURN_HERE:
463 # Restore values of CSRs and that of r3 and the divisor and the dividend
464--
4652.7.4
466
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0059-Reverting-the-patch-as-kernel-boot-is-not-working-wi.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0059-Reverting-the-patch-as-kernel-boot-is-not-working-wi.patch
new file mode 100644
index 00000000..be4dfad5
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0059-Reverting-the-patch-as-kernel-boot-is-not-working-wi.patch
@@ -0,0 +1,51 @@
1From 2f22090a7e8216f7a9f7e958b77ac83006a7ce89 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 16 Apr 2019 17:20:24 +0530
4Subject: [PATCH 59/61] Reverting the patch as kernel boot is not working with
5 this patch CR-1026413 Revert "[Patch,Microblaze]:reverting the cost check
6 before propagating constants."
7
8This reverts commit 7156e379a67fa47a5fb9ede1448c0d528dbda65b.
9---
10 gcc/cprop.c | 4 ----
11 1 file changed, 4 deletions(-)
12
13diff --git a/gcc/cprop.c b/gcc/cprop.c
14index deb706b..e4df509 100644
15--- a/gcc/cprop.c
16+++ b/gcc/cprop.c
17@@ -733,7 +733,6 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
18 int success = 0;
19 rtx set = single_set (insn);
20
21-#if 0
22 bool check_rtx_costs = true;
23 bool speed = optimize_bb_for_speed_p (BLOCK_FOR_INSN (insn));
24 int old_cost = set ? set_rtx_cost (set, speed) : 0;
25@@ -745,7 +744,6 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
26 && (GET_CODE (XEXP (note, 0)) == CONST
27 || CONSTANT_P (XEXP (note, 0)))))
28 check_rtx_costs = false;
29-#endif
30
31 /* Usually we substitute easy stuff, so we won't copy everything.
32 We however need to take care to not duplicate non-trivial CONST
33@@ -754,7 +752,6 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
34
35 validate_replace_src_group (from, to, insn);
36
37-#if 0
38 /* If TO is a constant, check the cost of the set after propagation
39 to the cost of the set before the propagation. If the cost is
40 higher, then do not replace FROM with TO. */
41@@ -767,7 +764,6 @@ try_replace_reg (rtx from, rtx to, rtx_insn *insn)
42 return false;
43 }
44
45-#endif
46
47 if (num_changes_pending () && apply_change_group ())
48 success = 1;
49--
502.7.4
51
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0060-Author-Nagaraju-nmekala-xilinx.com.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0060-Author-Nagaraju-nmekala-xilinx.com.patch
new file mode 100644
index 00000000..9f878669
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0060-Author-Nagaraju-nmekala-xilinx.com.patch
@@ -0,0 +1,479 @@
1From f0332f119c3cbe95886dae77c4b5a9b9907b4b17 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 18 Apr 2019 16:00:37 +0530
4Subject: [PATCH 60/63] Author: Nagaraju <nmekala@xilinx.com> Date: Wed Apr
5 17 14:11:00 2019 +0530
6
7 [Patch, microblaze]: MB-64 removal of barrel-shift instructions from default
8 By default MB-64 is generatting barrel-shift instructions. It has been
9 removed from default. Barrel-shift instructions will be generated only if
10 barrel-shifter is enabled. Similarly to double instructions as well.
11
12 Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
13---
14 gcc/config/microblaze/microblaze.c | 2 +-
15 gcc/config/microblaze/microblaze.md | 269 +++++++++++++++++++++++++++++++++---
16 2 files changed, 252 insertions(+), 19 deletions(-)
17
18diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
19index 220e03d..5c09452 100644
20--- a/gcc/config/microblaze/microblaze.c
21+++ b/gcc/config/microblaze/microblaze.c
22@@ -4008,7 +4008,7 @@ microblaze_expand_divide (rtx operands[])
23 emit_insn (gen_rtx_CLOBBER (Pmode, reg18));
24
25 if (TARGET_MB_64) {
26- emit_insn (gen_ashldi3_long (regt1, operands[1], GEN_INT(4)));
27+ emit_insn (gen_ashldi3 (regt1, operands[1], GEN_INT(4)));
28 emit_insn (gen_adddi3 (regt1, regt1, operands[2]));
29 }
30 else {
31diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
32index 830ef77..3e7c647 100644
33--- a/gcc/config/microblaze/microblaze.md
34+++ b/gcc/config/microblaze/microblaze.md
35@@ -547,7 +547,7 @@
36 [(set (match_operand:DF 0 "register_operand" "=d")
37 (plus:DF (match_operand:DF 1 "register_operand" "d")
38 (match_operand:DF 2 "register_operand" "d")))]
39- "TARGET_MB_64"
40+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
41 "dadd\t%0,%1,%2"
42 [(set_attr "type" "fadd")
43 (set_attr "mode" "DF")
44@@ -557,7 +557,7 @@
45 [(set (match_operand:DF 0 "register_operand" "=d")
46 (minus:DF (match_operand:DF 1 "register_operand" "d")
47 (match_operand:DF 2 "register_operand" "d")))]
48- "TARGET_MB_64"
49+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
50 "drsub\t%0,%2,%1"
51 [(set_attr "type" "frsub")
52 (set_attr "mode" "DF")
53@@ -567,7 +567,7 @@
54 [(set (match_operand:DF 0 "register_operand" "=d")
55 (mult:DF (match_operand:DF 1 "register_operand" "d")
56 (match_operand:DF 2 "register_operand" "d")))]
57- "TARGET_MB_64"
58+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
59 "dmul\t%0,%1,%2"
60 [(set_attr "type" "fmul")
61 (set_attr "mode" "DF")
62@@ -577,7 +577,7 @@
63 [(set (match_operand:DF 0 "register_operand" "=d")
64 (div:DF (match_operand:DF 1 "register_operand" "d")
65 (match_operand:DF 2 "register_operand" "d")))]
66- "TARGET_MB_64"
67+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
68 "ddiv\t%0,%2,%1"
69 [(set_attr "type" "fdiv")
70 (set_attr "mode" "DF")
71@@ -587,7 +587,7 @@
72 (define_insn "sqrtdf2"
73 [(set (match_operand:DF 0 "register_operand" "=d")
74 (sqrt:DF (match_operand:DF 1 "register_operand" "d")))]
75- "TARGET_MB_64"
76+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
77 "dsqrt\t%0,%1"
78 [(set_attr "type" "fsqrt")
79 (set_attr "mode" "DF")
80@@ -596,7 +596,7 @@
81 (define_insn "floatdidf2"
82 [(set (match_operand:DF 0 "register_operand" "=d")
83 (float:DF (match_operand:DI 1 "register_operand" "d")))]
84- "TARGET_MB_64"
85+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
86 "dbl\t%0,%1"
87 [(set_attr "type" "fcvt")
88 (set_attr "mode" "DF")
89@@ -605,7 +605,7 @@
90 (define_insn "fix_truncdfdi2"
91 [(set (match_operand:DI 0 "register_operand" "=d")
92 (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
93- "TARGET_MB_64"
94+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
95 "dlong\t%0,%1"
96 [(set_attr "type" "fcvt")
97 (set_attr "mode" "DI")
98@@ -1301,6 +1301,34 @@
99 (set_attr "mode" "DI")
100 (set_attr "length" "4")])
101
102+(define_insn "*movdi_internal2_bshift"
103+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
104+ (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
105+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
106+ {
107+ switch (which_alternative)
108+ {
109+ case 0:
110+ return "addlk\t%0,%1,r0";
111+ case 1:
112+ case 2:
113+ if (GET_CODE (operands[1]) == CONST_INT &&
114+ (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
115+ return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
116+ else
117+ return "addlik\t%0,r0,%1";
118+ case 3:
119+ case 4:
120+ return "ll%i1\t%0,%1";
121+ case 5:
122+ case 6:
123+ return "sl%i0\t%z1,%0";
124+ }
125+ }
126+ [(set_attr "type" "load,no_delay_load,no_delay_load,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
127+ (set_attr "mode" "DI")
128+ (set_attr "length" "4,4,12,4,8,4,8")])
129+
130 (define_insn "*movdi_internal2"
131 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
132 (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
133@@ -1314,7 +1342,15 @@
134 case 2:
135 if (GET_CODE (operands[1]) == CONST_INT &&
136 (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
137- return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
138+ {
139+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
140+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
141+ output_asm_insn ("addlik\t%2,r0,32", operands);
142+ output_asm_insn ("addlik\t%2,%2,-1", operands);
143+ output_asm_insn ("beaneid\t%2,.-8", operands);
144+ output_asm_insn ("addlk\t%0,%0,%0", operands);
145+ return "addlik\t%0,%0,%j1 #li => la";
146+ }
147 else
148 return "addlik\t%0,r0,%1";
149 case 3:
150@@ -1388,7 +1424,7 @@
151 (define_insn "movdi_long_int"
152 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
153 (match_operand:DI 1 "general_operand" "i"))]
154- "TARGET_MB_64"
155+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
156 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
157 [(set_attr "type" "no_delay_arith")
158 (set_attr "mode" "DI")
159@@ -1655,6 +1691,33 @@
160 ;; movdf_internal
161 ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
162 ;;
163+(define_insn "*movdf_internal_64_bshift"
164+ [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
165+ (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
166+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
167+ {
168+ switch (which_alternative)
169+ {
170+ case 0:
171+ return "addlk\t%0,%1,r0";
172+ case 1:
173+ return "addlk\t%0,r0,r0";
174+ case 2:
175+ case 4:
176+ return "ll%i1\t%0,%1";
177+ case 3:
178+ {
179+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
180+ }
181+ case 5:
182+ return "sl%i0\t%1,%0";
183+ }
184+ gcc_unreachable ();
185+ }
186+ [(set_attr "type" "no_delay_move,no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store")
187+ (set_attr "mode" "DF")
188+ (set_attr "length" "4,4,4,16,4,4")])
189+
190 (define_insn "*movdf_internal_64"
191 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
192 (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
193@@ -1671,7 +1734,13 @@
194 return "ll%i1\t%0,%1";
195 case 3:
196 {
197- return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
198+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
199+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
200+ output_asm_insn ("addlik\t%2,r0,32", operands);
201+ output_asm_insn ("addlik\t%2,%2,-1", operands);
202+ output_asm_insn ("beaneid\t%2,.-8", operands);
203+ output_asm_insn ("addlk\t%0,%0,%0", operands);
204+ return "addlik\t%0,%0,%j1 #li => la";
205 }
206 case 5:
207 return "sl%i0\t%1,%0";
208@@ -1791,11 +1860,21 @@
209 "TARGET_MB_64"
210 {
211 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
212-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
213+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
214 {
215 emit_insn(gen_ashldi3_long (operands[0], operands[1],operands[2]));
216 DONE;
217 }
218+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
219+ {
220+ emit_insn(gen_ashldi3_const (operands[0], operands[1],operands[2]));
221+ DONE;
222+ }
223+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
224+ {
225+ emit_insn(gen_ashldi3_reg (operands[0], operands[1],operands[2]));
226+ DONE;
227+ }
228 else
229 FAIL;
230 }
231@@ -1805,7 +1884,7 @@ else
232 [(set (match_operand:DI 0 "register_operand" "=d,d")
233 (ashift:DI (match_operand:DI 1 "register_operand" "d,d")
234 (match_operand:DI 2 "arith_operand" "I,d")))]
235- "TARGET_MB_64"
236+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
237 "@
238 bsllli\t%0,%1,%2
239 bslll\t%0,%1,%2"
240@@ -1813,6 +1892,51 @@ else
241 (set_attr "mode" "DI,DI")
242 (set_attr "length" "4,4")]
243 )
244+
245+(define_insn "ashldi3_const"
246+ [(set (match_operand:DI 0 "register_operand" "=&d")
247+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
248+ (match_operand:DI 2 "immediate_operand" "I")))]
249+ "TARGET_MB_64"
250+ {
251+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
252+
253+ output_asm_insn ("orli\t%3,r0,%2", operands);
254+ if (REGNO (operands[0]) != REGNO (operands[1]))
255+ output_asm_insn ("addlk\t%0,%1,r0", operands);
256+
257+ output_asm_insn ("addlik\t%3,%3,-1", operands);
258+ output_asm_insn ("beaneid\t%3,.-8", operands);
259+ return "addlk\t%0,%0,%0";
260+ }
261+ [(set_attr "type" "multi")
262+ (set_attr "mode" "DI")
263+ (set_attr "length" "20")]
264+)
265+
266+(define_insn "ashldi3_reg"
267+ [(set (match_operand:DI 0 "register_operand" "=&d")
268+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
269+ (match_operand:DI 2 "register_operand" "d")))]
270+ "TARGET_MB_64"
271+ {
272+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
273+ output_asm_insn ("andli\t%3,%2,31", operands);
274+ if (REGNO (operands[0]) != REGNO (operands[1]))
275+ output_asm_insn ("addlk\t%0,r0,%1", operands);
276+ /* Exit the loop if zero shift. */
277+ output_asm_insn ("beaeqid\t%3,.+24", operands);
278+ /* Emit the loop. */
279+ output_asm_insn ("addlk\t%0,%0,r0", operands);
280+ output_asm_insn ("addlik\t%3,%3,-1", operands);
281+ output_asm_insn ("beaneid\t%3,.-8", operands);
282+ return "addlk\t%0,%0,%0";
283+ }
284+ [(set_attr "type" "multi")
285+ (set_attr "mode" "DI")
286+ (set_attr "length" "28")]
287+)
288+
289 ;; The following patterns apply when there is no barrel shifter present
290
291 (define_insn "*ashlsi3_with_mul_delay"
292@@ -1946,11 +2070,21 @@ else
293 "TARGET_MB_64"
294 {
295 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
296-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
297+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
298 {
299 emit_insn(gen_ashrdi3_long (operands[0], operands[1],operands[2]));
300 DONE;
301 }
302+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
303+ {
304+ emit_insn(gen_ashrdi3_const (operands[0], operands[1],operands[2]));
305+ DONE;
306+ }
307+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
308+ {
309+ emit_insn(gen_ashrdi3_reg (operands[0], operands[1],operands[2]));
310+ DONE;
311+ }
312 else
313 FAIL;
314 }
315@@ -1960,7 +2094,7 @@ else
316 [(set (match_operand:DI 0 "register_operand" "=d,d")
317 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
318 (match_operand:DI 2 "arith_operand" "I,d")))]
319- "TARGET_MB_64"
320+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
321 "@
322 bslrai\t%0,%1,%2
323 bslra\t%0,%1,%2"
324@@ -1968,6 +2102,51 @@ else
325 (set_attr "mode" "DI,DI")
326 (set_attr "length" "4,4")]
327 )
328+
329+(define_insn "ashrdi3_const"
330+ [(set (match_operand:DI 0 "register_operand" "=&d")
331+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
332+ (match_operand:DI 2 "immediate_operand" "I")))]
333+ "TARGET_MB_64"
334+ {
335+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
336+
337+ output_asm_insn ("orli\t%3,r0,%2", operands);
338+ if (REGNO (operands[0]) != REGNO (operands[1]))
339+ output_asm_insn ("addlk\t%0,%1,r0", operands);
340+
341+ output_asm_insn ("addlik\t%3,%3,-1", operands);
342+ output_asm_insn ("beaneid\t%3,.-8", operands);
343+ return "srla\t%0,%0";
344+ }
345+ [(set_attr "type" "arith")
346+ (set_attr "mode" "DI")
347+ (set_attr "length" "20")]
348+)
349+
350+(define_insn "ashrdi3_reg"
351+ [(set (match_operand:DI 0 "register_operand" "=&d")
352+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
353+ (match_operand:DI 2 "register_operand" "d")))]
354+ "TARGET_MB_64"
355+ {
356+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
357+ output_asm_insn ("andli\t%3,%2,31", operands);
358+ if (REGNO (operands[0]) != REGNO (operands[1]))
359+ output_asm_insn ("addlk\t%0,r0,%1", operands);
360+ /* Exit the loop if zero shift. */
361+ output_asm_insn ("beaeqid\t%3,.+24", operands);
362+ /* Emit the loop. */
363+ output_asm_insn ("addlk\t%0,%0,r0", operands);
364+ output_asm_insn ("addlik\t%3,%3,-1", operands);
365+ output_asm_insn ("beaneid\t%3,.-8", operands);
366+ return "srla\t%0,%0";
367+ }
368+ [(set_attr "type" "multi")
369+ (set_attr "mode" "DI")
370+ (set_attr "length" "28")]
371+)
372+
373 (define_expand "ashrsi3"
374 [(set (match_operand:SI 0 "register_operand" "=&d")
375 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
376@@ -2085,11 +2264,21 @@ else
377 "TARGET_MB_64"
378 {
379 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
380-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
381+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
382 {
383 emit_insn(gen_lshrdi3_long (operands[0], operands[1],operands[2]));
384 DONE;
385 }
386+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
387+ {
388+ emit_insn(gen_lshrdi3_const (operands[0], operands[1],operands[2]));
389+ DONE;
390+ }
391+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
392+ {
393+ emit_insn(gen_lshrdi3_reg (operands[0], operands[1],operands[2]));
394+ DONE;
395+ }
396 else
397 FAIL;
398 }
399@@ -2099,7 +2288,7 @@ else
400 [(set (match_operand:DI 0 "register_operand" "=d,d")
401 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
402 (match_operand:DI 2 "arith_operand" "I,d")))]
403- "TARGET_MB_64"
404+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
405 "@
406 bslrli\t%0,%1,%2
407 bslrl\t%0,%1,%2"
408@@ -2108,6 +2297,50 @@ else
409 (set_attr "length" "4,4")]
410 )
411
412+(define_insn "lshrdi3_const"
413+ [(set (match_operand:DI 0 "register_operand" "=&d")
414+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
415+ (match_operand:DI 2 "immediate_operand" "I")))]
416+ "TARGET_MB_64"
417+ {
418+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
419+
420+ output_asm_insn ("orli\t%3,r0,%2", operands);
421+ if (REGNO (operands[0]) != REGNO (operands[1]))
422+ output_asm_insn ("addlk\t%0,%1,r0", operands);
423+
424+ output_asm_insn ("addlik\t%3,%3,-1", operands);
425+ output_asm_insn ("beaneid\t%3,.-8", operands);
426+ return "srll\t%0,%0";
427+ }
428+ [(set_attr "type" "multi")
429+ (set_attr "mode" "DI")
430+ (set_attr "length" "20")]
431+)
432+
433+(define_insn "lshrdi3_reg"
434+ [(set (match_operand:DI 0 "register_operand" "=&d")
435+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
436+ (match_operand:DI 2 "register_operand" "d")))]
437+ "TARGET_MB_64"
438+ {
439+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
440+ output_asm_insn ("andli\t%3,%2,31", operands);
441+ if (REGNO (operands[0]) != REGNO (operands[1]))
442+ output_asm_insn ("addlk\t%0,r0,%1", operands);
443+ /* Exit the loop if zero shift. */
444+ output_asm_insn ("beaeqid\t%3,.+24", operands);
445+ /* Emit the loop. */
446+ output_asm_insn ("addlk\t%0,%0,r0", operands);
447+ output_asm_insn ("addlik\t%3,%3,-1", operands);
448+ output_asm_insn ("beaneid\t%3,.-8", operands);
449+ return "srll\t%0,%0";
450+ }
451+ [(set_attr "type" "multi")
452+ (set_attr "mode" "SI")
453+ (set_attr "length" "28")]
454+)
455+
456 (define_expand "lshrsi3"
457 [(set (match_operand:SI 0 "register_operand" "=&d")
458 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
459@@ -2235,7 +2468,7 @@ else
460 (eq:DI
461 (match_operand:DI 1 "register_operand" "d")
462 (match_operand:DI 2 "register_operand" "d")))]
463- "TARGET_MB_64"
464+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
465 "pcmpleq\t%0,%1,%2"
466 [(set_attr "type" "arith")
467 (set_attr "mode" "DI")
468@@ -2247,7 +2480,7 @@ else
469 (ne:DI
470 (match_operand:DI 1 "register_operand" "d")
471 (match_operand:DI 2 "register_operand" "d")))]
472- "TARGET_MB_64"
473+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
474 "pcmplne\t%0,%1,%2"
475 [(set_attr "type" "arith")
476 (set_attr "mode" "DI")
477--
4782.7.4
479
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0060-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0060-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch
new file mode 100644
index 00000000..1548faad
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0060-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch
@@ -0,0 +1,466 @@
1From 80919b0f43b275e70521e4f85cd28bcd0ece3b80 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 17 Apr 2019 12:36:16 +0530
4Subject: [PATCH 60/61] [Patch,MicroBlaze]: fixed typos in mul,div and mod
5 assembly files.
6
7---
8 libgcc/config/microblaze/divsi3.S | 47 ++++++++++++++++++++++++++----
9 libgcc/config/microblaze/modsi3.S | 40 +++++++++++++++++++++++---
10 libgcc/config/microblaze/mulsi3.S | 33 +++++++++++++++++++++-
11 libgcc/config/microblaze/udivsi3.S | 54 +++++++++++++++++++++++++++++++----
12 libgcc/config/microblaze/umodsi3.S | 58 +++++++++++++++++++++++++++++++++++---
13 5 files changed, 212 insertions(+), 20 deletions(-)
14
15diff --git a/libgcc/config/microblaze/divsi3.S b/libgcc/config/microblaze/divsi3.S
16index 7e7d875..cfb4c05 100644
17--- a/libgcc/config/microblaze/divsi3.S
18+++ b/libgcc/config/microblaze/divsi3.S
19@@ -46,7 +46,7 @@
20 __divsi3:
21 .frame r1,0,r15
22
23- ADDIK r1,r1,-32
24+ ADDLIK r1,r1,-32
25 SLI r28,r1,0
26 SLI r29,r1,8
27 SLI r30,r1,16
28@@ -61,13 +61,23 @@ __divsi3:
29 SWI r30,r1,8
30 SWI r31,r1,12
31 #endif
32- BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
33- BEQI r5,$LaResult_Is_Zero # Result is Zero
34- BGEID r5,$LaR5_Pos
35+#ifdef __arch64__
36+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
37+ BEAEQI r5,$LaResult_Is_Zero # Result is Zero
38+ BEAGEID r5,$LaR5_Pos
39+#else
40+ BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
41+ BEQI r5,$LaResult_Is_Zero # Result is Zero
42+ BGEID r5,$LaR5_Pos
43+#endif
44 XOR r28,r5,r6 # Get the sign of the result
45 RSUBI r5,r5,0 # Make r5 positive
46 $LaR5_Pos:
47- BGEI r6,$LaR6_Pos
48+#ifdef __arch64__
49+ BEAGEI r6,$LaR6_Pos
50+#else
51+ BGEI r6,$LaR6_Pos
52+#endif
53 RSUBI r6,r6,0 # Make r6 positive
54 $LaR6_Pos:
55 ADDIK r30,r0,0 # Clear mod
56@@ -76,26 +86,51 @@ $LaR6_Pos:
57
58 # First part try to find the first '1' in the r5
59 $LaDIV0:
60- BLTI r5,$LaDIV2 # This traps r5 == 0x80000000
61+#ifdef __arch64__
62+ BEALTI r5,$LaDIV2 # This traps r5 == 0x80000000
63+#else
64+ BLTI r5,$LaDIV2 # This traps r5 == 0x80000000
65+#endif
66 $LaDIV1:
67 ADD r5,r5,r5 # left shift logical r5
68+#ifdef __arch64__
69+ BEAGTID r5,$LaDIV1
70+#else
71 BGTID r5,$LaDIV1
72+#endif
73 ADDIK r29,r29,-1
74 $LaDIV2:
75 ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
76 ADDC r30,r30,r30 # Move that bit into the Mod register
77 RSUB r31,r6,r30 # Try to subtract (r30 a r6)
78+#ifdef __arch64__
79+ BEALTI r31,$LaMOD_TOO_SMALL
80+#else
81 BLTI r31,$LaMOD_TOO_SMALL
82+#endif
83 OR r30,r0,r31 # Move the r31 to mod since the result was positive
84 ADDIK r3,r3,1
85 $LaMOD_TOO_SMALL:
86 ADDIK r29,r29,-1
87+#ifdef __arch64__
88+ BEAEQi r29,$LaLOOP_END
89+#else
90 BEQi r29,$LaLOOP_END
91+#endif
92 ADD r3,r3,r3 # Shift in the '1' into div
93+#ifdef __arch64__
94+ BREAI $LaDIV2 # Div2
95+#else
96 BRI $LaDIV2 # Div2
97+#endif
98 $LaLOOP_END:
99+#ifdef __arch64__
100+ BEAGEI r28,$LaRETURN_HERE
101+ BREAID $LaRETURN_HERE
102+#else
103 BGEI r28,$LaRETURN_HERE
104 BRID $LaRETURN_HERE
105+#endif
106 RSUBI r3,r3,0 # Negate the result
107 $LaDiv_By_Zero:
108 $LaResult_Is_Zero:
109diff --git a/libgcc/config/microblaze/modsi3.S b/libgcc/config/microblaze/modsi3.S
110index 46ff34a..49618dd 100644
111--- a/libgcc/config/microblaze/modsi3.S
112+++ b/libgcc/config/microblaze/modsi3.S
113@@ -62,40 +62,72 @@ __modsi3:
114 swi r31,r1,12
115 #endif
116
117+#ifdef __arch64__
118+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
119+ BEAEQI r5,$LaResult_Is_Zero # Result is Zero
120+ BEAGEId r5,$LaR5_Pos
121+#else
122 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
123 BEQI r5,$LaResult_Is_Zero # Result is Zero
124 BGEId r5,$LaR5_Pos
125+#endif
126 ADD r28,r5,r0 # Get the sign of the result [ Depends only on the first arg]
127 RSUBI r5,r5,0 # Make r5 positive
128 $LaR5_Pos:
129- BGEI r6,$LaR6_Pos
130+#ifdef __arch64__
131+ BEAGEI r6,$LaR6_Pos
132+#else
133+ BGEI r6,$LaR6_Pos
134+#endif
135 RSUBI r6,r6,0 # Make r6 positive
136 $LaR6_Pos:
137 ADDIK r3,r0,0 # Clear mod
138 ADDIK r30,r0,0 # clear div
139- BLTId r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
140+#ifdef __arch64__
141+ BEALTId r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
142 # the first bit search.
143+#else
144+ BLTId r5,$LaDIV2 # If r5 is still negative (0x80000000), skip
145+ # the first bit search.
146+#endif
147 ADDIK r29,r0,32 # Initialize the loop count
148 # First part try to find the first '1' in the r5
149 $LaDIV1:
150 ADD r5,r5,r5 # left shift logical r5
151- BGEID r5,$LaDIV1 #
152+#ifdef __arch64__
153+ BEAGEID r5,$LaDIV1 #
154+#else
155+ BGEID r5,$LaDIV1 #
156+#endif
157 ADDIK r29,r29,-1
158 $LaDIV2:
159 ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
160 ADDC r3,r3,r3 # Move that bit into the Mod register
161 rSUB r31,r6,r3 # Try to subtract (r30 a r6)
162+#ifdef __arch64__
163+ BEALTi r31,$LaMOD_TOO_SMALL
164+#else
165 BLTi r31,$LaMOD_TOO_SMALL
166+#endif
167 OR r3,r0,r31 # Move the r31 to mod since the result was positive
168 ADDIK r30,r30,1
169 $LaMOD_TOO_SMALL:
170 ADDIK r29,r29,-1
171+#ifdef __arch64__
172+ BEAEQi r29,$LaLOOP_END
173+ ADD r30,r30,r30 # Shift in the '1' into div
174+ BREAI $LaDIV2 # Div2
175+$LaLOOP_END:
176+ BEAGEI r28,$LaRETURN_HERE
177+ BREAId $LaRETURN_HERE
178+#else
179 BEQi r29,$LaLOOP_END
180 ADD r30,r30,r30 # Shift in the '1' into div
181 BRI $LaDIV2 # Div2
182 $LaLOOP_END:
183 BGEI r28,$LaRETURN_HERE
184 BRId $LaRETURN_HERE
185+#endif
186 rsubi r3,r3,0 # Negate the result
187 $LaDiv_By_Zero:
188 $LaResult_Is_Zero:
189@@ -108,7 +140,7 @@ $LaRETURN_HERE:
190 lli r29,r1,8
191 lli r30,r1,16
192 lli r31,r1,24
193- addik r1,r1,32
194+ addlik r1,r1,32
195 rtsd r15,8
196 nop
197 #else
198diff --git a/libgcc/config/microblaze/mulsi3.S b/libgcc/config/microblaze/mulsi3.S
199index 31a73c2..39951be 100644
200--- a/libgcc/config/microblaze/mulsi3.S
201+++ b/libgcc/config/microblaze/mulsi3.S
202@@ -43,7 +43,37 @@
203 .type __mulsi3,@function
204 #ifdef __arch64__
205 .align 3
206-#endif
207+__mulsi3:
208+ .frame r1,0,r15
209+ add r3,r0,r0
210+ BEAEQI r5,$L_Result_Is_Zero # Multiply by Zero
211+ BEAEQI r6,$L_Result_Is_Zero # Multiply by Zero
212+ BEAGEId r5,$L_R5_Pos
213+ XOR r4,r5,r6 # Get the sign of the result
214+ RSUBI r5,r5,0 # Make r5 positive
215+$L_R5_Pos:
216+ BEAGEI r6,$L_R6_Pos
217+ RSUBI r6,r6,0 # Make r6 positive
218+$L_R6_Pos:
219+ breai $L1
220+$L2:
221+ add r5,r5,r5
222+$L1:
223+ srl r6,r6
224+ addc r7,r0,r0
225+ beaeqi r7,$L2
226+ beaneid r6,$L2
227+ add r3,r3,r5
228+ bealti r4,$L_NegateResult
229+ rtsd r15,8
230+ nop
231+$L_NegateResult:
232+ rtsd r15,8
233+ rsub r3,r3,r0
234+$L_Result_Is_Zero:
235+ rtsd r15,8
236+ addi r3,r0,0
237+#else
238 __mulsi3:
239 .frame r1,0,r15
240 add r3,r0,r0
241@@ -74,5 +104,6 @@ $L_NegateResult:
242 $L_Result_Is_Zero:
243 rtsd r15,8
244 addi r3,r0,0
245+#endif
246 .end __mulsi3
247 .size __mulsi3, . - __mulsi3
248diff --git a/libgcc/config/microblaze/udivsi3.S b/libgcc/config/microblaze/udivsi3.S
249index 94adb6a..d4fe285 100644
250--- a/libgcc/config/microblaze/udivsi3.S
251+++ b/libgcc/config/microblaze/udivsi3.S
252@@ -59,52 +59,96 @@ __udivsi3:
253 SWI r30,r1,4
254 SWI r31,r1,8
255 #endif
256+#ifdef __arch64__
257+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
258+ BEAEQID r5,$LaResult_Is_Zero # Result is Zero
259+#else
260 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
261 BEQID r5,$LaResult_Is_Zero # Result is Zero
262+#endif
263 ADDIK r30,r0,0 # Clear mod
264 ADDIK r29,r0,32 # Initialize the loop count
265
266 # Check if r6 and r5 are equal # if yes, return 1
267 RSUB r18,r5,r6
268+#ifdef __arch64__
269+ BEAEQID r18,$LaRETURN_HERE
270+#else
271 BEQID r18,$LaRETURN_HERE
272+#endif
273 ADDIK r3,r0,1
274
275 # Check if (uns)r6 is greater than (uns)r5. In that case, just return 0
276 XOR r18,r5,r6
277- BGEID r18,16
278+#ifdef __arch64__
279+ BEAGEID r18,16
280+#else
281+ BGEID r18,16
282+#endif
283 ADD r3,r0,r0 # We would anyways clear r3
284+#ifdef __arch64__
285+ BEALTI r6,$LaRETURN_HERE # r6[bit 31 = 1] hence is greater
286+ BREAI $LCheckr6
287+ RSUB r18,r6,r5 # MICROBLAZEcmp
288+ BEALTI r18,$LaRETURN_HERE
289+#else
290 BLTI r6,$LaRETURN_HERE # r6[bit 31 = 1] hence is greater
291 BRI $LCheckr6
292 RSUB r18,r6,r5 # MICROBLAZEcmp
293 BLTI r18,$LaRETURN_HERE
294-
295+#endif
296 # If r6 [bit 31] is set, then return result as 1
297 $LCheckr6:
298- BGTI r6,$LaDIV0
299- BRID $LaRETURN_HERE
300+#ifdef __arch64__
301+ BEAGTI r6,$LaDIV0
302+ BREAID $LaRETURN_HERE
303+#else
304+ BGTI r6,$LaDIV0
305+ BRID $LaRETURN_HERE
306+#endif
307 ADDIK r3,r0,1
308
309 # First part try to find the first '1' in the r5
310 $LaDIV0:
311+#ifdef __arch64__
312+ BEALTI r5,$LaDIV2
313+#else
314 BLTI r5,$LaDIV2
315+#endif
316 $LaDIV1:
317 ADD r5,r5,r5 # left shift logical r5
318+#ifdef __arch64__
319+ BEAGTID r5,$LaDIV1
320+#else
321 BGTID r5,$LaDIV1
322+#endif
323 ADDIK r29,r29,-1
324 $LaDIV2:
325 ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
326 ADDC r30,r30,r30 # Move that bit into the Mod register
327 RSUB r31,r6,r30 # Try to subtract (r30 a r6)
328+#ifdef __arch64__
329+ BEALTI r31,$LaMOD_TOO_SMALL
330+#else
331 BLTI r31,$LaMOD_TOO_SMALL
332+#endif
333 OR r30,r0,r31 # Move the r31 to mod since the result was positive
334 ADDIK r3,r3,1
335 $LaMOD_TOO_SMALL:
336 ADDIK r29,r29,-1
337+#ifdef __arch64__
338+ BEAEQi r29,$LaLOOP_END
339+ ADD r3,r3,r3 # Shift in the '1' into div
340+ BREAI $LaDIV2 # Div2
341+$LaLOOP_END:
342+ BREAI $LaRETURN_HERE
343+#else
344 BEQi r29,$LaLOOP_END
345 ADD r3,r3,r3 # Shift in the '1' into div
346 BRI $LaDIV2 # Div2
347 $LaLOOP_END:
348 BRI $LaRETURN_HERE
349+#endif
350 $LaDiv_By_Zero:
351 $LaResult_Is_Zero:
352 OR r3,r0,r0 # set result to 0
353@@ -115,7 +159,7 @@ $LaRETURN_HERE:
354 LLI r29,r1,0
355 LLI r30,r1,8
356 LLI r31,r1,16
357- ADDIK r1,r1,24
358+ ADDLIK r1,r1,24
359 RTSD r15,8
360 NOP
361 #else
362diff --git a/libgcc/config/microblaze/umodsi3.S b/libgcc/config/microblaze/umodsi3.S
363index 9bf65c3..3bd5d48 100644
364--- a/libgcc/config/microblaze/umodsi3.S
365+++ b/libgcc/config/microblaze/umodsi3.S
366@@ -46,7 +46,7 @@
367 __umodsi3:
368 .frame r1,0,r15
369
370- addik r1,r1,-24
371+ addlik r1,r1,-24
372 sli r29,r1,0
373 sli r30,r1,8
374 sli r31,r1,16
375@@ -59,27 +59,77 @@ __umodsi3:
376 swi r30,r1,4
377 swi r31,r1,8
378 #endif
379+#ifdef __arch64__
380+ BEAEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
381+ BEAEQId r5,$LaResult_Is_Zero # Result is Zero
382+#else
383 BEQI r6,$LaDiv_By_Zero # Div_by_Zero # Division Error
384 BEQId r5,$LaResult_Is_Zero # Result is Zero
385+#endif
386 ADDIK r3,r0,0 # Clear div
387 ADDIK r30,r0,0 # clear mod
388 ADDIK r29,r0,32 # Initialize the loop count
389
390 # Check if r6 and r5 are equal # if yes, return 0
391 rsub r18,r5,r6
392- beqi r18,$LaRETURN_HERE
393
394+#ifdef __arch64__
395+ beaeqi r18,$LaRETURN_HERE
396+#else
397+ beqi r18,$LaRETURN_HERE
398+#endif
399 # Check if (uns)r6 is greater than (uns)r5. In that case, just return r5
400 xor r18,r5,r6
401+#ifdef __arch64__
402+ beageid r18,16
403+ addik r3,r5,0
404+ bealti r6,$LaRETURN_HERE
405+ breai $LCheckr6
406+ rsub r18,r5,r6 # MICROBLAZEcmp
407+ beagti r18,$LaRETURN_HERE
408+#else
409 bgeid r18,16
410 addik r3,r5,0
411 blti r6,$LaRETURN_HERE
412 bri $LCheckr6
413 rsub r18,r5,r6 # MICROBLAZEcmp
414 bgti r18,$LaRETURN_HERE
415-
416+#endif
417 # If r6 [bit 31] is set, then return result as r5-r6
418 $LCheckr6:
419+#ifdef __arch64__
420+ beagtid r6,$LaDIV0
421+ addik r3,r0,0
422+ addik r18,r0,0x7fffffff
423+ and r5,r5,r18
424+ and r6,r6,r18
425+ breaid $LaRETURN_HERE
426+ rsub r3,r6,r5
427+# First part: try to find the first '1' in the r5
428+$LaDIV0:
429+ BEALTI r5,$LaDIV2
430+$LaDIV1:
431+ ADD r5,r5,r5 # left shift logical r5
432+ BEAGEID r5,$LaDIV1 #
433+ ADDIK r29,r29,-1
434+$LaDIV2:
435+ ADD r5,r5,r5 # left shift logical r5 get the '1' into the Carry
436+ ADDC r3,r3,r3 # Move that bit into the Mod register
437+ rSUB r31,r6,r3 # Try to subtract (r3 a r6)
438+ BEALTi r31,$LaMOD_TOO_SMALL
439+ OR r3,r0,r31 # Move the r31 to mod since the result was positive
440+ ADDIK r30,r30,1
441+$LaMOD_TOO_SMALL:
442+ ADDIK r29,r29,-1
443+ BEAEQi r29,$LaLOOP_END
444+ ADD r30,r30,r30 # Shift in the '1' into div
445+ BREAI $LaDIV2 # Div2
446+$LaLOOP_END:
447+ BREAI $LaRETURN_HERE
448+$LaDiv_By_Zero:
449+$LaResult_Is_Zero:
450+ or r3,r0,r0 # set result to 0
451+#else
452 bgtid r6,$LaDIV0
453 addik r3,r0,0
454 addik r18,r0,0x7fffffff
455@@ -111,7 +161,7 @@ $LaLOOP_END:
456 $LaDiv_By_Zero:
457 $LaResult_Is_Zero:
458 or r3,r0,r0 # set result to 0
459-
460+#endif
461 #ifdef __arch64__
462 $LaRETURN_HERE:
463 # Restore values of CSRs and that of r3 and the divisor and the dividend
464--
4652.7.4
466
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0061-Author-Nagaraju-nmekala-xilinx.com.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0061-Author-Nagaraju-nmekala-xilinx.com.patch
new file mode 100644
index 00000000..690bc727
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0061-Author-Nagaraju-nmekala-xilinx.com.patch
@@ -0,0 +1,479 @@
1From e1b8cfe6c0b4a0bd90ecbd3e85ae7114df21b6cc Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 18 Apr 2019 16:00:37 +0530
4Subject: [PATCH 61/62] Author: Nagaraju <nmekala@xilinx.com> Date: Wed Apr
5 17 14:11:00 2019 +0530
6
7 [Patch, microblaze]: MB-64 removal of barrel-shift instructions from default
8 By default MB-64 is generatting barrel-shift instructions. It has been
9 removed from default. Barrel-shift instructions will be generated only if
10 barrel-shifter is enabled. Similarly to double instructions as well.
11
12 Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
13---
14 gcc/config/microblaze/microblaze.c | 2 +-
15 gcc/config/microblaze/microblaze.md | 269 +++++++++++++++++++++++++++++++++---
16 2 files changed, 252 insertions(+), 19 deletions(-)
17
18diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
19index 33d183e..c321b03 100644
20--- a/gcc/config/microblaze/microblaze.c
21+++ b/gcc/config/microblaze/microblaze.c
22@@ -3868,7 +3868,7 @@ microblaze_expand_divide (rtx operands[])
23 emit_insn (gen_rtx_CLOBBER (Pmode, reg18));
24
25 if (TARGET_MB_64) {
26- emit_insn (gen_ashldi3_long (regt1, operands[1], GEN_INT(4)));
27+ emit_insn (gen_ashldi3 (regt1, operands[1], GEN_INT(4)));
28 emit_insn (gen_adddi3 (regt1, regt1, operands[2]));
29 }
30 else {
31diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
32index 8bd175f..b5b60fb 100644
33--- a/gcc/config/microblaze/microblaze.md
34+++ b/gcc/config/microblaze/microblaze.md
35@@ -545,7 +545,7 @@
36 [(set (match_operand:DF 0 "register_operand" "=d")
37 (plus:DF (match_operand:DF 1 "register_operand" "d")
38 (match_operand:DF 2 "register_operand" "d")))]
39- "TARGET_MB_64"
40+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
41 "dadd\t%0,%1,%2"
42 [(set_attr "type" "fadd")
43 (set_attr "mode" "DF")
44@@ -555,7 +555,7 @@
45 [(set (match_operand:DF 0 "register_operand" "=d")
46 (minus:DF (match_operand:DF 1 "register_operand" "d")
47 (match_operand:DF 2 "register_operand" "d")))]
48- "TARGET_MB_64"
49+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
50 "drsub\t%0,%2,%1"
51 [(set_attr "type" "frsub")
52 (set_attr "mode" "DF")
53@@ -565,7 +565,7 @@
54 [(set (match_operand:DF 0 "register_operand" "=d")
55 (mult:DF (match_operand:DF 1 "register_operand" "d")
56 (match_operand:DF 2 "register_operand" "d")))]
57- "TARGET_MB_64"
58+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
59 "dmul\t%0,%1,%2"
60 [(set_attr "type" "fmul")
61 (set_attr "mode" "DF")
62@@ -575,7 +575,7 @@
63 [(set (match_operand:DF 0 "register_operand" "=d")
64 (div:DF (match_operand:DF 1 "register_operand" "d")
65 (match_operand:DF 2 "register_operand" "d")))]
66- "TARGET_MB_64"
67+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
68 "ddiv\t%0,%2,%1"
69 [(set_attr "type" "fdiv")
70 (set_attr "mode" "DF")
71@@ -585,7 +585,7 @@
72 (define_insn "sqrtdf2"
73 [(set (match_operand:DF 0 "register_operand" "=d")
74 (sqrt:DF (match_operand:DF 1 "register_operand" "d")))]
75- "TARGET_MB_64"
76+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
77 "dsqrt\t%0,%1"
78 [(set_attr "type" "fsqrt")
79 (set_attr "mode" "DF")
80@@ -594,7 +594,7 @@
81 (define_insn "floatdidf2"
82 [(set (match_operand:DF 0 "register_operand" "=d")
83 (float:DF (match_operand:DI 1 "register_operand" "d")))]
84- "TARGET_MB_64"
85+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
86 "dbl\t%0,%1"
87 [(set_attr "type" "fcvt")
88 (set_attr "mode" "DF")
89@@ -603,7 +603,7 @@
90 (define_insn "fix_truncdfdi2"
91 [(set (match_operand:DI 0 "register_operand" "=d")
92 (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
93- "TARGET_MB_64"
94+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
95 "dlong\t%0,%1"
96 [(set_attr "type" "fcvt")
97 (set_attr "mode" "DI")
98@@ -1299,6 +1299,34 @@
99 (set_attr "mode" "DI")
100 (set_attr "length" "4")])
101
102+(define_insn "*movdi_internal2_bshift"
103+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
104+ (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
105+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
106+ {
107+ switch (which_alternative)
108+ {
109+ case 0:
110+ return "addlk\t%0,%1,r0";
111+ case 1:
112+ case 2:
113+ if (GET_CODE (operands[1]) == CONST_INT &&
114+ (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
115+ return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
116+ else
117+ return "addlik\t%0,r0,%1";
118+ case 3:
119+ case 4:
120+ return "ll%i1\t%0,%1";
121+ case 5:
122+ case 6:
123+ return "sl%i0\t%z1,%0";
124+ }
125+ }
126+ [(set_attr "type" "load,no_delay_load,no_delay_load,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
127+ (set_attr "mode" "DI")
128+ (set_attr "length" "4,4,12,4,8,4,8")])
129+
130 (define_insn "*movdi_internal2"
131 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
132 (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
133@@ -1312,7 +1340,15 @@
134 case 2:
135 if (GET_CODE (operands[1]) == CONST_INT &&
136 (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
137- return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
138+ {
139+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
140+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
141+ output_asm_insn ("addlik\t%2,r0,32", operands);
142+ output_asm_insn ("addlik\t%2,%2,-1", operands);
143+ output_asm_insn ("beaneid\t%2,.-8", operands);
144+ output_asm_insn ("addlk\t%0,%0,%0", operands);
145+ return "addlik\t%0,%0,%j1 #li => la";
146+ }
147 else
148 return "addlik\t%0,r0,%1";
149 case 3:
150@@ -1386,7 +1422,7 @@
151 (define_insn "movdi_long_int"
152 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
153 (match_operand:DI 1 "general_operand" "i"))]
154- "TARGET_MB_64"
155+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
156 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
157 [(set_attr "type" "no_delay_arith")
158 (set_attr "mode" "DI")
159@@ -1653,6 +1689,33 @@
160 ;; movdf_internal
161 ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
162 ;;
163+(define_insn "*movdf_internal_64_bshift"
164+ [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
165+ (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
166+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
167+ {
168+ switch (which_alternative)
169+ {
170+ case 0:
171+ return "addlk\t%0,%1,r0";
172+ case 1:
173+ return "addlk\t%0,r0,r0";
174+ case 2:
175+ case 4:
176+ return "ll%i1\t%0,%1";
177+ case 3:
178+ {
179+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
180+ }
181+ case 5:
182+ return "sl%i0\t%1,%0";
183+ }
184+ gcc_unreachable ();
185+ }
186+ [(set_attr "type" "no_delay_move,no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store")
187+ (set_attr "mode" "DF")
188+ (set_attr "length" "4,4,4,16,4,4")])
189+
190 (define_insn "*movdf_internal_64"
191 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
192 (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
193@@ -1669,7 +1732,13 @@
194 return "ll%i1\t%0,%1";
195 case 3:
196 {
197- return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
198+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
199+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
200+ output_asm_insn ("addlik\t%2,r0,32", operands);
201+ output_asm_insn ("addlik\t%2,%2,-1", operands);
202+ output_asm_insn ("beaneid\t%2,.-8", operands);
203+ output_asm_insn ("addlk\t%0,%0,%0", operands);
204+ return "addlik\t%0,%0,%j1 #li => la";
205 }
206 case 5:
207 return "sl%i0\t%1,%0";
208@@ -1789,11 +1858,21 @@
209 "TARGET_MB_64"
210 {
211 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
212-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
213+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
214 {
215 emit_insn(gen_ashldi3_long (operands[0], operands[1],operands[2]));
216 DONE;
217 }
218+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
219+ {
220+ emit_insn(gen_ashldi3_const (operands[0], operands[1],operands[2]));
221+ DONE;
222+ }
223+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
224+ {
225+ emit_insn(gen_ashldi3_reg (operands[0], operands[1],operands[2]));
226+ DONE;
227+ }
228 else
229 FAIL;
230 }
231@@ -1803,7 +1882,7 @@ else
232 [(set (match_operand:DI 0 "register_operand" "=d,d")
233 (ashift:DI (match_operand:DI 1 "register_operand" "d,d")
234 (match_operand:DI 2 "arith_operand" "I,d")))]
235- "TARGET_MB_64"
236+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
237 "@
238 bsllli\t%0,%1,%2
239 bslll\t%0,%1,%2"
240@@ -1811,6 +1890,51 @@ else
241 (set_attr "mode" "DI,DI")
242 (set_attr "length" "4,4")]
243 )
244+
245+(define_insn "ashldi3_const"
246+ [(set (match_operand:DI 0 "register_operand" "=&d")
247+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
248+ (match_operand:DI 2 "immediate_operand" "I")))]
249+ "TARGET_MB_64"
250+ {
251+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
252+
253+ output_asm_insn ("orli\t%3,r0,%2", operands);
254+ if (REGNO (operands[0]) != REGNO (operands[1]))
255+ output_asm_insn ("addlk\t%0,%1,r0", operands);
256+
257+ output_asm_insn ("addlik\t%3,%3,-1", operands);
258+ output_asm_insn ("beaneid\t%3,.-8", operands);
259+ return "addlk\t%0,%0,%0";
260+ }
261+ [(set_attr "type" "multi")
262+ (set_attr "mode" "DI")
263+ (set_attr "length" "20")]
264+)
265+
266+(define_insn "ashldi3_reg"
267+ [(set (match_operand:DI 0 "register_operand" "=&d")
268+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
269+ (match_operand:DI 2 "register_operand" "d")))]
270+ "TARGET_MB_64"
271+ {
272+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
273+ output_asm_insn ("andli\t%3,%2,31", operands);
274+ if (REGNO (operands[0]) != REGNO (operands[1]))
275+ output_asm_insn ("addlk\t%0,r0,%1", operands);
276+ /* Exit the loop if zero shift. */
277+ output_asm_insn ("beaeqid\t%3,.+24", operands);
278+ /* Emit the loop. */
279+ output_asm_insn ("addlk\t%0,%0,r0", operands);
280+ output_asm_insn ("addlik\t%3,%3,-1", operands);
281+ output_asm_insn ("beaneid\t%3,.-8", operands);
282+ return "addlk\t%0,%0,%0";
283+ }
284+ [(set_attr "type" "multi")
285+ (set_attr "mode" "DI")
286+ (set_attr "length" "28")]
287+)
288+
289 ;; The following patterns apply when there is no barrel shifter present
290
291 (define_insn "*ashlsi3_with_mul_delay"
292@@ -1944,11 +2068,21 @@ else
293 "TARGET_MB_64"
294 {
295 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
296-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
297+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
298 {
299 emit_insn(gen_ashrdi3_long (operands[0], operands[1],operands[2]));
300 DONE;
301 }
302+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
303+ {
304+ emit_insn(gen_ashrdi3_const (operands[0], operands[1],operands[2]));
305+ DONE;
306+ }
307+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
308+ {
309+ emit_insn(gen_ashrdi3_reg (operands[0], operands[1],operands[2]));
310+ DONE;
311+ }
312 else
313 FAIL;
314 }
315@@ -1958,7 +2092,7 @@ else
316 [(set (match_operand:DI 0 "register_operand" "=d,d")
317 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
318 (match_operand:DI 2 "arith_operand" "I,d")))]
319- "TARGET_MB_64"
320+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
321 "@
322 bslrai\t%0,%1,%2
323 bslra\t%0,%1,%2"
324@@ -1966,6 +2100,51 @@ else
325 (set_attr "mode" "DI,DI")
326 (set_attr "length" "4,4")]
327 )
328+
329+(define_insn "ashrdi3_const"
330+ [(set (match_operand:DI 0 "register_operand" "=&d")
331+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
332+ (match_operand:DI 2 "immediate_operand" "I")))]
333+ "TARGET_MB_64"
334+ {
335+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
336+
337+ output_asm_insn ("orli\t%3,r0,%2", operands);
338+ if (REGNO (operands[0]) != REGNO (operands[1]))
339+ output_asm_insn ("addlk\t%0,%1,r0", operands);
340+
341+ output_asm_insn ("addlik\t%3,%3,-1", operands);
342+ output_asm_insn ("beaneid\t%3,.-8", operands);
343+ return "srla\t%0,%0";
344+ }
345+ [(set_attr "type" "arith")
346+ (set_attr "mode" "DI")
347+ (set_attr "length" "20")]
348+)
349+
350+(define_insn "ashrdi3_reg"
351+ [(set (match_operand:DI 0 "register_operand" "=&d")
352+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
353+ (match_operand:DI 2 "register_operand" "d")))]
354+ "TARGET_MB_64"
355+ {
356+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
357+ output_asm_insn ("andli\t%3,%2,31", operands);
358+ if (REGNO (operands[0]) != REGNO (operands[1]))
359+ output_asm_insn ("addlk\t%0,r0,%1", operands);
360+ /* Exit the loop if zero shift. */
361+ output_asm_insn ("beaeqid\t%3,.+24", operands);
362+ /* Emit the loop. */
363+ output_asm_insn ("addlk\t%0,%0,r0", operands);
364+ output_asm_insn ("addlik\t%3,%3,-1", operands);
365+ output_asm_insn ("beaneid\t%3,.-8", operands);
366+ return "srla\t%0,%0";
367+ }
368+ [(set_attr "type" "multi")
369+ (set_attr "mode" "DI")
370+ (set_attr "length" "28")]
371+)
372+
373 (define_expand "ashrsi3"
374 [(set (match_operand:SI 0 "register_operand" "=&d")
375 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
376@@ -2083,11 +2262,21 @@ else
377 "TARGET_MB_64"
378 {
379 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
380-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
381+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
382 {
383 emit_insn(gen_lshrdi3_long (operands[0], operands[1],operands[2]));
384 DONE;
385 }
386+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
387+ {
388+ emit_insn(gen_lshrdi3_const (operands[0], operands[1],operands[2]));
389+ DONE;
390+ }
391+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
392+ {
393+ emit_insn(gen_lshrdi3_reg (operands[0], operands[1],operands[2]));
394+ DONE;
395+ }
396 else
397 FAIL;
398 }
399@@ -2097,7 +2286,7 @@ else
400 [(set (match_operand:DI 0 "register_operand" "=d,d")
401 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
402 (match_operand:DI 2 "arith_operand" "I,d")))]
403- "TARGET_MB_64"
404+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
405 "@
406 bslrli\t%0,%1,%2
407 bslrl\t%0,%1,%2"
408@@ -2106,6 +2295,50 @@ else
409 (set_attr "length" "4,4")]
410 )
411
412+(define_insn "lshrdi3_const"
413+ [(set (match_operand:DI 0 "register_operand" "=&d")
414+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
415+ (match_operand:DI 2 "immediate_operand" "I")))]
416+ "TARGET_MB_64"
417+ {
418+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
419+
420+ output_asm_insn ("orli\t%3,r0,%2", operands);
421+ if (REGNO (operands[0]) != REGNO (operands[1]))
422+ output_asm_insn ("addlk\t%0,%1,r0", operands);
423+
424+ output_asm_insn ("addlik\t%3,%3,-1", operands);
425+ output_asm_insn ("beaneid\t%3,.-8", operands);
426+ return "srll\t%0,%0";
427+ }
428+ [(set_attr "type" "multi")
429+ (set_attr "mode" "DI")
430+ (set_attr "length" "20")]
431+)
432+
433+(define_insn "lshrdi3_reg"
434+ [(set (match_operand:DI 0 "register_operand" "=&d")
435+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
436+ (match_operand:DI 2 "register_operand" "d")))]
437+ "TARGET_MB_64"
438+ {
439+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
440+ output_asm_insn ("andli\t%3,%2,31", operands);
441+ if (REGNO (operands[0]) != REGNO (operands[1]))
442+ output_asm_insn ("addlk\t%0,r0,%1", operands);
443+ /* Exit the loop if zero shift. */
444+ output_asm_insn ("beaeqid\t%3,.+24", operands);
445+ /* Emit the loop. */
446+ output_asm_insn ("addlk\t%0,%0,r0", operands);
447+ output_asm_insn ("addlik\t%3,%3,-1", operands);
448+ output_asm_insn ("beaneid\t%3,.-8", operands);
449+ return "srll\t%0,%0";
450+ }
451+ [(set_attr "type" "multi")
452+ (set_attr "mode" "SI")
453+ (set_attr "length" "28")]
454+)
455+
456 (define_expand "lshrsi3"
457 [(set (match_operand:SI 0 "register_operand" "=&d")
458 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
459@@ -2233,7 +2466,7 @@ else
460 (eq:DI
461 (match_operand:DI 1 "register_operand" "d")
462 (match_operand:DI 2 "register_operand" "d")))]
463- "TARGET_MB_64"
464+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
465 "pcmpleq\t%0,%1,%2"
466 [(set_attr "type" "arith")
467 (set_attr "mode" "DI")
468@@ -2245,7 +2478,7 @@ else
469 (ne:DI
470 (match_operand:DI 1 "register_operand" "d")
471 (match_operand:DI 2 "register_operand" "d")))]
472- "TARGET_MB_64"
473+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
474 "pcmplne\t%0,%1,%2"
475 [(set_attr "type" "arith")
476 (set_attr "mode" "DI")
477--
4782.7.4
479
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0061-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0061-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch
new file mode 100644
index 00000000..d3ed669c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0061-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch
@@ -0,0 +1,41 @@
1From 11766e4f7aaad3f217944079335c71525b72201c Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Wed, 8 May 2019 14:12:03 +0530
4Subject: [PATCH 61/63] [Patch, microblaze]: Add TARGET_OPTION_OPTIMIZATION and
5 disable fivopts by default
6
7Added TARGET_OPTION_OPTIMIZATIONS and Turn off ivopts by default.
8
9 * gcc/common/config/microblaze/microblaze-common.c
10 (microblaze_option_optimization_table): Disable fivopts by default.
11
12Signed-off-by: Nagaraju Mekala <nmekala@xilinx.com>
13---
14 gcc/common/config/microblaze/microblaze-common.c | 6 ++++--
15 1 file changed, 4 insertions(+), 2 deletions(-)
16
17diff --git a/gcc/common/config/microblaze/microblaze-common.c b/gcc/common/config/microblaze/microblaze-common.c
18index 9b6ef21..3cae2a6 100644
19--- a/gcc/common/config/microblaze/microblaze-common.c
20+++ b/gcc/common/config/microblaze/microblaze-common.c
21@@ -27,13 +27,15 @@
22 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
23 static const struct default_options microblaze_option_optimization_table[] =
24 {
25- /* Turn off ivopts by default. It messes up cse. */
26+ /* Turn off ivopts by default. It messes up cse.
27+ { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 }, */
28 { OPT_LEVELS_ALL, OPT_fivopts, NULL, 0 },
29- { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
30 { OPT_LEVELS_NONE, 0, NULL, 0 }
31 };
32
33 #undef TARGET_DEFAULT_TARGET_FLAGS
34 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
35
36+#undef TARGET_OPTION_OPTIMIZATION_TABLE
37+#define TARGET_OPTION_OPTIMIZATION_TABLE microblaze_option_optimization_table
38 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
39--
402.7.4
41
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0062-Added-new-MB-64-single-register-arithmetic-instructi.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0062-Added-new-MB-64-single-register-arithmetic-instructi.patch
new file mode 100644
index 00000000..ca1a2b9f
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0062-Added-new-MB-64-single-register-arithmetic-instructi.patch
@@ -0,0 +1,107 @@
1From bb65903ab6293a47d154764a585f6c53b5fcf853 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Fri, 23 Aug 2019 16:16:53 +0530
4Subject: [PATCH 62/63] Added new MB-64 single register arithmetic instructions
5
6---
7 gcc/config/microblaze/microblaze.md | 56 +++++++++++++++++++++++++++++++++++++
8 1 file changed, 56 insertions(+)
9
10diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
11index 3e7c647..4d40cc5 100644
12--- a/gcc/config/microblaze/microblaze.md
13+++ b/gcc/config/microblaze/microblaze.md
14@@ -654,6 +654,18 @@
15 }
16 })
17
18+(define_insn "adddi3_int"
19+ [(set (match_operand:DI 0 "register_operand" "=d")
20+ (plus:DI (match_operand:DI 1 "register_operand" "%0")
21+ (match_operand:DI 2 "immediate_operand" "I")))]
22+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767)"
23+ "@
24+ addlik\t%0,%2"
25+ [(set_attr "type" "darith")
26+ (set_attr "mode" "DI")
27+ (set_attr "length" "4")]
28+)
29+
30 (define_insn "*adddi3_long"
31 [(set (match_operand:DI 0 "register_operand" "=d,d")
32 (plus:DI (match_operand:DI 1 "register_operand" "%d,d")
33@@ -719,6 +731,18 @@
34 {
35 }")
36
37+(define_insn "subdi316imm"
38+ [(set (match_operand:DI 0 "register_operand" "=d")
39+ (minus:DI (match_operand:DI 1 "register_operand" "d")
40+ (match_operand:DI 2 "arith_operand" "K")))]
41+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767) && (REGNO (operands[0]) == REGNO (operands[1]))"
42+ "@
43+ addlik\t%0,-%2"
44+ [(set_attr "type" "darith")
45+ (set_attr "mode" "DI")
46+ (set_attr "length" "4")])
47+
48+
49 (define_insn "subsidi3"
50 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
51 (minus:DI (match_operand:DI 1 "register_operand" "d,d,d")
52@@ -1015,6 +1039,17 @@
53 ;; Logical
54 ;;----------------------------------------------------------------
55
56+(define_insn "anddi3imm16"
57+ [(set (match_operand:DI 0 "register_operand" "=d")
58+ (and:DI (match_operand:DI 1 "arith_operand" "%0")
59+ (match_operand:DI 2 "arith_operand" "K")))]
60+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767)"
61+ "@
62+ andli\t%0,%2"
63+ [(set_attr "type" "darith")
64+ (set_attr "mode" "DI")
65+ (set_attr "length" "4")])
66+
67 (define_insn "anddi3"
68 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
69 (and:DI (match_operand:DI 1 "arith_operand" "d,d,d")
70@@ -1042,6 +1077,16 @@
71 (set_attr "mode" "SI,SI,SI,SI")
72 (set_attr "length" "4,8,8,8")])
73
74+(define_insn "iordi3imm16"
75+ [(set (match_operand:DI 0 "register_operand" "=d")
76+ (ior:DI (match_operand:DI 1 "arith_operand" "%0")
77+ (match_operand:DI 2 "arith_operand" "K")))]
78+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767)"
79+ "@
80+ orli\t%0,%2"
81+ [(set_attr "type" "darith")
82+ (set_attr "mode" "DI")
83+ (set_attr "length" "4")])
84
85 (define_insn "iordi3"
86 [(set (match_operand:DI 0 "register_operand" "=d,d")
87@@ -1069,6 +1114,17 @@
88 (set_attr "mode" "SI,SI,SI,SI")
89 (set_attr "length" "4,8,8,8")])
90
91+(define_insn "xordi3imm16"
92+ [(set (match_operand:DI 0 "register_operand" "=d")
93+ (xor:DI (match_operand:DI 1 "arith_operand" "%0")
94+ (match_operand:DI 2 "arith_operand" "K")))]
95+ "TARGET_MB_64 && ((long long)INTVAL(operands[2]) > (long long)-32768) && ((long long) INTVAL(operands[2]) < (long long)32767)"
96+ "@
97+ xorli\t%0,%2"
98+ [(set_attr "type" "darith")
99+ (set_attr "mode" "DI")
100+ (set_attr "length" "4")])
101+
102 (define_insn "xordi3"
103 [(set (match_operand:DI 0 "register_operand" "=d,d")
104 (xor:DI (match_operand:DI 1 "arith_operand" "%d,d")
105--
1062.7.4
107
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0062-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0062-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch
new file mode 100644
index 00000000..e7dfa89c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0062-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch
@@ -0,0 +1,41 @@
1From 612e6579116e6714417ea21e6c13b0968bb6aac2 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Wed, 8 May 2019 14:12:03 +0530
4Subject: [PATCH 62/62] [Patch, microblaze]: Add TARGET_OPTION_OPTIMIZATION and
5 disable fivopts by default
6
7Added TARGET_OPTION_OPTIMIZATIONS and Turn off ivopts by default.
8
9 * gcc/common/config/microblaze/microblaze-common.c
10 (microblaze_option_optimization_table): Disable fivopts by default.
11
12Signed-off-by: Nagaraju Mekala <nmekala@xilinx.com>
13---
14 gcc/common/config/microblaze/microblaze-common.c | 6 ++++--
15 1 file changed, 4 insertions(+), 2 deletions(-)
16
17diff --git a/gcc/common/config/microblaze/microblaze-common.c b/gcc/common/config/microblaze/microblaze-common.c
18index fe45f2e..2873d4b 100644
19--- a/gcc/common/config/microblaze/microblaze-common.c
20+++ b/gcc/common/config/microblaze/microblaze-common.c
21@@ -27,13 +27,15 @@
22 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */
23 static const struct default_options microblaze_option_optimization_table[] =
24 {
25- /* Turn off ivopts by default. It messes up cse. */
26+ /* Turn off ivopts by default. It messes up cse.
27+ { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 }, */
28 { OPT_LEVELS_ALL, OPT_fivopts, NULL, 0 },
29- { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
30 { OPT_LEVELS_NONE, 0, NULL, 0 }
31 };
32
33 #undef TARGET_DEFAULT_TARGET_FLAGS
34 #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT
35
36+#undef TARGET_OPTION_OPTIMIZATION_TABLE
37+#define TARGET_OPTION_OPTIMIZATION_TABLE microblaze_option_optimization_table
38 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
39--
402.7.4
41
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0063-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0063-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch
new file mode 100644
index 00000000..edf6a0f3
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0063-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch
@@ -0,0 +1,44 @@
1From d4b23a1dd0564bcf67b5b88a68d62eb49bdab15d Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 26 Aug 2019 15:55:22 +0530
4Subject: [PATCH 63/63] [Patch,MicroBlaze] : Added support for 64 bit Immediate
5 values.
6
7---
8 gcc/config/microblaze/constraints.md | 4 ++--
9 gcc/config/microblaze/microblaze.md | 3 +--
10 2 files changed, 3 insertions(+), 4 deletions(-)
11
12diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md
13index 9a5aa6b..e87a90f 100644
14--- a/gcc/config/microblaze/constraints.md
15+++ b/gcc/config/microblaze/constraints.md
16@@ -53,9 +53,9 @@
17 (match_test "ival > 0 && ival < 0x10000")))
18
19 (define_constraint "K"
20- "A constant in the range 0xffffff8000000000L to 0x0000007fffffffffL (inclusive)."
21+ "A constant in the range -9223372036854775808 to 9223372036854775807 (inclusive)."
22 (and (match_code "const_int")
23- (match_test "ival > (long long)-549755813888 && ival < (long long)549755813887")))
24+ (match_test "ival > (long long)-9223372036854775808 && ival < (long long)9223372036854775807")))
25
26 ;; Define floating point constraints
27
28diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
29index 4d40cc5..6e74503 100644
30--- a/gcc/config/microblaze/microblaze.md
31+++ b/gcc/config/microblaze/microblaze.md
32@@ -1334,8 +1334,7 @@
33 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d")
34 (match_operand:DI 1 "immediate_operand" "J,I,Mnis"))]
35 "TARGET_MB_64 && (register_operand (operands[0], DImode) &&
36- (GET_CODE (operands[1]) == CONST_INT &&
37- (INTVAL (operands[1]) <= (long long)549755813887 && INTVAL (operands[1]) >= (long long)-549755813888)))"
38+ (GET_CODE (operands[1]) == CONST_INT))"
39 "@
40 addlk\t%0,r0,r0\t
41 addlik\t%0,r0,%1\t #N1 %X1
42--
432.7.4
44
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-10/0064-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0064-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch
new file mode 100644
index 00000000..41c90353
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-10/0064-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch
@@ -0,0 +1,77 @@
1From 5f54efe1e7d9604b45ddddd510ce439477d0e94f Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 9 Jan 2020 12:30:41 +0530
4Subject: [PATCH] [Patch, microblaze]: Fix Compiler crash with
5 -freg-struct-return This patch fixes a bug in MB GCC regarding the passing
6 struct values in registers. Currently we are only handling SImode With this
7 patch all other modes are handled properly
8
9Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
10
11---
12 gcc/config/microblaze/microblaze.c | 11 ++++++++++-
13 gcc/config/microblaze/microblaze.h | 19 -------------------
14 2 files changed, 10 insertions(+), 20 deletions(-)
15
16diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
17index 5c09452..beccd12 100644
18--- a/gcc/config/microblaze/microblaze.c
19+++ b/gcc/config/microblaze/microblaze.c
20@@ -4046,7 +4046,16 @@ microblaze_function_value (const_tree valtype,
21 const_tree func ATTRIBUTE_UNUSED,
22 bool outgoing ATTRIBUTE_UNUSED)
23 {
24- return LIBCALL_VALUE (TYPE_MODE (valtype));
25+ return gen_rtx_REG (TYPE_MODE (valtype), GP_RETURN);
26+}
27+
28+#undef TARGET_LIBCALL_VALUE
29+#define TARGET_LIBCALL_VALUE microblaze_libcall_value
30+
31+rtx
32+microblaze_libcall_value (machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED)
33+{
34+ return gen_rtx_REG (mode, GP_RETURN);
35 }
36
37 /* Implement TARGET_SCHED_ADJUST_COST. */
38diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
39index ab541f7..100e7b2 100644
40--- a/gcc/config/microblaze/microblaze.h
41+++ b/gcc/config/microblaze/microblaze.h
42@@ -266,13 +266,6 @@ extern enum pipeline_type microblaze_pipe;
43
44 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
45
46-#ifndef __arch64__
47-#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
48- if (GET_MODE_CLASS (MODE) == MODE_INT \
49- && GET_MODE_SIZE (MODE) < 4) \
50- (MODE) = SImode;
51-#endif
52-
53 /* Standard register usage. */
54
55 /* On the MicroBlaze, we have 32 integer registers */
56@@ -471,18 +464,6 @@ extern struct microblaze_frame_info current_frame_info;
57
58 #define MAX_ARGS_IN_REGISTERS MB_ABI_MAX_ARG_REGS
59
60-#ifdef __aarch64__
61-#define LIBCALL_VALUE(MODE) \
62- gen_rtx_REG (MODE,GP_RETURN)
63-#else
64-#define LIBCALL_VALUE(MODE) \
65- gen_rtx_REG ( \
66- ((GET_MODE_CLASS (MODE) != MODE_INT \
67- || GET_MODE_SIZE (MODE) >= 4) \
68- ? (MODE) \
69- : SImode), GP_RETURN)
70-#endif
71-
72 /* 1 if N is a possible register number for a function value.
73 On the MicroBlaze, R2 R3 are the only register thus used.
74 Currently, R2 are only implemented here (C has no complex type) */
75--
761.8.3.1
77
diff --git a/meta-microblaze/recipes-microblaze/gcc/gcc-source_10.%.bbappend b/meta-microblaze/recipes-microblaze/gcc/gcc-source_10.%.bbappend
new file mode 100644
index 00000000..2f80661a
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gcc/gcc-source_10.%.bbappend
@@ -0,0 +1,69 @@
1# Add MicroBlaze Patches (only when using MicroBlaze)
2FILESEXTRAPATHS_append_microblaze := ":${THISDIR}/gcc-9"
3SRC_URI_append_microblaze = " \
4 file://0001-LOCAL-Testsuite-builtins-tests-require-fpic.patch \
5 file://0002-LOCAL-Quick-fail-g-.dg-opt-memcpy1.C.patch \
6 file://0003-LOCAL-Testsuite-explicitly-add-fivopts-for-tests-tha.patch \
7 file://0004-LOCAL-For-dejagnu-static-testing-on-qemu-suppress-wa.patch \
8 file://0005-Patch-testsuite-Add-MicroBlaze-to-target-supports-fo.patch \
9 file://0006-Patch-testsuite-Update-MicroBlaze-strings-test.patch \
10 file://0007-Patch-testsuite-Allow-MicroBlaze-.weakext-pattern-in.patch \
11 file://0008-Patch-testsuite-Add-MicroBlaze-to-check_profiling_av.patch \
12 file://0009-Patch-microblaze-Fix-atomic-side-effects.patch \
13 file://0010-Patch-microblaze-Fix-atomic-boolean-return-value.patch \
14 file://0011-Patch-microblaze-Fix-the-Microblaze-crash-with-msmal.patch \
15 file://0012-Patch-microblaze-Added-ashrsi3_with_size_opt.patch \
16 file://0013-Patch-microblaze-Fixed-missing-save-of-r18-in-fast_i.patch \
17 file://0014-Patch-microblaze-Use-bralid-for-profiler-calls.patch \
18 file://0015-Patch-microblaze-Disable-fivopts-by-default.patch \
19 file://0016-Patch-microblaze-Removed-moddi3-routinue.patch \
20 file://0017-Patch-microblaze-Add-INIT_PRIORITY-support.patch \
21 file://0018-Patch-microblaze-Add-optimized-lshrsi3.patch \
22 file://0019-Patch-microblaze-Modified-trap-instruction.patch \
23 file://0020-Patch-microblaze-Reducing-Stack-space-for-arguments.patch \
24 file://0021-Patch-microblaze-Add-cbranchsi4_reg.patch \
25 file://0022-Patch-microblaze-Inline-Expansion-of-fsqrt-builtin.patch \
26 file://0023-Patch-OPT-Update-heuristics-for-loop-invariant-for-a.patch \
27 file://0024-PATCH-microblaze.md-Improve-adddi3-and-subdi3-insn-d.patch \
28 file://0025-Patch-microblaze-Update-ashlsi3-movsf-patterns.patch \
29 file://0026-Patch-microblaze-8-stage-pipeline-for-microblaze.patch \
30 file://0027-Patch-rtl-Optimization-Better-register-pressure-esti.patch \
31 file://0028-Patch-microblaze-Correct-the-const-high-double-immed.patch \
32 file://0029-Fix-microblaze-Fix-internal-compiler-error-with-msma.patch \
33 file://0030-patch-microblaze-Fix-the-calculation-of-high-word-in.patch \
34 file://0031-Patch-microblaze-Add-new-bit-field-instructions.patch \
35 file://0032-Patch-microblaze-Fix-bug-in-MB-version-calculation.patch \
36 file://0033-Fixing-the-bug-in-the-bit-field-instruction.patch \
37 file://0034-Patch-microblaze-Macros-used-in-Xilinx-internal-patc.patch \
38 file://0035-Fixing-the-issue-with-the-builtin_alloc.patch \
39 file://0036-Patch-Microblaze-reverting-the-cost-check-before-pro.patch \
40 file://0037-Patch-Microblaze-update-in-constraints-for-bitfield-.patch \
41 file://0038-Patch-Microblaze-Removed-fsqrt-generation-for-double.patch \
42 file://0039-Intial-commit-of-64-bit-Microblaze.patch \
43 file://0040-Added-load-store-pattern-movdi-and-also-adding-missi.patch \
44 file://0041-Intial-commit-for-64bit-MB-sources.patch \
45 file://0042-re-arrangement-of-the-compare-branches.patch \
46 file://0043-Patch-Microblaze-previous-commit-broke-the-handling-.patch \
47 file://0044-Patch-Microblaze-Support-of-multilibs-with-m64.patch \
48 file://0045-Fixed-issues-like.patch \
49 file://0046-Fixed-below-issues.patch \
50 file://0047-Added-double-arith-instructions.patch \
51 file://0048-Fixed-the-issue-in-the-delay-slot-with-swap-instruct.patch \
52 file://0049-Fixed-the-load-store-issue-with-the-32bit-arith-libr.patch \
53 file://0050-extending-the-Dwarf-support-to-64bit-Microblaze.patch \
54 file://0051-fixing-the-typo-errors-in-umodsi3-file.patch \
55 file://0052-fixing-the-32bit-LTO-related-issue9-1014024.patch \
56 file://0053-Fixed-the-missing-stack-adjustment-in-prologue-of-mo.patch \
57 file://0054-Patch-Microblaze-corrected-SPN-for-dlong-instruction.patch \
58 file://0055-fixing-the-long-long-long-mingw-toolchain-issue.patch \
59 file://0056-Fix-the-MB-64-bug-of-handling-QI-objects.patch \
60 file://0057-Patch-Microblaze-We-will-check-the-possibility-of-pe.patch \
61 file://0058-Reverting-the-patch-as-kernel-boot-is-not-working-wi.patch \
62 file://0059-Patch-MicroBlaze-fixed-typos-in-mul-div-and-mod-asse.patch \
63 file://0060-Author-Nagaraju-nmekala-xilinx.com.patch \
64 file://0061-Patch-microblaze-Add-TARGET_OPTION_OPTIMIZATION-and-.patch \
65 file://0062-Added-new-MB-64-single-register-arithmetic-instructi.patch \
66 file://0063-Patch-MicroBlaze-Added-support-for-64-bit-Immediate-.patch \
67 file://0064-Patch-microblaze-Fix-Compiler-crash-with-freg-struct.patch \
68 file://0065-microblaze-multilib-hack.patch \
69"
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb-cross-canadian_%.bbappend b/meta-microblaze/recipes-microblaze/gdb/gdb-cross-canadian_%.bbappend
new file mode 100644
index 00000000..ceb7b02b
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb-cross-canadian_%.bbappend
@@ -0,0 +1,4 @@
1MICROBLAZEPATCHES = ""
2MICROBLAZEPATCHES_microblaze = "gdb-microblaze.inc"
3
4require ${MICROBLAZEPATCHES}
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb-cross_%.bbappend b/meta-microblaze/recipes-microblaze/gdb/gdb-cross_%.bbappend
new file mode 100644
index 00000000..ceb7b02b
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb-cross_%.bbappend
@@ -0,0 +1,4 @@
1MICROBLAZEPATCHES = ""
2MICROBLAZEPATCHES_microblaze = "gdb-microblaze.inc"
3
4require ${MICROBLAZEPATCHES}
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb-microblaze.inc b/meta-microblaze/recipes-microblaze/gdb/gdb-microblaze.inc
new file mode 100644
index 00000000..4db9957c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb-microblaze.inc
@@ -0,0 +1,47 @@
1# MicroBlaze does not support LTTng UST
2LTTNGUST_microblaze = ""
3
4# Add MicroBlaze patches
5FILESEXTRAPATHS_append := ":${THISDIR}/gdb"
6
7SRC_URI_append_microblaze = " \
8 file://0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch \
9 file://0003-Disable-the-warning-message-for-eh_frame_hdr.patch \
10 file://0004-Fix-relaxation-of-assembler-resolved-references.patch \
11 file://0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch \
12 file://0006-upstream-change-to-garbage-collection-sweep-causes-m.patch \
13 file://0007-Fix-bug-in-TLSTPREL-Relocation.patch \
14 file://0008-Added-Address-extension-instructions.patch \
15 file://0009-fixing-the-MAX_OPCODES-to-correct-value.patch \
16 file://0010-Add-new-bit-field-instructions.patch \
17 file://0011-fixing-the-imm-bug.patch \
18 file://0015-intial-commit-of-MB-64-bit.patch \
19 file://0016-MB-X-initial-commit.patch \
20 file://0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch \
21 file://0018-Added-relocations-for-MB-X.patch \
22 file://0019-Fixed-MB-x-relocation-issues.patch \
23 file://0020-Fixing-the-branch-related-issues.patch \
24 file://0021-Fixed-address-computation-issues-with-64bit-address.patch \
25 file://0022-Adding-new-relocation-to-support-64bit-rodata.patch \
26 file://0023-fixing-the-.bss-relocation-issue.patch \
27 file://0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch \
28 file://0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch \
29 file://0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch \
30 file://0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch \
31 file://0029-fixing-the-long-long-long-mingw-toolchain-issue.patch \
32 file://0030-Added-support-to-new-arithmetic-single-register-inst.patch \
33 file://0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch \
34 file://0032-Add-initial-port-of-linux-gdbserver.patch \
35 file://0033-Initial-port-of-core-reading-support.patch \
36 file://0034-Fix-debug-message-when-register-is-unavailable.patch \
37 file://0035-revert-master-rebase-changes-to-gdbserver.patch \
38 file://0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch \
39 file://0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch \
40 file://0038-Initial-support-for-native-gdb.patch \
41 file://0039-Fixing-the-issues-related-to-GDB-7.12.patch \
42 file://0040-Patch-microblaze-Adding-64-bit-MB-support.patch \
43 file://0041-patch-MicroBlaze-porting-GDB-for-linux.patch \
44 file://0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch \
45 file://0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch \
46 file://0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch \
47 "
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch
new file mode 100644
index 00000000..4b85d7c9
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0001-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch
@@ -0,0 +1,65 @@
1From f1cb2126c751d6c2526ea969918d5b51dd5b851f Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Wed, 8 May 2013 11:03:36 +1000
4Subject: [PATCH 01/43] Add wdc.ext.clear and wdc.ext.flush insns
5
6Added two new instructions, wdc.ext.clear and wdc.ext.flush,
7to enable MicroBlaze to flush an external cache, which is
8used with the new coherency support for multiprocessing.
9
10Signed-off-by:nagaraju <nmekala@xilix.com>
11Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
12---
13 opcodes/microblaze-opc.h | 5 ++++-
14 opcodes/microblaze-opcm.h | 4 ++--
15 2 files changed, 6 insertions(+), 3 deletions(-)
16
17diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
18index 62ee3c9a4d..865151f95b 100644
19--- a/opcodes/microblaze-opc.h
20+++ b/opcodes/microblaze-opc.h
21@@ -91,6 +91,7 @@
22 #define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22. */
23 #define OPCODE_MASK_H32 0xFC00FC00 /* High 6 bits and bit 16-21. */
24 #define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits. */
25+#define OPCODE_MASK_H35B 0xFC0004FF /* High 6 bits and low 9 bits. */
26 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
27
28 /* New Mask for msrset, msrclr insns. */
29@@ -101,7 +102,7 @@
30 #define DELAY_SLOT 1
31 #define NO_DELAY_SLOT 0
32
33-#define MAX_OPCODES 289
34+#define MAX_OPCODES 291
35
36 struct op_code_struct
37 {
38@@ -174,7 +175,9 @@ struct op_code_struct
39 {"wic", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000068, OPCODE_MASK_H34B, wic, special_inst },
40 {"wdc", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000064, OPCODE_MASK_H34B, wdc, special_inst },
41 {"wdc.clear", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000066, OPCODE_MASK_H34B, wdcclear, special_inst },
42+ {"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 },
43 {"wdc.flush", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000074, OPCODE_MASK_H34B, wdcflush, special_inst },
44+ {"wdc.ext.flush", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000476, OPCODE_MASK_H35B, wdcextflush, special_inst },
45 {"mts", INST_TYPE_SPECIAL_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MTS, 0x9400C000, OPCODE_MASK_H13S, mts, special_inst },
46 {"mfs", INST_TYPE_RD_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MFS, 0x94008000, OPCODE_MASK_H23S, mfs, special_inst },
47 {"br", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98000000, OPCODE_MASK_H124, br, branch_inst },
48diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
49index 5a2d3b0c8b..42f3dd3be5 100644
50--- a/opcodes/microblaze-opcm.h
51+++ b/opcodes/microblaze-opcm.h
52@@ -33,8 +33,8 @@ enum microblaze_instr
53 /* 'or/and/xor' are C++ keywords. */
54 microblaze_or, microblaze_and, microblaze_xor,
55 andn, pcmpbf, pcmpbc, pcmpeq, pcmpne, sra, src, srl, sext8, sext16,
56- wic, wdc, wdcclear, wdcflush, mts, mfs, mbar, br, brd,
57- brld, bra, brad, brald, microblaze_brk, beq, beqd, bne, bned, blt,
58+ wic, wdc, wdcclear, wdcextclear, wdcflush, wdcextflush, mts, mfs, mbar, br,
59+ brd, brld, bra, brad, brald, microblaze_brk, beq, beqd, bne, bned, blt,
60 bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni,
61 imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid,
62 brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti,
63--
642.17.1
65
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0003-Disable-the-warning-message-for-eh_frame_hdr.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0003-Disable-the-warning-message-for-eh_frame_hdr.patch
new file mode 100644
index 00000000..53415370
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0003-Disable-the-warning-message-for-eh_frame_hdr.patch
@@ -0,0 +1,31 @@
1From 68fe2e975f229cce08029b3a5afb06132f1cb31c Mon Sep 17 00:00:00 2001
2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
3Date: Fri, 22 Jun 2012 01:20:20 +0200
4Subject: [PATCH 03/43] Disable the warning message for eh_frame_hdr
5
6Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
7---
8 bfd/elf-eh-frame.c | 3 +++
9 1 file changed, 3 insertions(+)
10
11diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
12index a13e81ebb8..1824ba6e5b 100644
13--- a/bfd/elf-eh-frame.c
14+++ b/bfd/elf-eh-frame.c
15@@ -1044,10 +1044,13 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
16 goto success;
17
18 free_no_table:
19+/* FIXME: Remove the microblaze specifics when relaxing gets fixed. */
20+if (bfd_get_arch(abfd) != bfd_arch_microblaze) {
21 _bfd_error_handler
22 /* xgettext:c-format */
23 (_("error in %pB(%pA); no .eh_frame_hdr table will be created"),
24 abfd, sec);
25+}
26 hdr_info->u.dwarf.table = FALSE;
27 if (sec_info)
28 free (sec_info);
29--
302.17.1
31
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0004-Fix-relaxation-of-assembler-resolved-references.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0004-Fix-relaxation-of-assembler-resolved-references.patch
new file mode 100644
index 00000000..7ba07a0c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0004-Fix-relaxation-of-assembler-resolved-references.patch
@@ -0,0 +1,61 @@
1From 1ea25f31c38e606603bf406efebfb6cfc26aec38 Mon Sep 17 00:00:00 2001
2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
3Date: Tue, 14 Feb 2012 01:00:22 +0100
4Subject: [PATCH 04/43] Fix relaxation of assembler resolved references
5
6---
7 bfd/elf32-microblaze.c | 38 ++++++++++++++++++++++++++++++++++++++
8 2 files changed, 39 insertions(+)
9
10diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
11index e3c8027248..359484dd5e 100644
12--- a/bfd/elf32-microblaze.c
13+++ b/bfd/elf32-microblaze.c
14@@ -1973,6 +1973,44 @@ microblaze_elf_relax_section (bfd *abfd,
15 irelscanend = irelocs + o->reloc_count;
16 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
17 {
18+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
19+ {
20+ unsigned int val;
21+
22+ isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
23+
24+ /* This was a PC-relative instruction that was completely resolved. */
25+ if (ocontents == NULL)
26+ {
27+ if (elf_section_data (o)->this_hdr.contents != NULL)
28+ ocontents = elf_section_data (o)->this_hdr.contents;
29+ else
30+ {
31+ /* We always cache the section contents.
32+ Perhaps, if info->keep_memory is FALSE, we
33+ should free them, if we are permitted to. */
34+
35+ if (o->rawsize == 0)
36+ o->rawsize = o->size;
37+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
38+ if (ocontents == NULL)
39+ goto error_return;
40+ if (!bfd_get_section_contents (abfd, o, ocontents,
41+ (file_ptr) 0,
42+ o->rawsize))
43+ goto error_return;
44+ elf_section_data (o)->this_hdr.contents = ocontents;
45+ }
46+ }
47+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
48+ + isym->st_value, sec);
49+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
50+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
51+ irelscan->r_addend);
52+ }
53+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
54+ fprintf(stderr, "Unhandled NONE 64\n");
55+ }
56 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
57 {
58 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
59--
602.17.1
61
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch
new file mode 100644
index 00000000..18646195
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0005-LOCAL-Fixup-debug_loc-sections-after-linker-relaxati.patch
@@ -0,0 +1,207 @@
1From 62859c17077c559ad5e5db1cfbb496d5e8c3da68 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 6 Feb 2017 15:53:08 +0530
4Subject: [PATCH 05/43] [LOCAL]: Fixup debug_loc sections after linker
5 relaxation Adds a new reloctype R_MICROBLAZE_32_NONE, used for passing reloc
6 info from the assembler to the linker when the linker manages to fully
7 resolve a local symbol reference.
8
9This is a workaround for design flaws in the assembler to
10linker interface with regards to linker relaxation.
11
12Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
13Signed-off-by: Nagaraju Mekala <nmekala@xilinx.com>
14---
15 bfd/bfd-in2.h | 9 +++++--
16 bfd/elf32-microblaze.c | 53 ++++++++++++++++++++++++++++----------
17 bfd/libbfd.h | 1 +
18 bfd/reloc.c | 6 +++++
19 include/elf/microblaze.h | 2 ++
20 7 files changed, 64 insertions(+), 16 deletions(-)
21
22diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
23index e25da50aaf..721531886a 100644
24--- a/bfd/bfd-in2.h
25+++ b/bfd/bfd-in2.h
26@@ -5866,10 +5866,15 @@ value relative to the read-write small data area anchor */
27 expressions of the form "Symbol Op Symbol" */
28 BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM,
29
30-/* This is a 64 bit reloc that stores the 32 bit pc relative
31+/* This is a 32 bit reloc that stores the 32 bit pc relative
32 value in two words (with an imm instruction). No relocation is
33 done here - only used for relaxing */
34- BFD_RELOC_MICROBLAZE_64_NONE,
35+ BFD_RELOC_MICROBLAZE_32_NONE,
36+
37+/* This is a 64 bit reloc that stores the 32 bit pc relative
38+ * +value in two words (with an imm instruction). No relocation is
39+ * +done here - only used for relaxing */
40+ BFD_RELOC_MICROBLAZE_64_NONE,
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
44diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
45index 359484dd5e..1c69c269c7 100644
46--- a/bfd/elf32-microblaze.c
47+++ b/bfd/elf32-microblaze.c
48@@ -176,7 +176,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
49 0x0000ffff, /* Dest Mask. */
50 FALSE), /* PC relative offset? */
51
52- /* This reloc does nothing. Used for relaxation. */
53+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
54+ 0, /* Rightshift. */
55+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
56+ 32, /* Bitsize. */
57+ TRUE, /* PC_relative. */
58+ 0, /* Bitpos. */
59+ complain_overflow_bitfield, /* Complain on overflow. */
60+ NULL, /* Special Function. */
61+ "R_MICROBLAZE_32_NONE",/* Name. */
62+ FALSE, /* Partial Inplace. */
63+ 0, /* Source Mask. */
64+ 0, /* Dest Mask. */
65+ FALSE), /* PC relative offset? */
66+
67+ /* This reloc does nothing. Used for relaxation. */
68 HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
69 0, /* Rightshift. */
70 3, /* Size (0 = byte, 1 = short, 2 = long). */
71@@ -562,6 +576,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
72 case BFD_RELOC_NONE:
73 microblaze_reloc = R_MICROBLAZE_NONE;
74 break;
75+ case BFD_RELOC_MICROBLAZE_32_NONE:
76+ microblaze_reloc = R_MICROBLAZE_32_NONE;
77+ break;
78 case BFD_RELOC_MICROBLAZE_64_NONE:
79 microblaze_reloc = R_MICROBLAZE_64_NONE;
80 break;
81@@ -1918,6 +1935,7 @@ microblaze_elf_relax_section (bfd *abfd,
82 }
83 break;
84 case R_MICROBLAZE_NONE:
85+ case R_MICROBLAZE_32_NONE:
86 {
87 /* This was a PC-relative instruction that was
88 completely resolved. */
89@@ -1926,12 +1944,18 @@ microblaze_elf_relax_section (bfd *abfd,
90 target_address = irel->r_addend + irel->r_offset;
91 sfix = calc_fixup (irel->r_offset, 0, sec);
92 efix = calc_fixup (target_address, 0, sec);
93+
94+ /* Validate the in-band val. */
95+ val = bfd_get_32 (abfd, contents + irel->r_offset);
96+ if (val != irel->r_addend && ELF32_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
97+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
98+ }
99 irel->r_addend -= (efix - sfix);
100 /* Should use HOWTO. */
101 microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
102 irel->r_addend);
103- }
104- break;
105+ }
106+ break;
107 case R_MICROBLAZE_64_NONE:
108 {
109 /* This was a PC-relative 64-bit instruction that was
110@@ -1973,12 +1997,16 @@ microblaze_elf_relax_section (bfd *abfd,
111 irelscanend = irelocs + o->reloc_count;
112 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
113 {
114- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
115+ if (1 && ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
116 {
117 unsigned int val;
118
119 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
120
121+ /* hax: We only do the following fixup for debug location lists. */
122+ if (strcmp(".debug_loc", o->name))
123+ continue;
124+
125 /* This was a PC-relative instruction that was completely resolved. */
126 if (ocontents == NULL)
127 {
128@@ -1999,18 +2027,17 @@ microblaze_elf_relax_section (bfd *abfd,
129 (file_ptr) 0,
130 o->rawsize))
131 goto error_return;
132- elf_section_data (o)->this_hdr.contents = ocontents;
133- }
134- }
135- irelscan->r_addend -= calc_fixup (irelscan->r_addend
136- + isym->st_value, sec);
137+ elf_section_data (o)->this_hdr.contents = ocontents;
138+ }
139+ }
140 val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
141+ if (val != irelscan->r_addend) {
142+ fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend);
143+ }
144+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
145 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
146 irelscan->r_addend);
147 }
148- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
149- fprintf(stderr, "Unhandled NONE 64\n");
150- }
151 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
152 {
153 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
154@@ -2070,7 +2097,7 @@ microblaze_elf_relax_section (bfd *abfd,
155 elf_section_data (o)->this_hdr.contents = ocontents;
156 }
157 }
158- irelscan->r_addend -= calc_fixup (irel->r_addend
159+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
160 + isym->st_value,
161 0,
162 sec);
163diff --git a/bfd/libbfd.h b/bfd/libbfd.h
164index 36284d71a9..feb9fada1e 100644
165--- a/bfd/libbfd.h
166+++ b/bfd/libbfd.h
167@@ -2901,6 +2901,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
168 "BFD_RELOC_MICROBLAZE_32_ROSDA",
169 "BFD_RELOC_MICROBLAZE_32_RWSDA",
170 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
171+ "BFD_RELOC_MICROBLAZE_32_NONE",
172 "BFD_RELOC_MICROBLAZE_64_NONE",
173 "BFD_RELOC_MICROBLAZE_64_GOTPC",
174 "BFD_RELOC_MICROBLAZE_64_GOT",
175diff --git a/bfd/reloc.c b/bfd/reloc.c
176index e6446a7809..87753ae4f0 100644
177--- a/bfd/reloc.c
178+++ b/bfd/reloc.c
179@@ -6795,6 +6795,12 @@ ENUM
180 ENUMDOC
181 This is a 32 bit reloc for the microblaze to handle
182 expressions of the form "Symbol Op Symbol"
183+ENUM
184+ BFD_RELOC_MICROBLAZE_32_NONE
185+ENUMDOC
186+ This is a 32 bit reloc that stores the 32 bit pc relative
187+ value in two words (with an imm instruction). No relocation is
188+ done here - only used for relaxing
189 ENUM
190 BFD_RELOC_MICROBLAZE_64_NONE
191 ENUMDOC
192diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h
193index 830b5ad446..6ee0966444 100644
194--- a/include/elf/microblaze.h
195+++ b/include/elf/microblaze.h
196@@ -61,6 +61,8 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type)
197 RELOC_NUMBER (R_MICROBLAZE_TEXTPCREL_64, 30) /* PC-relative TEXT offset. */
198 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_64, 31) /* TEXT Entry offset 64-bit. */
199 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_32_LO, 32) /* TEXT Entry offset 32-bit. */
200+ RELOC_NUMBER (R_MICROBLAZE_32_NONE, 33)
201+
202 END_RELOC_NUMBERS (R_MICROBLAZE_max)
203
204 /* Global base address names. */
205--
2062.17.1
207
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch
new file mode 100644
index 00000000..35d44be4
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0006-upstream-change-to-garbage-collection-sweep-causes-m.patch
@@ -0,0 +1,39 @@
1From 72fe91edf03a0270ecd9df795f1a1eaded3b7d15 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/43] 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>
21---
22 bfd/elflink.c | 1 -
23 1 file changed, 1 deletion(-)
24
25diff --git a/bfd/elflink.c b/bfd/elflink.c
26index e50c0e4b38..09d43e3ca5 100644
27--- a/bfd/elflink.c
28+++ b/bfd/elflink.c
29@@ -6187,7 +6187,6 @@ elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
30
31 inf = (struct elf_gc_sweep_symbol_info *) data;
32 (*inf->hide_symbol) (inf->info, h, TRUE);
33- h->def_regular = 0;
34 h->ref_regular = 0;
35 h->ref_regular_nonweak = 0;
36 }
37--
382.17.1
39
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0007-Fix-bug-in-TLSTPREL-Relocation.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0007-Fix-bug-in-TLSTPREL-Relocation.patch
new file mode 100644
index 00000000..a5cc8114
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0007-Fix-bug-in-TLSTPREL-Relocation.patch
@@ -0,0 +1,33 @@
1From 2ea146401a9aed9e3b6cc07e1b6c0f81e5a0527c Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 15 Jun 2015 16:50:30 +0530
4Subject: [PATCH 07/43] Fix bug in TLSTPREL Relocation
5
6Fixed the problem related to the fixup/relocations TLSTPREL.
7When the fixup is applied the addend is not added at the correct offset
8of the instruction. The offset is hard coded considering its big endian
9and it fails for Little endian. This patch allows support for both
10big & little-endian compilers
11---
12 bfd/elf32-microblaze.c | 4 ++--
13 1 file changed, 2 insertions(+), 2 deletions(-)
14
15diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
16index 1c69c269c7..d19a6dca84 100644
17--- a/bfd/elf32-microblaze.c
18+++ b/bfd/elf32-microblaze.c
19@@ -1451,9 +1451,9 @@ microblaze_elf_relocate_section (bfd *output_bfd,
20 relocation += addend;
21 relocation -= dtprel_base(info);
22 bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
23- contents + offset + 2);
24+ contents + offset + endian);
25 bfd_put_16 (input_bfd, relocation & 0xffff,
26- contents + offset + 2 + INST_WORD_SIZE);
27+ contents + offset + endian + INST_WORD_SIZE);
28 break;
29 case (int) R_MICROBLAZE_TEXTREL_64:
30 case (int) R_MICROBLAZE_TEXTREL_32_LO:
31--
322.17.1
33
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0008-Added-Address-extension-instructions.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0008-Added-Address-extension-instructions.patch
new file mode 100644
index 00000000..933e51e1
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0008-Added-Address-extension-instructions.patch
@@ -0,0 +1,98 @@
1From a4b50cb6f4b8d2f4e7d3b28bbc2f8110277e441d Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 18 Jan 2016 12:28:21 +0530
4Subject: [PATCH 08/43] Added Address extension instructions
5
6This patch adds the support of new instructions which are required
7for supporting Address extension feature.
8
9Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
10
11ChangeLog:
12 2016-01-18 Nagaraju Mekala <nmekala@xilix.com>
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---
19 opcodes/microblaze-opc.h | 11 +++++++++++
20 opcodes/microblaze-opcm.h | 10 +++++-----
21 2 files changed, 16 insertions(+), 5 deletions(-)
22
23diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
24index 865151f95b..330f1040e7 100644
25--- a/opcodes/microblaze-opc.h
26+++ b/opcodes/microblaze-opc.h
27@@ -178,8 +178,11 @@ struct op_code_struct
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 },
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 },
30 {"wdc.ext.flush", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000476, OPCODE_MASK_H35B, wdcextflush, special_inst },
31+ {"wdc.clear.ea", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900000E6, OPCODE_MASK_H34B, wdcclearea, special_inst },
32 {"mts", INST_TYPE_SPECIAL_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MTS, 0x9400C000, OPCODE_MASK_H13S, mts, special_inst },
33+ {"mtse", INST_TYPE_SPECIAL_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MTS, 0x9500C000, OPCODE_MASK_H13S, mtse,special_inst },
34 {"mfs", INST_TYPE_RD_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MFS, 0x94008000, OPCODE_MASK_H23S, mfs, special_inst },
35+ {"mfse", INST_TYPE_RD_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_MFS, 0x94088000, OPCODE_MASK_H23S, mfse, special_inst },
36 {"br", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98000000, OPCODE_MASK_H124, br, branch_inst },
37 {"brd", INST_TYPE_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98100000, OPCODE_MASK_H124, brd, branch_inst },
38 {"brld", INST_TYPE_RD_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98140000, OPCODE_MASK_H24, brld, branch_inst },
39@@ -229,18 +232,24 @@ struct op_code_struct
40 {"bgeid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBEA00000, OPCODE_MASK_H1, bgeid, branch_inst },
41 {"lbu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000000, OPCODE_MASK_H4, lbu, memory_load_inst },
42 {"lbur", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000200, OPCODE_MASK_H4, lbur, memory_load_inst },
43+ {"lbuea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000080, OPCODE_MASK_H4, lbuea, memory_load_inst },
44 {"lhu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC4000000, OPCODE_MASK_H4, lhu, memory_load_inst },
45 {"lhur", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC4000200, OPCODE_MASK_H4, lhur, memory_load_inst },
46+ {"lhuea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC4000080, OPCODE_MASK_H4, lhuea, memory_load_inst },
47 {"lw", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000000, OPCODE_MASK_H4, lw, memory_load_inst },
48 {"lwr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000200, OPCODE_MASK_H4, lwr, memory_load_inst },
49 {"lwx", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000400, OPCODE_MASK_H4, lwx, memory_load_inst },
50+ {"lwea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000080, OPCODE_MASK_H4, lwea, memory_load_inst },
51 {"sb", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD0000000, OPCODE_MASK_H4, sb, memory_store_inst },
52 {"sbr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD0000200, OPCODE_MASK_H4, sbr, memory_store_inst },
53+ {"sbea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD0000080, OPCODE_MASK_H4, sbea, memory_store_inst },
54 {"sh", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD4000000, OPCODE_MASK_H4, sh, memory_store_inst },
55 {"shr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD4000200, OPCODE_MASK_H4, shr, memory_store_inst },
56+ {"shea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD4000080, OPCODE_MASK_H4, shea, memory_store_inst },
57 {"sw", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000000, OPCODE_MASK_H4, sw, memory_store_inst },
58 {"swr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000200, OPCODE_MASK_H4, swr, memory_store_inst },
59 {"swx", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000400, OPCODE_MASK_H4, swx, memory_store_inst },
60+ {"swea", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000080, OPCODE_MASK_H4, swea, memory_store_inst },
61 {"lbui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE0000000, OPCODE_MASK_H, lbui, memory_load_inst },
62 {"lhui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE4000000, OPCODE_MASK_H, lhui, memory_load_inst },
63 {"lwi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, lwi, memory_load_inst },
64@@ -405,6 +414,8 @@ struct op_code_struct
65 {"clz", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900000E0, OPCODE_MASK_H34, clz, special_inst },
66 {"mbar", INST_TYPE_IMM5, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8020004, OPCODE_MASK_HN, mbar, special_inst },
67 {"sleep", INST_TYPE_NONE, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBA020004, OPCODE_MASK_HN, invalid_inst, special_inst }, /* translates to mbar 16. */
68+ {"hibernate", INST_TYPE_NONE, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB9020004, OPCODE_MASK_HN, invalid_inst, special_inst }, /* translates to mbar 8. */
69+ {"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. */
70 {"swapb", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E0, OPCODE_MASK_H4, swapb, arithmetic_inst },
71 {"swaph", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E2, OPCODE_MASK_H4, swaph, arithmetic_inst },
72 {"", 0, 0, 0, 0, 0, 0, 0, 0},
73diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
74index 42f3dd3be5..1c39dbf50b 100644
75--- a/opcodes/microblaze-opcm.h
76+++ b/opcodes/microblaze-opcm.h
77@@ -33,13 +33,13 @@ enum microblaze_instr
78 /* 'or/and/xor' are C++ keywords. */
79 microblaze_or, microblaze_and, microblaze_xor,
80 andn, pcmpbf, pcmpbc, pcmpeq, pcmpne, sra, src, srl, sext8, sext16,
81- wic, wdc, wdcclear, wdcextclear, wdcflush, wdcextflush, mts, mfs, mbar, br,
82- brd, brld, bra, brad, brald, microblaze_brk, beq, beqd, bne, bned, blt,
83- bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni,
84+ wic, wdc, wdcclear, wdcextclear, wdcflush, wdcextflush, wdcclearea, mts, mtse,
85+ mfs, mfse, mbar, br, brd, brld, bra, brad, brald, microblaze_brk, beq, beqd,
86+ bne, bned, blt, bltd, ble, bled, bgt, bgtd, bge, bged, ori, andi, xori, andni,
87 imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid,
88 brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti,
89- bgtid, bgei, bgeid, lbu, lbur, lhu, lhur, lw, lwr, lwx, sb, sbr, sh,
90- shr, sw, swr, swx, lbui, lhui, lwi,
91+ bgtid, bgei, bgeid, lbu, lbuea, lbur, lhu, lhuea, lhur, lw, lwea, lwr, lwx,
92+ sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi,
93 sbi, shi, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv,
94 fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, flt,
95 fint, fsqrt,
96--
972.17.1
98
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0009-fixing-the-MAX_OPCODES-to-correct-value.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0009-fixing-the-MAX_OPCODES-to-correct-value.patch
new file mode 100644
index 00000000..8b51a7a7
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0009-fixing-the-MAX_OPCODES-to-correct-value.patch
@@ -0,0 +1,25 @@
1From 9c7c893866ab6b63942b86be6134c34b96272306 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/43] fixing the MAX_OPCODES to correct value
5
6---
7 opcodes/microblaze-opc.h | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-)
9
10diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
11index 330f1040e7..2a6b841232 100644
12--- a/opcodes/microblaze-opc.h
13+++ b/opcodes/microblaze-opc.h
14@@ -102,7 +102,7 @@
15 #define DELAY_SLOT 1
16 #define NO_DELAY_SLOT 0
17
18-#define MAX_OPCODES 291
19+#define MAX_OPCODES 299
20
21 struct op_code_struct
22 {
23--
242.17.1
25
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0010-Add-new-bit-field-instructions.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0010-Add-new-bit-field-instructions.patch
new file mode 100644
index 00000000..11d45a23
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0010-Add-new-bit-field-instructions.patch
@@ -0,0 +1,139 @@
1From 55acba095458b872b500e978af946733a9f33021 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 18 Jul 2016 12:24:28 +0530
4Subject: [PATCH 10/43] Add new bit-field instructions
5
6This patches adds new bsefi and bsifi instructions.
7BSEFI- The instruction shall extract a bit field from a
8register and place it right-adjusted in the destination register.
9The other bits in the destination register shall be set to zero
10BSIFI- The instruction shall insert a right-adjusted bit field
11from a register at another position in the destination register.
12The rest of the bits in the destination register shall be unchanged
13
14Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
15---
16 opcodes/microblaze-dis.c | 16 +++++++++
17 opcodes/microblaze-opc.h | 12 ++++++-
18 opcodes/microblaze-opcm.h | 6 +++-
19 4 files changed, 102 insertions(+), 3 deletions(-)
20
21diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
22index f691740dfd..f8aaf27873 100644
23--- a/opcodes/microblaze-dis.c
24+++ b/opcodes/microblaze-dis.c
25@@ -73,6 +73,18 @@ get_field_imm5_mbar (long instr)
26 return(strdup(tmpstr));
27 }
28
29+static char *
30+get_field_imm5width (long instr)
31+{
32+ char tmpstr[25];
33+
34+ if (instr & 0x00004000)
35+ sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW))); /* bsefi */
36+ else
37+ sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW) - ((instr & IMM5_MASK) >> IMM_LOW) + 1)); /* bsifi */
38+ return (strdup (tmpstr));
39+}
40+
41 static char *
42 get_field_rfsl (long instr)
43 {
44@@ -396,6 +408,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
45 /* For mbar 16 or sleep insn. */
46 case INST_TYPE_NONE:
47 break;
48+ /* For bit field insns. */
49+ case INST_TYPE_RD_R1_IMM5_IMM5:
50+ print_func (stream, "\t%s, %s, %s, %s", get_field_rd (inst),get_field_r1(inst),get_field_imm5width (inst), get_field_imm5 (inst));
51+ break;
52 /* For tuqula instruction */
53 case INST_TYPE_RD:
54 print_func (stream, "\t%s", get_field_rd (inst));
55diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
56index 2a6b841232..ce8ac351b5 100644
57--- a/opcodes/microblaze-opc.h
58+++ b/opcodes/microblaze-opc.h
59@@ -59,6 +59,9 @@
60 /* For mbar. */
61 #define INST_TYPE_IMM5 20
62
63+/* For bsefi and bsifi */
64+#define INST_TYPE_RD_R1_IMM5_IMM5 21
65+
66 #define INST_TYPE_NONE 25
67
68
69@@ -89,7 +92,9 @@
70 #define OPCODE_MASK_H124 0xFFFF07FF /* High 16, and low 11 bits. */
71 #define OPCODE_MASK_H1234 0xFFFFFFFF /* All 32 bits. */
72 #define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22. */
73+#define OPCODE_MASK_H3B 0xFC00C600 /* High 6 bits and bits 16, 17, 21, 22. */
74 #define OPCODE_MASK_H32 0xFC00FC00 /* High 6 bits and bit 16-21. */
75+#define OPCODE_MASK_H32B 0xFC00C000 /* High 6 bits and bit 16, 17. */
76 #define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits. */
77 #define OPCODE_MASK_H35B 0xFC0004FF /* High 6 bits and low 9 bits. */
78 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
79@@ -102,7 +107,7 @@
80 #define DELAY_SLOT 1
81 #define NO_DELAY_SLOT 0
82
83-#define MAX_OPCODES 299
84+#define MAX_OPCODES 301
85
86 struct op_code_struct
87 {
88@@ -159,6 +164,8 @@ struct op_code_struct
89 {"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3, bslli, barrel_shift_inst },
90 {"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3, bsrai, barrel_shift_inst },
91 {"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3, bsrli, barrel_shift_inst },
92+ {"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 },
93+ {"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 },
94 {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst },
95 {"and", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000000, OPCODE_MASK_H4, microblaze_and, logical_inst },
96 {"xor", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000000, OPCODE_MASK_H4, microblaze_xor, logical_inst },
97@@ -438,5 +445,8 @@ char pvr_register_prefix[] = "rpvr";
98 #define MIN_IMM5 ((int) 0x00000000)
99 #define MAX_IMM5 ((int) 0x0000001f)
100
101+#define MIN_IMM_WIDTH ((int) 0x00000001)
102+#define MAX_IMM_WIDTH ((int) 0x00000020)
103+
104 #endif /* MICROBLAZE_OPC */
105
106diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
107index 1c39dbf50b..28662694cd 100644
108--- a/opcodes/microblaze-opcm.h
109+++ b/opcodes/microblaze-opcm.h
110@@ -29,7 +29,7 @@ enum microblaze_instr
111 addi, rsubi, addic, rsubic, addik, rsubik, addikc, rsubikc, mul,
112 mulh, mulhu, mulhsu,swapb,swaph,
113 idiv, idivu, bsll, bsra, bsrl, get, put, nget, nput, cget, cput,
114- ncget, ncput, muli, bslli, bsrai, bsrli, mului,
115+ ncget, ncput, muli, bslli, bsrai, bsrli, bsefi, bsifi, mului,
116 /* 'or/and/xor' are C++ keywords. */
117 microblaze_or, microblaze_and, microblaze_xor,
118 andn, pcmpbf, pcmpbc, pcmpeq, pcmpne, sra, src, srl, sext8, sext16,
119@@ -129,6 +129,7 @@ enum microblaze_instr_type
120 #define RB_LOW 11 /* Low bit for RB. */
121 #define IMM_LOW 0 /* Low bit for immediate. */
122 #define IMM_MBAR 21 /* low bit for mbar instruction. */
123+#define IMM_WIDTH_LOW 6 /* Low bit for immediate width */
124
125 #define RD_MASK 0x03E00000
126 #define RA_MASK 0x001F0000
127@@ -141,6 +142,9 @@ enum microblaze_instr_type
128 /* Imm mask for mbar. */
129 #define IMM5_MBAR_MASK 0x03E00000
130
131+/* Imm mask for extract/insert width. */
132+#define IMM5_WIDTH_MASK 0x000007C0
133+
134 /* FSL imm mask for get, put instructions. */
135 #define RFSL_MASK 0x000000F
136
137--
1382.17.1
139
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0011-fixing-the-imm-bug.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0011-fixing-the-imm-bug.patch
new file mode 100644
index 00000000..b6f2920a
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0011-fixing-the-imm-bug.patch
@@ -0,0 +1,27 @@
1From f42a99be023e3f933c0a228ac8e08d59c59ec8d7 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 10 Jul 2017 16:07:28 +0530
4Subject: [PATCH 11/43] fixing the imm bug. with relax option imm -1 is also
5 getting removed this is corrected now.
6
7---
8 bfd/elf32-microblaze.c | 3 +--
9 1 file changed, 1 insertion(+), 2 deletions(-)
10
11diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
12index d19a6dca84..d001437b3f 100644
13--- a/bfd/elf32-microblaze.c
14+++ b/bfd/elf32-microblaze.c
15@@ -1869,8 +1869,7 @@ microblaze_elf_relax_section (bfd *abfd,
16 else
17 symval += irel->r_addend;
18
19- if ((symval & 0xffff8000) == 0
20- || (symval & 0xffff8000) == 0xffff8000)
21+ if ((symval & 0xffff8000) == 0)
22 {
23 /* We can delete this instruction. */
24 sec->relax[sec->relax_count].addr = irel->r_offset;
25--
262.17.1
27
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0015-intial-commit-of-MB-64-bit.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0015-intial-commit-of-MB-64-bit.patch
new file mode 100644
index 00000000..96cab28a
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0015-intial-commit-of-MB-64-bit.patch
@@ -0,0 +1,4186 @@
1From b42fae987795bb210476dcaa5e086f42602208f8 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/43] intial commit of MB 64-bit
5
6---
7 bfd/Makefile.am | 2 +
8 bfd/Makefile.in | 3 +
9 bfd/config.bfd | 4 +
10 bfd/configure | 2 +
11 bfd/configure.ac | 2 +
12 bfd/cpu-microblaze.c | 52 +-
13 bfd/elf64-microblaze.c | 3584 ++++++++++++++++++++++++++++
14 bfd/targets.c | 6 +
15 include/elf/common.h | 1 +
16 opcodes/microblaze-dis.c | 39 +-
17 opcodes/microblaze-opc.h | 162 +-
18 opcodes/microblaze-opcm.h | 20 +-
19 19 files changed, 4181 insertions(+), 41 deletions(-)
20 create mode 100644 bfd/elf64-microblaze.c
21
22diff --git a/bfd/Makefile.am b/bfd/Makefile.am
23index a9191555ad..c5fd250812 100644
24--- a/bfd/Makefile.am
25+++ b/bfd/Makefile.am
26@@ -570,6 +570,7 @@ BFD64_BACKENDS = \
27 elf64-riscv.lo \
28 elfxx-riscv.lo \
29 elf64-s390.lo \
30+ elf64-microblaze.lo \
31 elf64-sparc.lo \
32 elf64-tilegx.lo \
33 elf64-x86-64.lo \
34@@ -603,6 +604,7 @@ BFD64_BACKENDS_CFILES = \
35 elf64-nfp.c \
36 elf64-ppc.c \
37 elf64-s390.c \
38+ elf64-microblaze.c \
39 elf64-sparc.c \
40 elf64-tilegx.c \
41 elf64-x86-64.c \
42diff --git a/bfd/Makefile.in b/bfd/Makefile.in
43index 896df52042..fd457cba1e 100644
44--- a/bfd/Makefile.in
45+++ b/bfd/Makefile.in
46@@ -995,6 +995,7 @@ BFD64_BACKENDS = \
47 elf64-riscv.lo \
48 elfxx-riscv.lo \
49 elf64-s390.lo \
50+ elf64-microblaze.lo \
51 elf64-sparc.lo \
52 elf64-tilegx.lo \
53 elf64-x86-64.lo \
54@@ -1028,6 +1029,7 @@ BFD64_BACKENDS_CFILES = \
55 elf64-nfp.c \
56 elf64-ppc.c \
57 elf64-s390.c \
58+ elf64-microblaze.c \
59 elf64-sparc.c \
60 elf64-tilegx.c \
61 elf64-x86-64.c \
62@@ -1494,6 +1496,7 @@ distclean-compile:
63 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-ppc.Plo@am__quote@
64 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-riscv.Plo@am__quote@
65 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-s390.Plo@am__quote@
66+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-microblaze.Plo@am__quote@
67 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-sparc.Plo@am__quote@
68 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-tilegx.Plo@am__quote@
69 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-x86-64.Plo@am__quote@
70diff --git a/bfd/config.bfd b/bfd/config.bfd
71index f13812b7c7..a98c220db5 100644
72--- a/bfd/config.bfd
73+++ b/bfd/config.bfd
74@@ -850,11 +850,15 @@ case "${targ}" in
75 microblazeel*-*)
76 targ_defvec=microblaze_elf32_le_vec
77 targ_selvecs=microblaze_elf32_vec
78+ targ64_selvecs=microblaze_elf64_vec
79+ targ64_selvecs=microblaze_elf64_le_vec
80 ;;
81
82 microblaze*-*)
83 targ_defvec=microblaze_elf32_vec
84 targ_selvecs=microblaze_elf32_le_vec
85+ targ64_selvecs=microblaze_elf64_vec
86+ targ64_selvecs=microblaze_elf64_le_vec
87 ;;
88
89 #ifdef BFD64
90diff --git a/bfd/configure b/bfd/configure
91index 8d6c94aef2..3defb1f784 100755
92--- a/bfd/configure
93+++ b/bfd/configure
94@@ -14847,6 +14847,8 @@ do
95 rx_elf32_linux_le_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;;
96 s390_elf32_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
97 s390_elf64_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
98+ microblaze_elf64_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
99+ microblaze_elf64_le_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
100 score_elf32_be_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
101 score_elf32_le_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
102 sh_coff_vec) tb="$tb coff-sh.lo $coff" ;;
103diff --git a/bfd/configure.ac b/bfd/configure.ac
104index 5f02c41520..d3010b47dc 100644
105--- a/bfd/configure.ac
106+++ b/bfd/configure.ac
107@@ -615,6 +615,8 @@ do
108 rx_elf32_linux_le_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;;
109 s390_elf32_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
110 s390_elf64_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
111+ microblaze_elf64_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
112+ microblaze_elf64_le_vec) tb="$tb elf64-microblaze.lo elf64.lo $elf"; target_size=64 ;;
113 score_elf32_be_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
114 score_elf32_le_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true; target_size=64 ;;
115 sh_coff_vec) tb="$tb coff-sh.lo $coff" ;;
116diff --git a/bfd/cpu-microblaze.c b/bfd/cpu-microblaze.c
117index 9bc2eb3de9..c91ba46f75 100644
118--- a/bfd/cpu-microblaze.c
119+++ b/bfd/cpu-microblaze.c
120@@ -23,7 +23,24 @@
121 #include "bfd.h"
122 #include "libbfd.h"
123
124-const bfd_arch_info_type bfd_microblaze_arch =
125+const bfd_arch_info_type bfd_microblaze_arch[] =
126+{
127+#if BFD_DEFAULT_TARGET_SIZE == 64
128+{
129+ 64, /* 32 bits in a word. */
130+ 64, /* 32 bits in an address. */
131+ 8, /* 8 bits in a byte. */
132+ bfd_arch_microblaze, /* Architecture. */
133+ 0, /* Machine number - 0 for now. */
134+ "microblaze", /* Architecture name. */
135+ "MicroBlaze", /* Printable name. */
136+ 3, /* Section align power. */
137+ FALSE, /* Is this the default architecture ? */
138+ bfd_default_compatible, /* Architecture comparison function. */
139+ bfd_default_scan, /* String to architecture conversion. */
140+ bfd_arch_default_fill, /* Default fill. */
141+ &bfd_microblaze_arch[1] /* Next in list. */
142+},
143 {
144 32, /* 32 bits in a word. */
145 32, /* 32 bits in an address. */
146@@ -38,4 +55,37 @@ const bfd_arch_info_type bfd_microblaze_arch =
147 bfd_default_scan, /* String to architecture conversion. */
148 bfd_arch_default_fill, /* Default fill. */
149 NULL /* Next in list. */
150+}
151+#else
152+{
153+ 32, /* 32 bits in a word. */
154+ 32, /* 32 bits in an address. */
155+ 8, /* 8 bits in a byte. */
156+ bfd_arch_microblaze, /* Architecture. */
157+ 0, /* Machine number - 0 for now. */
158+ "microblaze", /* Architecture name. */
159+ "MicroBlaze", /* Printable name. */
160+ 3, /* Section align power. */
161+ TRUE, /* Is this the default architecture ? */
162+ bfd_default_compatible, /* Architecture comparison function. */
163+ bfd_default_scan, /* String to architecture conversion. */
164+ bfd_arch_default_fill, /* Default fill. */
165+ &bfd_microblaze_arch[1] /* Next in list. */
166+},
167+{
168+ 64, /* 32 bits in a word. */
169+ 64, /* 32 bits in an address. */
170+ 8, /* 8 bits in a byte. */
171+ bfd_arch_microblaze, /* Architecture. */
172+ 0, /* Machine number - 0 for now. */
173+ "microblaze", /* Architecture name. */
174+ "MicroBlaze", /* Printable name. */
175+ 3, /* Section align power. */
176+ FALSE, /* Is this the default architecture ? */
177+ bfd_default_compatible, /* Architecture comparison function. */
178+ bfd_default_scan, /* String to architecture conversion. */
179+ bfd_arch_default_fill, /* Default fill. */
180+ NULL /* Next in list. */
181+}
182+#endif
183 };
184diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
185new file mode 100644
186index 0000000000..0f43ae6ea8
187--- /dev/null
188+++ b/bfd/elf64-microblaze.c
189@@ -0,0 +1,3584 @@
190+/* Xilinx MicroBlaze-specific support for 32-bit ELF
191+
192+ Copyright (C) 2009-2016 Free Software Foundation, Inc.
193+
194+ This file is part of BFD, the Binary File Descriptor library.
195+
196+ This program is free software; you can redistribute it and/or modify
197+ it under the terms of the GNU General Public License as published by
198+ the Free Software Foundation; either version 3 of the License, or
199+ (at your option) any later version.
200+
201+ This program is distributed in the hope that it will be useful,
202+ but WITHOUT ANY WARRANTY; without even the implied warranty of
203+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
204+ GNU General Public License for more details.
205+
206+ You should have received a copy of the GNU General Public License
207+ along with this program; if not, write to the
208+ Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
209+ Boston, MA 02110-1301, USA. */
210+
211+
212+int dbg1 = 0;
213+
214+#include "sysdep.h"
215+#include "bfd.h"
216+#include "bfdlink.h"
217+#include "libbfd.h"
218+#include "elf-bfd.h"
219+#include "elf/microblaze.h"
220+#include <assert.h>
221+
222+#define USE_RELA /* Only USE_REL is actually significant, but this is
223+ here are a reminder... */
224+#define INST_WORD_SIZE 4
225+
226+static int ro_small_data_pointer = 0;
227+static int rw_small_data_pointer = 0;
228+
229+static reloc_howto_type * microblaze_elf_howto_table [(int) R_MICROBLAZE_max];
230+
231+static reloc_howto_type microblaze_elf_howto_raw[] =
232+{
233+ /* This reloc does nothing. */
234+ HOWTO (R_MICROBLAZE_NONE, /* Type. */
235+ 0, /* Rightshift. */
236+ 3, /* Size (0 = byte, 1 = short, 2 = long). */
237+ 0, /* Bitsize. */
238+ FALSE, /* PC_relative. */
239+ 0, /* Bitpos. */
240+ complain_overflow_dont, /* Complain on overflow. */
241+ NULL, /* Special Function. */
242+ "R_MICROBLAZE_NONE", /* Name. */
243+ FALSE, /* Partial Inplace. */
244+ 0, /* Source Mask. */
245+ 0, /* Dest Mask. */
246+ FALSE), /* PC relative offset? */
247+
248+ /* A standard 32 bit relocation. */
249+ HOWTO (R_MICROBLAZE_32, /* Type. */
250+ 0, /* Rightshift. */
251+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
252+ 32, /* Bitsize. */
253+ FALSE, /* PC_relative. */
254+ 0, /* Bitpos. */
255+ complain_overflow_bitfield, /* Complain on overflow. */
256+ bfd_elf_generic_reloc,/* Special Function. */
257+ "R_MICROBLAZE_32", /* Name. */
258+ FALSE, /* Partial Inplace. */
259+ 0, /* Source Mask. */
260+ 0xffffffff, /* Dest Mask. */
261+ FALSE), /* PC relative offset? */
262+
263+ /* A standard PCREL 32 bit relocation. */
264+ HOWTO (R_MICROBLAZE_32_PCREL,/* Type. */
265+ 0, /* Rightshift. */
266+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
267+ 32, /* Bitsize. */
268+ TRUE, /* PC_relative. */
269+ 0, /* Bitpos. */
270+ complain_overflow_bitfield, /* Complain on overflow. */
271+ bfd_elf_generic_reloc,/* Special Function. */
272+ "R_MICROBLAZE_32_PCREL", /* Name. */
273+ TRUE, /* Partial Inplace. */
274+ 0, /* Source Mask. */
275+ 0xffffffff, /* Dest Mask. */
276+ TRUE), /* PC relative offset? */
277+
278+ /* A 64 bit PCREL relocation. Table-entry not really used. */
279+ HOWTO (R_MICROBLAZE_64_PCREL,/* Type. */
280+ 0, /* Rightshift. */
281+ 4, /* Size (0 = byte, 1 = short, 2 = long). */
282+ 64, /* Bitsize. */
283+ TRUE, /* PC_relative. */
284+ 0, /* Bitpos. */
285+ complain_overflow_dont, /* Complain on overflow. */
286+ bfd_elf_generic_reloc,/* Special Function. */
287+ "R_MICROBLAZE_64_PCREL", /* Name. */
288+ FALSE, /* Partial Inplace. */
289+ 0, /* Source Mask. */
290+ 0x0000ffff, /* Dest Mask. */
291+ TRUE), /* PC relative offset? */
292+
293+ /* The low half of a PCREL 32 bit relocation. */
294+ HOWTO (R_MICROBLAZE_32_PCREL_LO, /* Type. */
295+ 0, /* Rightshift. */
296+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
297+ 16, /* Bitsize. */
298+ TRUE, /* PC_relative. */
299+ 0, /* Bitpos. */
300+ complain_overflow_signed, /* Complain on overflow. */
301+ bfd_elf_generic_reloc, /* Special Function. */
302+ "R_MICROBLAZE_32_PCREL_LO", /* Name. */
303+ FALSE, /* Partial Inplace. */
304+ 0, /* Source Mask. */
305+ 0x0000ffff, /* Dest Mask. */
306+ TRUE), /* PC relative offset? */
307+
308+ /* A 64 bit relocation. Table entry not really used. */
309+ HOWTO (R_MICROBLAZE_64, /* Type. */
310+ 0, /* Rightshift. */
311+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
312+ 16, /* Bitsize. */
313+ FALSE, /* PC_relative. */
314+ 0, /* Bitpos. */
315+ complain_overflow_dont, /* Complain on overflow. */
316+ bfd_elf_generic_reloc,/* Special Function. */
317+ "R_MICROBLAZE_64", /* Name. */
318+ FALSE, /* Partial Inplace. */
319+ 0, /* Source Mask. */
320+ 0x0000ffff, /* Dest Mask. */
321+ FALSE), /* PC relative offset? */
322+
323+ /* The low half of a 32 bit relocation. */
324+ HOWTO (R_MICROBLAZE_32_LO, /* Type. */
325+ 0, /* Rightshift. */
326+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
327+ 16, /* Bitsize. */
328+ FALSE, /* PC_relative. */
329+ 0, /* Bitpos. */
330+ complain_overflow_signed, /* Complain on overflow. */
331+ bfd_elf_generic_reloc,/* Special Function. */
332+ "R_MICROBLAZE_32_LO", /* Name. */
333+ FALSE, /* Partial Inplace. */
334+ 0, /* Source Mask. */
335+ 0x0000ffff, /* Dest Mask. */
336+ FALSE), /* PC relative offset? */
337+
338+ /* Read-only small data section relocation. */
339+ HOWTO (R_MICROBLAZE_SRO32, /* Type. */
340+ 0, /* Rightshift. */
341+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
342+ 16, /* Bitsize. */
343+ FALSE, /* PC_relative. */
344+ 0, /* Bitpos. */
345+ complain_overflow_bitfield, /* Complain on overflow. */
346+ bfd_elf_generic_reloc,/* Special Function. */
347+ "R_MICROBLAZE_SRO32", /* Name. */
348+ FALSE, /* Partial Inplace. */
349+ 0, /* Source Mask. */
350+ 0x0000ffff, /* Dest Mask. */
351+ FALSE), /* PC relative offset? */
352+
353+ /* Read-write small data area relocation. */
354+ HOWTO (R_MICROBLAZE_SRW32, /* Type. */
355+ 0, /* Rightshift. */
356+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
357+ 16, /* Bitsize. */
358+ FALSE, /* PC_relative. */
359+ 0, /* Bitpos. */
360+ complain_overflow_bitfield, /* Complain on overflow. */
361+ bfd_elf_generic_reloc,/* Special Function. */
362+ "R_MICROBLAZE_SRW32", /* Name. */
363+ FALSE, /* Partial Inplace. */
364+ 0, /* Source Mask. */
365+ 0x0000ffff, /* Dest Mask. */
366+ FALSE), /* PC relative offset? */
367+
368+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
369+ 0, /* Rightshift. */
370+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
371+ 32, /* Bitsize. */
372+ TRUE, /* PC_relative. */
373+ 0, /* Bitpos. */
374+ complain_overflow_bitfield, /* Complain on overflow. */
375+ NULL, /* Special Function. */
376+ "R_MICROBLAZE_32_NONE",/* Name. */
377+ FALSE, /* Partial Inplace. */
378+ 0, /* Source Mask. */
379+ 0, /* Dest Mask. */
380+ FALSE), /* PC relative offset? */
381+
382+ /* This reloc does nothing. Used for relaxation. */
383+ HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
384+ 0, /* Rightshift. */
385+ 3, /* Size (0 = byte, 1 = short, 2 = long). */
386+ 0, /* Bitsize. */
387+ TRUE, /* PC_relative. */
388+ 0, /* Bitpos. */
389+ complain_overflow_dont, /* Complain on overflow. */
390+ NULL, /* Special Function. */
391+ "R_MICROBLAZE_64_NONE",/* Name. */
392+ FALSE, /* Partial Inplace. */
393+ 0, /* Source Mask. */
394+ 0, /* Dest Mask. */
395+ FALSE), /* PC relative offset? */
396+
397+ /* Symbol Op Symbol relocation. */
398+ HOWTO (R_MICROBLAZE_32_SYM_OP_SYM, /* Type. */
399+ 0, /* Rightshift. */
400+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
401+ 32, /* Bitsize. */
402+ FALSE, /* PC_relative. */
403+ 0, /* Bitpos. */
404+ complain_overflow_bitfield, /* Complain on overflow. */
405+ bfd_elf_generic_reloc,/* Special Function. */
406+ "R_MICROBLAZE_32_SYM_OP_SYM", /* Name. */
407+ FALSE, /* Partial Inplace. */
408+ 0, /* Source Mask. */
409+ 0xffffffff, /* Dest Mask. */
410+ FALSE), /* PC relative offset? */
411+
412+ /* GNU extension to record C++ vtable hierarchy. */
413+ HOWTO (R_MICROBLAZE_GNU_VTINHERIT, /* Type. */
414+ 0, /* Rightshift. */
415+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
416+ 0, /* Bitsize. */
417+ FALSE, /* PC_relative. */
418+ 0, /* Bitpos. */
419+ complain_overflow_dont,/* Complain on overflow. */
420+ NULL, /* Special Function. */
421+ "R_MICROBLAZE_GNU_VTINHERIT", /* Name. */
422+ FALSE, /* Partial Inplace. */
423+ 0, /* Source Mask. */
424+ 0, /* Dest Mask. */
425+ FALSE), /* PC relative offset? */
426+
427+ /* GNU extension to record C++ vtable member usage. */
428+ HOWTO (R_MICROBLAZE_GNU_VTENTRY, /* Type. */
429+ 0, /* Rightshift. */
430+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
431+ 0, /* Bitsize. */
432+ FALSE, /* PC_relative. */
433+ 0, /* Bitpos. */
434+ complain_overflow_dont,/* Complain on overflow. */
435+ _bfd_elf_rel_vtable_reloc_fn, /* Special Function. */
436+ "R_MICROBLAZE_GNU_VTENTRY", /* Name. */
437+ FALSE, /* Partial Inplace. */
438+ 0, /* Source Mask. */
439+ 0, /* Dest Mask. */
440+ FALSE), /* PC relative offset? */
441+
442+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
443+ HOWTO (R_MICROBLAZE_GOTPC_64, /* Type. */
444+ 0, /* Rightshift. */
445+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
446+ 16, /* Bitsize. */
447+ TRUE, /* PC_relative. */
448+ 0, /* Bitpos. */
449+ complain_overflow_dont, /* Complain on overflow. */
450+ bfd_elf_generic_reloc, /* Special Function. */
451+ "R_MICROBLAZE_GOTPC_64", /* Name. */
452+ FALSE, /* Partial Inplace. */
453+ 0, /* Source Mask. */
454+ 0x0000ffff, /* Dest Mask. */
455+ TRUE), /* PC relative offset? */
456+
457+ /* A 64 bit GOT relocation. Table-entry not really used. */
458+ HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
459+ 0, /* Rightshift. */
460+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
461+ 16, /* Bitsize. */
462+ FALSE, /* PC_relative. */
463+ 0, /* Bitpos. */
464+ complain_overflow_dont, /* Complain on overflow. */
465+ bfd_elf_generic_reloc,/* Special Function. */
466+ "R_MICROBLAZE_GOT_64",/* Name. */
467+ FALSE, /* Partial Inplace. */
468+ 0, /* Source Mask. */
469+ 0x0000ffff, /* Dest Mask. */
470+ FALSE), /* PC relative offset? */
471+
472+ /* A 64 bit PLT relocation. Table-entry not really used. */
473+ HOWTO (R_MICROBLAZE_PLT_64, /* Type. */
474+ 0, /* Rightshift. */
475+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
476+ 16, /* Bitsize. */
477+ TRUE, /* PC_relative. */
478+ 0, /* Bitpos. */
479+ complain_overflow_dont, /* Complain on overflow. */
480+ bfd_elf_generic_reloc,/* Special Function. */
481+ "R_MICROBLAZE_PLT_64",/* Name. */
482+ FALSE, /* Partial Inplace. */
483+ 0, /* Source Mask. */
484+ 0x0000ffff, /* Dest Mask. */
485+ TRUE), /* PC relative offset? */
486+
487+ /* Table-entry not really used. */
488+ HOWTO (R_MICROBLAZE_REL, /* Type. */
489+ 0, /* Rightshift. */
490+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
491+ 16, /* Bitsize. */
492+ TRUE, /* PC_relative. */
493+ 0, /* Bitpos. */
494+ complain_overflow_dont, /* Complain on overflow. */
495+ bfd_elf_generic_reloc,/* Special Function. */
496+ "R_MICROBLAZE_REL", /* Name. */
497+ FALSE, /* Partial Inplace. */
498+ 0, /* Source Mask. */
499+ 0x0000ffff, /* Dest Mask. */
500+ TRUE), /* PC relative offset? */
501+
502+ /* Table-entry not really used. */
503+ HOWTO (R_MICROBLAZE_JUMP_SLOT,/* Type. */
504+ 0, /* Rightshift. */
505+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
506+ 16, /* Bitsize. */
507+ TRUE, /* PC_relative. */
508+ 0, /* Bitpos. */
509+ complain_overflow_dont, /* Complain on overflow. */
510+ bfd_elf_generic_reloc,/* Special Function. */
511+ "R_MICROBLAZE_JUMP_SLOT", /* Name. */
512+ FALSE, /* Partial Inplace. */
513+ 0, /* Source Mask. */
514+ 0x0000ffff, /* Dest Mask. */
515+ TRUE), /* PC relative offset? */
516+
517+ /* Table-entry not really used. */
518+ HOWTO (R_MICROBLAZE_GLOB_DAT,/* Type. */
519+ 0, /* Rightshift. */
520+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
521+ 16, /* Bitsize. */
522+ TRUE, /* PC_relative. */
523+ 0, /* Bitpos. */
524+ complain_overflow_dont, /* Complain on overflow. */
525+ bfd_elf_generic_reloc,/* Special Function. */
526+ "R_MICROBLAZE_GLOB_DAT", /* Name. */
527+ FALSE, /* Partial Inplace. */
528+ 0, /* Source Mask. */
529+ 0x0000ffff, /* Dest Mask. */
530+ TRUE), /* PC relative offset? */
531+
532+ /* A 64 bit GOT relative relocation. Table-entry not really used. */
533+ HOWTO (R_MICROBLAZE_GOTOFF_64, /* Type. */
534+ 0, /* Rightshift. */
535+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
536+ 16, /* Bitsize. */
537+ FALSE, /* PC_relative. */
538+ 0, /* Bitpos. */
539+ complain_overflow_dont, /* Complain on overflow. */
540+ bfd_elf_generic_reloc,/* Special Function. */
541+ "R_MICROBLAZE_GOTOFF_64", /* Name. */
542+ FALSE, /* Partial Inplace. */
543+ 0, /* Source Mask. */
544+ 0x0000ffff, /* Dest Mask. */
545+ FALSE), /* PC relative offset? */
546+
547+ /* A 32 bit GOT relative relocation. Table-entry not really used. */
548+ HOWTO (R_MICROBLAZE_GOTOFF_32, /* Type. */
549+ 0, /* Rightshift. */
550+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
551+ 16, /* Bitsize. */
552+ FALSE, /* PC_relative. */
553+ 0, /* Bitpos. */
554+ complain_overflow_dont, /* Complain on overflow. */
555+ bfd_elf_generic_reloc, /* Special Function. */
556+ "R_MICROBLAZE_GOTOFF_32", /* Name. */
557+ FALSE, /* Partial Inplace. */
558+ 0, /* Source Mask. */
559+ 0x0000ffff, /* Dest Mask. */
560+ FALSE), /* PC relative offset? */
561+
562+ /* COPY relocation. Table-entry not really used. */
563+ HOWTO (R_MICROBLAZE_COPY, /* Type. */
564+ 0, /* Rightshift. */
565+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
566+ 16, /* Bitsize. */
567+ FALSE, /* PC_relative. */
568+ 0, /* Bitpos. */
569+ complain_overflow_dont, /* Complain on overflow. */
570+ bfd_elf_generic_reloc,/* Special Function. */
571+ "R_MICROBLAZE_COPY", /* Name. */
572+ FALSE, /* Partial Inplace. */
573+ 0, /* Source Mask. */
574+ 0x0000ffff, /* Dest Mask. */
575+ FALSE), /* PC relative offset? */
576+
577+ /* Marker relocs for TLS. */
578+ HOWTO (R_MICROBLAZE_TLS,
579+ 0, /* rightshift */
580+ 2, /* size (0 = byte, 1 = short, 2 = long) */
581+ 32, /* bitsize */
582+ FALSE, /* pc_relative */
583+ 0, /* bitpos */
584+ complain_overflow_dont, /* complain_on_overflow */
585+ bfd_elf_generic_reloc, /* special_function */
586+ "R_MICROBLAZE_TLS", /* name */
587+ FALSE, /* partial_inplace */
588+ 0, /* src_mask */
589+ 0x0000ffff, /* dst_mask */
590+ FALSE), /* pcrel_offset */
591+
592+ HOWTO (R_MICROBLAZE_TLSGD,
593+ 0, /* rightshift */
594+ 2, /* size (0 = byte, 1 = short, 2 = long) */
595+ 32, /* bitsize */
596+ FALSE, /* pc_relative */
597+ 0, /* bitpos */
598+ complain_overflow_dont, /* complain_on_overflow */
599+ bfd_elf_generic_reloc, /* special_function */
600+ "R_MICROBLAZE_TLSGD", /* name */
601+ FALSE, /* partial_inplace */
602+ 0, /* src_mask */
603+ 0x0000ffff, /* dst_mask */
604+ FALSE), /* pcrel_offset */
605+
606+ HOWTO (R_MICROBLAZE_TLSLD,
607+ 0, /* rightshift */
608+ 2, /* size (0 = byte, 1 = short, 2 = long) */
609+ 32, /* bitsize */
610+ FALSE, /* pc_relative */
611+ 0, /* bitpos */
612+ complain_overflow_dont, /* complain_on_overflow */
613+ bfd_elf_generic_reloc, /* special_function */
614+ "R_MICROBLAZE_TLSLD", /* name */
615+ FALSE, /* partial_inplace */
616+ 0, /* src_mask */
617+ 0x0000ffff, /* dst_mask */
618+ FALSE), /* pcrel_offset */
619+
620+ /* Computes the load module index of the load module that contains the
621+ definition of its TLS sym. */
622+ HOWTO (R_MICROBLAZE_TLSDTPMOD32,
623+ 0, /* rightshift */
624+ 2, /* size (0 = byte, 1 = short, 2 = long) */
625+ 32, /* bitsize */
626+ FALSE, /* pc_relative */
627+ 0, /* bitpos */
628+ complain_overflow_dont, /* complain_on_overflow */
629+ bfd_elf_generic_reloc, /* special_function */
630+ "R_MICROBLAZE_TLSDTPMOD32", /* name */
631+ FALSE, /* partial_inplace */
632+ 0, /* src_mask */
633+ 0x0000ffff, /* dst_mask */
634+ FALSE), /* pcrel_offset */
635+
636+ /* Computes a dtv-relative displacement, the difference between the value
637+ of sym+add and the base address of the thread-local storage block that
638+ contains the definition of sym, minus 0x8000. Used for initializing GOT */
639+ HOWTO (R_MICROBLAZE_TLSDTPREL32,
640+ 0, /* rightshift */
641+ 2, /* size (0 = byte, 1 = short, 2 = long) */
642+ 32, /* bitsize */
643+ FALSE, /* pc_relative */
644+ 0, /* bitpos */
645+ complain_overflow_dont, /* complain_on_overflow */
646+ bfd_elf_generic_reloc, /* special_function */
647+ "R_MICROBLAZE_TLSDTPREL32", /* name */
648+ FALSE, /* partial_inplace */
649+ 0, /* src_mask */
650+ 0x0000ffff, /* dst_mask */
651+ FALSE), /* pcrel_offset */
652+
653+ /* Computes a dtv-relative displacement, the difference between the value
654+ of sym+add and the base address of the thread-local storage block that
655+ contains the definition of sym, minus 0x8000. */
656+ HOWTO (R_MICROBLAZE_TLSDTPREL64,
657+ 0, /* rightshift */
658+ 2, /* size (0 = byte, 1 = short, 2 = long) */
659+ 32, /* bitsize */
660+ FALSE, /* pc_relative */
661+ 0, /* bitpos */
662+ complain_overflow_dont, /* complain_on_overflow */
663+ bfd_elf_generic_reloc, /* special_function */
664+ "R_MICROBLAZE_TLSDTPREL64", /* name */
665+ FALSE, /* partial_inplace */
666+ 0, /* src_mask */
667+ 0x0000ffff, /* dst_mask */
668+ FALSE), /* pcrel_offset */
669+
670+ /* Computes a tp-relative displacement, the difference between the value of
671+ sym+add and the value of the thread pointer (r13). */
672+ HOWTO (R_MICROBLAZE_TLSGOTTPREL32,
673+ 0, /* rightshift */
674+ 2, /* size (0 = byte, 1 = short, 2 = long) */
675+ 32, /* bitsize */
676+ FALSE, /* pc_relative */
677+ 0, /* bitpos */
678+ complain_overflow_dont, /* complain_on_overflow */
679+ bfd_elf_generic_reloc, /* special_function */
680+ "R_MICROBLAZE_TLSGOTTPREL32", /* name */
681+ FALSE, /* partial_inplace */
682+ 0, /* src_mask */
683+ 0x0000ffff, /* dst_mask */
684+ FALSE), /* pcrel_offset */
685+
686+ /* Computes a tp-relative displacement, the difference between the value of
687+ sym+add and the value of the thread pointer (r13). */
688+ HOWTO (R_MICROBLAZE_TLSTPREL32,
689+ 0, /* rightshift */
690+ 2, /* size (0 = byte, 1 = short, 2 = long) */
691+ 32, /* bitsize */
692+ FALSE, /* pc_relative */
693+ 0, /* bitpos */
694+ complain_overflow_dont, /* complain_on_overflow */
695+ bfd_elf_generic_reloc, /* special_function */
696+ "R_MICROBLAZE_TLSTPREL32", /* name */
697+ FALSE, /* partial_inplace */
698+ 0, /* src_mask */
699+ 0x0000ffff, /* dst_mask */
700+ FALSE), /* pcrel_offset */
701+
702+};
703+
704+#ifndef NUM_ELEM
705+#define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0])
706+#endif
707+
708+/* Initialize the microblaze_elf_howto_table, so that linear accesses can be done. */
709+
710+static void
711+microblaze_elf_howto_init (void)
712+{
713+ unsigned int i;
714+
715+ for (i = NUM_ELEM (microblaze_elf_howto_raw); i--;)
716+ {
717+ unsigned int type;
718+
719+ type = microblaze_elf_howto_raw[i].type;
720+
721+ BFD_ASSERT (type < NUM_ELEM (microblaze_elf_howto_table));
722+
723+ microblaze_elf_howto_table [type] = & microblaze_elf_howto_raw [i];
724+ }
725+}
726+
727+static reloc_howto_type *
728+microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
729+ bfd_reloc_code_real_type code)
730+{
731+ enum elf_microblaze_reloc_type microblaze_reloc = R_MICROBLAZE_NONE;
732+
733+ switch (code)
734+ {
735+ case BFD_RELOC_NONE:
736+ microblaze_reloc = R_MICROBLAZE_NONE;
737+ break;
738+ case BFD_RELOC_MICROBLAZE_32_NONE:
739+ microblaze_reloc = R_MICROBLAZE_32_NONE;
740+ break;
741+ case BFD_RELOC_MICROBLAZE_64_NONE:
742+ microblaze_reloc = R_MICROBLAZE_64_NONE;
743+ break;
744+ case BFD_RELOC_32:
745+ microblaze_reloc = R_MICROBLAZE_32;
746+ break;
747+ /* RVA is treated the same as 32 */
748+ case BFD_RELOC_RVA:
749+ microblaze_reloc = R_MICROBLAZE_32;
750+ break;
751+ case BFD_RELOC_32_PCREL:
752+ microblaze_reloc = R_MICROBLAZE_32_PCREL;
753+ break;
754+ case BFD_RELOC_64_PCREL:
755+ microblaze_reloc = R_MICROBLAZE_64_PCREL;
756+ break;
757+ case BFD_RELOC_MICROBLAZE_32_LO_PCREL:
758+ microblaze_reloc = R_MICROBLAZE_32_PCREL_LO;
759+ break;
760+ case BFD_RELOC_64:
761+ microblaze_reloc = R_MICROBLAZE_64;
762+ break;
763+ case BFD_RELOC_MICROBLAZE_32_LO:
764+ microblaze_reloc = R_MICROBLAZE_32_LO;
765+ break;
766+ case BFD_RELOC_MICROBLAZE_32_ROSDA:
767+ microblaze_reloc = R_MICROBLAZE_SRO32;
768+ break;
769+ case BFD_RELOC_MICROBLAZE_32_RWSDA:
770+ microblaze_reloc = R_MICROBLAZE_SRW32;
771+ break;
772+ case BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM:
773+ microblaze_reloc = R_MICROBLAZE_32_SYM_OP_SYM;
774+ break;
775+ case BFD_RELOC_VTABLE_INHERIT:
776+ microblaze_reloc = R_MICROBLAZE_GNU_VTINHERIT;
777+ break;
778+ case BFD_RELOC_VTABLE_ENTRY:
779+ microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
780+ break;
781+ case BFD_RELOC_MICROBLAZE_64_GOTPC:
782+ microblaze_reloc = R_MICROBLAZE_GOTPC_64;
783+ break;
784+ case BFD_RELOC_MICROBLAZE_64_GOT:
785+ microblaze_reloc = R_MICROBLAZE_GOT_64;
786+ break;
787+ case BFD_RELOC_MICROBLAZE_64_PLT:
788+ microblaze_reloc = R_MICROBLAZE_PLT_64;
789+ break;
790+ case BFD_RELOC_MICROBLAZE_64_GOTOFF:
791+ microblaze_reloc = R_MICROBLAZE_GOTOFF_64;
792+ break;
793+ case BFD_RELOC_MICROBLAZE_32_GOTOFF:
794+ microblaze_reloc = R_MICROBLAZE_GOTOFF_32;
795+ break;
796+ case BFD_RELOC_MICROBLAZE_64_TLSGD:
797+ microblaze_reloc = R_MICROBLAZE_TLSGD;
798+ break;
799+ case BFD_RELOC_MICROBLAZE_64_TLSLD:
800+ microblaze_reloc = R_MICROBLAZE_TLSLD;
801+ break;
802+ case BFD_RELOC_MICROBLAZE_32_TLSDTPREL:
803+ microblaze_reloc = R_MICROBLAZE_TLSDTPREL32;
804+ break;
805+ case BFD_RELOC_MICROBLAZE_64_TLSDTPREL:
806+ microblaze_reloc = R_MICROBLAZE_TLSDTPREL64;
807+ break;
808+ case BFD_RELOC_MICROBLAZE_32_TLSDTPMOD:
809+ microblaze_reloc = R_MICROBLAZE_TLSDTPMOD32;
810+ break;
811+ case BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL:
812+ microblaze_reloc = R_MICROBLAZE_TLSGOTTPREL32;
813+ break;
814+ case BFD_RELOC_MICROBLAZE_64_TLSTPREL:
815+ microblaze_reloc = R_MICROBLAZE_TLSTPREL32;
816+ break;
817+ case BFD_RELOC_MICROBLAZE_COPY:
818+ microblaze_reloc = R_MICROBLAZE_COPY;
819+ break;
820+ default:
821+ return (reloc_howto_type *) NULL;
822+ }
823+
824+ if (!microblaze_elf_howto_table [R_MICROBLAZE_32])
825+ /* Initialize howto table if needed. */
826+ microblaze_elf_howto_init ();
827+
828+ return microblaze_elf_howto_table [(int) microblaze_reloc];
829+};
830+
831+static reloc_howto_type *
832+microblaze_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
833+ const char *r_name)
834+{
835+ unsigned int i;
836+
837+ for (i = 0; i < NUM_ELEM (microblaze_elf_howto_raw); i++)
838+ if (microblaze_elf_howto_raw[i].name != NULL
839+ && strcasecmp (microblaze_elf_howto_raw[i].name, r_name) == 0)
840+ return &microblaze_elf_howto_raw[i];
841+
842+ return NULL;
843+}
844+
845+/* Set the howto pointer for a RCE ELF reloc. */
846+
847+static void
848+microblaze_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
849+ arelent * cache_ptr,
850+ Elf_Internal_Rela * dst)
851+{
852+ unsigned int r_type;
853+
854+ if (!microblaze_elf_howto_table [R_MICROBLAZE_32])
855+ /* Initialize howto table if needed. */
856+ microblaze_elf_howto_init ();
857+
858+ r_type = ELF64_R_TYPE (dst->r_info);
859+ if (r_type >= R_MICROBLAZE_max)
860+ {
861+ (*_bfd_error_handler) (_("%B: unrecognised MicroBlaze reloc number: %d"),
862+ abfd, r_type);
863+ bfd_set_error (bfd_error_bad_value);
864+ r_type = R_MICROBLAZE_NONE;
865+ }
866+
867+ cache_ptr->howto = microblaze_elf_howto_table [r_type];
868+}
869+
870+/* Microblaze ELF local labels start with 'L.' or '$L', not '.L'. */
871+
872+static bfd_boolean
873+microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
874+{
875+ if (name[0] == 'L' && name[1] == '.')
876+ return TRUE;
877+
878+ if (name[0] == '$' && name[1] == 'L')
879+ return TRUE;
880+
881+ /* With gcc, the labels go back to starting with '.', so we accept
882+ the generic ELF local label syntax as well. */
883+ return _bfd_elf_is_local_label_name (abfd, name);
884+}
885+
886+/* The microblaze linker (like many others) needs to keep track of
887+ the number of relocs that it decides to copy as dynamic relocs in
888+ check_relocs for each symbol. This is so that it can later discard
889+ them if they are found to be unnecessary. We store the information
890+ in a field extending the regular ELF linker hash table. */
891+
892+struct elf64_mb_dyn_relocs
893+{
894+ struct elf64_mb_dyn_relocs *next;
895+
896+ /* The input section of the reloc. */
897+ asection *sec;
898+
899+ /* Total number of relocs copied for the input section. */
900+ bfd_size_type count;
901+
902+ /* Number of pc-relative relocs copied for the input section. */
903+ bfd_size_type pc_count;
904+};
905+
906+/* ELF linker hash entry. */
907+
908+struct elf64_mb_link_hash_entry
909+{
910+ struct elf_link_hash_entry elf;
911+
912+ /* Track dynamic relocs copied for this symbol. */
913+ struct elf64_mb_dyn_relocs *dyn_relocs;
914+
915+ /* TLS Reference Types for the symbol; Updated by check_relocs */
916+#define TLS_GD 1 /* GD reloc. */
917+#define TLS_LD 2 /* LD reloc. */
918+#define TLS_TPREL 4 /* TPREL reloc, => IE. */
919+#define TLS_DTPREL 8 /* DTPREL reloc, => LD. */
920+#define TLS_TLS 16 /* Any TLS reloc. */
921+ unsigned char tls_mask;
922+
923+};
924+
925+#define IS_TLS_GD(x) (x == (TLS_TLS | TLS_GD))
926+#define IS_TLS_LD(x) (x == (TLS_TLS | TLS_LD))
927+#define IS_TLS_DTPREL(x) (x == (TLS_TLS | TLS_DTPREL))
928+#define IS_TLS_NONE(x) (x == 0)
929+
930+#define elf64_mb_hash_entry(ent) ((struct elf64_mb_link_hash_entry *)(ent))
931+
932+/* ELF linker hash table. */
933+
934+struct elf64_mb_link_hash_table
935+{
936+ struct elf_link_hash_table elf;
937+
938+ /* Short-cuts to get to dynamic linker sections. */
939+ asection *sgot;
940+ asection *sgotplt;
941+ asection *srelgot;
942+ asection *splt;
943+ asection *srelplt;
944+ asection *sdynbss;
945+ asection *srelbss;
946+
947+ /* Small local sym to section mapping cache. */
948+ struct sym_cache sym_sec;
949+
950+ /* TLS Local Dynamic GOT Entry */
951+ union {
952+ bfd_signed_vma refcount;
953+ bfd_vma offset;
954+ } tlsld_got;
955+};
956+
957+/* Nonzero if this section has TLS related relocations. */
958+#define has_tls_reloc sec_flg0
959+
960+/* Get the ELF linker hash table from a link_info structure. */
961+
962+#define elf64_mb_hash_table(p) \
963+ (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
964+ == MICROBLAZE_ELF_DATA ? ((struct elf64_mb_link_hash_table *) ((p)->hash)) : NULL)
965+
966+/* Create an entry in a microblaze ELF linker hash table. */
967+
968+static struct bfd_hash_entry *
969+link_hash_newfunc (struct bfd_hash_entry *entry,
970+ struct bfd_hash_table *table,
971+ const char *string)
972+{
973+ /* Allocate the structure if it has not already been allocated by a
974+ subclass. */
975+ if (entry == NULL)
976+ {
977+ entry = bfd_hash_allocate (table,
978+ sizeof (struct elf64_mb_link_hash_entry));
979+ if (entry == NULL)
980+ return entry;
981+ }
982+
983+ /* Call the allocation method of the superclass. */
984+ entry = _bfd_elf_link_hash_newfunc (entry, table, string);
985+ if (entry != NULL)
986+ {
987+ struct elf64_mb_link_hash_entry *eh;
988+
989+ eh = (struct elf64_mb_link_hash_entry *) entry;
990+ eh->dyn_relocs = NULL;
991+ eh->tls_mask = 0;
992+ }
993+
994+ return entry;
995+}
996+
997+/* Create a mb ELF linker hash table. */
998+
999+static struct bfd_link_hash_table *
1000+microblaze_elf_link_hash_table_create (bfd *abfd)
1001+{
1002+ struct elf64_mb_link_hash_table *ret;
1003+ bfd_size_type amt = sizeof (struct elf64_mb_link_hash_table);
1004+
1005+ ret = (struct elf64_mb_link_hash_table *) bfd_zmalloc (amt);
1006+ if (ret == NULL)
1007+ return NULL;
1008+
1009+ if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
1010+ sizeof (struct elf64_mb_link_hash_entry),
1011+ MICROBLAZE_ELF_DATA))
1012+ {
1013+ free (ret);
1014+ return NULL;
1015+ }
1016+
1017+ return &ret->elf.root;
1018+}
1019+
1020+/* Set the values of the small data pointers. */
1021+
1022+static void
1023+microblaze_elf_final_sdp (struct bfd_link_info *info)
1024+{
1025+ struct bfd_link_hash_entry *h;
1026+
1027+ h = bfd_link_hash_lookup (info->hash, RO_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE);
1028+ if (h != (struct bfd_link_hash_entry *) NULL
1029+ && h->type == bfd_link_hash_defined)
1030+ ro_small_data_pointer = (h->u.def.value
1031+ + h->u.def.section->output_section->vma
1032+ + h->u.def.section->output_offset);
1033+
1034+ h = bfd_link_hash_lookup (info->hash, RW_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE);
1035+ if (h != (struct bfd_link_hash_entry *) NULL
1036+ && h->type == bfd_link_hash_defined)
1037+ rw_small_data_pointer = (h->u.def.value
1038+ + h->u.def.section->output_section->vma
1039+ + h->u.def.section->output_offset);
1040+}
1041+
1042+static bfd_vma
1043+dtprel_base (struct bfd_link_info *info)
1044+{
1045+ /* If tls_sec is NULL, we should have signalled an error already. */
1046+ if (elf_hash_table (info)->tls_sec == NULL)
1047+ return 0;
1048+ return elf_hash_table (info)->tls_sec->vma;
1049+}
1050+
1051+/* The size of the thread control block. */
1052+#define TCB_SIZE 8
1053+
1054+/* Output a simple dynamic relocation into SRELOC. */
1055+
1056+static void
1057+microblaze_elf_output_dynamic_relocation (bfd *output_bfd,
1058+ asection *sreloc,
1059+ unsigned long reloc_index,
1060+ unsigned long indx,
1061+ int r_type,
1062+ bfd_vma offset,
1063+ bfd_vma addend)
1064+{
1065+
1066+ Elf_Internal_Rela rel;
1067+
1068+ rel.r_info = ELF64_R_INFO (indx, r_type);
1069+ rel.r_offset = offset;
1070+ rel.r_addend = addend;
1071+
1072+ bfd_elf64_swap_reloca_out (output_bfd, &rel,
1073+ (sreloc->contents + reloc_index * sizeof (Elf64_External_Rela)));
1074+}
1075+
1076+/* This code is taken from elf64-m32r.c
1077+ There is some attempt to make this function usable for many architectures,
1078+ both USE_REL and USE_RELA ['twould be nice if such a critter existed],
1079+ if only to serve as a learning tool.
1080+
1081+ The RELOCATE_SECTION function is called by the new ELF backend linker
1082+ to handle the relocations for a section.
1083+
1084+ The relocs are always passed as Rela structures; if the section
1085+ actually uses Rel structures, the r_addend field will always be
1086+ zero.
1087+
1088+ This function is responsible for adjust the section contents as
1089+ necessary, and (if using Rela relocs and generating a
1090+ relocatable output file) adjusting the reloc addend as
1091+ necessary.
1092+
1093+ This function does not have to worry about setting the reloc
1094+ address or the reloc symbol index.
1095+
1096+ LOCAL_SYMS is a pointer to the swapped in local symbols.
1097+
1098+ LOCAL_SECTIONS is an array giving the section in the input file
1099+ corresponding to the st_shndx field of each local symbol.
1100+
1101+ The global hash table entry for the global symbols can be found
1102+ via elf_sym_hashes (input_bfd).
1103+
1104+ When generating relocatable output, this function must handle
1105+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is
1106+ going to be the section symbol corresponding to the output
1107+ section, which means that the addend must be adjusted
1108+ accordingly. */
1109+
1110+static bfd_boolean
1111+microblaze_elf_relocate_section (bfd *output_bfd,
1112+ struct bfd_link_info *info,
1113+ bfd *input_bfd,
1114+ asection *input_section,
1115+ bfd_byte *contents,
1116+ Elf_Internal_Rela *relocs,
1117+ Elf_Internal_Sym *local_syms,
1118+ asection **local_sections)
1119+{
1120+ struct elf64_mb_link_hash_table *htab;
1121+ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1122+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
1123+ Elf_Internal_Rela *rel, *relend;
1124+ int endian = (bfd_little_endian (output_bfd)) ? 0 : 2;
1125+ /* Assume success. */
1126+ bfd_boolean ret = TRUE;
1127+ asection *sreloc;
1128+ bfd_vma *local_got_offsets;
1129+ unsigned int tls_type;
1130+
1131+ if (!microblaze_elf_howto_table[R_MICROBLAZE_max-1])
1132+ microblaze_elf_howto_init ();
1133+
1134+ htab = elf64_mb_hash_table (info);
1135+ if (htab == NULL)
1136+ return FALSE;
1137+
1138+ local_got_offsets = elf_local_got_offsets (input_bfd);
1139+
1140+ sreloc = elf_section_data (input_section)->sreloc;
1141+
1142+ rel = relocs;
1143+ relend = relocs + input_section->reloc_count;
1144+ for (; rel < relend; rel++)
1145+ {
1146+ int r_type;
1147+ reloc_howto_type *howto;
1148+ unsigned long r_symndx;
1149+ bfd_vma addend = rel->r_addend;
1150+ bfd_vma offset = rel->r_offset;
1151+ struct elf_link_hash_entry *h;
1152+ Elf_Internal_Sym *sym;
1153+ asection *sec;
1154+ const char *sym_name;
1155+ bfd_reloc_status_type r = bfd_reloc_ok;
1156+ const char *errmsg = NULL;
1157+ bfd_boolean unresolved_reloc = FALSE;
1158+
1159+ h = NULL;
1160+ r_type = ELF64_R_TYPE (rel->r_info);
1161+ tls_type = 0;
1162+
1163+ if (r_type < 0 || r_type >= (int) R_MICROBLAZE_max)
1164+ {
1165+ (*_bfd_error_handler) (_("%s: unknown relocation type %d"),
1166+ bfd_get_filename (input_bfd), (int) r_type);
1167+ bfd_set_error (bfd_error_bad_value);
1168+ ret = FALSE;
1169+ continue;
1170+ }
1171+
1172+ howto = microblaze_elf_howto_table[r_type];
1173+ r_symndx = ELF64_R_SYM (rel->r_info);
1174+
1175+ if (bfd_link_relocatable (info))
1176+ {
1177+ /* This is a relocatable link. We don't have to change
1178+ anything, unless the reloc is against a section symbol,
1179+ in which case we have to adjust according to where the
1180+ section symbol winds up in the output section. */
1181+ sec = NULL;
1182+ if (r_symndx >= symtab_hdr->sh_info)
1183+ /* External symbol. */
1184+ continue;
1185+
1186+ /* Local symbol. */
1187+ sym = local_syms + r_symndx;
1188+ sym_name = "<local symbol>";
1189+ /* STT_SECTION: symbol is associated with a section. */
1190+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
1191+ /* Symbol isn't associated with a section. Nothing to do. */
1192+ continue;
1193+
1194+ sec = local_sections[r_symndx];
1195+ addend += sec->output_offset + sym->st_value;
1196+#ifndef USE_REL
1197+ /* This can't be done for USE_REL because it doesn't mean anything
1198+ and elf_link_input_bfd asserts this stays zero. */
1199+ /* rel->r_addend = addend; */
1200+#endif
1201+
1202+#ifndef USE_REL
1203+ /* Addends are stored with relocs. We're done. */
1204+ continue;
1205+#else /* USE_REL */
1206+ /* If partial_inplace, we need to store any additional addend
1207+ back in the section. */
1208+ if (!howto->partial_inplace)
1209+ continue;
1210+ /* ??? Here is a nice place to call a special_function like handler. */
1211+ r = _bfd_relocate_contents (howto, input_bfd, addend,
1212+ contents + offset);
1213+#endif /* USE_REL */
1214+ }
1215+ else
1216+ {
1217+ bfd_vma relocation;
1218+
1219+ /* This is a final link. */
1220+ sym = NULL;
1221+ sec = NULL;
1222+ unresolved_reloc = FALSE;
1223+
1224+ if (r_symndx < symtab_hdr->sh_info)
1225+ {
1226+ /* Local symbol. */
1227+ sym = local_syms + r_symndx;
1228+ sec = local_sections[r_symndx];
1229+ if (sec == 0)
1230+ continue;
1231+ sym_name = "<local symbol>";
1232+ relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
1233+ /* r_addend may have changed if the reference section was
1234+ a merge section. */
1235+ addend = rel->r_addend;
1236+ }
1237+ else
1238+ {
1239+ /* External symbol. */
1240+ bfd_boolean warned ATTRIBUTE_UNUSED;
1241+ bfd_boolean ignored ATTRIBUTE_UNUSED;
1242+
1243+ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
1244+ r_symndx, symtab_hdr, sym_hashes,
1245+ h, sec, relocation,
1246+ unresolved_reloc, warned, ignored);
1247+ sym_name = h->root.root.string;
1248+ }
1249+
1250+ /* Sanity check the address. */
1251+ if (offset > bfd_get_section_limit (input_bfd, input_section))
1252+ {
1253+ r = bfd_reloc_outofrange;
1254+ goto check_reloc;
1255+ }
1256+
1257+ switch ((int) r_type)
1258+ {
1259+ case (int) R_MICROBLAZE_SRO32 :
1260+ {
1261+ const char *name;
1262+
1263+ /* Only relocate if the symbol is defined. */
1264+ if (sec)
1265+ {
1266+ name = bfd_get_section_name (sec->owner, sec);
1267+
1268+ if (strcmp (name, ".sdata2") == 0
1269+ || strcmp (name, ".sbss2") == 0)
1270+ {
1271+ if (ro_small_data_pointer == 0)
1272+ microblaze_elf_final_sdp (info);
1273+ if (ro_small_data_pointer == 0)
1274+ {
1275+ ret = FALSE;
1276+ r = bfd_reloc_undefined;
1277+ goto check_reloc;
1278+ }
1279+
1280+ /* At this point `relocation' contains the object's
1281+ address. */
1282+ relocation -= ro_small_data_pointer;
1283+ /* Now it contains the offset from _SDA2_BASE_. */
1284+ r = _bfd_final_link_relocate (howto, input_bfd,
1285+ input_section,
1286+ contents, offset,
1287+ relocation, addend);
1288+ }
1289+ else
1290+ {
1291+ (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
1292+ bfd_get_filename (input_bfd),
1293+ sym_name,
1294+ microblaze_elf_howto_table[(int) r_type]->name,
1295+ bfd_get_section_name (sec->owner, sec));
1296+ /*bfd_set_error (bfd_error_bad_value); ??? why? */
1297+ ret = FALSE;
1298+ continue;
1299+ }
1300+ }
1301+ }
1302+ break;
1303+
1304+ case (int) R_MICROBLAZE_SRW32 :
1305+ {
1306+ const char *name;
1307+
1308+ /* Only relocate if the symbol is defined. */
1309+ if (sec)
1310+ {
1311+ name = bfd_get_section_name (sec->owner, sec);
1312+
1313+ if (strcmp (name, ".sdata") == 0
1314+ || strcmp (name, ".sbss") == 0)
1315+ {
1316+ if (rw_small_data_pointer == 0)
1317+ microblaze_elf_final_sdp (info);
1318+ if (rw_small_data_pointer == 0)
1319+ {
1320+ ret = FALSE;
1321+ r = bfd_reloc_undefined;
1322+ goto check_reloc;
1323+ }
1324+
1325+ /* At this point `relocation' contains the object's
1326+ address. */
1327+ relocation -= rw_small_data_pointer;
1328+ /* Now it contains the offset from _SDA_BASE_. */
1329+ r = _bfd_final_link_relocate (howto, input_bfd,
1330+ input_section,
1331+ contents, offset,
1332+ relocation, addend);
1333+ }
1334+ else
1335+ {
1336+ (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
1337+ bfd_get_filename (input_bfd),
1338+ sym_name,
1339+ microblaze_elf_howto_table[(int) r_type]->name,
1340+ bfd_get_section_name (sec->owner, sec));
1341+ /*bfd_set_error (bfd_error_bad_value); ??? why? */
1342+ ret = FALSE;
1343+ continue;
1344+ }
1345+ }
1346+ }
1347+ break;
1348+
1349+ case (int) R_MICROBLAZE_32_SYM_OP_SYM:
1350+ break; /* Do nothing. */
1351+
1352+ case (int) R_MICROBLAZE_GOTPC_64:
1353+ relocation = htab->sgotplt->output_section->vma
1354+ + htab->sgotplt->output_offset;
1355+ relocation -= (input_section->output_section->vma
1356+ + input_section->output_offset
1357+ + offset + INST_WORD_SIZE);
1358+ relocation += addend;
1359+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1360+ contents + offset + endian);
1361+ bfd_put_16 (input_bfd, relocation & 0xffff,
1362+ contents + offset + endian + INST_WORD_SIZE);
1363+ break;
1364+
1365+ case (int) R_MICROBLAZE_PLT_64:
1366+ {
1367+ bfd_vma immediate;
1368+ if (htab->splt != NULL && h != NULL
1369+ && h->plt.offset != (bfd_vma) -1)
1370+ {
1371+ relocation = (htab->splt->output_section->vma
1372+ + htab->splt->output_offset
1373+ + h->plt.offset);
1374+ unresolved_reloc = FALSE;
1375+ immediate = relocation - (input_section->output_section->vma
1376+ + input_section->output_offset
1377+ + offset + INST_WORD_SIZE);
1378+ bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff,
1379+ contents + offset + endian);
1380+ bfd_put_16 (input_bfd, immediate & 0xffff,
1381+ contents + offset + endian + INST_WORD_SIZE);
1382+ }
1383+ else
1384+ {
1385+ relocation -= (input_section->output_section->vma
1386+ + input_section->output_offset
1387+ + offset + INST_WORD_SIZE);
1388+ immediate = relocation;
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+ break;
1395+ }
1396+
1397+ case (int) R_MICROBLAZE_TLSGD:
1398+ tls_type = (TLS_TLS | TLS_GD);
1399+ goto dogot;
1400+ case (int) R_MICROBLAZE_TLSLD:
1401+ tls_type = (TLS_TLS | TLS_LD);
1402+ dogot:
1403+ case (int) R_MICROBLAZE_GOT_64:
1404+ {
1405+ bfd_vma *offp;
1406+ bfd_vma off, off2;
1407+ unsigned long indx;
1408+ bfd_vma static_value;
1409+
1410+ bfd_boolean need_relocs = FALSE;
1411+ if (htab->sgot == NULL)
1412+ abort ();
1413+
1414+ indx = 0;
1415+ offp = NULL;
1416+
1417+ /* 1. Identify GOT Offset;
1418+ 2. Compute Static Values
1419+ 3. Process Module Id, Process Offset
1420+ 4. Fixup Relocation with GOT offset value. */
1421+
1422+ /* 1. Determine GOT Offset to use : TLS_LD, global, local */
1423+ if (IS_TLS_LD (tls_type))
1424+ offp = &htab->tlsld_got.offset;
1425+ else if (h != NULL)
1426+ {
1427+ if (htab->sgotplt != NULL && h->got.offset != (bfd_vma) -1)
1428+ offp = &h->got.offset;
1429+ else
1430+ abort ();
1431+ }
1432+ else
1433+ {
1434+ if (local_got_offsets == NULL)
1435+ abort ();
1436+ offp = &local_got_offsets[r_symndx];
1437+ }
1438+
1439+ if (!offp)
1440+ abort ();
1441+
1442+ off = (*offp) & ~1;
1443+ off2 = off;
1444+
1445+ if (IS_TLS_LD(tls_type) || IS_TLS_GD(tls_type))
1446+ off2 = off + 4;
1447+
1448+ /* Symbol index to use for relocs */
1449+ if (h != NULL)
1450+ {
1451+ bfd_boolean dyn =
1452+ elf_hash_table (info)->dynamic_sections_created;
1453+
1454+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
1455+ bfd_link_pic (info),
1456+ h)
1457+ && (!bfd_link_pic (info)
1458+ || !SYMBOL_REFERENCES_LOCAL (info, h)))
1459+ indx = h->dynindx;
1460+ }
1461+
1462+ /* Need to generate relocs ? */
1463+ if ((bfd_link_pic (info) || indx != 0)
1464+ && (h == NULL
1465+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
1466+ || h->root.type != bfd_link_hash_undefweak))
1467+ need_relocs = TRUE;
1468+
1469+ /* 2. Compute/Emit Static value of r-expression */
1470+ static_value = relocation + addend;
1471+
1472+ /* 3. Process module-id and offset */
1473+ if (! ((*offp) & 1) )
1474+ {
1475+ bfd_vma got_offset;
1476+
1477+ got_offset = (htab->sgot->output_section->vma
1478+ + htab->sgot->output_offset
1479+ + off);
1480+
1481+ /* Process module-id */
1482+ if (IS_TLS_LD(tls_type))
1483+ {
1484+ if (! bfd_link_pic (info))
1485+ {
1486+ bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
1487+ }
1488+ else
1489+ {
1490+ microblaze_elf_output_dynamic_relocation (output_bfd,
1491+ htab->srelgot, htab->srelgot->reloc_count++,
1492+ /* symindex= */ 0, R_MICROBLAZE_TLSDTPMOD32,
1493+ got_offset, 0);
1494+ }
1495+ }
1496+ else if (IS_TLS_GD(tls_type))
1497+ {
1498+ if (! need_relocs)
1499+ {
1500+ bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
1501+ }
1502+ else
1503+ {
1504+ microblaze_elf_output_dynamic_relocation (output_bfd,
1505+ htab->srelgot,
1506+ htab->srelgot->reloc_count++,
1507+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPMOD32,
1508+ got_offset, indx ? 0 : static_value);
1509+ }
1510+ }
1511+
1512+ /* Process Offset */
1513+ if (htab->srelgot == NULL)
1514+ abort ();
1515+
1516+ got_offset = (htab->sgot->output_section->vma
1517+ + htab->sgot->output_offset
1518+ + off2);
1519+ if (IS_TLS_LD(tls_type))
1520+ {
1521+ /* For LD, offset should be 0 */
1522+ *offp |= 1;
1523+ bfd_put_32 (output_bfd, 0, htab->sgot->contents + off2);
1524+ }
1525+ else if (IS_TLS_GD(tls_type))
1526+ {
1527+ *offp |= 1;
1528+ static_value -= dtprel_base(info);
1529+ if (need_relocs)
1530+ {
1531+ microblaze_elf_output_dynamic_relocation (output_bfd,
1532+ htab->srelgot, htab->srelgot->reloc_count++,
1533+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPREL32,
1534+ got_offset, indx ? 0 : static_value);
1535+ }
1536+ else
1537+ {
1538+ bfd_put_32 (output_bfd, static_value,
1539+ htab->sgot->contents + off2);
1540+ }
1541+ }
1542+ else
1543+ {
1544+ bfd_put_32 (output_bfd, static_value,
1545+ htab->sgot->contents + off2);
1546+
1547+ /* Relocs for dyn symbols generated by
1548+ finish_dynamic_symbols */
1549+ if (bfd_link_pic (info) && h == NULL)
1550+ {
1551+ *offp |= 1;
1552+ microblaze_elf_output_dynamic_relocation (output_bfd,
1553+ htab->srelgot, htab->srelgot->reloc_count++,
1554+ /* symindex= */ indx, R_MICROBLAZE_REL,
1555+ got_offset, static_value);
1556+ }
1557+ }
1558+ }
1559+
1560+ /* 4. Fixup Relocation with GOT offset value
1561+ Compute relative address of GOT entry for applying
1562+ the current relocation */
1563+ relocation = htab->sgot->output_section->vma
1564+ + htab->sgot->output_offset
1565+ + off
1566+ - htab->sgotplt->output_section->vma
1567+ - htab->sgotplt->output_offset;
1568+
1569+ /* Apply Current Relocation */
1570+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1571+ contents + offset + endian);
1572+ bfd_put_16 (input_bfd, relocation & 0xffff,
1573+ contents + offset + endian + INST_WORD_SIZE);
1574+
1575+ unresolved_reloc = FALSE;
1576+ break;
1577+ }
1578+
1579+ case (int) R_MICROBLAZE_GOTOFF_64:
1580+ {
1581+ bfd_vma immediate;
1582+ unsigned short lo, high;
1583+ relocation += addend;
1584+ relocation -= htab->sgotplt->output_section->vma
1585+ + htab->sgotplt->output_offset;
1586+ /* Write this value into correct location. */
1587+ immediate = relocation;
1588+ lo = immediate & 0x0000ffff;
1589+ high = (immediate >> 16) & 0x0000ffff;
1590+ bfd_put_16 (input_bfd, high, contents + offset + endian);
1591+ bfd_put_16 (input_bfd, lo, contents + offset + INST_WORD_SIZE + endian);
1592+ break;
1593+ }
1594+
1595+ case (int) R_MICROBLAZE_GOTOFF_32:
1596+ {
1597+ relocation += addend;
1598+ relocation -= htab->sgotplt->output_section->vma
1599+ + htab->sgotplt->output_offset;
1600+ /* Write this value into correct location. */
1601+ bfd_put_32 (input_bfd, relocation, contents + offset);
1602+ break;
1603+ }
1604+
1605+ case (int) R_MICROBLAZE_TLSDTPREL64:
1606+ relocation += addend;
1607+ relocation -= dtprel_base(info);
1608+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1609+ contents + offset + endian);
1610+ bfd_put_16 (input_bfd, relocation & 0xffff,
1611+ contents + offset + endian + INST_WORD_SIZE);
1612+ break;
1613+ case (int) R_MICROBLAZE_64_PCREL :
1614+ case (int) R_MICROBLAZE_64:
1615+ case (int) R_MICROBLAZE_32:
1616+ {
1617+ /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
1618+ from removed linkonce sections, or sections discarded by
1619+ a linker script. */
1620+ if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
1621+ {
1622+ relocation += addend;
1623+ if (r_type == R_MICROBLAZE_32)
1624+ bfd_put_32 (input_bfd, relocation, contents + offset);
1625+ else
1626+ {
1627+ if (r_type == R_MICROBLAZE_64_PCREL)
1628+ relocation -= (input_section->output_section->vma
1629+ + input_section->output_offset
1630+ + offset + INST_WORD_SIZE);
1631+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1632+ contents + offset + endian);
1633+ bfd_put_16 (input_bfd, relocation & 0xffff,
1634+ contents + offset + endian + INST_WORD_SIZE);
1635+ }
1636+ break;
1637+ }
1638+
1639+ if ((bfd_link_pic (info)
1640+ && (h == NULL
1641+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
1642+ || h->root.type != bfd_link_hash_undefweak)
1643+ && (!howto->pc_relative
1644+ || (h != NULL
1645+ && h->dynindx != -1
1646+ && (!info->symbolic
1647+ || !h->def_regular))))
1648+ || (!bfd_link_pic (info)
1649+ && h != NULL
1650+ && h->dynindx != -1
1651+ && !h->non_got_ref
1652+ && ((h->def_dynamic
1653+ && !h->def_regular)
1654+ || h->root.type == bfd_link_hash_undefweak
1655+ || h->root.type == bfd_link_hash_undefined)))
1656+ {
1657+ Elf_Internal_Rela outrel;
1658+ bfd_byte *loc;
1659+ bfd_boolean skip;
1660+
1661+ /* When generating a shared object, these relocations
1662+ are copied into the output file to be resolved at run
1663+ time. */
1664+
1665+ BFD_ASSERT (sreloc != NULL);
1666+
1667+ skip = FALSE;
1668+
1669+ outrel.r_offset =
1670+ _bfd_elf_section_offset (output_bfd, info, input_section,
1671+ rel->r_offset);
1672+ if (outrel.r_offset == (bfd_vma) -1)
1673+ skip = TRUE;
1674+ else if (outrel.r_offset == (bfd_vma) -2)
1675+ skip = TRUE;
1676+ outrel.r_offset += (input_section->output_section->vma
1677+ + input_section->output_offset);
1678+
1679+ if (skip)
1680+ memset (&outrel, 0, sizeof outrel);
1681+ /* h->dynindx may be -1 if the symbol was marked to
1682+ become local. */
1683+ else if (h != NULL
1684+ && ((! info->symbolic && h->dynindx != -1)
1685+ || !h->def_regular))
1686+ {
1687+ BFD_ASSERT (h->dynindx != -1);
1688+ outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
1689+ outrel.r_addend = addend;
1690+ }
1691+ else
1692+ {
1693+ if (r_type == R_MICROBLAZE_32)
1694+ {
1695+ outrel.r_info = ELF64_R_INFO (0, R_MICROBLAZE_REL);
1696+ outrel.r_addend = relocation + addend;
1697+ }
1698+ else
1699+ {
1700+ BFD_FAIL ();
1701+ (*_bfd_error_handler)
1702+ (_("%B: probably compiled without -fPIC?"),
1703+ input_bfd);
1704+ bfd_set_error (bfd_error_bad_value);
1705+ return FALSE;
1706+ }
1707+ }
1708+
1709+ loc = sreloc->contents;
1710+ loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
1711+ bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
1712+ break;
1713+ }
1714+ else
1715+ {
1716+ relocation += addend;
1717+ if (r_type == R_MICROBLAZE_32)
1718+ bfd_put_32 (input_bfd, relocation, contents + offset);
1719+ else
1720+ {
1721+ if (r_type == R_MICROBLAZE_64_PCREL)
1722+ relocation -= (input_section->output_section->vma
1723+ + input_section->output_offset
1724+ + offset + INST_WORD_SIZE);
1725+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1726+ contents + offset + endian);
1727+ bfd_put_16 (input_bfd, relocation & 0xffff,
1728+ contents + offset + endian + INST_WORD_SIZE);
1729+ }
1730+ break;
1731+ }
1732+ }
1733+
1734+ default :
1735+ r = _bfd_final_link_relocate (howto, input_bfd, input_section,
1736+ contents, offset,
1737+ relocation, addend);
1738+ break;
1739+ }
1740+ }
1741+
1742+ check_reloc:
1743+
1744+ if (r != bfd_reloc_ok)
1745+ {
1746+ /* FIXME: This should be generic enough to go in a utility. */
1747+ const char *name;
1748+
1749+ if (h != NULL)
1750+ name = h->root.root.string;
1751+ else
1752+ {
1753+ name = (bfd_elf_string_from_elf_section
1754+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
1755+ if (name == NULL || *name == '\0')
1756+ name = bfd_section_name (input_bfd, sec);
1757+ }
1758+
1759+ if (errmsg != NULL)
1760+ goto common_error;
1761+
1762+ switch (r)
1763+ {
1764+ case bfd_reloc_overflow:
1765+ (*info->callbacks->reloc_overflow)
1766+ (info, (h ? &h->root : NULL), name, howto->name,
1767+ (bfd_vma) 0, input_bfd, input_section, offset);
1768+ break;
1769+
1770+ case bfd_reloc_undefined:
1771+ (*info->callbacks->undefined_symbol)
1772+ (info, name, input_bfd, input_section, offset, TRUE);
1773+ break;
1774+
1775+ case bfd_reloc_outofrange:
1776+ errmsg = _("internal error: out of range error");
1777+ goto common_error;
1778+
1779+ case bfd_reloc_notsupported:
1780+ errmsg = _("internal error: unsupported relocation error");
1781+ goto common_error;
1782+
1783+ case bfd_reloc_dangerous:
1784+ errmsg = _("internal error: dangerous error");
1785+ goto common_error;
1786+
1787+ default:
1788+ errmsg = _("internal error: unknown error");
1789+ /* Fall through. */
1790+ common_error:
1791+ (*info->callbacks->warning) (info, errmsg, name, input_bfd,
1792+ input_section, offset);
1793+ break;
1794+ }
1795+ }
1796+ }
1797+
1798+ return ret;
1799+}
1800+
1801+/* Merge backend specific data from an object file to the output
1802+ object file when linking.
1803+
1804+ Note: We only use this hook to catch endian mismatches. */
1805+static bfd_boolean
1806+microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
1807+{
1808+ /* Check if we have the same endianess. */
1809+ if (! _bfd_generic_verify_endian_match (ibfd, obfd))
1810+ return FALSE;
1811+
1812+ return TRUE;
1813+}
1814+
1815+
1816+/* Calculate fixup value for reference. */
1817+
1818+static int
1819+calc_fixup (bfd_vma start, bfd_vma size, asection *sec)
1820+{
1821+ bfd_vma end = start + size;
1822+ int i, fixup = 0;
1823+
1824+ if (sec == NULL || sec->relax == NULL)
1825+ return 0;
1826+
1827+ /* Look for addr in relax table, total fixup value. */
1828+ for (i = 0; i < sec->relax_count; i++)
1829+ {
1830+ if (end <= sec->relax[i].addr)
1831+ break;
1832+ if ((end != start) && (start > sec->relax[i].addr))
1833+ continue;
1834+ fixup += sec->relax[i].size;
1835+ }
1836+ return fixup;
1837+}
1838+
1839+/* Read-modify-write into the bfd, an immediate value into appropriate fields of
1840+ a 32-bit instruction. */
1841+static void
1842+microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
1843+{
1844+ unsigned long instr = bfd_get_32 (abfd, bfd_addr);
1845+ instr &= ~0x0000ffff;
1846+ instr |= (val & 0x0000ffff);
1847+ bfd_put_32 (abfd, instr, bfd_addr);
1848+}
1849+
1850+/* Read-modify-write into the bfd, an immediate value into appropriate fields of
1851+ two consecutive 32-bit instructions. */
1852+static void
1853+microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
1854+{
1855+ unsigned long instr_hi;
1856+ unsigned long instr_lo;
1857+
1858+ instr_hi = bfd_get_32 (abfd, bfd_addr);
1859+ instr_hi &= ~0x0000ffff;
1860+ instr_hi |= ((val >> 16) & 0x0000ffff);
1861+ bfd_put_32 (abfd, instr_hi, bfd_addr);
1862+
1863+ instr_lo = bfd_get_32 (abfd, bfd_addr + INST_WORD_SIZE);
1864+ instr_lo &= ~0x0000ffff;
1865+ instr_lo |= (val & 0x0000ffff);
1866+ bfd_put_32 (abfd, instr_lo, bfd_addr + INST_WORD_SIZE);
1867+}
1868+
1869+static bfd_boolean
1870+microblaze_elf_relax_section (bfd *abfd,
1871+ asection *sec,
1872+ struct bfd_link_info *link_info,
1873+ bfd_boolean *again)
1874+{
1875+ Elf_Internal_Shdr *symtab_hdr;
1876+ Elf_Internal_Rela *internal_relocs;
1877+ Elf_Internal_Rela *free_relocs = NULL;
1878+ Elf_Internal_Rela *irel, *irelend;
1879+ bfd_byte *contents = NULL;
1880+ bfd_byte *free_contents = NULL;
1881+ int rel_count;
1882+ unsigned int shndx;
1883+ int i, sym_index;
1884+ asection *o;
1885+ struct elf_link_hash_entry *sym_hash;
1886+ Elf_Internal_Sym *isymbuf, *isymend;
1887+ Elf_Internal_Sym *isym;
1888+ int symcount;
1889+ int offset;
1890+ bfd_vma src, dest;
1891+
1892+ /* We only do this once per section. We may be able to delete some code
1893+ by running multiple passes, but it is not worth it. */
1894+ *again = FALSE;
1895+
1896+ /* Only do this for a text section. */
1897+ if (bfd_link_relocatable (link_info)
1898+ || (sec->flags & SEC_RELOC) == 0
1899+ || (sec->reloc_count == 0)
1900+ || (sec->flags & SEC_CODE) == 0)
1901+ return TRUE;
1902+
1903+ BFD_ASSERT ((sec->size > 0) || (sec->rawsize > 0));
1904+
1905+ /* If this is the first time we have been called for this section,
1906+ initialize the cooked size. */
1907+ if (sec->size == 0)
1908+ sec->size = sec->rawsize;
1909+
1910+ /* Get symbols for this section. */
1911+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1912+ isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
1913+ symcount = symtab_hdr->sh_size / sizeof (Elf64_External_Sym);
1914+ if (isymbuf == NULL)
1915+ isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr, symcount,
1916+ 0, NULL, NULL, NULL);
1917+ BFD_ASSERT (isymbuf != NULL);
1918+
1919+ internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, link_info->keep_memory);
1920+ if (internal_relocs == NULL)
1921+ goto error_return;
1922+ if (! link_info->keep_memory)
1923+ free_relocs = internal_relocs;
1924+
1925+ sec->relax = (struct relax_table *) bfd_malloc ((sec->reloc_count + 1)
1926+ * sizeof (struct relax_table));
1927+ if (sec->relax == NULL)
1928+ goto error_return;
1929+ sec->relax_count = 0;
1930+
1931+ irelend = internal_relocs + sec->reloc_count;
1932+ rel_count = 0;
1933+ for (irel = internal_relocs; irel < irelend; irel++, rel_count++)
1934+ {
1935+ bfd_vma symval;
1936+ if ((ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64_PCREL)
1937+ && (ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64 ))
1938+ continue; /* Can't delete this reloc. */
1939+
1940+ /* Get the section contents. */
1941+ if (contents == NULL)
1942+ {
1943+ if (elf_section_data (sec)->this_hdr.contents != NULL)
1944+ contents = elf_section_data (sec)->this_hdr.contents;
1945+ else
1946+ {
1947+ contents = (bfd_byte *) bfd_malloc (sec->size);
1948+ if (contents == NULL)
1949+ goto error_return;
1950+ free_contents = contents;
1951+
1952+ if (!bfd_get_section_contents (abfd, sec, contents,
1953+ (file_ptr) 0, sec->size))
1954+ goto error_return;
1955+ elf_section_data (sec)->this_hdr.contents = contents;
1956+ }
1957+ }
1958+
1959+ /* Get the value of the symbol referred to by the reloc. */
1960+ if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
1961+ {
1962+ /* A local symbol. */
1963+ asection *sym_sec;
1964+
1965+ isym = isymbuf + ELF64_R_SYM (irel->r_info);
1966+ if (isym->st_shndx == SHN_UNDEF)
1967+ sym_sec = bfd_und_section_ptr;
1968+ else if (isym->st_shndx == SHN_ABS)
1969+ sym_sec = bfd_abs_section_ptr;
1970+ else if (isym->st_shndx == SHN_COMMON)
1971+ sym_sec = bfd_com_section_ptr;
1972+ else
1973+ sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
1974+
1975+ symval = _bfd_elf_rela_local_sym (abfd, isym, &sym_sec, irel);
1976+ }
1977+ else
1978+ {
1979+ unsigned long indx;
1980+ struct elf_link_hash_entry *h;
1981+
1982+ indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
1983+ h = elf_sym_hashes (abfd)[indx];
1984+ BFD_ASSERT (h != NULL);
1985+
1986+ if (h->root.type != bfd_link_hash_defined
1987+ && h->root.type != bfd_link_hash_defweak)
1988+ /* This appears to be a reference to an undefined
1989+ symbol. Just ignore it--it will be caught by the
1990+ regular reloc processing. */
1991+ continue;
1992+
1993+ symval = (h->root.u.def.value
1994+ + h->root.u.def.section->output_section->vma
1995+ + h->root.u.def.section->output_offset);
1996+ }
1997+
1998+ /* If this is a PC-relative reloc, subtract the instr offset from
1999+ the symbol value. */
2000+ if (ELF64_R_TYPE (irel->r_info) == (int) R_MICROBLAZE_64_PCREL)
2001+ {
2002+ symval = symval + irel->r_addend
2003+ - (irel->r_offset
2004+ + sec->output_section->vma
2005+ + sec->output_offset);
2006+ }
2007+ else
2008+ symval += irel->r_addend;
2009+
2010+ if ((symval & 0xffff8000) == 0)
2011+ {
2012+ /* We can delete this instruction. */
2013+ sec->relax[sec->relax_count].addr = irel->r_offset;
2014+ sec->relax[sec->relax_count].size = INST_WORD_SIZE;
2015+ sec->relax_count++;
2016+
2017+ /* Rewrite relocation type. */
2018+ switch ((enum elf_microblaze_reloc_type) ELF64_R_TYPE (irel->r_info))
2019+ {
2020+ case R_MICROBLAZE_64_PCREL:
2021+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
2022+ (int) R_MICROBLAZE_32_PCREL_LO);
2023+ break;
2024+ case R_MICROBLAZE_64:
2025+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
2026+ (int) R_MICROBLAZE_32_LO);
2027+ break;
2028+ default:
2029+ /* Cannot happen. */
2030+ BFD_ASSERT (FALSE);
2031+ }
2032+ }
2033+ } /* Loop through all relocations. */
2034+
2035+ /* Loop through the relocs again, and see if anything needs to change. */
2036+ if (sec->relax_count > 0)
2037+ {
2038+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
2039+ rel_count = 0;
2040+ sec->relax[sec->relax_count].addr = sec->size;
2041+
2042+ for (irel = internal_relocs; irel < irelend; irel++, rel_count++)
2043+ {
2044+ bfd_vma nraddr;
2045+
2046+ /* Get the new reloc address. */
2047+ nraddr = irel->r_offset - calc_fixup (irel->r_offset, 0, sec);
2048+ switch ((enum elf_microblaze_reloc_type) ELF64_R_TYPE (irel->r_info))
2049+ {
2050+ default:
2051+ break;
2052+ case R_MICROBLAZE_64_PCREL:
2053+ break;
2054+ case R_MICROBLAZE_64:
2055+ case R_MICROBLAZE_32_LO:
2056+ /* If this reloc is against a symbol defined in this
2057+ section, we must check the addend to see it will put the value in
2058+ range to be adjusted, and hence must be changed. */
2059+ if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
2060+ {
2061+ isym = isymbuf + ELF64_R_SYM (irel->r_info);
2062+ /* Only handle relocs against .text. */
2063+ if (isym->st_shndx == shndx
2064+ && ELF64_ST_TYPE (isym->st_info) == STT_SECTION)
2065+ irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
2066+ }
2067+ break;
2068+ case R_MICROBLAZE_NONE:
2069+ case R_MICROBLAZE_32_NONE:
2070+ {
2071+ /* This was a PC-relative instruction that was
2072+ completely resolved. */
2073+ int sfix, efix;
2074+ unsigned int val;
2075+ bfd_vma target_address;
2076+ target_address = irel->r_addend + irel->r_offset;
2077+ sfix = calc_fixup (irel->r_offset, 0, sec);
2078+ efix = calc_fixup (target_address, 0, sec);
2079+
2080+ /* Validate the in-band val. */
2081+ val = bfd_get_32 (abfd, contents + irel->r_offset);
2082+ if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
2083+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
2084+ }
2085+ irel->r_addend -= (efix - sfix);
2086+ /* Should use HOWTO. */
2087+ microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
2088+ irel->r_addend);
2089+ }
2090+ break;
2091+ case R_MICROBLAZE_64_NONE:
2092+ {
2093+ /* This was a PC-relative 64-bit instruction that was
2094+ completely resolved. */
2095+ int sfix, efix;
2096+ bfd_vma target_address;
2097+ target_address = irel->r_addend + irel->r_offset + INST_WORD_SIZE;
2098+ sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
2099+ efix = calc_fixup (target_address, 0, sec);
2100+ irel->r_addend -= (efix - sfix);
2101+ microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
2102+ + INST_WORD_SIZE, irel->r_addend);
2103+ }
2104+ break;
2105+ }
2106+ irel->r_offset = nraddr;
2107+ } /* Change all relocs in this section. */
2108+
2109+ /* Look through all other sections. */
2110+ for (o = abfd->sections; o != NULL; o = o->next)
2111+ {
2112+ Elf_Internal_Rela *irelocs;
2113+ Elf_Internal_Rela *irelscan, *irelscanend;
2114+ bfd_byte *ocontents;
2115+
2116+ if (o == sec
2117+ || (o->flags & SEC_RELOC) == 0
2118+ || o->reloc_count == 0)
2119+ continue;
2120+
2121+ /* We always cache the relocs. Perhaps, if info->keep_memory is
2122+ FALSE, we should free them, if we are permitted to. */
2123+
2124+ irelocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, TRUE);
2125+ if (irelocs == NULL)
2126+ goto error_return;
2127+
2128+ ocontents = NULL;
2129+ irelscanend = irelocs + o->reloc_count;
2130+ for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
2131+ {
2132+ if (1 && ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
2133+ {
2134+ unsigned int val;
2135+
2136+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2137+
2138+ /* hax: We only do the following fixup for debug location lists. */
2139+ if (strcmp(".debug_loc", o->name))
2140+ continue;
2141+
2142+ /* This was a PC-relative instruction that was completely resolved. */
2143+ if (ocontents == NULL)
2144+ {
2145+ if (elf_section_data (o)->this_hdr.contents != NULL)
2146+ ocontents = elf_section_data (o)->this_hdr.contents;
2147+ else
2148+ {
2149+ /* We always cache the section contents.
2150+ Perhaps, if info->keep_memory is FALSE, we
2151+ should free them, if we are permitted to. */
2152+
2153+ if (o->rawsize == 0)
2154+ o->rawsize = o->size;
2155+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2156+ if (ocontents == NULL)
2157+ goto error_return;
2158+ if (!bfd_get_section_contents (abfd, o, ocontents,
2159+ (file_ptr) 0,
2160+ o->rawsize))
2161+ goto error_return;
2162+ elf_section_data (o)->this_hdr.contents = ocontents;
2163+ }
2164+ }
2165+
2166+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
2167+ if (val != irelscan->r_addend) {
2168+ fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend);
2169+ }
2170+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
2171+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
2172+ irelscan->r_addend);
2173+ }
2174+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
2175+ {
2176+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2177+
2178+ /* Look at the reloc only if the value has been resolved. */
2179+ if (isym->st_shndx == shndx
2180+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2181+ {
2182+ if (ocontents == NULL)
2183+ {
2184+ if (elf_section_data (o)->this_hdr.contents != NULL)
2185+ ocontents = elf_section_data (o)->this_hdr.contents;
2186+ else
2187+ {
2188+ /* We always cache the section contents.
2189+ Perhaps, if info->keep_memory is FALSE, we
2190+ should free them, if we are permitted to. */
2191+ if (o->rawsize == 0)
2192+ o->rawsize = o->size;
2193+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2194+ if (ocontents == NULL)
2195+ goto error_return;
2196+ if (!bfd_get_section_contents (abfd, o, ocontents,
2197+ (file_ptr) 0,
2198+ o->rawsize))
2199+ goto error_return;
2200+ elf_section_data (o)->this_hdr.contents = ocontents;
2201+ }
2202+
2203+ }
2204+ irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
2205+ }
2206+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_SYM_OP_SYM)
2207+ {
2208+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2209+
2210+ /* Look at the reloc only if the value has been resolved. */
2211+ if (ocontents == NULL)
2212+ {
2213+ if (elf_section_data (o)->this_hdr.contents != NULL)
2214+ ocontents = elf_section_data (o)->this_hdr.contents;
2215+ else
2216+ {
2217+ /* We always cache the section contents.
2218+ Perhaps, if info->keep_memory is FALSE, we
2219+ should free them, if we are permitted to. */
2220+
2221+ if (o->rawsize == 0)
2222+ o->rawsize = o->size;
2223+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2224+ if (ocontents == NULL)
2225+ goto error_return;
2226+ if (!bfd_get_section_contents (abfd, o, ocontents,
2227+ (file_ptr) 0,
2228+ o->rawsize))
2229+ goto error_return;
2230+ elf_section_data (o)->this_hdr.contents = ocontents;
2231+ }
2232+ }
2233+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
2234+ + isym->st_value,
2235+ 0,
2236+ sec);
2237+ }
2238+ }
2239+ else if ((ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_PCREL_LO)
2240+ || (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_LO))
2241+ {
2242+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2243+
2244+ /* Look at the reloc only if the value has been resolved. */
2245+ if (isym->st_shndx == shndx
2246+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2247+ {
2248+ bfd_vma immediate;
2249+ bfd_vma target_address;
2250+
2251+ if (ocontents == NULL)
2252+ {
2253+ if (elf_section_data (o)->this_hdr.contents != NULL)
2254+ ocontents = elf_section_data (o)->this_hdr.contents;
2255+ else
2256+ {
2257+ /* We always cache the section contents.
2258+ Perhaps, if info->keep_memory is FALSE, we
2259+ should free them, if we are permitted to. */
2260+ if (o->rawsize == 0)
2261+ o->rawsize = o->size;
2262+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2263+ if (ocontents == NULL)
2264+ goto error_return;
2265+ if (!bfd_get_section_contents (abfd, o, ocontents,
2266+ (file_ptr) 0,
2267+ o->rawsize))
2268+ goto error_return;
2269+ elf_section_data (o)->this_hdr.contents = ocontents;
2270+ }
2271+ }
2272+
2273+ unsigned long instr = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
2274+ immediate = instr & 0x0000ffff;
2275+ target_address = immediate;
2276+ offset = calc_fixup (target_address, 0, sec);
2277+ immediate -= offset;
2278+ irelscan->r_addend -= offset;
2279+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
2280+ irelscan->r_addend);
2281+ }
2282+ }
2283+
2284+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64)
2285+ {
2286+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2287+
2288+ /* Look at the reloc only if the value has been resolved. */
2289+ if (isym->st_shndx == shndx
2290+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2291+ {
2292+ bfd_vma immediate;
2293+
2294+ if (ocontents == NULL)
2295+ {
2296+ if (elf_section_data (o)->this_hdr.contents != NULL)
2297+ ocontents = elf_section_data (o)->this_hdr.contents;
2298+ else
2299+ {
2300+ /* We always cache the section contents.
2301+ Perhaps, if info->keep_memory is FALSE, we
2302+ should free them, if we are permitted to. */
2303+
2304+ if (o->rawsize == 0)
2305+ o->rawsize = o->size;
2306+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2307+ if (ocontents == NULL)
2308+ goto error_return;
2309+ if (!bfd_get_section_contents (abfd, o, ocontents,
2310+ (file_ptr) 0,
2311+ o->rawsize))
2312+ goto error_return;
2313+ elf_section_data (o)->this_hdr.contents = ocontents;
2314+ }
2315+ }
2316+ unsigned long instr_hi = bfd_get_32 (abfd, ocontents
2317+ + irelscan->r_offset);
2318+ unsigned long instr_lo = bfd_get_32 (abfd, ocontents
2319+ + irelscan->r_offset
2320+ + INST_WORD_SIZE);
2321+ immediate = (instr_hi & 0x0000ffff) << 16;
2322+ immediate |= (instr_lo & 0x0000ffff);
2323+ offset = calc_fixup (irelscan->r_addend, 0, sec);
2324+ immediate -= offset;
2325+ irelscan->r_addend -= offset;
2326+ }
2327+ }
2328+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_PCREL)
2329+ {
2330+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2331+
2332+ /* Look at the reloc only if the value has been resolved. */
2333+ if (isym->st_shndx == shndx
2334+ && (ELF64_ST_TYPE (isym->st_info) == STT_SECTION))
2335+ {
2336+ bfd_vma immediate;
2337+ bfd_vma target_address;
2338+
2339+ if (ocontents == NULL)
2340+ {
2341+ if (elf_section_data (o)->this_hdr.contents != NULL)
2342+ ocontents = elf_section_data (o)->this_hdr.contents;
2343+ else
2344+ {
2345+ /* We always cache the section contents.
2346+ Perhaps, if info->keep_memory is FALSE, we
2347+ should free them, if we are permitted to. */
2348+ if (o->rawsize == 0)
2349+ o->rawsize = o->size;
2350+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
2351+ if (ocontents == NULL)
2352+ goto error_return;
2353+ if (!bfd_get_section_contents (abfd, o, ocontents,
2354+ (file_ptr) 0,
2355+ o->rawsize))
2356+ goto error_return;
2357+ elf_section_data (o)->this_hdr.contents = ocontents;
2358+ }
2359+ }
2360+ unsigned long instr_hi = bfd_get_32 (abfd, ocontents
2361+ + irelscan->r_offset);
2362+ unsigned long instr_lo = bfd_get_32 (abfd, ocontents
2363+ + irelscan->r_offset
2364+ + INST_WORD_SIZE);
2365+ immediate = (instr_hi & 0x0000ffff) << 16;
2366+ immediate |= (instr_lo & 0x0000ffff);
2367+ target_address = immediate;
2368+ offset = calc_fixup (target_address, 0, sec);
2369+ immediate -= offset;
2370+ irelscan->r_addend -= offset;
2371+ microblaze_bfd_write_imm_value_64 (abfd, ocontents
2372+ + irelscan->r_offset, immediate);
2373+ }
2374+ }
2375+ }
2376+ }
2377+
2378+ /* Adjust the local symbols defined in this section. */
2379+ isymend = isymbuf + symtab_hdr->sh_info;
2380+ for (isym = isymbuf; isym < isymend; isym++)
2381+ {
2382+ if (isym->st_shndx == shndx)
2383+ {
2384+ isym->st_value -= calc_fixup (isym->st_value, 0, sec);
2385+ if (isym->st_size)
2386+ isym->st_size -= calc_fixup (isym->st_value, isym->st_size, sec);
2387+ }
2388+ }
2389+
2390+ /* Now adjust the global symbols defined in this section. */
2391+ isym = isymbuf + symtab_hdr->sh_info;
2392+ symcount = (symtab_hdr->sh_size / sizeof (Elf64_External_Sym)) - symtab_hdr->sh_info;
2393+ for (sym_index = 0; sym_index < symcount; sym_index++)
2394+ {
2395+ sym_hash = elf_sym_hashes (abfd)[sym_index];
2396+ if ((sym_hash->root.type == bfd_link_hash_defined
2397+ || sym_hash->root.type == bfd_link_hash_defweak)
2398+ && sym_hash->root.u.def.section == sec)
2399+ {
2400+ sym_hash->root.u.def.value -= calc_fixup (sym_hash->root.u.def.value,
2401+ 0, sec);
2402+ if (sym_hash->size)
2403+ sym_hash->size -= calc_fixup (sym_hash->root.u.def.value,
2404+ sym_hash->size, sec);
2405+ }
2406+ }
2407+
2408+ /* Physically move the code and change the cooked size. */
2409+ dest = sec->relax[0].addr;
2410+ for (i = 0; i < sec->relax_count; i++)
2411+ {
2412+ int len;
2413+ src = sec->relax[i].addr + sec->relax[i].size;
2414+ len = sec->relax[i+1].addr - sec->relax[i].addr - sec->relax[i].size;
2415+
2416+ memmove (contents + dest, contents + src, len);
2417+ sec->size -= sec->relax[i].size;
2418+ dest += len;
2419+ }
2420+
2421+ elf_section_data (sec)->relocs = internal_relocs;
2422+ free_relocs = NULL;
2423+
2424+ elf_section_data (sec)->this_hdr.contents = contents;
2425+ free_contents = NULL;
2426+
2427+ symtab_hdr->contents = (bfd_byte *) isymbuf;
2428+ }
2429+
2430+ if (free_relocs != NULL)
2431+ {
2432+ free (free_relocs);
2433+ free_relocs = NULL;
2434+ }
2435+
2436+ if (free_contents != NULL)
2437+ {
2438+ if (!link_info->keep_memory)
2439+ free (free_contents);
2440+ else
2441+ /* Cache the section contents for elf_link_input_bfd. */
2442+ elf_section_data (sec)->this_hdr.contents = contents;
2443+ free_contents = NULL;
2444+ }
2445+
2446+ if (sec->relax_count == 0)
2447+ {
2448+ *again = FALSE;
2449+ free (sec->relax);
2450+ sec->relax = NULL;
2451+ }
2452+ else
2453+ *again = TRUE;
2454+ return TRUE;
2455+
2456+ error_return:
2457+ if (free_relocs != NULL)
2458+ free (free_relocs);
2459+ if (free_contents != NULL)
2460+ free (free_contents);
2461+ if (sec->relax != NULL)
2462+ {
2463+ free (sec->relax);
2464+ sec->relax = NULL;
2465+ sec->relax_count = 0;
2466+ }
2467+ return FALSE;
2468+}
2469+
2470+/* Return the section that should be marked against GC for a given
2471+ relocation. */
2472+
2473+static asection *
2474+microblaze_elf_gc_mark_hook (asection *sec,
2475+ struct bfd_link_info * info,
2476+ Elf_Internal_Rela * rel,
2477+ struct elf_link_hash_entry * h,
2478+ Elf_Internal_Sym * sym)
2479+{
2480+ if (h != NULL)
2481+ switch (ELF64_R_TYPE (rel->r_info))
2482+ {
2483+ case R_MICROBLAZE_GNU_VTINHERIT:
2484+ case R_MICROBLAZE_GNU_VTENTRY:
2485+ return NULL;
2486+ }
2487+
2488+ return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
2489+}
2490+
2491+/* Update the got entry reference counts for the section being removed. */
2492+
2493+static bfd_boolean
2494+microblaze_elf_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED,
2495+ struct bfd_link_info * info ATTRIBUTE_UNUSED,
2496+ asection * sec ATTRIBUTE_UNUSED,
2497+ const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
2498+{
2499+ return TRUE;
2500+}
2501+
2502+/* PIC support. */
2503+
2504+#define PLT_ENTRY_SIZE 16
2505+
2506+#define PLT_ENTRY_WORD_0 0xb0000000 /* "imm 0". */
2507+#define PLT_ENTRY_WORD_1 0xe9940000 /* "lwi r12,r20,0" - relocated to lwi r12,r20,func@GOT. */
2508+#define PLT_ENTRY_WORD_1_NOPIC 0xe9800000 /* "lwi r12,r0,0" - non-PIC object. */
2509+#define PLT_ENTRY_WORD_2 0x98186000 /* "brad r12". */
2510+#define PLT_ENTRY_WORD_3 0x80000000 /* "nop". */
2511+
2512+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
2513+ shortcuts to them in our hash table. */
2514+
2515+static bfd_boolean
2516+create_got_section (bfd *dynobj, struct bfd_link_info *info)
2517+{
2518+ struct elf64_mb_link_hash_table *htab;
2519+
2520+ if (! _bfd_elf_create_got_section (dynobj, info))
2521+ return FALSE;
2522+ htab = elf64_mb_hash_table (info);
2523+ if (htab == NULL)
2524+ return FALSE;
2525+
2526+ htab->sgot = bfd_get_linker_section (dynobj, ".got");
2527+ htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
2528+ if (!htab->sgot || !htab->sgotplt)
2529+ return FALSE;
2530+
2531+ if ((htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got")) == NULL)
2532+ htab->srelgot = bfd_make_section_anyway (dynobj, ".rela.got");
2533+ if (htab->srelgot == NULL
2534+ || ! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC
2535+ | SEC_LOAD
2536+ | SEC_HAS_CONTENTS
2537+ | SEC_IN_MEMORY
2538+ | SEC_LINKER_CREATED
2539+ | SEC_READONLY)
2540+ || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
2541+ return FALSE;
2542+ return TRUE;
2543+}
2544+
2545+static bfd_boolean
2546+update_local_sym_info (bfd *abfd,
2547+ Elf_Internal_Shdr *symtab_hdr,
2548+ unsigned long r_symndx,
2549+ unsigned int tls_type)
2550+{
2551+ bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd);
2552+ unsigned char *local_got_tls_masks;
2553+
2554+ if (local_got_refcounts == NULL)
2555+ {
2556+ bfd_size_type size = symtab_hdr->sh_info;
2557+
2558+ size *= (sizeof (*local_got_refcounts) + sizeof (*local_got_tls_masks));
2559+ local_got_refcounts = bfd_zalloc (abfd, size);
2560+ if (local_got_refcounts == NULL)
2561+ return FALSE;
2562+ elf_local_got_refcounts (abfd) = local_got_refcounts;
2563+ }
2564+
2565+ local_got_tls_masks =
2566+ (unsigned char *) (local_got_refcounts + symtab_hdr->sh_info);
2567+ local_got_tls_masks[r_symndx] |= tls_type;
2568+ local_got_refcounts[r_symndx] += 1;
2569+
2570+ return TRUE;
2571+}
2572+/* Look through the relocs for a section during the first phase. */
2573+
2574+static bfd_boolean
2575+microblaze_elf_check_relocs (bfd * abfd,
2576+ struct bfd_link_info * info,
2577+ asection * sec,
2578+ const Elf_Internal_Rela * relocs)
2579+{
2580+ Elf_Internal_Shdr * symtab_hdr;
2581+ struct elf_link_hash_entry ** sym_hashes;
2582+ struct elf_link_hash_entry ** sym_hashes_end;
2583+ const Elf_Internal_Rela * rel;
2584+ const Elf_Internal_Rela * rel_end;
2585+ struct elf64_mb_link_hash_table *htab;
2586+ asection *sreloc = NULL;
2587+
2588+ if (bfd_link_relocatable (info))
2589+ return TRUE;
2590+
2591+ htab = elf64_mb_hash_table (info);
2592+ if (htab == NULL)
2593+ return FALSE;
2594+
2595+ symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
2596+ sym_hashes = elf_sym_hashes (abfd);
2597+ sym_hashes_end = sym_hashes + symtab_hdr->sh_size / sizeof (Elf64_External_Sym);
2598+ if (!elf_bad_symtab (abfd))
2599+ sym_hashes_end -= symtab_hdr->sh_info;
2600+
2601+ rel_end = relocs + sec->reloc_count;
2602+
2603+ for (rel = relocs; rel < rel_end; rel++)
2604+ {
2605+ unsigned int r_type;
2606+ struct elf_link_hash_entry * h;
2607+ unsigned long r_symndx;
2608+ unsigned char tls_type = 0;
2609+
2610+ r_symndx = ELF64_R_SYM (rel->r_info);
2611+ r_type = ELF64_R_TYPE (rel->r_info);
2612+
2613+ if (r_symndx < symtab_hdr->sh_info)
2614+ h = NULL;
2615+ else
2616+ {
2617+ h = sym_hashes [r_symndx - symtab_hdr->sh_info];
2618+
2619+ /* PR15323, ref flags aren't set for references in the same
2620+ object. */
2621+ h->root.non_ir_ref = 1;
2622+ }
2623+
2624+ switch (r_type)
2625+ {
2626+ /* This relocation describes the C++ object vtable hierarchy.
2627+ Reconstruct it for later use during GC. */
2628+ case R_MICROBLAZE_GNU_VTINHERIT:
2629+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
2630+ return FALSE;
2631+ break;
2632+
2633+ /* This relocation describes which C++ vtable entries are actually
2634+ used. Record for later use during GC. */
2635+ case R_MICROBLAZE_GNU_VTENTRY:
2636+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
2637+ return FALSE;
2638+ break;
2639+
2640+ /* This relocation requires .plt entry. */
2641+ case R_MICROBLAZE_PLT_64:
2642+ if (h != NULL)
2643+ {
2644+ h->needs_plt = 1;
2645+ h->plt.refcount += 1;
2646+ }
2647+ break;
2648+
2649+ /* This relocation requires .got entry. */
2650+ case R_MICROBLAZE_TLSGD:
2651+ tls_type |= (TLS_TLS | TLS_GD);
2652+ goto dogottls;
2653+ case R_MICROBLAZE_TLSLD:
2654+ tls_type |= (TLS_TLS | TLS_LD);
2655+ dogottls:
2656+ sec->has_tls_reloc = 1;
2657+ case R_MICROBLAZE_GOT_64:
2658+ if (htab->sgot == NULL)
2659+ {
2660+ if (htab->elf.dynobj == NULL)
2661+ htab->elf.dynobj = abfd;
2662+ if (!create_got_section (htab->elf.dynobj, info))
2663+ return FALSE;
2664+ }
2665+ if (h != NULL)
2666+ {
2667+ h->got.refcount += 1;
2668+ elf64_mb_hash_entry (h)->tls_mask |= tls_type;
2669+ }
2670+ else
2671+ {
2672+ if (! update_local_sym_info(abfd, symtab_hdr, r_symndx, tls_type) )
2673+ return FALSE;
2674+ }
2675+ break;
2676+
2677+ case R_MICROBLAZE_64:
2678+ case R_MICROBLAZE_64_PCREL:
2679+ case R_MICROBLAZE_32:
2680+ {
2681+ if (h != NULL && !bfd_link_pic (info))
2682+ {
2683+ /* we may need a copy reloc. */
2684+ h->non_got_ref = 1;
2685+
2686+ /* we may also need a .plt entry. */
2687+ h->plt.refcount += 1;
2688+ if (ELF64_R_TYPE (rel->r_info) != R_MICROBLAZE_64_PCREL)
2689+ h->pointer_equality_needed = 1;
2690+ }
2691+
2692+
2693+ /* If we are creating a shared library, and this is a reloc
2694+ against a global symbol, or a non PC relative reloc
2695+ against a local symbol, then we need to copy the reloc
2696+ into the shared library. However, if we are linking with
2697+ -Bsymbolic, we do not need to copy a reloc against a
2698+ global symbol which is defined in an object we are
2699+ including in the link (i.e., DEF_REGULAR is set). At
2700+ this point we have not seen all the input files, so it is
2701+ possible that DEF_REGULAR is not set now but will be set
2702+ later (it is never cleared). In case of a weak definition,
2703+ DEF_REGULAR may be cleared later by a strong definition in
2704+ a shared library. We account for that possibility below by
2705+ storing information in the relocs_copied field of the hash
2706+ table entry. A similar situation occurs when creating
2707+ shared libraries and symbol visibility changes render the
2708+ symbol local.
2709+
2710+ If on the other hand, we are creating an executable, we
2711+ may need to keep relocations for symbols satisfied by a
2712+ dynamic library if we manage to avoid copy relocs for the
2713+ symbol. */
2714+
2715+ if ((bfd_link_pic (info)
2716+ && (sec->flags & SEC_ALLOC) != 0
2717+ && (r_type != R_MICROBLAZE_64_PCREL
2718+ || (h != NULL
2719+ && (! info->symbolic
2720+ || h->root.type == bfd_link_hash_defweak
2721+ || !h->def_regular))))
2722+ || (!bfd_link_pic (info)
2723+ && (sec->flags & SEC_ALLOC) != 0
2724+ && h != NULL
2725+ && (h->root.type == bfd_link_hash_defweak
2726+ || !h->def_regular)))
2727+ {
2728+ struct elf64_mb_dyn_relocs *p;
2729+ struct elf64_mb_dyn_relocs **head;
2730+
2731+ /* When creating a shared object, we must copy these
2732+ relocs into the output file. We create a reloc
2733+ section in dynobj and make room for the reloc. */
2734+
2735+ if (sreloc == NULL)
2736+ {
2737+ bfd *dynobj;
2738+
2739+ if (htab->elf.dynobj == NULL)
2740+ htab->elf.dynobj = abfd;
2741+ dynobj = htab->elf.dynobj;
2742+
2743+ sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj,
2744+ 2, abfd, 1);
2745+ if (sreloc == NULL)
2746+ return FALSE;
2747+ }
2748+
2749+ /* If this is a global symbol, we count the number of
2750+ relocations we need for this symbol. */
2751+ if (h != NULL)
2752+ head = &((struct elf64_mb_link_hash_entry *) h)->dyn_relocs;
2753+ else
2754+ {
2755+ /* Track dynamic relocs needed for local syms too.
2756+ We really need local syms available to do this
2757+ easily. Oh well. */
2758+
2759+ asection *s;
2760+ Elf_Internal_Sym *isym;
2761+ void *vpp;
2762+
2763+ isym = bfd_sym_from_r_symndx (&htab->sym_sec,
2764+ abfd, r_symndx);
2765+ if (isym == NULL)
2766+ return FALSE;
2767+
2768+ s = bfd_section_from_elf_index (abfd, isym->st_shndx);
2769+ if (s == NULL)
2770+ return FALSE;
2771+
2772+ vpp = &elf_section_data (s)->local_dynrel;
2773+ head = (struct elf64_mb_dyn_relocs **) vpp;
2774+ }
2775+
2776+ p = *head;
2777+ if (p == NULL || p->sec != sec)
2778+ {
2779+ bfd_size_type amt = sizeof *p;
2780+ p = ((struct elf64_mb_dyn_relocs *)
2781+ bfd_alloc (htab->elf.dynobj, amt));
2782+ if (p == NULL)
2783+ return FALSE;
2784+ p->next = *head;
2785+ *head = p;
2786+ p->sec = sec;
2787+ p->count = 0;
2788+ p->pc_count = 0;
2789+ }
2790+
2791+ p->count += 1;
2792+ if (r_type == R_MICROBLAZE_64_PCREL)
2793+ p->pc_count += 1;
2794+ }
2795+ }
2796+ break;
2797+ }
2798+ }
2799+
2800+ return TRUE;
2801+}
2802+
2803+static bfd_boolean
2804+microblaze_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
2805+{
2806+ struct elf64_mb_link_hash_table *htab;
2807+
2808+ htab = elf64_mb_hash_table (info);
2809+ if (htab == NULL)
2810+ return FALSE;
2811+
2812+ if (!htab->sgot && !create_got_section (dynobj, info))
2813+ return FALSE;
2814+
2815+ if (!_bfd_elf_create_dynamic_sections (dynobj, info))
2816+ return FALSE;
2817+
2818+ htab->splt = bfd_get_linker_section (dynobj, ".plt");
2819+ htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
2820+ htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
2821+ if (!bfd_link_pic (info))
2822+ htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
2823+
2824+ if (!htab->splt || !htab->srelplt || !htab->sdynbss
2825+ || (!bfd_link_pic (info) && !htab->srelbss))
2826+ abort ();
2827+
2828+ return TRUE;
2829+}
2830+
2831+/* Copy the extra info we tack onto an elf_link_hash_entry. */
2832+
2833+static void
2834+microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info,
2835+ struct elf_link_hash_entry *dir,
2836+ struct elf_link_hash_entry *ind)
2837+{
2838+ struct elf64_mb_link_hash_entry *edir, *eind;
2839+
2840+ edir = (struct elf64_mb_link_hash_entry *) dir;
2841+ eind = (struct elf64_mb_link_hash_entry *) ind;
2842+
2843+ if (eind->dyn_relocs != NULL)
2844+ {
2845+ if (edir->dyn_relocs != NULL)
2846+ {
2847+ struct elf64_mb_dyn_relocs **pp;
2848+ struct elf64_mb_dyn_relocs *p;
2849+
2850+ if (ind->root.type == bfd_link_hash_indirect)
2851+ abort ();
2852+
2853+ /* Add reloc counts against the weak sym to the strong sym
2854+ list. Merge any entries against the same section. */
2855+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
2856+ {
2857+ struct elf64_mb_dyn_relocs *q;
2858+
2859+ for (q = edir->dyn_relocs; q != NULL; q = q->next)
2860+ if (q->sec == p->sec)
2861+ {
2862+ q->pc_count += p->pc_count;
2863+ q->count += p->count;
2864+ *pp = p->next;
2865+ break;
2866+ }
2867+ if (q == NULL)
2868+ pp = &p->next;
2869+ }
2870+ *pp = edir->dyn_relocs;
2871+ }
2872+
2873+ edir->dyn_relocs = eind->dyn_relocs;
2874+ eind->dyn_relocs = NULL;
2875+ }
2876+
2877+ edir->tls_mask |= eind->tls_mask;
2878+
2879+ _bfd_elf_link_hash_copy_indirect (info, dir, ind);
2880+}
2881+
2882+static bfd_boolean
2883+microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
2884+ struct elf_link_hash_entry *h)
2885+{
2886+ struct elf64_mb_link_hash_table *htab;
2887+ struct elf64_mb_link_hash_entry * eh;
2888+ struct elf64_mb_dyn_relocs *p;
2889+ asection *sdynbss, *s;
2890+ unsigned int power_of_two;
2891+ bfd *dynobj;
2892+
2893+ htab = elf64_mb_hash_table (info);
2894+ if (htab == NULL)
2895+ return FALSE;
2896+
2897+ /* If this is a function, put it in the procedure linkage table. We
2898+ will fill in the contents of the procedure linkage table later,
2899+ when we know the address of the .got section. */
2900+ if (h->type == STT_FUNC
2901+ || h->needs_plt)
2902+ {
2903+ if (h->plt.refcount <= 0
2904+ || SYMBOL_CALLS_LOCAL (info, h)
2905+ || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
2906+ && h->root.type == bfd_link_hash_undefweak))
2907+ {
2908+ /* This case can occur if we saw a PLT reloc in an input
2909+ file, but the symbol was never referred to by a dynamic
2910+ object, or if all references were garbage collected. In
2911+ such a case, we don't actually need to build a procedure
2912+ linkage table, and we can just do a PC32 reloc instead. */
2913+ h->plt.offset = (bfd_vma) -1;
2914+ h->needs_plt = 0;
2915+ }
2916+
2917+ return TRUE;
2918+ }
2919+ else
2920+ /* It's possible that we incorrectly decided a .plt reloc was
2921+ needed for an R_MICROBLAZE_64_PCREL reloc to a non-function sym in
2922+ check_relocs. We can't decide accurately between function and
2923+ non-function syms in check-relocs; Objects loaded later in
2924+ the link may change h->type. So fix it now. */
2925+ h->plt.offset = (bfd_vma) -1;
2926+
2927+ /* If this is a weak symbol, and there is a real definition, the
2928+ processor independent code will have arranged for us to see the
2929+ real definition first, and we can just use the same value. */
2930+ if (h->u.weakdef != NULL)
2931+ {
2932+ BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
2933+ || h->u.weakdef->root.type == bfd_link_hash_defweak);
2934+ h->root.u.def.section = h->u.weakdef->root.u.def.section;
2935+ h->root.u.def.value = h->u.weakdef->root.u.def.value;
2936+ return TRUE;
2937+ }
2938+
2939+ /* This is a reference to a symbol defined by a dynamic object which
2940+ is not a function. */
2941+
2942+ /* If we are creating a shared library, we must presume that the
2943+ only references to the symbol are via the global offset table.
2944+ For such cases we need not do anything here; the relocations will
2945+ be handled correctly by relocate_section. */
2946+ if (bfd_link_pic (info))
2947+ return TRUE;
2948+
2949+ /* If there are no references to this symbol that do not use the
2950+ GOT, we don't need to generate a copy reloc. */
2951+ if (!h->non_got_ref)
2952+ return TRUE;
2953+
2954+ /* If -z nocopyreloc was given, we won't generate them either. */
2955+ if (info->nocopyreloc)
2956+ {
2957+ h->non_got_ref = 0;
2958+ return TRUE;
2959+ }
2960+
2961+ eh = (struct elf64_mb_link_hash_entry *) h;
2962+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
2963+ {
2964+ s = p->sec->output_section;
2965+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
2966+ break;
2967+ }
2968+
2969+ /* If we didn't find any dynamic relocs in read-only sections, then
2970+ we'll be keeping the dynamic relocs and avoiding the copy reloc. */
2971+ if (p == NULL)
2972+ {
2973+ h->non_got_ref = 0;
2974+ return TRUE;
2975+ }
2976+
2977+ /* We must allocate the symbol in our .dynbss section, which will
2978+ become part of the .bss section of the executable. There will be
2979+ an entry for this symbol in the .dynsym section. The dynamic
2980+ object will contain position independent code, so all references
2981+ from the dynamic object to this symbol will go through the global
2982+ offset table. The dynamic linker will use the .dynsym entry to
2983+ determine the address it must put in the global offset table, so
2984+ both the dynamic object and the regular object will refer to the
2985+ same memory location for the variable. */
2986+
2987+ /* We must generate a R_MICROBLAZE_COPY reloc to tell the dynamic linker
2988+ to copy the initial value out of the dynamic object and into the
2989+ runtime process image. */
2990+ dynobj = elf_hash_table (info)->dynobj;
2991+ BFD_ASSERT (dynobj != NULL);
2992+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
2993+ {
2994+ htab->srelbss->size += sizeof (Elf64_External_Rela);
2995+ h->needs_copy = 1;
2996+ }
2997+
2998+ /* We need to figure out the alignment required for this symbol. I
2999+ have no idea how ELF linkers handle this. */
3000+ power_of_two = bfd_log2 (h->size);
3001+ if (power_of_two > 3)
3002+ power_of_two = 3;
3003+
3004+ sdynbss = htab->sdynbss;
3005+ /* Apply the required alignment. */
3006+ sdynbss->size = BFD_ALIGN (sdynbss->size, (bfd_size_type) (1 << power_of_two));
3007+ if (power_of_two > bfd_get_section_alignment (dynobj, sdynbss))
3008+ {
3009+ if (! bfd_set_section_alignment (dynobj, sdynbss, power_of_two))
3010+ return FALSE;
3011+ }
3012+
3013+ /* Define the symbol as being at this point in the section. */
3014+ h->root.u.def.section = sdynbss;
3015+ h->root.u.def.value = sdynbss->size;
3016+
3017+ /* Increment the section size to make room for the symbol. */
3018+ sdynbss->size += h->size;
3019+ return TRUE;
3020+}
3021+
3022+/* Allocate space in .plt, .got and associated reloc sections for
3023+ dynamic relocs. */
3024+
3025+static bfd_boolean
3026+allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
3027+{
3028+ struct bfd_link_info *info;
3029+ struct elf64_mb_link_hash_table *htab;
3030+ struct elf64_mb_link_hash_entry *eh;
3031+ struct elf64_mb_dyn_relocs *p;
3032+
3033+ if (h->root.type == bfd_link_hash_indirect)
3034+ return TRUE;
3035+
3036+ info = (struct bfd_link_info *) dat;
3037+ htab = elf64_mb_hash_table (info);
3038+ if (htab == NULL)
3039+ return FALSE;
3040+
3041+ if (htab->elf.dynamic_sections_created
3042+ && h->plt.refcount > 0)
3043+ {
3044+ /* Make sure this symbol is output as a dynamic symbol.
3045+ Undefined weak syms won't yet be marked as dynamic. */
3046+ if (h->dynindx == -1
3047+ && !h->forced_local)
3048+ {
3049+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3050+ return FALSE;
3051+ }
3052+
3053+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
3054+ {
3055+ asection *s = htab->splt;
3056+
3057+ /* The first entry in .plt is reserved. */
3058+ if (s->size == 0)
3059+ s->size = PLT_ENTRY_SIZE;
3060+
3061+ h->plt.offset = s->size;
3062+
3063+ /* If this symbol is not defined in a regular file, and we are
3064+ not generating a shared library, then set the symbol to this
3065+ location in the .plt. This is required to make function
3066+ pointers compare as equal between the normal executable and
3067+ the shared library. */
3068+ if (! bfd_link_pic (info)
3069+ && !h->def_regular)
3070+ {
3071+ h->root.u.def.section = s;
3072+ h->root.u.def.value = h->plt.offset;
3073+ }
3074+
3075+ /* Make room for this entry. */
3076+ s->size += PLT_ENTRY_SIZE;
3077+
3078+ /* We also need to make an entry in the .got.plt section, which
3079+ will be placed in the .got section by the linker script. */
3080+ htab->sgotplt->size += 4;
3081+
3082+ /* We also need to make an entry in the .rel.plt section. */
3083+ htab->srelplt->size += sizeof (Elf64_External_Rela);
3084+ }
3085+ else
3086+ {
3087+ h->plt.offset = (bfd_vma) -1;
3088+ h->needs_plt = 0;
3089+ }
3090+ }
3091+ else
3092+ {
3093+ h->plt.offset = (bfd_vma) -1;
3094+ h->needs_plt = 0;
3095+ }
3096+
3097+ eh = (struct elf64_mb_link_hash_entry *) h;
3098+ if (h->got.refcount > 0)
3099+ {
3100+ unsigned int need;
3101+ asection *s;
3102+
3103+ /* Make sure this symbol is output as a dynamic symbol.
3104+ Undefined weak syms won't yet be marked as dynamic. */
3105+ if (h->dynindx == -1
3106+ && !h->forced_local)
3107+ {
3108+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3109+ return FALSE;
3110+ }
3111+
3112+ need = 0;
3113+ if ((eh->tls_mask & TLS_TLS) != 0)
3114+ {
3115+ /* Handle TLS Symbol */
3116+ if ((eh->tls_mask & TLS_LD) != 0)
3117+ {
3118+ if (!eh->elf.def_dynamic)
3119+ /* We'll just use htab->tlsld_got.offset. This should
3120+ always be the case. It's a little odd if we have
3121+ a local dynamic reloc against a non-local symbol. */
3122+ htab->tlsld_got.refcount += 1;
3123+ else
3124+ need += 8;
3125+ }
3126+ if ((eh->tls_mask & TLS_GD) != 0)
3127+ need += 8;
3128+ }
3129+ else
3130+ {
3131+ /* Regular (non-TLS) symbol */
3132+ need += 4;
3133+ }
3134+ if (need == 0)
3135+ {
3136+ h->got.offset = (bfd_vma) -1;
3137+ }
3138+ else
3139+ {
3140+ s = htab->sgot;
3141+ h->got.offset = s->size;
3142+ s->size += need;
3143+ htab->srelgot->size += need * (sizeof (Elf64_External_Rela) / 4);
3144+ }
3145+ }
3146+ else
3147+ h->got.offset = (bfd_vma) -1;
3148+
3149+ if (eh->dyn_relocs == NULL)
3150+ return TRUE;
3151+
3152+ /* In the shared -Bsymbolic case, discard space allocated for
3153+ dynamic pc-relative relocs against symbols which turn out to be
3154+ defined in regular objects. For the normal shared case, discard
3155+ space for pc-relative relocs that have become local due to symbol
3156+ visibility changes. */
3157+
3158+ if (bfd_link_pic (info))
3159+ {
3160+ if (h->def_regular
3161+ && (h->forced_local
3162+ || info->symbolic))
3163+ {
3164+ struct elf64_mb_dyn_relocs **pp;
3165+
3166+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
3167+ {
3168+ p->count -= p->pc_count;
3169+ p->pc_count = 0;
3170+ if (p->count == 0)
3171+ *pp = p->next;
3172+ else
3173+ pp = &p->next;
3174+ }
3175+ }
3176+ }
3177+ else
3178+ {
3179+ /* For the non-shared case, discard space for relocs against
3180+ symbols which turn out to need copy relocs or are not
3181+ dynamic. */
3182+
3183+ if (!h->non_got_ref
3184+ && ((h->def_dynamic
3185+ && !h->def_regular)
3186+ || (htab->elf.dynamic_sections_created
3187+ && (h->root.type == bfd_link_hash_undefweak
3188+ || h->root.type == bfd_link_hash_undefined))))
3189+ {
3190+ /* Make sure this symbol is output as a dynamic symbol.
3191+ Undefined weak syms won't yet be marked as dynamic. */
3192+ if (h->dynindx == -1
3193+ && !h->forced_local)
3194+ {
3195+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3196+ return FALSE;
3197+ }
3198+
3199+ /* If that succeeded, we know we'll be keeping all the
3200+ relocs. */
3201+ if (h->dynindx != -1)
3202+ goto keep;
3203+ }
3204+
3205+ eh->dyn_relocs = NULL;
3206+
3207+ keep: ;
3208+ }
3209+
3210+ /* Finally, allocate space. */
3211+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
3212+ {
3213+ asection *sreloc = elf_section_data (p->sec)->sreloc;
3214+ sreloc->size += p->count * sizeof (Elf64_External_Rela);
3215+ }
3216+
3217+ return TRUE;
3218+}
3219+
3220+/* Set the sizes of the dynamic sections. */
3221+
3222+static bfd_boolean
3223+microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
3224+ struct bfd_link_info *info)
3225+{
3226+ struct elf64_mb_link_hash_table *htab;
3227+ bfd *dynobj;
3228+ asection *s;
3229+ bfd *ibfd;
3230+
3231+ htab = elf64_mb_hash_table (info);
3232+ if (htab == NULL)
3233+ return FALSE;
3234+
3235+ dynobj = htab->elf.dynobj;
3236+ BFD_ASSERT (dynobj != NULL);
3237+
3238+ /* Set up .got offsets for local syms, and space for local dynamic
3239+ relocs. */
3240+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
3241+ {
3242+ bfd_signed_vma *local_got;
3243+ bfd_signed_vma *end_local_got;
3244+ bfd_size_type locsymcount;
3245+ Elf_Internal_Shdr *symtab_hdr;
3246+ unsigned char *lgot_masks;
3247+ asection *srel;
3248+
3249+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
3250+ continue;
3251+
3252+ for (s = ibfd->sections; s != NULL; s = s->next)
3253+ {
3254+ struct elf64_mb_dyn_relocs *p;
3255+
3256+ for (p = ((struct elf64_mb_dyn_relocs *)
3257+ elf_section_data (s)->local_dynrel);
3258+ p != NULL;
3259+ p = p->next)
3260+ {
3261+ if (!bfd_is_abs_section (p->sec)
3262+ && bfd_is_abs_section (p->sec->output_section))
3263+ {
3264+ /* Input section has been discarded, either because
3265+ it is a copy of a linkonce section or due to
3266+ linker script /DISCARD/, so we'll be discarding
3267+ the relocs too. */
3268+ }
3269+ else if (p->count != 0)
3270+ {
3271+ srel = elf_section_data (p->sec)->sreloc;
3272+ srel->size += p->count * sizeof (Elf64_External_Rela);
3273+ if ((p->sec->output_section->flags & SEC_READONLY) != 0)
3274+ info->flags |= DF_TEXTREL;
3275+ }
3276+ }
3277+ }
3278+
3279+ local_got = elf_local_got_refcounts (ibfd);
3280+ if (!local_got)
3281+ continue;
3282+
3283+ symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
3284+ locsymcount = symtab_hdr->sh_info;
3285+ end_local_got = local_got + locsymcount;
3286+ lgot_masks = (unsigned char *) end_local_got;
3287+ s = htab->sgot;
3288+ srel = htab->srelgot;
3289+
3290+ for (; local_got < end_local_got; ++local_got, ++lgot_masks)
3291+ {
3292+ if (*local_got > 0)
3293+ {
3294+ unsigned int need = 0;
3295+ if ((*lgot_masks & TLS_TLS) != 0)
3296+ {
3297+ if ((*lgot_masks & TLS_GD) != 0)
3298+ need += 8;
3299+ if ((*lgot_masks & TLS_LD) != 0)
3300+ htab->tlsld_got.refcount += 1;
3301+ }
3302+ else
3303+ need += 4;
3304+
3305+ if (need == 0)
3306+ {
3307+ *local_got = (bfd_vma) -1;
3308+ }
3309+ else
3310+ {
3311+ *local_got = s->size;
3312+ s->size += need;
3313+ if (bfd_link_pic (info))
3314+ srel->size += need * (sizeof (Elf64_External_Rela) / 4);
3315+ }
3316+ }
3317+ else
3318+ *local_got = (bfd_vma) -1;
3319+ }
3320+ }
3321+
3322+ /* Allocate global sym .plt and .got entries, and space for global
3323+ sym dynamic relocs. */
3324+ elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info);
3325+
3326+ if (htab->tlsld_got.refcount > 0)
3327+ {
3328+ htab->tlsld_got.offset = htab->sgot->size;
3329+ htab->sgot->size += 8;
3330+ if (bfd_link_pic (info))
3331+ htab->srelgot->size += sizeof (Elf64_External_Rela);
3332+ }
3333+ else
3334+ htab->tlsld_got.offset = (bfd_vma) -1;
3335+
3336+ if (elf_hash_table (info)->dynamic_sections_created)
3337+ {
3338+ /* Make space for the trailing nop in .plt. */
3339+ if (htab->splt->size > 0)
3340+ htab->splt->size += 4;
3341+ }
3342+
3343+ /* The check_relocs and adjust_dynamic_symbol entry points have
3344+ determined the sizes of the various dynamic sections. Allocate
3345+ memory for them. */
3346+ for (s = dynobj->sections; s != NULL; s = s->next)
3347+ {
3348+ const char *name;
3349+ bfd_boolean strip = FALSE;
3350+
3351+ if ((s->flags & SEC_LINKER_CREATED) == 0)
3352+ continue;
3353+
3354+ /* It's OK to base decisions on the section name, because none
3355+ of the dynobj section names depend upon the input files. */
3356+ name = bfd_get_section_name (dynobj, s);
3357+
3358+ if (strncmp (name, ".rela", 5) == 0)
3359+ {
3360+ if (s->size == 0)
3361+ {
3362+ /* If we don't need this section, strip it from the
3363+ output file. This is to handle .rela.bss and
3364+ .rela.plt. We must create it in
3365+ create_dynamic_sections, because it must be created
3366+ before the linker maps input sections to output
3367+ sections. The linker does that before
3368+ adjust_dynamic_symbol is called, and it is that
3369+ function which decides whether anything needs to go
3370+ into these sections. */
3371+ strip = TRUE;
3372+ }
3373+ else
3374+ {
3375+ /* We use the reloc_count field as a counter if we need
3376+ to copy relocs into the output file. */
3377+ s->reloc_count = 0;
3378+ }
3379+ }
3380+ else if (s != htab->splt && s != htab->sgot && s != htab->sgotplt)
3381+ {
3382+ /* It's not one of our sections, so don't allocate space. */
3383+ continue;
3384+ }
3385+
3386+ if (strip)
3387+ {
3388+ s->flags |= SEC_EXCLUDE;
3389+ continue;
3390+ }
3391+
3392+ /* Allocate memory for the section contents. */
3393+ /* FIXME: This should be a call to bfd_alloc not bfd_zalloc.
3394+ Unused entries should be reclaimed before the section's contents
3395+ are written out, but at the moment this does not happen. Thus in
3396+ order to prevent writing out garbage, we initialise the section's
3397+ contents to zero. */
3398+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
3399+ if (s->contents == NULL && s->size != 0)
3400+ return FALSE;
3401+ }
3402+
3403+ if (elf_hash_table (info)->dynamic_sections_created)
3404+ {
3405+ /* Add some entries to the .dynamic section. We fill in the
3406+ values later, in microblaze_elf_finish_dynamic_sections, but we
3407+ must add the entries now so that we get the correct size for
3408+ the .dynamic section. The DT_DEBUG entry is filled in by the
3409+ dynamic linker and used by the debugger. */
3410+#define add_dynamic_entry(TAG, VAL) \
3411+ _bfd_elf_add_dynamic_entry (info, TAG, VAL)
3412+
3413+ if (bfd_link_executable (info))
3414+ {
3415+ if (!add_dynamic_entry (DT_DEBUG, 0))
3416+ return FALSE;
3417+ }
3418+
3419+ if (!add_dynamic_entry (DT_RELA, 0)
3420+ || !add_dynamic_entry (DT_RELASZ, 0)
3421+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
3422+ return FALSE;
3423+
3424+ if (htab->splt->size != 0)
3425+ {
3426+ if (!add_dynamic_entry (DT_PLTGOT, 0)
3427+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
3428+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
3429+ || !add_dynamic_entry (DT_JMPREL, 0)
3430+ || !add_dynamic_entry (DT_BIND_NOW, 1))
3431+ return FALSE;
3432+ }
3433+
3434+ if (info->flags & DF_TEXTREL)
3435+ {
3436+ if (!add_dynamic_entry (DT_TEXTREL, 0))
3437+ return FALSE;
3438+ }
3439+ }
3440+#undef add_dynamic_entry
3441+ return TRUE;
3442+}
3443+
3444+/* Finish up dynamic symbol handling. We set the contents of various
3445+ dynamic sections here. */
3446+
3447+static bfd_boolean
3448+microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
3449+ struct bfd_link_info *info,
3450+ struct elf_link_hash_entry *h,
3451+ Elf_Internal_Sym *sym)
3452+{
3453+ struct elf64_mb_link_hash_table *htab;
3454+ struct elf64_mb_link_hash_entry *eh = elf64_mb_hash_entry(h);
3455+
3456+ htab = elf64_mb_hash_table (info);
3457+ if (htab == NULL)
3458+ return FALSE;
3459+
3460+ if (h->plt.offset != (bfd_vma) -1)
3461+ {
3462+ asection *splt;
3463+ asection *srela;
3464+ asection *sgotplt;
3465+ Elf_Internal_Rela rela;
3466+ bfd_byte *loc;
3467+ bfd_vma plt_index;
3468+ bfd_vma got_offset;
3469+ bfd_vma got_addr;
3470+
3471+ /* This symbol has an entry in the procedure linkage table. Set
3472+ it up. */
3473+ BFD_ASSERT (h->dynindx != -1);
3474+
3475+ splt = htab->splt;
3476+ srela = htab->srelplt;
3477+ sgotplt = htab->sgotplt;
3478+ BFD_ASSERT (splt != NULL && srela != NULL && sgotplt != NULL);
3479+
3480+ plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; /* first entry reserved. */
3481+ got_offset = (plt_index + 3) * 4; /* 3 reserved ??? */
3482+ got_addr = got_offset;
3483+
3484+ /* For non-PIC objects we need absolute address of the GOT entry. */
3485+ if (!bfd_link_pic (info))
3486+ got_addr += htab->sgotplt->output_section->vma + sgotplt->output_offset;
3487+
3488+ /* Fill in the entry in the procedure linkage table. */
3489+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_0 + ((got_addr >> 16) & 0xffff),
3490+ splt->contents + h->plt.offset);
3491+ if (bfd_link_pic (info))
3492+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_1 + (got_addr & 0xffff),
3493+ splt->contents + h->plt.offset + 4);
3494+ else
3495+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_1_NOPIC + (got_addr & 0xffff),
3496+ splt->contents + h->plt.offset + 4);
3497+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD_2,
3498+ splt->contents + h->plt.offset + 8);
3499+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD_3,
3500+ splt->contents + h->plt.offset + 12);
3501+
3502+ /* Any additions to the .got section??? */
3503+ /* bfd_put_32 (output_bfd,
3504+ splt->output_section->vma + splt->output_offset + h->plt.offset + 4,
3505+ sgotplt->contents + got_offset); */
3506+
3507+ /* Fill in the entry in the .rela.plt section. */
3508+ rela.r_offset = (sgotplt->output_section->vma
3509+ + sgotplt->output_offset
3510+ + got_offset);
3511+ rela.r_info = ELF64_R_INFO (h->dynindx, R_MICROBLAZE_JUMP_SLOT);
3512+ rela.r_addend = 0;
3513+ loc = srela->contents;
3514+ loc += plt_index * sizeof (Elf64_External_Rela);
3515+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
3516+
3517+ if (!h->def_regular)
3518+ {
3519+ /* Mark the symbol as undefined, rather than as defined in
3520+ the .plt section. Zero the value. */
3521+ sym->st_shndx = SHN_UNDEF;
3522+ sym->st_value = 0;
3523+ }
3524+ }
3525+
3526+ /* h->got.refcount to be checked ? */
3527+ if (h->got.offset != (bfd_vma) -1 &&
3528+ ! ((h->got.offset & 1) ||
3529+ IS_TLS_LD(eh->tls_mask) || IS_TLS_GD(eh->tls_mask)))
3530+ {
3531+ asection *sgot;
3532+ asection *srela;
3533+ bfd_vma offset;
3534+
3535+ /* This symbol has an entry in the global offset table. Set it
3536+ up. */
3537+
3538+ sgot = htab->sgot;
3539+ srela = htab->srelgot;
3540+ BFD_ASSERT (sgot != NULL && srela != NULL);
3541+
3542+ offset = (sgot->output_section->vma + sgot->output_offset
3543+ + (h->got.offset &~ (bfd_vma) 1));
3544+
3545+ /* If this is a -Bsymbolic link, and the symbol is defined
3546+ locally, we just want to emit a RELATIVE reloc. Likewise if
3547+ the symbol was forced to be local because of a version file.
3548+ The entry in the global offset table will already have been
3549+ initialized in the relocate_section function. */
3550+ if (bfd_link_pic (info)
3551+ && ((info->symbolic && h->def_regular)
3552+ || h->dynindx == -1))
3553+ {
3554+ asection *sec = h->root.u.def.section;
3555+ microblaze_elf_output_dynamic_relocation (output_bfd,
3556+ srela, srela->reloc_count++,
3557+ /* symindex= */ 0,
3558+ R_MICROBLAZE_REL, offset,
3559+ h->root.u.def.value
3560+ + sec->output_section->vma
3561+ + sec->output_offset);
3562+ }
3563+ else
3564+ {
3565+ microblaze_elf_output_dynamic_relocation (output_bfd,
3566+ srela, srela->reloc_count++,
3567+ h->dynindx,
3568+ R_MICROBLAZE_GLOB_DAT,
3569+ offset, 0);
3570+ }
3571+
3572+ bfd_put_32 (output_bfd, (bfd_vma) 0,
3573+ sgot->contents + (h->got.offset &~ (bfd_vma) 1));
3574+ }
3575+
3576+ if (h->needs_copy)
3577+ {
3578+ asection *s;
3579+ Elf_Internal_Rela rela;
3580+ bfd_byte *loc;
3581+
3582+ /* This symbols needs a copy reloc. Set it up. */
3583+
3584+ BFD_ASSERT (h->dynindx != -1);
3585+
3586+ s = bfd_get_linker_section (htab->elf.dynobj, ".rela.bss");
3587+ BFD_ASSERT (s != NULL);
3588+
3589+ rela.r_offset = (h->root.u.def.value
3590+ + h->root.u.def.section->output_section->vma
3591+ + h->root.u.def.section->output_offset);
3592+ rela.r_info = ELF64_R_INFO (h->dynindx, R_MICROBLAZE_COPY);
3593+ rela.r_addend = 0;
3594+ loc = s->contents + s->reloc_count++ * sizeof (Elf64_External_Rela);
3595+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
3596+ }
3597+
3598+ /* Mark some specially defined symbols as absolute. */
3599+ if (h == htab->elf.hdynamic
3600+ || h == htab->elf.hgot
3601+ || h == htab->elf.hplt)
3602+ sym->st_shndx = SHN_ABS;
3603+
3604+ return TRUE;
3605+}
3606+
3607+
3608+/* Finish up the dynamic sections. */
3609+
3610+static bfd_boolean
3611+microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
3612+ struct bfd_link_info *info)
3613+{
3614+ bfd *dynobj;
3615+ asection *sdyn, *sgot;
3616+ struct elf64_mb_link_hash_table *htab;
3617+
3618+ htab = elf64_mb_hash_table (info);
3619+ if (htab == NULL)
3620+ return FALSE;
3621+
3622+ dynobj = htab->elf.dynobj;
3623+
3624+ sdyn = bfd_get_linker_section (dynobj, ".dynamic");
3625+
3626+ if (htab->elf.dynamic_sections_created)
3627+ {
3628+ asection *splt;
3629+ Elf64_External_Dyn *dyncon, *dynconend;
3630+
3631+ splt = bfd_get_linker_section (dynobj, ".plt");
3632+ BFD_ASSERT (splt != NULL && sdyn != NULL);
3633+
3634+ dyncon = (Elf64_External_Dyn *) sdyn->contents;
3635+ dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
3636+ for (; dyncon < dynconend; dyncon++)
3637+ {
3638+ Elf_Internal_Dyn dyn;
3639+ const char *name;
3640+ bfd_boolean size;
3641+
3642+ bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
3643+
3644+ switch (dyn.d_tag)
3645+ {
3646+ case DT_PLTGOT: name = ".got.plt"; size = FALSE; break;
3647+ case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break;
3648+ case DT_JMPREL: name = ".rela.plt"; size = FALSE; break;
3649+ case DT_RELA: name = ".rela.dyn"; size = FALSE; break;
3650+ case DT_RELASZ: name = ".rela.dyn"; size = TRUE; break;
3651+ default: name = NULL; size = FALSE; break;
3652+ }
3653+
3654+ if (name != NULL)
3655+ {
3656+ asection *s;
3657+
3658+ s = bfd_get_section_by_name (output_bfd, name);
3659+ if (s == NULL)
3660+ dyn.d_un.d_val = 0;
3661+ else
3662+ {
3663+ if (! size)
3664+ dyn.d_un.d_ptr = s->vma;
3665+ else
3666+ dyn.d_un.d_val = s->size;
3667+ }
3668+ bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
3669+ }
3670+ }
3671+
3672+ /* Clear the first entry in the procedure linkage table,
3673+ and put a nop in the last four bytes. */
3674+ if (splt->size > 0)
3675+ {
3676+ memset (splt->contents, 0, PLT_ENTRY_SIZE);
3677+ bfd_put_32 (output_bfd, (bfd_vma) 0x80000000 /* nop. */,
3678+ splt->contents + splt->size - 4);
3679+ }
3680+
3681+ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
3682+ }
3683+
3684+ /* Set the first entry in the global offset table to the address of
3685+ the dynamic section. */
3686+ sgot = bfd_get_linker_section (dynobj, ".got.plt");
3687+ if (sgot && sgot->size > 0)
3688+ {
3689+ if (sdyn == NULL)
3690+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
3691+ else
3692+ bfd_put_32 (output_bfd,
3693+ sdyn->output_section->vma + sdyn->output_offset,
3694+ sgot->contents);
3695+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
3696+ }
3697+
3698+ if (htab->sgot && htab->sgot->size > 0)
3699+ elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4;
3700+
3701+ return TRUE;
3702+}
3703+
3704+/* Hook called by the linker routine which adds symbols from an object
3705+ file. We use it to put .comm items in .sbss, and not .bss. */
3706+
3707+static bfd_boolean
3708+microblaze_elf_add_symbol_hook (bfd *abfd,
3709+ struct bfd_link_info *info,
3710+ Elf_Internal_Sym *sym,
3711+ const char **namep ATTRIBUTE_UNUSED,
3712+ flagword *flagsp ATTRIBUTE_UNUSED,
3713+ asection **secp,
3714+ bfd_vma *valp)
3715+{
3716+ if (sym->st_shndx == SHN_COMMON
3717+ && !bfd_link_relocatable (info)
3718+ && sym->st_size <= elf_gp_size (abfd))
3719+ {
3720+ /* Common symbols less than or equal to -G nn bytes are automatically
3721+ put into .sbss. */
3722+ *secp = bfd_make_section_old_way (abfd, ".sbss");
3723+ if (*secp == NULL
3724+ || ! bfd_set_section_flags (abfd, *secp, SEC_IS_COMMON))
3725+ return FALSE;
3726+
3727+ *valp = sym->st_size;
3728+ }
3729+
3730+ return TRUE;
3731+}
3732+
3733+#define TARGET_LITTLE_SYM microblaze_elf64_le_vec
3734+#define TARGET_LITTLE_NAME "elf64-microblazeel"
3735+
3736+#define TARGET_BIG_SYM microblaze_elf64_vec
3737+#define TARGET_BIG_NAME "elf64-microblaze"
3738+
3739+#define ELF_ARCH bfd_arch_microblaze
3740+#define ELF_TARGET_ID MICROBLAZE_ELF_DATA
3741+#define ELF_MACHINE_CODE EM_MICROBLAZE
3742+#define ELF_MACHINE_ALT1 EM_MICROBLAZE_OLD
3743+#define ELF_MAXPAGESIZE 0x1000
3744+#define elf_info_to_howto microblaze_elf_info_to_howto
3745+#define elf_info_to_howto_rel NULL
3746+
3747+#define bfd_elf64_bfd_reloc_type_lookup microblaze_elf_reloc_type_lookup
3748+#define bfd_elf64_bfd_is_local_label_name microblaze_elf_is_local_label_name
3749+#define elf_backend_relocate_section microblaze_elf_relocate_section
3750+#define bfd_elf64_bfd_relax_section microblaze_elf_relax_section
3751+#define bfd_elf64_bfd_merge_private_bfd_data microblaze_elf_merge_private_bfd_data
3752+#define bfd_elf64_bfd_reloc_name_lookup microblaze_elf_reloc_name_lookup
3753+
3754+#define elf_backend_gc_mark_hook microblaze_elf_gc_mark_hook
3755+#define elf_backend_gc_sweep_hook microblaze_elf_gc_sweep_hook
3756+#define elf_backend_check_relocs microblaze_elf_check_relocs
3757+#define elf_backend_copy_indirect_symbol microblaze_elf_copy_indirect_symbol
3758+#define bfd_elf64_bfd_link_hash_table_create microblaze_elf_link_hash_table_create
3759+#define elf_backend_can_gc_sections 1
3760+#define elf_backend_can_refcount 1
3761+#define elf_backend_want_got_plt 1
3762+#define elf_backend_plt_readonly 1
3763+#define elf_backend_got_header_size 12
3764+#define elf_backend_rela_normal 1
3765+
3766+#define elf_backend_adjust_dynamic_symbol microblaze_elf_adjust_dynamic_symbol
3767+#define elf_backend_create_dynamic_sections microblaze_elf_create_dynamic_sections
3768+#define elf_backend_finish_dynamic_sections microblaze_elf_finish_dynamic_sections
3769+#define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
3770+#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
3771+#define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
3772+
3773+#include "elf64-target.h"
3774diff --git a/bfd/targets.c b/bfd/targets.c
3775index 158168cb3b..ef567a30c8 100644
3776--- a/bfd/targets.c
3777+++ b/bfd/targets.c
3778@@ -706,6 +706,8 @@ extern const bfd_target mep_elf32_le_vec;
3779 extern const bfd_target metag_elf32_vec;
3780 extern const bfd_target microblaze_elf32_vec;
3781 extern const bfd_target microblaze_elf32_le_vec;
3782+extern const bfd_target microblaze_elf64_vec;
3783+extern const bfd_target microblaze_elf64_le_vec;
3784 extern const bfd_target mips_ecoff_be_vec;
3785 extern const bfd_target mips_ecoff_le_vec;
3786 extern const bfd_target mips_ecoff_bele_vec;
3787@@ -1073,6 +1075,10 @@ static const bfd_target * const _bfd_target_vector[] =
3788
3789 &metag_elf32_vec,
3790
3791+#ifdef BFD64
3792+ &microblaze_elf64_vec,
3793+ &microblaze_elf64_le_vec,
3794+#endif
3795 &microblaze_elf32_vec,
3796
3797 &mips_ecoff_be_vec,
3798diff --git a/include/elf/common.h b/include/elf/common.h
3799index e8faf67be3..ca89da1631 100644
3800--- a/include/elf/common.h
3801+++ b/include/elf/common.h
3802@@ -339,6 +339,7 @@
3803 #define EM_RISCV 243 /* RISC-V */
3804 #define EM_LANAI 244 /* Lanai 32-bit processor. */
3805 #define EM_BPF 247 /* Linux BPF – in-kernel virtual machine. */
3806+#define EM_MB_64 248 /* Xilinx MicroBlaze 32-bit RISC soft processor core */
3807 #define EM_NFP 250 /* Netronome Flow Processor. */
3808 #define EM_CSKY 252 /* C-SKY processor family. */
3809
3810diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
3811index f8aaf27873..20ea6a885a 100644
3812--- a/opcodes/microblaze-dis.c
3813+++ b/opcodes/microblaze-dis.c
3814@@ -33,6 +33,7 @@
3815 #define get_field_r1(instr) get_field (instr, RA_MASK, RA_LOW)
3816 #define get_field_r2(instr) get_field (instr, RB_MASK, RB_LOW)
3817 #define get_int_field_imm(instr) ((instr & IMM_MASK) >> IMM_LOW)
3818+#define get_int_field_imml(instr) ((instr & IMML_MASK) >> IMM_LOW)
3819 #define get_int_field_r1(instr) ((instr & RA_MASK) >> RA_LOW)
3820
3821
3822@@ -56,11 +57,20 @@ get_field_imm (long instr)
3823 }
3824
3825 static char *
3826-get_field_imm5 (long instr)
3827+get_field_imml (long instr)
3828 {
3829 char tmpstr[25];
3830
3831- sprintf (tmpstr, "%d", (short)((instr & IMM5_MASK) >> IMM_LOW));
3832+ sprintf (tmpstr, "%d", (short)((instr & IMML_MASK) >> IMM_LOW));
3833+ return (strdup (tmpstr));
3834+}
3835+
3836+static char *
3837+get_field_imms (long instr)
3838+{
3839+ char tmpstr[25];
3840+
3841+ sprintf (tmpstr, "%d", (short)((instr & IMM6_MASK) >> IMM_LOW));
3842 return (strdup (tmpstr));
3843 }
3844
3845@@ -74,14 +84,14 @@ get_field_imm5_mbar (long instr)
3846 }
3847
3848 static char *
3849-get_field_imm5width (long instr)
3850+get_field_immw (long instr)
3851 {
3852 char tmpstr[25];
3853
3854 if (instr & 0x00004000)
3855- sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW))); /* bsefi */
3856+ sprintf (tmpstr, "%d", (short)(((instr & IMM6_WIDTH_MASK) >> IMM_WIDTH_LOW))); /* bsefi */
3857 else
3858- sprintf (tmpstr, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW) - ((instr & IMM5_MASK) >> IMM_LOW) + 1)); /* bsifi */
3859+ sprintf (tmpstr, "%d", (short)(((instr & IMM6_WIDTH_MASK) >> IMM_WIDTH_LOW) - ((instr & IMM6_MASK) >> IMM_LOW) + 1)); /* bsifi */
3860 return (strdup (tmpstr));
3861 }
3862
3863@@ -286,9 +296,13 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
3864 }
3865 }
3866 break;
3867- case INST_TYPE_RD_R1_IMM5:
3868+ case INST_TYPE_RD_R1_IMML:
3869+ print_func (stream, "\t%s, %s, %s", get_field_rd (inst),
3870+ get_field_r1(inst), get_field_imm (inst));
3871+ /* TODO: Also print symbol */
3872+ case INST_TYPE_RD_R1_IMMS:
3873 print_func (stream, "\t%s, %s, %s", get_field_rd (inst),
3874- get_field_r1(inst), get_field_imm5 (inst));
3875+ get_field_r1(inst), get_field_imms (inst));
3876 break;
3877 case INST_TYPE_RD_RFSL:
3878 print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_rfsl (inst));
3879@@ -386,6 +400,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
3880 }
3881 }
3882 break;
3883+ case INST_TYPE_IMML:
3884+ print_func (stream, "\t%s", get_field_imml (inst));
3885+ /* TODO: Also print symbol */
3886+ break;
3887 case INST_TYPE_RD_R2:
3888 print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_r2 (inst));
3889 break;
3890@@ -409,9 +427,10 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
3891 case INST_TYPE_NONE:
3892 break;
3893 /* For bit field insns. */
3894- case INST_TYPE_RD_R1_IMM5_IMM5:
3895- print_func (stream, "\t%s, %s, %s, %s", get_field_rd (inst),get_field_r1(inst),get_field_imm5width (inst), get_field_imm5 (inst));
3896- break;
3897+ case INST_TYPE_RD_R1_IMMW_IMMS:
3898+ print_func (stream, "\t%s, %s, %s, %s", get_field_rd (inst), get_field_r1(inst),
3899+ get_field_immw (inst), get_field_imms (inst));
3900+ break;
3901 /* For tuqula instruction */
3902 case INST_TYPE_RD:
3903 print_func (stream, "\t%s", get_field_rd (inst));
3904diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
3905index ce8ac351b5..985834b8df 100644
3906--- a/opcodes/microblaze-opc.h
3907+++ b/opcodes/microblaze-opc.h
3908@@ -40,7 +40,7 @@
3909 #define INST_TYPE_RD_SPECIAL 11
3910 #define INST_TYPE_R1 12
3911 /* New instn type for barrel shift imms. */
3912-#define INST_TYPE_RD_R1_IMM5 13
3913+#define INST_TYPE_RD_R1_IMMS 13
3914 #define INST_TYPE_RD_RFSL 14
3915 #define INST_TYPE_R1_RFSL 15
3916
3917@@ -60,7 +60,13 @@
3918 #define INST_TYPE_IMM5 20
3919
3920 /* For bsefi and bsifi */
3921-#define INST_TYPE_RD_R1_IMM5_IMM5 21
3922+#define INST_TYPE_RD_R1_IMMW_IMMS 21
3923+
3924+/* For 64-bit instructions */
3925+#define INST_TYPE_IMML 22
3926+#define INST_TYPE_RD_R1_IMML 23
3927+#define INST_TYPE_R1_IMML 24
3928+#define INST_TYPE_RD_R1_IMMW_IMMS 21
3929
3930 #define INST_TYPE_NONE 25
3931
3932@@ -91,13 +97,14 @@
3933 #define OPCODE_MASK_H24 0xFC1F07FF /* High 6, bits 20-16 and low 11 bits. */
3934 #define OPCODE_MASK_H124 0xFFFF07FF /* High 16, and low 11 bits. */
3935 #define OPCODE_MASK_H1234 0xFFFFFFFF /* All 32 bits. */
3936-#define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22. */
3937-#define OPCODE_MASK_H3B 0xFC00C600 /* High 6 bits and bits 16, 17, 21, 22. */
3938+#define OPCODE_MASK_H3 0xFC000700 /* High 6 bits and bits 21, 22, 23. */
3939+#define OPCODE_MASK_H3B 0xFC00E600 /* High 6 bits and bits 16, 17, 18, 21, 22. */
3940 #define OPCODE_MASK_H32 0xFC00FC00 /* High 6 bits and bit 16-21. */
3941-#define OPCODE_MASK_H32B 0xFC00C000 /* High 6 bits and bit 16, 17. */
3942+#define OPCODE_MASK_H32B 0xFC00E000 /* High 6 bits and bit 16, 17, 18. */
3943 #define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits. */
3944 #define OPCODE_MASK_H35B 0xFC0004FF /* High 6 bits and low 9 bits. */
3945 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
3946+#define OPCODE_MASK_H8 0xFF000000 /* High 8 bits only. */
3947
3948 /* New Mask for msrset, msrclr insns. */
3949 #define OPCODE_MASK_H23N 0xFC1F8000 /* High 6 and bits 11 - 16. */
3950@@ -107,7 +114,7 @@
3951 #define DELAY_SLOT 1
3952 #define NO_DELAY_SLOT 0
3953
3954-#define MAX_OPCODES 301
3955+#define MAX_OPCODES 412
3956
3957 struct op_code_struct
3958 {
3959@@ -125,6 +132,7 @@ struct op_code_struct
3960 /* More info about output format here. */
3961 } opcodes[MAX_OPCODES] =
3962 {
3963+ /* 32-bit instructions */
3964 {"add", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x00000000, OPCODE_MASK_H4, add, arithmetic_inst },
3965 {"rsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H4, rsub, arithmetic_inst },
3966 {"addc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x08000000, OPCODE_MASK_H4, addc, arithmetic_inst },
3967@@ -161,11 +169,11 @@ struct op_code_struct
3968 {"ncget", INST_TYPE_RD_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C006000, OPCODE_MASK_H32, ncget, anyware_inst },
3969 {"ncput", INST_TYPE_R1_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00E000, OPCODE_MASK_H32, ncput, anyware_inst },
3970 {"muli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x60000000, OPCODE_MASK_H, muli, mult_inst },
3971- {"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3, bslli, barrel_shift_inst },
3972- {"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3, bsrai, barrel_shift_inst },
3973- {"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3, bsrli, barrel_shift_inst },
3974- {"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 },
3975- {"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 },
3976+ {"bslli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3B, bslli, barrel_shift_inst },
3977+ {"bsrai", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3B, bsrai, barrel_shift_inst },
3978+ {"bsrli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3B, bsrli, barrel_shift_inst },
3979+ {"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 },
3980+ {"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 },
3981 {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst },
3982 {"and", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000000, OPCODE_MASK_H4, microblaze_and, logical_inst },
3983 {"xor", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000000, OPCODE_MASK_H4, microblaze_xor, logical_inst },
3984@@ -425,6 +433,129 @@ struct op_code_struct
3985 {"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. */
3986 {"swapb", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E0, OPCODE_MASK_H4, swapb, arithmetic_inst },
3987 {"swaph", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900001E2, OPCODE_MASK_H4, swaph, arithmetic_inst },
3988+
3989+ /* 64-bit instructions */
3990+ {"addl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x00000100, OPCODE_MASK_H4, addl, arithmetic_inst },
3991+ {"rsubl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000100, OPCODE_MASK_H4, rsubl, arithmetic_inst },
3992+ {"addlc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x08000100, OPCODE_MASK_H4, addlc, arithmetic_inst },
3993+ {"rsublc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x0C000100, OPCODE_MASK_H4, rsublc, arithmetic_inst },
3994+ {"addlk", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x10000100, OPCODE_MASK_H4, addlk, arithmetic_inst },
3995+ {"rsublk", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000100, OPCODE_MASK_H4, rsublk, arithmetic_inst },
3996+ {"addlkc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x18000100, OPCODE_MASK_H4, addlkc, arithmetic_inst },
3997+ {"rsublkc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x1C000100, OPCODE_MASK_H4, rsublkc, arithmetic_inst },
3998+ {"cmpl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000101, OPCODE_MASK_H4, cmpl, arithmetic_inst },
3999+ {"cmplu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000103, OPCODE_MASK_H4, cmplu, arithmetic_inst },
4000+ {"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 */
4001+ {"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 */
4002+ {"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 */
4003+ {"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 */
4004+ {"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 */
4005+ {"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 */
4006+ {"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 */
4007+ {"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 */
4008+ {"mull", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x40000100, OPCODE_MASK_H4, mull, mult_inst },
4009+ {"bslll", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000500, OPCODE_MASK_H3, bslll, barrel_shift_inst },
4010+ {"bslra", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000300, OPCODE_MASK_H3, bslra, barrel_shift_inst },
4011+ {"bslrl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000100, OPCODE_MASK_H3, bslrl, barrel_shift_inst },
4012+ {"bsllli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64002400, OPCODE_MASK_H3B, bsllli, barrel_shift_inst },
4013+ {"bslrai", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64002200, OPCODE_MASK_H3B, bslrai, barrel_shift_inst },
4014+ {"bslrli", INST_TYPE_RD_R1_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64002000, OPCODE_MASK_H3B, bslrli, barrel_shift_inst },
4015+ {"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 },
4016+ {"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 },
4017+ {"orl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000100, OPCODE_MASK_H4, orl, logical_inst },
4018+ {"andl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000100, OPCODE_MASK_H4, andl, logical_inst },
4019+ {"xorl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000100, OPCODE_MASK_H4, xorl, logical_inst },
4020+ {"andnl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x8C000100, OPCODE_MASK_H4, andnl, logical_inst },
4021+ {"pcmplbf", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000500, OPCODE_MASK_H4, pcmplbf, logical_inst },
4022+ {"pcmpleq", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000500, OPCODE_MASK_H4, pcmpleq, logical_inst },
4023+ {"pcmplne", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x8C000500, OPCODE_MASK_H4, pcmplne, logical_inst },
4024+ {"srla", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000101, OPCODE_MASK_H34, srla, logical_inst },
4025+ {"srlc", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000121, OPCODE_MASK_H34, srlc, logical_inst },
4026+ {"srll", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000141, OPCODE_MASK_H34, srll, logical_inst },
4027+ {"sextl8", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000160, OPCODE_MASK_H34, sextl8, logical_inst },
4028+ {"sextl16", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000161, OPCODE_MASK_H34, sextl16, logical_inst },
4029+ {"sextl32", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000162, OPCODE_MASK_H34, sextl32, logical_inst },
4030+ {"brea", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98010000, OPCODE_MASK_H124, brea, branch_inst },
4031+ {"bread", INST_TYPE_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98110000, OPCODE_MASK_H124, bread, branch_inst },
4032+ {"breald", INST_TYPE_RD_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98150000, OPCODE_MASK_H24, breald, branch_inst },
4033+ {"beaeq", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D000000, OPCODE_MASK_H14, beaeq, branch_inst },
4034+ {"bealeq", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D000100, OPCODE_MASK_H14, bealeq, branch_inst },
4035+ {"beaeqd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F000000, OPCODE_MASK_H14, beaeqd, branch_inst },
4036+ {"bealeqd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F000100, OPCODE_MASK_H14, bealeqd, branch_inst },
4037+ {"beane", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D200000, OPCODE_MASK_H14, beane, branch_inst },
4038+ {"bealne", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D200100, OPCODE_MASK_H14, bealne, branch_inst },
4039+ {"beaned", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F200000, OPCODE_MASK_H14, beaned, branch_inst },
4040+ {"bealned", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F200100, OPCODE_MASK_H14, bealned, branch_inst },
4041+ {"bealt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D400000, OPCODE_MASK_H14, bealt, branch_inst },
4042+ {"beallt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D400100, OPCODE_MASK_H14, beallt, branch_inst },
4043+ {"bealtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F400000, OPCODE_MASK_H14, bealtd, branch_inst },
4044+ {"bealltd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F400100, OPCODE_MASK_H14, bealltd, branch_inst },
4045+ {"beale", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D600000, OPCODE_MASK_H14, beale, branch_inst },
4046+ {"bealle", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D600100, OPCODE_MASK_H14, bealle, branch_inst },
4047+ {"bealed", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F600000, OPCODE_MASK_H14, bealed, branch_inst },
4048+ {"bealled", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F600100, OPCODE_MASK_H14, bealled, branch_inst },
4049+ {"beagt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D800000, OPCODE_MASK_H14, beagt, branch_inst },
4050+ {"bealgt", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9D800100, OPCODE_MASK_H14, bealgt, branch_inst },
4051+ {"beagtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F800000, OPCODE_MASK_H14, beagtd, branch_inst },
4052+ {"bealgtd", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9F800100, OPCODE_MASK_H14, bealgtd, branch_inst },
4053+ {"beage", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9DA00000, OPCODE_MASK_H14, beage, branch_inst },
4054+ {"bealge", INST_TYPE_R1_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9DA00100, OPCODE_MASK_H14, bealge, branch_inst },
4055+ {"beaged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00000, OPCODE_MASK_H14, beaged, branch_inst },
4056+ {"bealged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00100, OPCODE_MASK_H14, bealged, branch_inst },
4057+ {"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 */
4058+ {"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 */
4059+ {"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 */
4060+ {"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 */
4061+ {"imml", INST_TYPE_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB2000000, OPCODE_MASK_H8, imml, immediate_inst },
4062+ {"breai", INST_TYPE_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8010000, OPCODE_MASK_H12, breai, branch_inst },
4063+ {"breaid", INST_TYPE_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8110000, OPCODE_MASK_H12, breaid, branch_inst },
4064+ {"brealid", INST_TYPE_RD_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8150000, OPCODE_MASK_H2, brealid, branch_inst },
4065+ {"beaeqi", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD000000, OPCODE_MASK_H1, beaeqi, branch_inst },
4066+ {"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 */
4067+ {"beaeqid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF000000, OPCODE_MASK_H1, beaeqid, branch_inst },
4068+ {"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 */
4069+ {"beanei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD200000, OPCODE_MASK_H1, beanei, branch_inst },
4070+ {"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 */
4071+ {"beaneid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF200000, OPCODE_MASK_H1, beaneid, branch_inst },
4072+ {"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 */
4073+ {"bealti", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD400000, OPCODE_MASK_H1, bealti, branch_inst },
4074+ {"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 */
4075+ {"bealtid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF400000, OPCODE_MASK_H1, bealtid, branch_inst },
4076+ {"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 */
4077+ {"bealei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD600000, OPCODE_MASK_H1, bealei, branch_inst },
4078+ {"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 */
4079+ {"bealeid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF600000, OPCODE_MASK_H1, bealeid, branch_inst },
4080+ {"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 */
4081+ {"beagti", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBD800000, OPCODE_MASK_H1, beagti, branch_inst },
4082+ {"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 */
4083+ {"beagtid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBF800000, OPCODE_MASK_H1, beagtid, branch_inst },
4084+ {"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 */
4085+ {"beagei", INST_TYPE_R1_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBDA00000, OPCODE_MASK_H1, beagei, branch_inst },
4086+ {"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 */
4087+ {"beageid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBFA00000, OPCODE_MASK_H1, beageid, branch_inst },
4088+ {"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 */
4089+ {"ll", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000100, OPCODE_MASK_H4, ll, memory_load_inst },
4090+ {"llr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000300, OPCODE_MASK_H4, llr, memory_load_inst },
4091+ {"sl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000100, OPCODE_MASK_H4, sl, memory_store_inst },
4092+ {"slr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000300, OPCODE_MASK_H4, slr, memory_store_inst },
4093+ {"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 */
4094+ {"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 */
4095+ {"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 */
4096+ {"dadd", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000400, OPCODE_MASK_H4, dadd, arithmetic_inst },
4097+ {"drsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000480, OPCODE_MASK_H4, drsub, arithmetic_inst },
4098+ {"dmul", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000500, OPCODE_MASK_H4, dmul, arithmetic_inst },
4099+ {"ddiv", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000580, OPCODE_MASK_H4, ddiv, arithmetic_inst },
4100+ {"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 },
4101+ {"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 },
4102+ {"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 },
4103+ {"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 },
4104+ {"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 },
4105+ {"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 },
4106+ {"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 },
4107+ {"dbl", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000680, OPCODE_MASK_H4, dbl, arithmetic_inst },
4108+ {"dlong", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000700, OPCODE_MASK_H4, dlong, arithmetic_inst },
4109+ {"dsqrt", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000780, OPCODE_MASK_H4, dsqrt, arithmetic_inst },
4110+
4111 {"", 0, 0, 0, 0, 0, 0, 0, 0},
4112 };
4113
4114@@ -445,8 +576,17 @@ char pvr_register_prefix[] = "rpvr";
4115 #define MIN_IMM5 ((int) 0x00000000)
4116 #define MAX_IMM5 ((int) 0x0000001f)
4117
4118+#define MIN_IMM6 ((int) 0x00000000)
4119+#define MAX_IMM6 ((int) 0x0000003f)
4120+
4121 #define MIN_IMM_WIDTH ((int) 0x00000001)
4122 #define MAX_IMM_WIDTH ((int) 0x00000020)
4123
4124+#define MIN_IMM6_WIDTH ((int) 0x00000001)
4125+#define MAX_IMM6_WIDTH ((int) 0x00000040)
4126+
4127+#define MIN_IMML ((long) 0xffffff8000000000L)
4128+#define MAX_IMML ((long) 0x0000007fffffffffL)
4129+
4130 #endif /* MICROBLAZE_OPC */
4131
4132diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
4133index 28662694cd..076dbcd0b3 100644
4134--- a/opcodes/microblaze-opcm.h
4135+++ b/opcodes/microblaze-opcm.h
4136@@ -25,6 +25,7 @@
4137
4138 enum microblaze_instr
4139 {
4140+ /* 32-bit instructions */
4141 add, rsub, addc, rsubc, addk, rsubk, addkc, rsubkc, clz, cmp, cmpu,
4142 addi, rsubi, addic, rsubic, addik, rsubik, addikc, rsubikc, mul,
4143 mulh, mulhu, mulhsu,swapb,swaph,
4144@@ -58,6 +59,18 @@ enum microblaze_instr
4145 aputd, taputd, caputd, tcaputd, naputd, tnaputd, ncaputd, tncaputd,
4146 eagetd, teagetd, ecagetd, tecagetd, neagetd, tneagetd, necagetd, tnecagetd,
4147 eaputd, teaputd, ecaputd, tecaputd, neaputd, tneaputd, necaputd, tnecaputd,
4148+
4149+ /* 64-bit instructions */
4150+ addl, rsubl, addlc, rsublc, addlk, rsublk, addlkc, rsublkc, cmpl, cmplu, mull,
4151+ bslll, bslra, bslrl, bsllli, bslrai, bslrli, bslefi, bslifi, orl, andl, xorl,
4152+ andnl, pcmplbf, pcmpleq, pcmplne, srla, srlc, srll, sextl8, sextl16, sextl32,
4153+ brea, bread, breald, beaeq, bealeq, beaeqd, bealeqd, beane, bealne, beaned,
4154+ bealned, bealt, beallt, bealtd, bealltd, beale, bealle, bealed, bealled, beagt,
4155+ bealgt, beagtd, bealgtd, beage, bealge, beaged, bealged, breai, breaid, brealid,
4156+ beaeqi, beaeqid, beanei, beaneid, bealti, bealtid, bealei, bealeid, beagti,
4157+ beagtid, beagei, beageid, imml, ll, llr, sl, slr,
4158+ dadd, drsub, dmul, ddiv, dcmp_lt, dcmp_eq, dcmp_le, dcmp_gt, dcmp_ne, dcmp_ge,
4159+ dcmp_un, dbl, dlong, dsqrt,
4160 invalid_inst
4161 };
4162
4163@@ -135,15 +148,18 @@ enum microblaze_instr_type
4164 #define RA_MASK 0x001F0000
4165 #define RB_MASK 0x0000F800
4166 #define IMM_MASK 0x0000FFFF
4167+#define IMML_MASK 0x00FFFFFF
4168
4169-/* Imm mask for barrel shifts. */
4170+/* Imm masks for barrel shifts. */
4171 #define IMM5_MASK 0x0000001F
4172+#define IMM6_MASK 0x0000003F
4173
4174 /* Imm mask for mbar. */
4175 #define IMM5_MBAR_MASK 0x03E00000
4176
4177-/* Imm mask for extract/insert width. */
4178+/* Imm masks for extract/insert width. */
4179 #define IMM5_WIDTH_MASK 0x000007C0
4180+#define IMM6_WIDTH_MASK 0x00000FC0
4181
4182 /* FSL imm mask for get, put instructions. */
4183 #define RFSL_MASK 0x000000F
4184--
41852.17.1
4186
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0016-MB-X-initial-commit.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0016-MB-X-initial-commit.patch
new file mode 100644
index 00000000..d4441443
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0016-MB-X-initial-commit.patch
@@ -0,0 +1,355 @@
1From 92419bfa472c29b96ff85a9769b9301539867364 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/43] MB-X initial commit code cleanup is needed.
5
6---
7 bfd/bfd-in2.h | 10 +++
8 bfd/elf32-microblaze.c | 65 +++++++++++++++-
9 bfd/elf64-microblaze.c | 61 ++++++++++++++-
10 bfd/libbfd.h | 2 +
11 bfd/reloc.c | 12 +++
12 include/elf/microblaze.h | 2 +
13 opcodes/microblaze-opc.h | 4 +-
14 opcodes/microblaze-opcm.h | 4 +-
15 9 files changed, 277 insertions(+), 35 deletions(-)
16
17diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
18index 721531886a..4f777059d8 100644
19--- a/bfd/bfd-in2.h
20+++ b/bfd/bfd-in2.h
21@@ -5876,11 +5876,21 @@ done here - only used for relaxing */
22 * +done here - only used for relaxing */
23 BFD_RELOC_MICROBLAZE_64_NONE,
24
25+/* This is a 64 bit reloc that stores the 32 bit pc relative
26+ * +value in two words (with an imml instruction). No relocation is
27+ * +done here - only used for relaxing */
28+ BFD_RELOC_MICROBLAZE_64,
29+
30 /* This is a 64 bit reloc that stores the 32 bit pc relative
31 value in two words (with an imm instruction). The relocation is
32 PC-relative GOT offset */
33 BFD_RELOC_MICROBLAZE_64_GOTPC,
34
35+/* This is a 64 bit reloc that stores the 32 bit pc relative
36+value in two words (with an imml instruction). The relocation is
37+PC-relative GOT offset */
38+ BFD_RELOC_MICROBLAZE_64_GPC,
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 GOT offset */
43diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
44index d001437b3f..035e71f311 100644
45--- a/bfd/elf32-microblaze.c
46+++ b/bfd/elf32-microblaze.c
47@@ -116,6 +116,20 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
48 0x0000ffff, /* Dest Mask. */
49 TRUE), /* PC relative offset? */
50
51+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */
52+ 0, /* Rightshift. */
53+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
54+ 16, /* Bitsize. */
55+ TRUE, /* PC_relative. */
56+ 0, /* Bitpos. */
57+ complain_overflow_dont, /* Complain on overflow. */
58+ bfd_elf_generic_reloc,/* Special Function. */
59+ "R_MICROBLAZE_IMML_64", /* Name. */
60+ FALSE, /* Partial Inplace. */
61+ 0, /* Source Mask. */
62+ 0x0000ffff, /* Dest Mask. */
63+ FALSE), /* PC relative offset? */
64+
65 /* A 64 bit relocation. Table entry not really used. */
66 HOWTO (R_MICROBLAZE_64, /* Type. */
67 0, /* Rightshift. */
68@@ -280,6 +294,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
69 0x0000ffff, /* Dest Mask. */
70 TRUE), /* PC relative offset? */
71
72+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
73+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */
74+ 0, /* Rightshift. */
75+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
76+ 16, /* Bitsize. */
77+ TRUE, /* PC_relative. */
78+ 0, /* Bitpos. */
79+ complain_overflow_dont, /* Complain on overflow. */
80+ bfd_elf_generic_reloc, /* Special Function. */
81+ "R_MICROBLAZE_GPC_64", /* Name. */
82+ FALSE, /* Partial Inplace. */
83+ 0, /* Source Mask. */
84+ 0x0000ffff, /* Dest Mask. */
85+ TRUE), /* PC relative offset? */
86+
87 /* A 64 bit GOT relocation. Table-entry not really used. */
88 HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
89 0, /* Rightshift. */
90@@ -619,9 +648,15 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
91 case BFD_RELOC_VTABLE_ENTRY:
92 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
93 break;
94+ case BFD_RELOC_MICROBLAZE_64:
95+ microblaze_reloc = R_MICROBLAZE_IMML_64;
96+ break;
97 case BFD_RELOC_MICROBLAZE_64_GOTPC:
98 microblaze_reloc = R_MICROBLAZE_GOTPC_64;
99 break;
100+ case BFD_RELOC_MICROBLAZE_64_GPC:
101+ microblaze_reloc = R_MICROBLAZE_GPC_64;
102+ break;
103 case BFD_RELOC_MICROBLAZE_64_GOT:
104 microblaze_reloc = R_MICROBLAZE_GOT_64;
105 break;
106@@ -1467,7 +1502,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
107 if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
108 {
109 relocation += addend;
110- if (r_type == R_MICROBLAZE_32)
111+ if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
112 bfd_put_32 (input_bfd, relocation, contents + offset);
113 else
114 {
115@@ -1933,6 +1968,28 @@ microblaze_elf_relax_section (bfd *abfd,
116 irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
117 }
118 break;
119+ case R_MICROBLAZE_IMML_64:
120+ {
121+ /* This was a PC-relative instruction that was
122+ completely resolved. */
123+ int sfix, efix;
124+ unsigned int val;
125+ bfd_vma target_address;
126+ target_address = irel->r_addend + irel->r_offset;
127+ sfix = calc_fixup (irel->r_offset, 0, sec);
128+ efix = calc_fixup (target_address, 0, sec);
129+
130+ /* Validate the in-band val. */
131+ val = bfd_get_32 (abfd, contents + irel->r_offset);
132+ if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
133+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
134+ }
135+ irel->r_addend -= (efix - sfix);
136+ /* Should use HOWTO. */
137+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
138+ irel->r_addend);
139+ }
140+ break;
141 case R_MICROBLAZE_NONE:
142 case R_MICROBLAZE_32_NONE:
143 {
144@@ -2037,9 +2094,9 @@ microblaze_elf_relax_section (bfd *abfd,
145 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
146 irelscan->r_addend);
147 }
148- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
149- {
150- isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
151+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)// || ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64)
152+ {
153+ isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
154
155 /* Look at the reloc only if the value has been resolved. */
156 if (isym->st_shndx == shndx
157diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
158index 0f43ae6ea8..56a45f2a05 100644
159--- a/bfd/elf64-microblaze.c
160+++ b/bfd/elf64-microblaze.c
161@@ -116,6 +116,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
162 0x0000ffff, /* Dest Mask. */
163 TRUE), /* PC relative offset? */
164
165+ /* A 64 bit relocation. Table entry not really used. */
166+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */
167+ 0, /* Rightshift. */
168+ 4, /* Size (0 = byte, 1 = short, 2 = long). */
169+ 64, /* Bitsize. */
170+ TRUE, /* PC_relative. */
171+ 0, /* Bitpos. */
172+ complain_overflow_dont, /* Complain on overflow. */
173+ bfd_elf_generic_reloc,/* Special Function. */
174+ "R_MICROBLAZE_IMML_64", /* Name. */
175+ FALSE, /* Partial Inplace. */
176+ 0, /* Source Mask. */
177+ 0x0000ffff, /* Dest Mask. */
178+ TRUE), /* PC relative offset? */
179+
180 /* A 64 bit relocation. Table entry not really used. */
181 HOWTO (R_MICROBLAZE_64, /* Type. */
182 0, /* Rightshift. */
183@@ -265,6 +280,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
184 0x0000ffff, /* Dest Mask. */
185 TRUE), /* PC relative offset? */
186
187+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
188+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */
189+ 0, /* Rightshift. */
190+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
191+ 16, /* Bitsize. */
192+ TRUE, /* PC_relative. */
193+ 0, /* Bitpos. */
194+ complain_overflow_dont, /* Complain on overflow. */
195+ bfd_elf_generic_reloc, /* Special Function. */
196+ "R_MICROBLAZE_GPC_64", /* Name. */
197+ FALSE, /* Partial Inplace. */
198+ 0, /* Source Mask. */
199+ 0x0000ffff, /* Dest Mask. */
200+ TRUE), /* PC relative offset? */
201+
202 /* A 64 bit GOT relocation. Table-entry not really used. */
203 HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
204 0, /* Rightshift. */
205@@ -589,9 +619,15 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
206 case BFD_RELOC_VTABLE_ENTRY:
207 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
208 break;
209+ case BFD_RELOC_MICROBLAZE_64:
210+ microblaze_reloc = R_MICROBLAZE_IMML_64;
211+ break;
212 case BFD_RELOC_MICROBLAZE_64_GOTPC:
213 microblaze_reloc = R_MICROBLAZE_GOTPC_64;
214 break;
215+ case BFD_RELOC_MICROBLAZE_64_GPC:
216+ microblaze_reloc = R_MICROBLAZE_GPC_64;
217+ break;
218 case BFD_RELOC_MICROBLAZE_64_GOT:
219 microblaze_reloc = R_MICROBLAZE_GOT_64;
220 break;
221@@ -1161,6 +1197,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
222 break; /* Do nothing. */
223
224 case (int) R_MICROBLAZE_GOTPC_64:
225+ case (int) R_MICROBLAZE_GPC_64:
226 relocation = htab->sgotplt->output_section->vma
227 + htab->sgotplt->output_offset;
228 relocation -= (input_section->output_section->vma
229@@ -1431,7 +1468,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
230 if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
231 {
232 relocation += addend;
233- if (r_type == R_MICROBLAZE_32)
234+ if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
235 bfd_put_32 (input_bfd, relocation, contents + offset);
236 else
237 {
238@@ -1876,6 +1913,28 @@ microblaze_elf_relax_section (bfd *abfd,
239 irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
240 }
241 break;
242+ case R_MICROBLAZE_IMML_64:
243+ {
244+ /* This was a PC-relative instruction that was
245+ completely resolved. */
246+ int sfix, efix;
247+ unsigned int val;
248+ bfd_vma target_address;
249+ target_address = irel->r_addend + irel->r_offset;
250+ sfix = calc_fixup (irel->r_offset, 0, sec);
251+ efix = calc_fixup (target_address, 0, sec);
252+
253+ /* Validate the in-band val. */
254+ val = bfd_get_32 (abfd, contents + irel->r_offset);
255+ if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
256+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
257+ }
258+ irel->r_addend -= (efix - sfix);
259+ /* Should use HOWTO. */
260+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
261+ irel->r_addend);
262+ }
263+ break;
264 case R_MICROBLAZE_NONE:
265 case R_MICROBLAZE_32_NONE:
266 {
267diff --git a/bfd/libbfd.h b/bfd/libbfd.h
268index feb9fada1e..450653f2d8 100644
269--- a/bfd/libbfd.h
270+++ b/bfd/libbfd.h
271@@ -2903,7 +2903,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
272 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
273 "BFD_RELOC_MICROBLAZE_32_NONE",
274 "BFD_RELOC_MICROBLAZE_64_NONE",
275+ "BFD_RELOC_MICROBLAZE_64",
276 "BFD_RELOC_MICROBLAZE_64_GOTPC",
277+ "BFD_RELOC_MICROBLAZE_64_GPC",
278 "BFD_RELOC_MICROBLAZE_64_GOT",
279 "BFD_RELOC_MICROBLAZE_64_PLT",
280 "BFD_RELOC_MICROBLAZE_64_GOTOFF",
281diff --git a/bfd/reloc.c b/bfd/reloc.c
282index 87753ae4f0..ccf29f54cf 100644
283--- a/bfd/reloc.c
284+++ b/bfd/reloc.c
285@@ -6803,12 +6803,24 @@ ENUMDOC
286 done here - only used for relaxing
287 ENUM
288 BFD_RELOC_MICROBLAZE_64_NONE
289+ENUMDOC
290+ This is a 32 bit reloc that stores the 32 bit pc relative
291+ value in two words (with an imml instruction). No relocation is
292+ done here - only used for relaxing
293+ENUM
294+ BFD_RELOC_MICROBLAZE_64
295 ENUMDOC
296 This is a 64 bit reloc that stores the 32 bit pc relative
297 value in two words (with an imm instruction). No relocation is
298 done here - only used for relaxing
299 ENUM
300 BFD_RELOC_MICROBLAZE_64_GOTPC
301+ENUMDOC
302+ This is a 64 bit reloc that stores the 32 bit pc relative
303+ value in two words (with an imml instruction). No relocation is
304+ done here - only used for relaxing
305+ENUM
306+ BFD_RELOC_MICROBLAZE_64_GPC
307 ENUMDOC
308 This is a 64 bit reloc that stores the 32 bit pc relative
309 value in two words (with an imm instruction). The relocation is
310diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h
311index 6ee0966444..16b2736577 100644
312--- a/include/elf/microblaze.h
313+++ b/include/elf/microblaze.h
314@@ -62,6 +62,8 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type)
315 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_64, 31) /* TEXT Entry offset 64-bit. */
316 RELOC_NUMBER (R_MICROBLAZE_TEXTREL_32_LO, 32) /* TEXT Entry offset 32-bit. */
317 RELOC_NUMBER (R_MICROBLAZE_32_NONE, 33)
318+ RELOC_NUMBER (R_MICROBLAZE_IMML_64, 34)
319+ RELOC_NUMBER (R_MICROBLAZE_GPC_64, 35) /* GOT entry offset. */
320
321 END_RELOC_NUMBERS (R_MICROBLAZE_max)
322
323diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
324index 985834b8df..9b6264b61c 100644
325--- a/opcodes/microblaze-opc.h
326+++ b/opcodes/microblaze-opc.h
327@@ -538,8 +538,8 @@ struct op_code_struct
328 {"llr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC8000300, OPCODE_MASK_H4, llr, memory_load_inst },
329 {"sl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000100, OPCODE_MASK_H4, sl, memory_store_inst },
330 {"slr", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xD8000300, OPCODE_MASK_H4, slr, memory_store_inst },
331- {"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 */
332- {"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 */
333+ {"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 */
334+ {"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 */
335 {"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 */
336 {"dadd", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000400, OPCODE_MASK_H4, dadd, arithmetic_inst },
337 {"drsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000480, OPCODE_MASK_H4, drsub, arithmetic_inst },
338diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
339index 076dbcd0b3..5f2e190d23 100644
340--- a/opcodes/microblaze-opcm.h
341+++ b/opcodes/microblaze-opcm.h
342@@ -40,8 +40,8 @@ enum microblaze_instr
343 imm, rtsd, rtid, rtbd, rted, bri, brid, brlid, brai, braid, bralid,
344 brki, beqi, beqid, bnei, bneid, blti, bltid, blei, bleid, bgti,
345 bgtid, bgei, bgeid, lbu, lbuea, lbur, lhu, lhuea, lhur, lw, lwea, lwr, lwx,
346- sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi,
347- sbi, shi, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv,
348+ sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi, lli,
349+ sbi, shi, sli, swi, msrset, msrclr, tuqula, fadd, frsub, fmul, fdiv,
350 fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, flt,
351 fint, fsqrt,
352 tget, tcget, tnget, tncget, tput, tcput, tnput, tncput,
353--
3542.17.1
355
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch
new file mode 100644
index 00000000..26938396
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0017-Patch-Microblaze-negl-instruction-is-overriding-rsub.patch
@@ -0,0 +1,36 @@
1From 4010e83aa48f0415e4478d70871aa87cb204d350 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/43] [Patch,Microblaze] : negl instruction is overriding
5 rsubl,fixed it by changing the instruction order...
6
7---
8 opcodes/microblaze-opc.h | 4 ++--
9 1 file changed, 2 insertions(+), 2 deletions(-)
10
11diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
12index 9b6264b61c..824afc0ab0 100644
13--- a/opcodes/microblaze-opc.h
14+++ b/opcodes/microblaze-opc.h
15@@ -275,9 +275,7 @@ struct op_code_struct
16 {"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. */
17 {"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. */
18 {"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. */
19- {"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. */
20 {"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. */
21- {"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. */
22 {"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 },
23 {"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 },
24 {"msrset",INST_TYPE_RD_IMM15, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x94100000, OPCODE_MASK_H23N, msrset, special_inst },
25@@ -555,6 +553,8 @@ struct op_code_struct
26 {"dbl", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000680, OPCODE_MASK_H4, dbl, arithmetic_inst },
27 {"dlong", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000700, OPCODE_MASK_H4, dlong, arithmetic_inst },
28 {"dsqrt", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x58000780, OPCODE_MASK_H4, dsqrt, arithmetic_inst },
29+ {"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. */
30+ {"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. */
31
32 {"", 0, 0, 0, 0, 0, 0, 0, 0},
33 };
34--
352.17.1
36
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0018-Added-relocations-for-MB-X.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0018-Added-relocations-for-MB-X.patch
new file mode 100644
index 00000000..93ec10fd
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0018-Added-relocations-for-MB-X.patch
@@ -0,0 +1,113 @@
1From b625d19f8b86dd81c32f21793cc3e038ca275e57 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/43] Added relocations for MB-X
5
6---
7 bfd/bfd-in2.h | 11 +++--
8 bfd/libbfd.h | 4 +-
9 bfd/reloc.c | 26 ++++++-----
10 4 files changed, 62 insertions(+), 69 deletions(-)
11
12diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
13index 4f777059d8..de46e78902 100644
14--- a/bfd/bfd-in2.h
15+++ b/bfd/bfd-in2.h
16@@ -5872,15 +5872,20 @@ done here - only used for relaxing */
17 BFD_RELOC_MICROBLAZE_32_NONE,
18
19 /* This is a 64 bit reloc that stores the 32 bit pc relative
20- * +value in two words (with an imm instruction). No relocation is
21+ * +value in two words (with an imml instruction). No relocation is
22 * +done here - only used for relaxing */
23- BFD_RELOC_MICROBLAZE_64_NONE,
24+ BFD_RELOC_MICROBLAZE_64_PCREL,
25
26-/* This is a 64 bit reloc that stores the 32 bit pc relative
27+/* This is a 64 bit reloc that stores the 32 bit 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). No relocation is
34+ * +done here - only used for relaxing */
35+ BFD_RELOC_MICROBLAZE_64_NONE,
36+
37 /* This is a 64 bit reloc that stores the 32 bit pc relative
38 value in two words (with an imm instruction). The relocation is
39 PC-relative GOT offset */
40diff --git a/bfd/libbfd.h b/bfd/libbfd.h
41index 450653f2d8..d87a183d5e 100644
42--- a/bfd/libbfd.h
43+++ b/bfd/libbfd.h
44@@ -2903,14 +2903,14 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
45 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
46 "BFD_RELOC_MICROBLAZE_32_NONE",
47 "BFD_RELOC_MICROBLAZE_64_NONE",
48- "BFD_RELOC_MICROBLAZE_64",
49 "BFD_RELOC_MICROBLAZE_64_GOTPC",
50- "BFD_RELOC_MICROBLAZE_64_GPC",
51 "BFD_RELOC_MICROBLAZE_64_GOT",
52 "BFD_RELOC_MICROBLAZE_64_PLT",
53 "BFD_RELOC_MICROBLAZE_64_GOTOFF",
54 "BFD_RELOC_MICROBLAZE_32_GOTOFF",
55 "BFD_RELOC_MICROBLAZE_COPY",
56+ "BFD_RELOC_MICROBLAZE_64",
57+ "BFD_RELOC_MICROBLAZE_64_PCREL",
58 "BFD_RELOC_MICROBLAZE_64_TLS",
59 "BFD_RELOC_MICROBLAZE_64_TLSGD",
60 "BFD_RELOC_MICROBLAZE_64_TLSLD",
61diff --git a/bfd/reloc.c b/bfd/reloc.c
62index ccf29f54cf..861f2d48c0 100644
63--- a/bfd/reloc.c
64+++ b/bfd/reloc.c
65@@ -6803,24 +6803,12 @@ ENUMDOC
66 done here - only used for relaxing
67 ENUM
68 BFD_RELOC_MICROBLAZE_64_NONE
69-ENUMDOC
70- This is a 32 bit reloc that stores the 32 bit pc relative
71- value in two words (with an imml instruction). No relocation is
72- done here - only used for relaxing
73-ENUM
74- BFD_RELOC_MICROBLAZE_64
75 ENUMDOC
76 This is a 64 bit reloc that stores the 32 bit pc relative
77 value in two words (with an imm instruction). No relocation is
78 done here - only used for relaxing
79 ENUM
80 BFD_RELOC_MICROBLAZE_64_GOTPC
81-ENUMDOC
82- This is a 64 bit reloc that stores the 32 bit pc relative
83- value in two words (with an imml instruction). No relocation is
84- done here - only used for relaxing
85-ENUM
86- BFD_RELOC_MICROBLAZE_64_GPC
87 ENUMDOC
88 This is a 64 bit reloc that stores the 32 bit pc relative
89 value in two words (with an imm instruction). The relocation is
90@@ -6906,6 +6894,20 @@ ENUMDOC
91 value in two words (with an imm instruction). The relocation is
92 relative offset from start of TEXT.
93
94+ This is a 64 bit reloc that stores 64-bit thread pointer relative offset
95+ to two words (uses imml instruction).
96+ENUM
97+BFD_RELOC_MICROBLAZE_64,
98+ENUMDOC
99+ This is a 64 bit reloc that stores the 64 bit pc relative
100+ value in two words (with an imml instruction). No relocation is
101+ done here - only used for relaxing
102+ENUM
103+BFD_RELOC_MICROBLAZE_64_PCREL,
104+ENUMDOC
105+ This is a 32 bit reloc that stores the 32 bit pc relative
106+ value in two words (with an imml instruction). No relocation is
107+ done here - only used for relaxing
108 ENUM
109 BFD_RELOC_AARCH64_RELOC_START
110 ENUMDOC
111--
1122.17.1
113
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0019-Fixed-MB-x-relocation-issues.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0019-Fixed-MB-x-relocation-issues.patch
new file mode 100644
index 00000000..4a35a597
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0019-Fixed-MB-x-relocation-issues.patch
@@ -0,0 +1,115 @@
1From f190b9380c325b48697755328f4193791a758e55 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/43] -Fixed MB-x relocation issues -Added imml for required
5 MB-x instructions
6
7---
8 bfd/elf64-microblaze.c | 68 ++++++++++++++---
9 3 files changed, 167 insertions(+), 55 deletions(-)
10
11diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
12index 56a45f2a05..54a2461037 100644
13--- a/bfd/elf64-microblaze.c
14+++ b/bfd/elf64-microblaze.c
15@@ -1476,8 +1476,17 @@ microblaze_elf_relocate_section (bfd *output_bfd,
16 relocation -= (input_section->output_section->vma
17 + input_section->output_offset
18 + offset + INST_WORD_SIZE);
19- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
20+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
21+ if (insn == 0xb2000000 || insn == 0xb2ffffff)
22+ {
23+ insn &= ~0x00ffffff;
24+ insn |= (relocation >> 16) & 0xffffff;
25+ bfd_put_32 (input_bfd, insn,
26 contents + offset + endian);
27+ }
28+ else
29+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
30+ contents + offset + endian);
31 bfd_put_16 (input_bfd, relocation & 0xffff,
32 contents + offset + endian + INST_WORD_SIZE);
33 }
34@@ -1567,11 +1576,28 @@ microblaze_elf_relocate_section (bfd *output_bfd,
35 else
36 {
37 if (r_type == R_MICROBLAZE_64_PCREL)
38- relocation -= (input_section->output_section->vma
39- + input_section->output_offset
40- + offset + INST_WORD_SIZE);
41- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
42+ {
43+ if (!input_section->output_section->vma &&
44+ !input_section->output_offset && !offset)
45+ relocation -= (input_section->output_section->vma
46+ + input_section->output_offset
47+ + offset);
48+ else
49+ relocation -= (input_section->output_section->vma
50+ + input_section->output_offset
51+ + offset + INST_WORD_SIZE);
52+ }
53+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
54+ if (insn == 0xb2000000 || insn == 0xb2ffffff)
55+ {
56+ insn &= ~0x00ffffff;
57+ insn |= (relocation >> 16) & 0xffffff;
58+ bfd_put_32 (input_bfd, insn,
59 contents + offset + endian);
60+ }
61+ else
62+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
63+ contents + offset + endian);
64 bfd_put_16 (input_bfd, relocation & 0xffff,
65 contents + offset + endian + INST_WORD_SIZE);
66 }
67@@ -1690,9 +1716,19 @@ static void
68 microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
69 {
70 unsigned long instr = bfd_get_32 (abfd, bfd_addr);
71- instr &= ~0x0000ffff;
72- instr |= (val & 0x0000ffff);
73- bfd_put_32 (abfd, instr, bfd_addr);
74+
75+ if (instr == 0xb2000000 || instr == 0xb2ffffff)
76+ {
77+ instr &= ~0x00ffffff;
78+ instr |= (val & 0xffffff);
79+ bfd_put_32 (abfd, instr, bfd_addr);
80+ }
81+ else
82+ {
83+ instr &= ~0x0000ffff;
84+ instr |= (val & 0x0000ffff);
85+ bfd_put_32 (abfd, instr, bfd_addr);
86+ }
87 }
88
89 /* Read-modify-write into the bfd, an immediate value into appropriate fields of
90@@ -1704,10 +1740,18 @@ microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
91 unsigned long instr_lo;
92
93 instr_hi = bfd_get_32 (abfd, bfd_addr);
94- instr_hi &= ~0x0000ffff;
95- instr_hi |= ((val >> 16) & 0x0000ffff);
96- bfd_put_32 (abfd, instr_hi, bfd_addr);
97-
98+ if (instr_hi == 0xb2000000 || instr_hi == 0xb2ffffff)
99+ {
100+ instr_hi &= ~0x00ffffff;
101+ instr_hi |= (val >> 16) & 0xffffff;
102+ bfd_put_32 (abfd, instr_hi,bfd_addr);
103+ }
104+ else
105+ {
106+ instr_hi &= ~0x0000ffff;
107+ instr_hi |= ((val >> 16) & 0x0000ffff);
108+ bfd_put_32 (abfd, instr_hi, bfd_addr);
109+ }
110 instr_lo = bfd_get_32 (abfd, bfd_addr + INST_WORD_SIZE);
111 instr_lo &= ~0x0000ffff;
112 instr_lo |= (val & 0x0000ffff);
113--
1142.17.1
115
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0020-Fixing-the-branch-related-issues.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0020-Fixing-the-branch-related-issues.patch
new file mode 100644
index 00000000..2e790dc1
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0020-Fixing-the-branch-related-issues.patch
@@ -0,0 +1,25 @@
1From 534688ca48be148ade9bb1daf77c41c4b221ac0e 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/43] Fixing the branch related issues
5
6---
7 bfd/elf64-microblaze.c | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-)
9
10diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
11index 54a2461037..e9b3cf3a86 100644
12--- a/bfd/elf64-microblaze.c
13+++ b/bfd/elf64-microblaze.c
14@@ -2532,7 +2532,7 @@ microblaze_elf_check_relocs (bfd * abfd,
15
16 /* PR15323, ref flags aren't set for references in the same
17 object. */
18- h->root.non_ir_ref = 1;
19+ h->root.non_ir_ref_regular = 1;
20 }
21
22 switch (r_type)
23--
242.17.1
25
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0021-Fixed-address-computation-issues-with-64bit-address.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0021-Fixed-address-computation-issues-with-64bit-address.patch
new file mode 100644
index 00000000..dffdbd3a
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0021-Fixed-address-computation-issues-with-64bit-address.patch
@@ -0,0 +1,97 @@
1From a19471b62a23803a062693a61c783efc05e2cd33 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/43] - Fixed address computation issues with 64bit address -
5 Fixed imml dissassamble issue
6
7---
8 bfd/bfd-in2.h | 5 +++
9 bfd/elf64-microblaze.c | 14 ++++----
10 opcodes/microblaze-dis.c | 2 +-
11 4 files changed, 79 insertions(+), 16 deletions(-)
12
13diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
14index de46e78902..33c9cb62d9 100644
15--- a/bfd/bfd-in2.h
16+++ b/bfd/bfd-in2.h
17@@ -5881,6 +5881,11 @@ done here - only used for relaxing */
18 * +done here - only used for relaxing */
19 BFD_RELOC_MICROBLAZE_64,
20
21+/* This is a 64 bit reloc that stores the 32 bit relative
22+ * +value in two words (with an imml instruction). No relocation is
23+ * +done here - only used for relaxing */
24+ BFD_RELOC_MICROBLAZE_EA64,
25+
26 /* This is a 64 bit reloc that stores the 32 bit pc relative
27 * +value in two words (with an imm instruction). No relocation is
28 * +done here - only used for relaxing */
29diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
30index e9b3cf3a86..40f10aac6d 100644
31--- a/bfd/elf64-microblaze.c
32+++ b/bfd/elf64-microblaze.c
33@@ -121,15 +121,15 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
34 0, /* Rightshift. */
35 4, /* Size (0 = byte, 1 = short, 2 = long). */
36 64, /* Bitsize. */
37- TRUE, /* PC_relative. */
38+ FALSE, /* PC_relative. */
39 0, /* Bitpos. */
40 complain_overflow_dont, /* Complain on overflow. */
41 bfd_elf_generic_reloc,/* Special Function. */
42 "R_MICROBLAZE_IMML_64", /* Name. */
43 FALSE, /* Partial Inplace. */
44 0, /* Source Mask. */
45- 0x0000ffff, /* Dest Mask. */
46- TRUE), /* PC relative offset? */
47+ 0xffffffffffffff, /* Dest Mask. */
48+ FALSE), /* PC relative offset? */
49
50 /* A 64 bit relocation. Table entry not really used. */
51 HOWTO (R_MICROBLAZE_64, /* Type. */
52@@ -585,9 +585,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
53 case BFD_RELOC_32:
54 microblaze_reloc = R_MICROBLAZE_32;
55 break;
56- /* RVA is treated the same as 32 */
57+ /* RVA is treated the same as 64 */
58 case BFD_RELOC_RVA:
59- microblaze_reloc = R_MICROBLAZE_32;
60+ microblaze_reloc = R_MICROBLAZE_IMML_64;
61 break;
62 case BFD_RELOC_32_PCREL:
63 microblaze_reloc = R_MICROBLAZE_32_PCREL;
64@@ -619,7 +619,7 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
65 case BFD_RELOC_VTABLE_ENTRY:
66 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
67 break;
68- case BFD_RELOC_MICROBLAZE_64:
69+ case BFD_RELOC_MICROBLAZE_EA64:
70 microblaze_reloc = R_MICROBLAZE_IMML_64;
71 break;
72 case BFD_RELOC_MICROBLAZE_64_GOTPC:
73@@ -1969,7 +1969,7 @@ microblaze_elf_relax_section (bfd *abfd,
74 efix = calc_fixup (target_address, 0, sec);
75
76 /* Validate the in-band val. */
77- val = bfd_get_32 (abfd, contents + irel->r_offset);
78+ val = bfd_get_64 (abfd, contents + irel->r_offset);
79 if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
80 fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
81 }
82diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
83index 20ea6a885a..f679a43606 100644
84--- a/opcodes/microblaze-dis.c
85+++ b/opcodes/microblaze-dis.c
86@@ -61,7 +61,7 @@ get_field_imml (long instr)
87 {
88 char tmpstr[25];
89
90- sprintf (tmpstr, "%d", (short)((instr & IMML_MASK) >> IMM_LOW));
91+ sprintf (tmpstr, "%d", (int)((instr & IMML_MASK) >> IMM_LOW));
92 return (strdup (tmpstr));
93 }
94
95--
962.17.1
97
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0022-Adding-new-relocation-to-support-64bit-rodata.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0022-Adding-new-relocation-to-support-64bit-rodata.patch
new file mode 100644
index 00000000..e79b6626
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0022-Adding-new-relocation-to-support-64bit-rodata.patch
@@ -0,0 +1,69 @@
1From 2aa455f838644cd804ec93aeea0d30bb265e91df 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/43] Adding new relocation to support 64bit rodata
5
6---
7 bfd/elf64-microblaze.c | 11 +++++++--
8 2 files changed, 54 insertions(+), 6 deletions(-)
9
10diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
11index 40f10aac6d..4d9b90647f 100644
12--- a/bfd/elf64-microblaze.c
13+++ b/bfd/elf64-microblaze.c
14@@ -1461,6 +1461,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
15 case (int) R_MICROBLAZE_64_PCREL :
16 case (int) R_MICROBLAZE_64:
17 case (int) R_MICROBLAZE_32:
18+ case (int) R_MICROBLAZE_IMML_64:
19 {
20 /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
21 from removed linkonce sections, or sections discarded by
22@@ -1470,6 +1471,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
23 relocation += addend;
24 if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
25 bfd_put_32 (input_bfd, relocation, contents + offset);
26+ else if (r_type == R_MICROBLAZE_IMML_64)
27+ bfd_put_64 (input_bfd, relocation, contents + offset);
28 else
29 {
30 if (r_type == R_MICROBLAZE_64_PCREL)
31@@ -1547,7 +1550,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
32 }
33 else
34 {
35- if (r_type == R_MICROBLAZE_32)
36+ if (r_type == R_MICROBLAZE_32 || r_type == R_MICROBLAZE_IMML_64)
37 {
38 outrel.r_info = ELF64_R_INFO (0, R_MICROBLAZE_REL);
39 outrel.r_addend = relocation + addend;
40@@ -1573,6 +1576,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
41 relocation += addend;
42 if (r_type == R_MICROBLAZE_32)
43 bfd_put_32 (input_bfd, relocation, contents + offset);
44+ else if (r_type == R_MICROBLAZE_IMML_64)
45+ bfd_put_64 (input_bfd, relocation, contents + offset + endian);
46 else
47 {
48 if (r_type == R_MICROBLAZE_64_PCREL)
49@@ -2085,7 +2090,8 @@ microblaze_elf_relax_section (bfd *abfd,
50 microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
51 irelscan->r_addend);
52 }
53- if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
54+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32
55+ || ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64)
56 {
57 isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
58
59@@ -2591,6 +2597,7 @@ microblaze_elf_check_relocs (bfd * abfd,
60 case R_MICROBLAZE_64:
61 case R_MICROBLAZE_64_PCREL:
62 case R_MICROBLAZE_32:
63+ case R_MICROBLAZE_IMML_64:
64 {
65 if (h != NULL && !bfd_link_pic (info))
66 {
67--
682.17.1
69
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0023-fixing-the-.bss-relocation-issue.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0023-fixing-the-.bss-relocation-issue.patch
new file mode 100644
index 00000000..2458df6c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0023-fixing-the-.bss-relocation-issue.patch
@@ -0,0 +1,76 @@
1From 3240839197b1c42b3cd6e77c5b3b47aa7a1378a4 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/43] fixing the .bss relocation issue
5
6---
7 bfd/elf64-microblaze.c | 18 ++++++++++++------
8 1 file changed, 12 insertions(+), 6 deletions(-)
9
10diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
11index 4d9b90647f..184b7d560d 100644
12--- a/bfd/elf64-microblaze.c
13+++ b/bfd/elf64-microblaze.c
14@@ -1480,7 +1480,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
15 + input_section->output_offset
16 + offset + INST_WORD_SIZE);
17 unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
18- if (insn == 0xb2000000 || insn == 0xb2ffffff)
19+ if ((insn & 0xff000000) == 0xb2000000)
20 {
21 insn &= ~0x00ffffff;
22 insn |= (relocation >> 16) & 0xffffff;
23@@ -1593,7 +1593,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
24 + offset + INST_WORD_SIZE);
25 }
26 unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
27- if (insn == 0xb2000000 || insn == 0xb2ffffff)
28+ if ((insn & 0xff000000) == 0xb2000000)
29 {
30 insn &= ~0x00ffffff;
31 insn |= (relocation >> 16) & 0xffffff;
32@@ -1722,7 +1722,7 @@ microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
33 {
34 unsigned long instr = bfd_get_32 (abfd, bfd_addr);
35
36- if (instr == 0xb2000000 || instr == 0xb2ffffff)
37+ if ((instr & 0xff000000) == 0xb2000000)
38 {
39 instr &= ~0x00ffffff;
40 instr |= (val & 0xffffff);
41@@ -1745,7 +1745,7 @@ microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
42 unsigned long instr_lo;
43
44 instr_hi = bfd_get_32 (abfd, bfd_addr);
45- if (instr_hi == 0xb2000000 || instr_hi == 0xb2ffffff)
46+ if ((instr_hi & 0xff000000) == 0xb2000000)
47 {
48 instr_hi &= ~0x00ffffff;
49 instr_hi |= (val >> 16) & 0xffffff;
50@@ -2238,7 +2238,10 @@ microblaze_elf_relax_section (bfd *abfd,
51 unsigned long instr_lo = bfd_get_32 (abfd, ocontents
52 + irelscan->r_offset
53 + INST_WORD_SIZE);
54- immediate = (instr_hi & 0x0000ffff) << 16;
55+ if ((instr_hi & 0xff000000) == 0xb2000000)
56+ immediate = (instr_hi & 0x00ffffff) << 24;
57+ else
58+ immediate = (instr_hi & 0x0000ffff) << 16;
59 immediate |= (instr_lo & 0x0000ffff);
60 offset = calc_fixup (irelscan->r_addend, 0, sec);
61 immediate -= offset;
62@@ -2282,7 +2285,10 @@ microblaze_elf_relax_section (bfd *abfd,
63 unsigned long instr_lo = bfd_get_32 (abfd, ocontents
64 + irelscan->r_offset
65 + INST_WORD_SIZE);
66- immediate = (instr_hi & 0x0000ffff) << 16;
67+ if ((instr_hi & 0xff000000) == 0xb2000000)
68+ immediate = (instr_hi & 0x00ffffff) << 24;
69+ else
70+ immediate = (instr_hi & 0x0000ffff) << 16;
71 immediate |= (instr_lo & 0x0000ffff);
72 target_address = immediate;
73 offset = calc_fixup (target_address, 0, sec);
74--
752.17.1
76
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch
new file mode 100644
index 00000000..d0ca677c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0024-Fixed-the-bug-in-the-R_MICROBLAZE_64_NONE-relocation.patch
@@ -0,0 +1,44 @@
1From 50bd636604305329b302b9fbbb692795d26f5fa5 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/43] Fixed the bug in the R_MICROBLAZE_64_NONE relocation.
5 It was adjusting only lower 16bits.
6
7---
8 bfd/elf32-microblaze.c | 4 ++--
9 bfd/elf64-microblaze.c | 4 ++--
10 2 files changed, 4 insertions(+), 4 deletions(-)
11
12diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
13index 035e71f311..2d8c062a42 100644
14--- a/bfd/elf32-microblaze.c
15+++ b/bfd/elf32-microblaze.c
16@@ -2022,8 +2022,8 @@ microblaze_elf_relax_section (bfd *abfd,
17 sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
18 efix = calc_fixup (target_address, 0, sec);
19 irel->r_addend -= (efix - sfix);
20- microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
21- + INST_WORD_SIZE, irel->r_addend);
22+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
23+ irel->r_addend);
24 }
25 break;
26 }
27diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
28index 184b7d560d..ef6a87062b 100644
29--- a/bfd/elf64-microblaze.c
30+++ b/bfd/elf64-microblaze.c
31@@ -2017,8 +2017,8 @@ microblaze_elf_relax_section (bfd *abfd,
32 sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
33 efix = calc_fixup (target_address, 0, sec);
34 irel->r_addend -= (efix - sfix);
35- microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
36- + INST_WORD_SIZE, irel->r_addend);
37+ microblaze_bfd_write_imm_value_64 (abfd, contents + irel->r_offset,
38+ irel->r_addend);
39 }
40 break;
41 }
42--
432.17.1
44
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch
new file mode 100644
index 00000000..fba32c08
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0025-Patch-MicroBlaze-fixed-Build-issue-which-are-due-to-.patch
@@ -0,0 +1,51 @@
1From b8c4b1fa22137d18d4ada7e350948035705f402f 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/43] [Patch,MicroBlaze]: fixed Build issue which are due to
5 conflicts in patches.
6
7---
8 bfd/elf32-microblaze.c | 1 +
9 bfd/elf64-microblaze.c | 12 ++++++------
10 3 files changed, 9 insertions(+), 8 deletions(-)
11
12diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
13index 2d8c062a42..6a795c5069 100644
14--- a/bfd/elf32-microblaze.c
15+++ b/bfd/elf32-microblaze.c
16@@ -1996,6 +1996,7 @@ microblaze_elf_relax_section (bfd *abfd,
17 /* This was a PC-relative instruction that was
18 completely resolved. */
19 int sfix, efix;
20+ unsigned int val;
21 bfd_vma target_address;
22 target_address = irel->r_addend + irel->r_offset;
23 sfix = calc_fixup (irel->r_offset, 0, sec);
24diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
25index ef6a87062b..bed534e7dd 100644
26--- a/bfd/elf64-microblaze.c
27+++ b/bfd/elf64-microblaze.c
28@@ -2854,14 +2854,14 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
29 /* If this is a weak symbol, and there is a real definition, the
30 processor independent code will have arranged for us to see the
31 real definition first, and we can just use the same value. */
32- if (h->u.weakdef != NULL)
33+ if (h->is_weakalias)
34 {
35- BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
36- || h->u.weakdef->root.type == bfd_link_hash_defweak);
37- h->root.u.def.section = h->u.weakdef->root.u.def.section;
38- h->root.u.def.value = h->u.weakdef->root.u.def.value;
39+ struct elf_link_hash_entry *def = weakdef (h);
40+ BFD_ASSERT (def->root.type == bfd_link_hash_defined);
41+ h->root.u.def.section = def->root.u.def.section;
42+ h->root.u.def.value = def->root.u.def.value;
43 return TRUE;
44- }
45+ }
46
47 /* This is a reference to a symbol defined by a dynamic object which
48 is not a function. */
49--
502.17.1
51
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch
new file mode 100644
index 00000000..38245cbd
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0026-Patch-Microblaze-changes-of-PR22458-failure-to-choos.patch
@@ -0,0 +1,31 @@
1From 212c40ed034096069f3ab0dac74ccfb79063b84c 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/43] [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
8---
9 bfd/format.c | 5 +++++
10 1 file changed, 5 insertions(+)
11
12diff --git a/bfd/format.c b/bfd/format.c
13index 97a92291a8..3a74cc49d2 100644
14--- a/bfd/format.c
15+++ b/bfd/format.c
16@@ -292,7 +292,12 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
17
18 /* Don't check the default target twice. */
19 if (*target == &binary_vec
20+#if !BFD_SUPPORTS_PLUGINS
21 || (!abfd->target_defaulted && *target == save_targ))
22+#else
23+ || (!abfd->target_defaulted && *target == save_targ)
24+ || (*target)->match_priority > best_match)
25+#endif
26 continue;
27
28 /* If we already tried a match, the bfd is modified and may
29--
302.17.1
31
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch
new file mode 100644
index 00000000..664675b9
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0028-Patch-Microblaze-Binutils-security-check-is-causing-.patch
@@ -0,0 +1,33 @@
1From 7fdfff333f4982d7eb32a564aacfd2d8822c0004 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 11 Mar 2019 14:23:58 +0530
4Subject: [PATCH 28/43] [Patch,Microblaze] : Binutils security check is causing
5 build error for windows builds.commenting for now.
6
7---
8 bfd/elf-attrs.c | 2 ++
9 1 file changed, 2 insertions(+)
10
11diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
12index bfe135e7fb..feb5cb37f5 100644
13--- a/bfd/elf-attrs.c
14+++ b/bfd/elf-attrs.c
15@@ -440,6 +440,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
16 /* PR 17512: file: 2844a11d. */
17 if (hdr->sh_size == 0)
18 return;
19+ #if 0
20 if (hdr->sh_size > bfd_get_file_size (abfd))
21 {
22 /* xgettext:c-format */
23@@ -448,6 +449,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
24 bfd_set_error (bfd_error_invalid_operation);
25 return;
26 }
27+ #endif
28
29 contents = (bfd_byte *) bfd_malloc (hdr->sh_size + 1);
30 if (!contents)
31--
322.17.1
33
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0029-fixing-the-long-long-long-mingw-toolchain-issue.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0029-fixing-the-long-long-long-mingw-toolchain-issue.patch
new file mode 100644
index 00000000..0da9e7b4
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0029-fixing-the-long-long-long-mingw-toolchain-issue.patch
@@ -0,0 +1,27 @@
1From fcb9c923a78a6a6141626f4c2a82579cfc4e43d6 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 29 Nov 2018 17:59:25 +0530
4Subject: [PATCH 29/43] fixing the long & long long mingw toolchain issue
5
6---
7 opcodes/microblaze-opc.h | 4 ++--
8 2 files changed, 7 insertions(+), 7 deletions(-)
9
10diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
11index 824afc0ab0..d59ee0a95f 100644
12--- a/opcodes/microblaze-opc.h
13+++ b/opcodes/microblaze-opc.h
14@@ -585,8 +585,8 @@ char pvr_register_prefix[] = "rpvr";
15 #define MIN_IMM6_WIDTH ((int) 0x00000001)
16 #define MAX_IMM6_WIDTH ((int) 0x00000040)
17
18-#define MIN_IMML ((long) 0xffffff8000000000L)
19-#define MAX_IMML ((long) 0x0000007fffffffffL)
20+#define MIN_IMML ((long long) 0xffffff8000000000L)
21+#define MAX_IMML ((long long) 0x0000007fffffffffL)
22
23 #endif /* MICROBLAZE_OPC */
24
25--
262.17.1
27
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0030-Added-support-to-new-arithmetic-single-register-inst.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0030-Added-support-to-new-arithmetic-single-register-inst.patch
new file mode 100644
index 00000000..79d7f4fe
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0030-Added-support-to-new-arithmetic-single-register-inst.patch
@@ -0,0 +1,166 @@
1From f36d3bdd09f5c9987199f08ea3dd98bf45a9e18e Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Fri, 23 Aug 2019 16:18:43 +0530
4Subject: [PATCH 30/43] Added support to new arithmetic single register
5 instructions
6
7---
8 opcodes/microblaze-dis.c | 12 +++
9 opcodes/microblaze-opc.h | 43 ++++++++++-
10 opcodes/microblaze-opcm.h | 5 +-
11 4 files changed, 201 insertions(+), 6 deletions(-)
12
13diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
14index f679a43606..e5e880cb1c 100644
15--- a/opcodes/microblaze-dis.c
16+++ b/opcodes/microblaze-dis.c
17@@ -114,6 +114,15 @@ get_field_imm15 (long instr)
18 return (strdup (tmpstr));
19 }
20
21+static char *
22+get_field_imm16 (long instr)
23+{
24+ char tmpstr[25];
25+
26+ sprintf (tmpstr, "%d", (short)((instr & IMM16_MASK) >> IMM_LOW));
27+ return (strdup (tmpstr));
28+}
29+
30 static char *
31 get_field_special (long instr, struct op_code_struct * op)
32 {
33@@ -419,6 +428,9 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
34 case INST_TYPE_RD_IMM15:
35 print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_imm15 (inst));
36 break;
37+ case INST_TYPE_RD_IMML:
38+ print_func (stream, "\t%s, %s", get_field_rd (inst), get_field_imm16 (inst));
39+ break;
40 /* For mbar insn. */
41 case INST_TYPE_IMM5:
42 print_func (stream, "\t%s", get_field_imm5_mbar (inst));
43diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
44index d59ee0a95f..0774f70e08 100644
45--- a/opcodes/microblaze-opc.h
46+++ b/opcodes/microblaze-opc.h
47@@ -69,6 +69,7 @@
48 #define INST_TYPE_RD_R1_IMMW_IMMS 21
49
50 #define INST_TYPE_NONE 25
51+#define INST_TYPE_RD_IMML 26
52
53
54
55@@ -84,6 +85,7 @@
56 #define IMMVAL_MASK_MFS 0x0000
57
58 #define OPCODE_MASK_H 0xFC000000 /* High 6 bits only. */
59+#define OPCODE_MASK_LIMM 0xFC1F0000 /* High 6 bits and 12-16 bits */
60 #define OPCODE_MASK_H1 0xFFE00000 /* High 11 bits. */
61 #define OPCODE_MASK_H2 0xFC1F0000 /* High 6 and bits 20-16. */
62 #define OPCODE_MASK_H12 0xFFFF0000 /* High 16. */
63@@ -106,6 +108,33 @@
64 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
65 #define OPCODE_MASK_H8 0xFF000000 /* High 8 bits only. */
66
67+/*Defines to identify 64-bit single reg instructions */
68+#define ADDLI_ONE_REG_MASK 0x68000000
69+#define ADDLIC_ONE_REG_MASK 0x68020000
70+#define ADDLIK_ONE_REG_MASK 0x68040000
71+#define ADDLIKC_ONE_REG_MASK 0x68060000
72+#define RSUBLI_ONE_REG_MASK 0x68010000
73+#define RSUBLIC_ONE_REG_MASK 0x68030000
74+#define RSUBLIK_ONE_REG_MASK 0x68050000
75+#define RSUBLIKC_ONE_REG_MASK 0x68070000
76+#define ORLI_ONE_REG_MASK 0x68100000
77+#define ANDLI_ONE_REG_MASK 0x68110000
78+#define XORLI_ONE_REG_MASK 0x68120000
79+#define ANDLNI_ONE_REG_MASK 0x68130000
80+#define ADDLI_MASK 0x20000000
81+#define ADDLIC_MASK 0x28000000
82+#define ADDLIK_MASK 0x30000000
83+#define ADDLIKC_MASK 0x38000000
84+#define RSUBLI_MASK 0x24000000
85+#define RSUBLIC_MASK 0x2C000000
86+#define RSUBLIK_MASK 0x34000000
87+#define RSUBLIKC_MASK 0x3C000000
88+#define ANDLI_MASK 0xA4000000
89+#define ANDLNI_MASK 0xAC000000
90+#define ORLI_MASK 0xA0000000
91+#define XORLI_MASK 0xA8000000
92+
93+
94 /* New Mask for msrset, msrclr insns. */
95 #define OPCODE_MASK_H23N 0xFC1F8000 /* High 6 and bits 11 - 16. */
96 /* Mask for mbar insn. */
97@@ -114,7 +143,7 @@
98 #define DELAY_SLOT 1
99 #define NO_DELAY_SLOT 0
100
101-#define MAX_OPCODES 412
102+#define MAX_OPCODES 424
103
104 struct op_code_struct
105 {
106@@ -444,13 +473,21 @@ struct op_code_struct
107 {"cmpl", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000101, OPCODE_MASK_H4, cmpl, arithmetic_inst },
108 {"cmplu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x14000103, OPCODE_MASK_H4, cmplu, arithmetic_inst },
109 {"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 */
110+ {"addli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68000000, OPCODE_MASK_LIMM, addli, arithmetic_inst },
111 {"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 */
112+ {"rsubli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68010000, OPCODE_MASK_LIMM, rsubli, arithmetic_inst },
113 {"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 */
114+ {"addlic", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68020000, OPCODE_MASK_LIMM, addlic, arithmetic_inst },
115 {"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 */
116+ {"rsublic", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68030000, OPCODE_MASK_LIMM, rsublic, arithmetic_inst },
117 {"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 */
118+ {"addlik", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68040000, OPCODE_MASK_LIMM, addlik, arithmetic_inst },
119 {"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 */
120+ {"rsublik", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68050000, OPCODE_MASK_LIMM, rsublik, arithmetic_inst },
121 {"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 */
122+ {"addlikc", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68060000, OPCODE_MASK_LIMM, addlikc, arithmetic_inst },
123 {"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 */
124+ {"rsublikc", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68070000, OPCODE_MASK_LIMM, rsublikc, arithmetic_inst },
125 {"mull", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x40000100, OPCODE_MASK_H4, mull, mult_inst },
126 {"bslll", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000500, OPCODE_MASK_H3, bslll, barrel_shift_inst },
127 {"bslra", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x44000300, OPCODE_MASK_H3, bslra, barrel_shift_inst },
128@@ -501,9 +538,13 @@ struct op_code_struct
129 {"beaged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00000, OPCODE_MASK_H14, beaged, branch_inst },
130 {"bealged", INST_TYPE_R1_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x9FA00100, OPCODE_MASK_H14, bealged, branch_inst },
131 {"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 */
132+ {"orli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68100000, OPCODE_MASK_LIMM, orli, arithmetic_inst },
133 {"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 */
134+ {"andli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68110000, OPCODE_MASK_LIMM, andli, arithmetic_inst },
135 {"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 */
136+ {"xorli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68120000, OPCODE_MASK_LIMM, xorli, arithmetic_inst },
137 {"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 */
138+ {"andnli", INST_TYPE_RD_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL,0x68130000, OPCODE_MASK_LIMM, andnli, arithmetic_inst },
139 {"imml", INST_TYPE_IMML, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB2000000, OPCODE_MASK_H8, imml, immediate_inst },
140 {"breai", INST_TYPE_IMM, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8010000, OPCODE_MASK_H12, breai, branch_inst },
141 {"breaid", INST_TYPE_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8110000, OPCODE_MASK_H12, breaid, branch_inst },
142diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
143index 5f2e190d23..4d2ee2dd0d 100644
144--- a/opcodes/microblaze-opcm.h
145+++ b/opcodes/microblaze-opcm.h
146@@ -61,7 +61,9 @@ enum microblaze_instr
147 eaputd, teaputd, ecaputd, tecaputd, neaputd, tneaputd, necaputd, tnecaputd,
148
149 /* 64-bit instructions */
150- addl, rsubl, addlc, rsublc, addlk, rsublk, addlkc, rsublkc, cmpl, cmplu, mull,
151+ addl, addli, addlic, addlik, addlikc, rsubl, rsubli, rsublic, rsublik, rsublikc,
152+ addlc, rsublc, addlk, rsublk, addlkc, rsublkc, cmpl, cmplu, mull,
153+ andli, andnli, orli, xorli,
154 bslll, bslra, bslrl, bsllli, bslrai, bslrli, bslefi, bslifi, orl, andl, xorl,
155 andnl, pcmplbf, pcmpleq, pcmplne, srla, srlc, srll, sextl8, sextl16, sextl32,
156 brea, bread, breald, beaeq, bealeq, beaeqd, bealeqd, beane, bealne, beaned,
157@@ -166,5 +168,6 @@ enum microblaze_instr_type
158
159 /* Imm mask for msrset, msrclr instructions. */
160 #define IMM15_MASK 0x00007FFF
161+#define IMM16_MASK 0x0000FFFF
162
163 #endif /* MICROBLAZE-OPCM */
164--
1652.17.1
166
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch
new file mode 100644
index 00000000..0be07120
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0031-Patch-MicroBlaze-double-imml-generation-for-64-bit-v.patch
@@ -0,0 +1,28 @@
1From a15e73a33b3f395f2096e252b655775ed8424c14 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 26 Aug 2019 15:29:42 +0530
4Subject: [PATCH 31/43] [Patch,MicroBlaze] : double imml generation for 64 bit
5 values.
6
7---
8 opcodes/microblaze-opc.h | 4 +-
9 2 files changed, 263 insertions(+), 63 deletions(-)
10
11diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
12index 0774f70e08..bd9d91cd57 100644
13--- a/opcodes/microblaze-opc.h
14+++ b/opcodes/microblaze-opc.h
15@@ -626,8 +626,8 @@ char pvr_register_prefix[] = "rpvr";
16 #define MIN_IMM6_WIDTH ((int) 0x00000001)
17 #define MAX_IMM6_WIDTH ((int) 0x00000040)
18
19-#define MIN_IMML ((long long) 0xffffff8000000000L)
20-#define MAX_IMML ((long long) 0x0000007fffffffffL)
21+#define MIN_IMML ((long long) -9223372036854775808)
22+#define MAX_IMML ((long long) 9223372036854775807)
23
24 #endif /* MICROBLAZE_OPC */
25
26--
272.17.1
28
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0032-Add-initial-port-of-linux-gdbserver.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0032-Add-initial-port-of-linux-gdbserver.patch
new file mode 100644
index 00000000..88c137f5
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0032-Add-initial-port-of-linux-gdbserver.patch
@@ -0,0 +1,435 @@
1From 5c7fa77256c704cc493a6bd42425fcec814710e8 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 19:07:44 +0530
4Subject: [PATCH 32/43] Add initial port of linux gdbserver add
5 gdb_proc_service_h to gdbserver microblaze-linux
6
7gdbserver needs to initialise the microblaze registers
8
9other archs use this step to run a *_arch_setup() to carry out all
10architecture specific setup - may need to add in future
11
12 * add linux-ptrace.o to gdbserver configure
13 * Update breakpoint opcode
14 * fix segfault on connecting gdbserver
15 * add microblaze_linux_memory_remove_breakpoint
16 * add set_solib_svr4_fetch_link_map_offsets
17 * add set_gdbarch_fetch_tls_load_module_address
18 * Force reading of r0 as 0, prevent stores
19
20Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
21Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
22---
23 gdb/configure.host | 3 +
24 gdb/gdbserver/linux-microblaze-low.c | 189 +++++++++++++++++++++++++++
25 gdb/microblaze-linux-tdep.c | 29 +++-
26 gdb/microblaze-tdep.c | 35 ++++-
27 gdb/microblaze-tdep.h | 4 +-
28 gdb/regformats/reg-microblaze.dat | 41 ++++++
29 6 files changed, 298 insertions(+), 3 deletions(-)
30 create mode 100644 gdb/gdbserver/linux-microblaze-low.c
31 create mode 100644 gdb/regformats/reg-microblaze.dat
32
33diff --git a/gdb/configure.host b/gdb/configure.host
34index c87f997abc..de8d6b00f3 100644
35--- a/gdb/configure.host
36+++ b/gdb/configure.host
37@@ -65,6 +65,7 @@ hppa*) gdb_host_cpu=pa ;;
38 i[34567]86*) gdb_host_cpu=i386 ;;
39 m68*) gdb_host_cpu=m68k ;;
40 mips*) gdb_host_cpu=mips ;;
41+microblaze*) gdb_host_cpu=microblaze ;;
42 powerpc* | rs6000) gdb_host_cpu=powerpc ;;
43 sparcv9 | sparc64) gdb_host_cpu=sparc ;;
44 s390*) gdb_host_cpu=s390 ;;
45@@ -133,6 +134,8 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
46 mips*-*-freebsd*) gdb_host=fbsd ;;
47 mips64*-*-openbsd*) gdb_host=obsd64 ;;
48
49+microblaze*-*linux*) gdb_host=linux ;;
50+
51 powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
52 gdb_host=aix ;;
53 powerpc*-*-freebsd*) gdb_host=fbsd ;;
54diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c
55new file mode 100644
56index 0000000000..cba5d6fc58
57--- /dev/null
58+++ b/gdb/gdbserver/linux-microblaze-low.c
59@@ -0,0 +1,189 @@
60+/* GNU/Linux/Microblaze specific low level interface, for the remote server for
61+ GDB.
62+ Copyright (C) 1995-2013 Free Software Foundation, Inc.
63+
64+ This file is part of GDB.
65+
66+ This program is free software; you can redistribute it and/or modify
67+ it under the terms of the GNU General Public License as published by
68+ the Free Software Foundation; either version 3 of the License, or
69+ (at your option) any later version.
70+
71+ This program is distributed in the hope that it will be useful,
72+ but WITHOUT ANY WARRANTY; without even the implied warranty of
73+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74+ GNU General Public License for more details.
75+
76+ You should have received a copy of the GNU General Public License
77+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
78+
79+#include "server.h"
80+#include "linux-low.h"
81+
82+#include <asm/ptrace.h>
83+#include <sys/procfs.h>
84+#include <sys/ptrace.h>
85+
86+#include "gdb_proc_service.h"
87+
88+static int microblaze_regmap[] =
89+ {PT_GPR(0), PT_GPR(1), PT_GPR(2), PT_GPR(3),
90+ PT_GPR(4), PT_GPR(5), PT_GPR(6), PT_GPR(7),
91+ PT_GPR(8), PT_GPR(9), PT_GPR(10), PT_GPR(11),
92+ PT_GPR(12), PT_GPR(13), PT_GPR(14), PT_GPR(15),
93+ PT_GPR(16), PT_GPR(17), PT_GPR(18), PT_GPR(19),
94+ PT_GPR(20), PT_GPR(21), PT_GPR(22), PT_GPR(23),
95+ PT_GPR(24), PT_GPR(25), PT_GPR(26), PT_GPR(27),
96+ PT_GPR(28), PT_GPR(29), PT_GPR(30), PT_GPR(31),
97+ PT_PC, PT_MSR, PT_EAR, PT_ESR,
98+ PT_FSR
99+ };
100+
101+#define microblaze_num_regs (sizeof microblaze_regmap / sizeof microblaze_regmap[0])
102+
103+/* Defined in auto-generated file microblaze-linux.c. */
104+void init_registers_microblaze (void);
105+
106+static int
107+microblaze_cannot_store_register (int regno)
108+{
109+ if (microblaze_regmap[regno] == -1 || regno == 0)
110+ return 1;
111+
112+ return 0;
113+}
114+
115+static int
116+microblaze_cannot_fetch_register (int regno)
117+{
118+ return 0;
119+}
120+
121+static CORE_ADDR
122+microblaze_get_pc (struct regcache *regcache)
123+{
124+ unsigned long pc;
125+
126+ collect_register_by_name (regcache, "pc", &pc);
127+ return (CORE_ADDR) pc;
128+}
129+
130+static void
131+microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
132+{
133+ unsigned long newpc = pc;
134+
135+ supply_register_by_name (regcache, "pc", &newpc);
136+}
137+
138+/* dbtrap insn */
139+/* brki r16, 0x18; */
140+static const unsigned long microblaze_breakpoint = 0xba0c0018;
141+#define microblaze_breakpoint_len 4
142+
143+static int
144+microblaze_breakpoint_at (CORE_ADDR where)
145+{
146+ unsigned long insn;
147+
148+ (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
149+ if (insn == microblaze_breakpoint)
150+ return 1;
151+ /* If necessary, recognize more trap instructions here. GDB only uses the
152+ one. */
153+ return 0;
154+}
155+
156+static CORE_ADDR
157+microblaze_reinsert_addr (struct regcache *regcache)
158+{
159+ unsigned long pc;
160+ collect_register_by_name (regcache, "r15", &pc);
161+ return pc;
162+}
163+
164+#ifdef HAVE_PTRACE_GETREGS
165+
166+static void
167+microblaze_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
168+{
169+ int size = register_size (regno);
170+
171+ memset (buf, 0, sizeof (long));
172+
173+ if (size < sizeof (long))
174+ collect_register (regcache, regno, buf + sizeof (long) - size);
175+ else
176+ collect_register (regcache, regno, buf);
177+}
178+
179+static void
180+microblaze_supply_ptrace_register (struct regcache *regcache,
181+ int regno, const char *buf)
182+{
183+ int size = register_size (regno);
184+
185+ if (regno == 0) {
186+ unsigned long regbuf_0 = 0;
187+ /* clobbering r0 so that it is always 0 as enforced by hardware */
188+ supply_register (regcache, regno, (const char*)&regbuf_0);
189+ } else {
190+ if (size < sizeof (long))
191+ supply_register (regcache, regno, buf + sizeof (long) - size);
192+ else
193+ supply_register (regcache, regno, buf);
194+ }
195+}
196+
197+/* Provide only a fill function for the general register set. ps_lgetregs
198+ will use this for NPTL support. */
199+
200+static void microblaze_fill_gregset (struct regcache *regcache, void *buf)
201+{
202+ int i;
203+
204+ for (i = 0; i < 32; i++)
205+ microblaze_collect_ptrace_register (regcache, i, (char *) buf + microblaze_regmap[i]);
206+}
207+
208+static void
209+microblaze_store_gregset (struct regcache *regcache, const void *buf)
210+{
211+ int i;
212+
213+ for (i = 0; i < 32; i++)
214+ supply_register (regcache, i, (char *) buf + microblaze_regmap[i]);
215+}
216+
217+#endif /* HAVE_PTRACE_GETREGS */
218+
219+struct regset_info target_regsets[] = {
220+#ifdef HAVE_PTRACE_GETREGS
221+ { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
222+ { 0, 0, 0, -1, -1, NULL, NULL },
223+#endif /* HAVE_PTRACE_GETREGS */
224+ { 0, 0, 0, -1, -1, NULL, NULL }
225+};
226+
227+struct linux_target_ops the_low_target = {
228+ init_registers_microblaze,
229+ microblaze_num_regs,
230+ microblaze_regmap,
231+ NULL,
232+ microblaze_cannot_fetch_register,
233+ microblaze_cannot_store_register,
234+ NULL, /* fetch_register */
235+ microblaze_get_pc,
236+ microblaze_set_pc,
237+ (const unsigned char *) &microblaze_breakpoint,
238+ microblaze_breakpoint_len,
239+ microblaze_reinsert_addr,
240+ 0,
241+ microblaze_breakpoint_at,
242+ NULL,
243+ NULL,
244+ NULL,
245+ NULL,
246+ microblaze_collect_ptrace_register,
247+ microblaze_supply_ptrace_register,
248+};
249diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
250index 4e5f60cd4e..7ab650a1cc 100644
251--- a/gdb/microblaze-linux-tdep.c
252+++ b/gdb/microblaze-linux-tdep.c
253@@ -37,6 +37,22 @@
254 #include "tramp-frame.h"
255 #include "linux-tdep.h"
256
257+static int microblaze_debug_flag = 0;
258+
259+static void
260+microblaze_debug (const char *fmt, ...)
261+{
262+ if (microblaze_debug_flag)
263+ {
264+ va_list args;
265+
266+ va_start (args, fmt);
267+ printf_unfiltered ("MICROBLAZE LINUX: ");
268+ vprintf_unfiltered (fmt, args);
269+ va_end (args);
270+ }
271+}
272+
273 static int
274 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
275 struct bp_target_info *bp_tgt)
276@@ -46,18 +62,25 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
277 int val;
278 int bplen;
279 gdb_byte old_contents[BREAKPOINT_MAX];
280+ struct cleanup *cleanup;
281
282 /* Determine appropriate breakpoint contents and size for this address. */
283 bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
284
285+ /* Make sure we see the memory breakpoints. */
286+ cleanup = make_show_memory_breakpoints_cleanup (1);
287 val = target_read_memory (addr, old_contents, bplen);
288
289 /* If our breakpoint is no longer at the address, this means that the
290 program modified the code on us, so it is wrong to put back the
291 old value. */
292 if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
293- val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
294+ {
295+ val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
296+ microblaze_debug ("microblaze_linux_memory_remove_breakpoint writing back to memory at addr 0x%lx\n", addr);
297+ }
298
299+ do_cleanups (cleanup);
300 return val;
301 }
302
303@@ -129,6 +152,10 @@ microblaze_linux_init_abi (struct gdbarch_info info,
304 /* Trampolines. */
305 tramp_frame_prepend_unwinder (gdbarch,
306 &microblaze_linux_sighandler_tramp_frame);
307+
308+ /* Enable TLS support. */
309+ set_gdbarch_fetch_tls_load_module_address (gdbarch,
310+ svr4_fetch_objfile_link_map);
311 }
312
313 void
314diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
315index 1248acbdc9..730a2b281f 100644
316--- a/gdb/microblaze-tdep.c
317+++ b/gdb/microblaze-tdep.c
318@@ -137,7 +137,38 @@ microblaze_fetch_instruction (CORE_ADDR pc)
319 constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT;
320
321 typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint;
322-
323+static int
324+microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
325+ struct bp_target_info *bp_tgt)
326+{
327+ CORE_ADDR addr = bp_tgt->placed_address;
328+ const unsigned char *bp;
329+ int val;
330+ int bplen;
331+ gdb_byte old_contents[BREAKPOINT_MAX];
332+ struct cleanup *cleanup;
333+
334+ /* Determine appropriate breakpoint contents and size for this address. */
335+ bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
336+ if (bp == NULL)
337+ error (_("Software breakpoints not implemented for this target."));
338+
339+ /* Make sure we see the memory breakpoints. */
340+ cleanup = make_show_memory_breakpoints_cleanup (1);
341+ val = target_read_memory (addr, old_contents, bplen);
342+
343+ /* If our breakpoint is no longer at the address, this means that the
344+ program modified the code on us, so it is wrong to put back the
345+ old value. */
346+ if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
347+ {
348+ val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
349+ microblaze_debug ("microblaze_linux_memory_remove_breakpoint writing back to memory at addr 0x%lx\n", addr);
350+ }
351+
352+ do_cleanups (cleanup);
353+ return val;
354+}
355
356 /* Allocate and initialize a frame cache. */
357
358@@ -731,6 +762,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
359 microblaze_breakpoint::kind_from_pc);
360 set_gdbarch_sw_breakpoint_from_kind (gdbarch,
361 microblaze_breakpoint::bp_from_kind);
362+ set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint);
363
364 set_gdbarch_frame_args_skip (gdbarch, 8);
365
366@@ -770,4 +802,5 @@ When non-zero, microblaze specific debugging is enabled."),
367 NULL,
368 &setdebuglist, &showdebuglist);
369
370+
371 }
372diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
373index a0048148e4..63aab84ef6 100644
374--- a/gdb/microblaze-tdep.h
375+++ b/gdb/microblaze-tdep.h
376@@ -117,6 +117,8 @@ struct microblaze_frame_cache
377
378 /* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used.
379 Only used for native debugging. */
380-#define MICROBLAZE_BREAKPOINT {0xb9, 0xcc, 0x00, 0x60}
381+#define MICROBLAZE_BREAKPOINT {0xba, 0x0c, 0x00, 0x18}
382+#define MICROBLAZE_BREAKPOINT_LE {0x18, 0x00, 0x0c, 0xba}
383+
384
385 #endif /* microblaze-tdep.h */
386diff --git a/gdb/regformats/reg-microblaze.dat b/gdb/regformats/reg-microblaze.dat
387new file mode 100644
388index 0000000000..bd8a438442
389--- /dev/null
390+++ b/gdb/regformats/reg-microblaze.dat
391@@ -0,0 +1,41 @@
392+name:microblaze
393+expedite:r1,pc
394+32:r0
395+32:r1
396+32:r2
397+32:r3
398+32:r4
399+32:r5
400+32:r6
401+32:r7
402+32:r8
403+32:r9
404+32:r10
405+32:r11
406+32:r12
407+32:r13
408+32:r14
409+32:r15
410+32:r16
411+32:r17
412+32:r18
413+32:r19
414+32:r20
415+32:r21
416+32:r22
417+32:r23
418+32:r24
419+32:r25
420+32:r26
421+32:r27
422+32:r28
423+32:r29
424+32:r30
425+32:r31
426+32:pc
427+32:msr
428+32:ear
429+32:esr
430+32:fsr
431+32:slr
432+32:shr
433--
4342.17.1
435
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0033-Initial-port-of-core-reading-support.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0033-Initial-port-of-core-reading-support.patch
new file mode 100644
index 00000000..e60893ef
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0033-Initial-port-of-core-reading-support.patch
@@ -0,0 +1,388 @@
1From a9d58bc9edc348ed15d62598f2a0d0862aaf4e61 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 24 Jan 2017 14:55:56 +0530
4Subject: [PATCH 33/43] Initial port of core reading support Added support for
5 reading notes in linux core dumps Support for reading of PRSTATUS and PSINFO
6 information for rebuilding ".reg" sections of core dumps at run time.
7
8Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
9Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
10---
11 bfd/elf32-microblaze.c | 84 ++++++++++++++++++++++++++++++++++
12 gdb/configure.tgt | 2 +-
13 gdb/microblaze-linux-tdep.c | 57 +++++++++++++++++++++++
14 gdb/microblaze-tdep.c | 90 +++++++++++++++++++++++++++++++++++++
15 gdb/microblaze-tdep.h | 27 +++++++++++
16 5 files changed, 259 insertions(+), 1 deletion(-)
17
18diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
19index 6a795c5069..c280431df6 100644
20--- a/bfd/elf32-microblaze.c
21+++ b/bfd/elf32-microblaze.c
22@@ -767,6 +767,87 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
23 return _bfd_elf_is_local_label_name (abfd, name);
24 }
25
26+/* Support for core dump NOTE sections. */
27+static bfd_boolean
28+microblaze_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
29+{
30+ int offset;
31+ unsigned int size;
32+
33+ switch (note->descsz)
34+ {
35+ default:
36+ return FALSE;
37+
38+ case 228: /* Linux/MicroBlaze */
39+ /* pr_cursig */
40+ elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
41+
42+ /* pr_pid */
43+ elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
44+
45+ /* pr_reg */
46+ offset = 72;
47+ size = 50 * 4;
48+
49+ break;
50+ }
51+
52+ /* Make a ".reg/999" section. */
53+ return _bfd_elfcore_make_pseudosection (abfd, ".reg",
54+ size, note->descpos + offset);
55+}
56+
57+static bfd_boolean
58+microblaze_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
59+{
60+ switch (note->descsz)
61+ {
62+ default:
63+ return FALSE;
64+
65+ case 128: /* Linux/MicroBlaze elf_prpsinfo */
66+ elf_tdata (abfd)->core->program
67+ = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
68+ elf_tdata (abfd)->core->command
69+ = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
70+ }
71+
72+ /* Note that for some reason, a spurious space is tacked
73+ onto the end of the args in some (at least one anyway)
74+ implementations, so strip it off if it exists. */
75+
76+ {
77+ char *command = elf_tdata (abfd)->core->command;
78+ int n = strlen (command);
79+
80+ if (0 < n && command[n - 1] == ' ')
81+ command[n - 1] = '\0';
82+ }
83+
84+ return TRUE;
85+}
86+
87+/* The microblaze linker (like many others) needs to keep track of
88+ the number of relocs that it decides to copy as dynamic relocs in
89+ check_relocs for each symbol. This is so that it can later discard
90+ them if they are found to be unnecessary. We store the information
91+ in a field extending the regular ELF linker hash table. */
92+
93+struct elf32_mb_dyn_relocs
94+{
95+ struct elf32_mb_dyn_relocs *next;
96+
97+ /* The input section of the reloc. */
98+ asection *sec;
99+
100+ /* Total number of relocs copied for the input section. */
101+ bfd_size_type count;
102+
103+ /* Number of pc-relative relocs copied for the input section. */
104+ bfd_size_type pc_count;
105+};
106+
107 /* ELF linker hash entry. */
108
109 struct elf32_mb_link_hash_entry
110@@ -3672,4 +3753,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
111 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
112 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
113
114+#define elf_backend_grok_prstatus microblaze_elf_grok_prstatus
115+#define elf_backend_grok_psinfo microblaze_elf_grok_psinfo
116+
117 #include "elf32-target.h"
118diff --git a/gdb/configure.tgt b/gdb/configure.tgt
119index 27f122ad04..622bd486b3 100644
120--- a/gdb/configure.tgt
121+++ b/gdb/configure.tgt
122@@ -397,7 +397,7 @@ mep-*-*)
123
124 microblaze*-linux-*|microblaze*-*-linux*)
125 # Target: Xilinx MicroBlaze running Linux
126- gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o \
127+ gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o glibc-tdep.o \
128 symfile-mem.o linux-tdep.o"
129 gdb_sim=../sim/microblaze/libsim.a
130 ;;
131diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
132index 7ab650a1cc..e2225d778a 100644
133--- a/gdb/microblaze-linux-tdep.c
134+++ b/gdb/microblaze-linux-tdep.c
135@@ -135,11 +135,54 @@ static struct tramp_frame microblaze_linux_sighandler_tramp_frame =
136 microblaze_linux_sighandler_cache_init
137 };
138
139+const struct microblaze_gregset microblaze_linux_core_gregset;
140+
141+static void
142+microblaze_linux_supply_core_gregset (const struct regset *regset,
143+ struct regcache *regcache,
144+ int regnum, const void *gregs, size_t len)
145+{
146+ microblaze_supply_gregset (&microblaze_linux_core_gregset, regcache,
147+ regnum, gregs);
148+}
149+
150+static void
151+microblaze_linux_collect_core_gregset (const struct regset *regset,
152+ const struct regcache *regcache,
153+ int regnum, void *gregs, size_t len)
154+{
155+ microblaze_collect_gregset (&microblaze_linux_core_gregset, regcache,
156+ regnum, gregs);
157+}
158+
159+static void
160+microblaze_linux_supply_core_fpregset (const struct regset *regset,
161+ struct regcache *regcache,
162+ int regnum, const void *fpregs, size_t len)
163+{
164+ /* FIXME. */
165+ microblaze_supply_fpregset (regcache, regnum, fpregs);
166+}
167+
168+static void
169+microblaze_linux_collect_core_fpregset (const struct regset *regset,
170+ const struct regcache *regcache,
171+ int regnum, void *fpregs, size_t len)
172+{
173+ /* FIXME. */
174+ microblaze_collect_fpregset (regcache, regnum, fpregs);
175+}
176
177 static void
178 microblaze_linux_init_abi (struct gdbarch_info info,
179 struct gdbarch *gdbarch)
180 {
181+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
182+
183+ tdep->gregset = regset_alloc (gdbarch, microblaze_linux_supply_core_gregset,
184+ microblaze_linux_collect_core_gregset);
185+ tdep->sizeof_gregset = 200;
186+
187 linux_init_abi (info, gdbarch);
188
189 set_gdbarch_memory_remove_breakpoint (gdbarch,
190@@ -153,6 +196,20 @@ microblaze_linux_init_abi (struct gdbarch_info info,
191 tramp_frame_prepend_unwinder (gdbarch,
192 &microblaze_linux_sighandler_tramp_frame);
193
194+ /* BFD target for core files. */
195+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
196+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblaze");
197+ else
198+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblazeel");
199+
200+
201+ /* Shared library handling. */
202+ set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
203+ set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
204+
205+ set_gdbarch_regset_from_core_section (gdbarch,
206+ microblaze_regset_from_core_section);
207+
208 /* Enable TLS support. */
209 set_gdbarch_fetch_tls_load_module_address (gdbarch,
210 svr4_fetch_objfile_link_map);
211diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
212index 730a2b281f..49713ea9b1 100644
213--- a/gdb/microblaze-tdep.c
214+++ b/gdb/microblaze-tdep.c
215@@ -137,6 +137,14 @@ microblaze_fetch_instruction (CORE_ADDR pc)
216 constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT;
217
218 typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint;
219+static CORE_ADDR
220+microblaze_store_arguments (struct regcache *regcache, int nargs,
221+ struct value **args, CORE_ADDR sp,
222+ int struct_return, CORE_ADDR struct_addr)
223+{
224+ error (_("store_arguments not implemented"));
225+ return sp;
226+}
227 static int
228 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
229 struct bp_target_info *bp_tgt)
230@@ -541,6 +549,12 @@ microblaze_frame_base_address (struct frame_info *next_frame,
231 return cache->base;
232 }
233
234+static const struct frame_unwind *
235+microblaze_frame_sniffer (struct frame_info *next_frame)
236+{
237+ return &microblaze_frame_unwind;
238+}
239+
240 static const struct frame_base microblaze_frame_base =
241 {
242 &microblaze_frame_unwind,
243@@ -677,6 +691,71 @@ microblaze_register_g_packet_guesses (struct gdbarch *gdbarch)
244 tdesc_microblaze_with_stack_protect);
245 }
246
247+void
248+microblaze_supply_gregset (const struct microblaze_gregset *gregset,
249+ struct regcache *regcache,
250+ int regnum, const void *gregs)
251+{
252+ unsigned int *regs = gregs;
253+ if (regnum >= 0)
254+ regcache_raw_supply (regcache, regnum, regs + regnum);
255+
256+ if (regnum == -1) {
257+ int i;
258+
259+ for (i = 0; i < 50; i++) {
260+ regcache_raw_supply (regcache, i, regs + i);
261+ }
262+ }
263+}
264+
265+
266+void
267+microblaze_collect_gregset (const struct microblaze_gregset *gregset,
268+ const struct regcache *regcache,
269+ int regnum, void *gregs)
270+{
271+ /* FIXME. */
272+}
273+
274+void
275+microblaze_supply_fpregset (struct regcache *regcache,
276+ int regnum, const void *fpregs)
277+{
278+ /* FIXME. */
279+}
280+
281+void
282+microblaze_collect_fpregset (const struct regcache *regcache,
283+ int regnum, void *fpregs)
284+{
285+ /* FIXME. */
286+}
287+
288+
289+/* Return the appropriate register set for the core section identified
290+ by SECT_NAME and SECT_SIZE. */
291+
292+const struct regset *
293+microblaze_regset_from_core_section (struct gdbarch *gdbarch,
294+ const char *sect_name, size_t sect_size)
295+{
296+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
297+
298+ microblaze_debug ("microblaze_regset_from_core_section, sect_name = %s\n", sect_name);
299+
300+ if (strcmp (sect_name, ".reg") == 0 && sect_size >= tdep->sizeof_gregset)
301+ return tdep->gregset;
302+
303+ if (strcmp (sect_name, ".reg2") == 0 && sect_size >= tdep->sizeof_fpregset)
304+ return tdep->fpregset;
305+
306+ microblaze_debug ("microblaze_regset_from_core_section returning null :-( \n");
307+ return NULL;
308+}
309+
310+
311+
312 static struct gdbarch *
313 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
314 {
315@@ -733,6 +812,10 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
316 tdep = XCNEW (struct gdbarch_tdep);
317 gdbarch = gdbarch_alloc (&info, tdep);
318
319+ tdep->gregset = NULL;
320+ tdep->sizeof_gregset = 0;
321+ tdep->fpregset = NULL;
322+ tdep->sizeof_fpregset = 0;
323 set_gdbarch_long_double_bit (gdbarch, 128);
324
325 set_gdbarch_num_regs (gdbarch, MICROBLAZE_NUM_REGS);
326@@ -781,6 +864,13 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
327 frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
328 if (tdesc_data != NULL)
329 tdesc_use_registers (gdbarch, tdesc, tdesc_data);
330+ //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer);
331+
332+ /* If we have register sets, enable the generic core file support. */
333+ if (tdep->gregset) {
334+ set_gdbarch_regset_from_core_section (gdbarch,
335+ microblaze_regset_from_core_section);
336+ }
337
338 return gdbarch;
339 }
340diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
341index 63aab84ef6..02650f61d9 100644
342--- a/gdb/microblaze-tdep.h
343+++ b/gdb/microblaze-tdep.h
344@@ -22,8 +22,22 @@
345
346
347 /* Microblaze architecture-specific information. */
348+struct microblaze_gregset
349+{
350+ unsigned int gregs[32];
351+ unsigned int fpregs[32];
352+ unsigned int pregs[16];
353+};
354+
355 struct gdbarch_tdep
356 {
357+ int dummy; // declare something.
358+
359+ /* Register sets. */
360+ struct regset *gregset;
361+ size_t sizeof_gregset;
362+ struct regset *fpregset;
363+ size_t sizeof_fpregset;
364 };
365
366 /* Register numbers. */
367@@ -120,5 +134,18 @@ struct microblaze_frame_cache
368 #define MICROBLAZE_BREAKPOINT {0xba, 0x0c, 0x00, 0x18}
369 #define MICROBLAZE_BREAKPOINT_LE {0x18, 0x00, 0x0c, 0xba}
370
371+extern void microblaze_supply_gregset (const struct microblaze_gregset *gregset,
372+ struct regcache *regcache,
373+ int regnum, const void *gregs);
374+extern void microblaze_collect_gregset (const struct microblaze_gregset *gregset,
375+ const struct regcache *regcache,
376+ int regnum, void *gregs);
377+extern void microblaze_supply_fpregset (struct regcache *regcache,
378+ int regnum, const void *fpregs);
379+extern void microblaze_collect_fpregset (const struct regcache *regcache,
380+ int regnum, void *fpregs);
381+
382+extern const struct regset * microblaze_regset_from_core_section (struct gdbarch *gdbarch,
383+ const char *sect_name, size_t sect_size);
384
385 #endif /* microblaze-tdep.h */
386--
3872.17.1
388
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0034-Fix-debug-message-when-register-is-unavailable.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0034-Fix-debug-message-when-register-is-unavailable.patch
new file mode 100644
index 00000000..f0ec43b1
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0034-Fix-debug-message-when-register-is-unavailable.patch
@@ -0,0 +1,40 @@
1From 9e42c672613131b25da90e58aefd2d39e497c3f6 Mon Sep 17 00:00:00 2001
2From: Nathan Rossi <nathan.rossi@petalogix.com>
3Date: Tue, 8 May 2012 18:11:17 +1000
4Subject: [PATCH 34/43] Fix debug message when register is unavailable
5
6Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
7---
8 gdb/frame.c | 13 ++++++++++---
9 1 file changed, 10 insertions(+), 3 deletions(-)
10
11diff --git a/gdb/frame.c b/gdb/frame.c
12index d8b5f819f1..49706dc97c 100644
13--- a/gdb/frame.c
14+++ b/gdb/frame.c
15@@ -1227,12 +1227,19 @@ frame_unwind_register_value (frame_info *next_frame, int regnum)
16 else
17 {
18 int i;
19- const gdb_byte *buf = value_contents (value);
20+ const gdb_byte *buf = NULL;
21+ if (value_entirely_available(value)) {
22+ buf = value_contents (value);
23+ }
24
25 fprintf_unfiltered (gdb_stdlog, " bytes=");
26 fprintf_unfiltered (gdb_stdlog, "[");
27- for (i = 0; i < register_size (gdbarch, regnum); i++)
28- fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
29+ if (buf != NULL) {
30+ for (i = 0; i < register_size (gdbarch, regnum); i++)
31+ fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
32+ } else {
33+ fprintf_unfiltered (gdb_stdlog, "unavailable");
34+ }
35 fprintf_unfiltered (gdb_stdlog, "]");
36 }
37 }
38--
392.17.1
40
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0035-revert-master-rebase-changes-to-gdbserver.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0035-revert-master-rebase-changes-to-gdbserver.patch
new file mode 100644
index 00000000..0fe5c082
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0035-revert-master-rebase-changes-to-gdbserver.patch
@@ -0,0 +1,31 @@
1From 6f2d2fd5a214126e2c81dfb0dada3001ba353419 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Mon, 22 Jul 2013 11:16:05 +1000
4Subject: [PATCH 35/43] revert master-rebase changes to gdbserver
5
6Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
7---
8 gdb/gdbserver/configure.srv | 7 +++++++
9 1 file changed, 7 insertions(+)
10
11diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
12index bec72e2b19..153dcb4c71 100644
13--- a/gdb/gdbserver/configure.srv
14+++ b/gdb/gdbserver/configure.srv
15@@ -210,6 +210,13 @@ case "${target}" in
16 srv_linux_usrregs=yes
17 srv_linux_thread_db=yes
18 ;;
19+ microblaze*-*-linux*) srv_regobj=microblaze-linux.o
20+ srv_tgtobj="linux-low.o linux-osdata.o linux-microblaze-low.o "
21+ srv_tgtobj="${srv_tgtobj} linux-procfs.o linux-ptrace.o"
22+ srv_linux_regsets=yes
23+ srv_linux_usrregs=yes
24+ srv_linux_thread_db=yes
25+ ;;
26 powerpc*-*-linux*) srv_regobj="powerpc-32l.o"
27 srv_regobj="${srv_regobj} powerpc-altivec32l.o"
28 srv_regobj="${srv_regobj} powerpc-cell32l.o"
29--
302.17.1
31
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch
new file mode 100644
index 00000000..111d8059
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0036-revert-master-rebase-changes-to-gdbserver-previous-c.patch
@@ -0,0 +1,33 @@
1From a21f56098eb41e20ba2e6995e6dc72acdea045a0 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 30 Apr 2018 17:09:55 +0530
4Subject: [PATCH 36/43] revert master-rebase changes to gdbserver , previous
5 commit typo's
6
7---
8 gdb/gdbserver/Makefile.in | 2 ++
9 1 file changed, 2 insertions(+)
10
11diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
12index f5fc55034e..73ca5fd7c5 100644
13--- a/gdb/gdbserver/Makefile.in
14+++ b/gdb/gdbserver/Makefile.in
15@@ -169,6 +169,7 @@ SFILES = \
16 $(srcdir)/linux-low.c \
17 $(srcdir)/linux-m32r-low.c \
18 $(srcdir)/linux-m68k-low.c \
19+ $(srcdir)/linux-microblaze-low.c \
20 $(srcdir)/linux-mips-low.c \
21 $(srcdir)/linux-nios2-low.c \
22 $(srcdir)/linux-ppc-low.c \
23@@ -226,6 +227,7 @@ SFILES = \
24 $(srcdir)/nat/linux-osdata.c \
25 $(srcdir)/nat/linux-personality.c \
26 $(srcdir)/nat/mips-linux-watch.c \
27+ $(srcdir)/nat/microblaze-linux.c \
28 $(srcdir)/nat/ppc-linux.c \
29 $(srcdir)/nat/fork-inferior.c \
30 $(srcdir)/target/waitstatus.c
31--
322.17.1
33
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch
new file mode 100644
index 00000000..16b891bd
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0037-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch
@@ -0,0 +1,32 @@
1From 62bda7ae7bf0880201c4872c54e5b530b2fec27b Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Mon, 16 Dec 2013 16:37:32 +1000
4Subject: [PATCH 37/43] microblaze: Add build_gdbserver=yes to top level
5 configure.tgt
6
7For Microblaze linux toolchains, set the build_gdbserver=yes
8to allow driving gdbserver configuration from the upper level
9
10This patch has been absorbed into the original patch to add
11linux gdbserver support for Microblaze.
12
13Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
14---
15 gdb/configure.tgt | 1 +
16 1 file changed, 1 insertion(+)
17
18diff --git a/gdb/configure.tgt b/gdb/configure.tgt
19index 622bd486b3..989523735b 100644
20--- a/gdb/configure.tgt
21+++ b/gdb/configure.tgt
22@@ -405,6 +405,7 @@ microblaze*-*-*)
23 # Target: Xilinx MicroBlaze running standalone
24 gdb_target_obs="microblaze-tdep.o"
25 gdb_sim=../sim/microblaze/libsim.a
26+ build_gdbserver=yes
27 ;;
28
29 mips*-*-linux*)
30--
312.17.1
32
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0038-Initial-support-for-native-gdb.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0038-Initial-support-for-native-gdb.patch
new file mode 100644
index 00000000..ca37355c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0038-Initial-support-for-native-gdb.patch
@@ -0,0 +1,511 @@
1From fef2dfc9c55d19be25262175a4fa4921167a30b7 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@petalogix.com>
3Date: Fri, 20 Jul 2012 15:18:35 +1000
4Subject: [PATCH 38/43] Initial support for native gdb
5
6microblaze: Follow PPC method of getting setting registers
7using PTRACE PEEK/POKE
8
9Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
10
11Conflicts:
12 gdb/Makefile.in
13---
14 gdb/Makefile.in | 4 +-
15 gdb/config/microblaze/linux.mh | 9 +
16 gdb/microblaze-linux-nat.c | 431 +++++++++++++++++++++++++++++++++
17 3 files changed, 443 insertions(+), 1 deletion(-)
18 create mode 100644 gdb/config/microblaze/linux.mh
19 create mode 100644 gdb/microblaze-linux-nat.c
20
21diff --git a/gdb/Makefile.in b/gdb/Makefile.in
22index 5614cc3386..d620580498 100644
23--- a/gdb/Makefile.in
24+++ b/gdb/Makefile.in
25@@ -1316,6 +1316,7 @@ HFILES_NO_SRCDIR = \
26 memory-map.h \
27 memrange.h \
28 microblaze-tdep.h \
29+ microblaze-linux-tdep.h \
30 mips-linux-tdep.h \
31 mips-nbsd-tdep.h \
32 mips-tdep.h \
33@@ -1349,6 +1350,7 @@ HFILES_NO_SRCDIR = \
34 prologue-value.h \
35 psympriv.h \
36 psymtab.h \
37+ ia64-hpux-tdep.h \
38 ravenscar-thread.h \
39 record.h \
40 record-full.h \
41@@ -2263,6 +2265,7 @@ ALLDEPFILES = \
42 m68k-tdep.c \
43 microblaze-linux-tdep.c \
44 microblaze-tdep.c \
45+ microblaze-linux-nat.c \
46 mingw-hdep.c \
47 mips-fbsd-nat.c \
48 mips-fbsd-tdep.c \
49@@ -2365,7 +2368,6 @@ ALLDEPFILES = \
50 xtensa-linux-tdep.c \
51 xtensa-tdep.c \
52 xtensa-xtregs.c \
53- common/mingw-strerror.c \
54 common/posix-strerror.c
55
56 # Some files need explicit build rules (due to -Werror problems) or due
57diff --git a/gdb/config/microblaze/linux.mh b/gdb/config/microblaze/linux.mh
58new file mode 100644
59index 0000000000..a4eaf540e1
60--- /dev/null
61+++ b/gdb/config/microblaze/linux.mh
62@@ -0,0 +1,9 @@
63+# Host: Microblaze, running Linux
64+
65+NAT_FILE= config/nm-linux.h
66+NATDEPFILES= inf-ptrace.o fork-child.o \
67+ microblaze-linux-nat.o proc-service.o linux-thread-db.o \
68+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
69+NAT_CDEPS = $(srcdir)/proc-service.list
70+
71+LOADLIBES = -ldl $(RDYNAMIC)
72diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c
73new file mode 100644
74index 0000000000..e9b8c9c522
75--- /dev/null
76+++ b/gdb/microblaze-linux-nat.c
77@@ -0,0 +1,431 @@
78+/* Microblaze GNU/Linux native support.
79+
80+ Copyright (C) 1988-1989, 1991-1992, 1994, 1996, 2000-2012 Free
81+ Software Foundation, Inc.
82+
83+ This file is part of GDB.
84+
85+ This program is free software; you can redistribute it and/or modify
86+ it under the terms of the GNU General Public License as published by
87+ the Free Software Foundation; either version 3 of the License, or
88+ (at your option) any later version.
89+
90+ This program is distributed in the hope that it will be useful,
91+ but WITHOUT ANY WARRANTY; without even the implied warranty of
92+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93+ GNU General Public License for more details.
94+
95+ You should have received a copy of the GNU General Public License
96+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
97+
98+#include "defs.h"
99+#include "arch-utils.h"
100+#include "dis-asm.h"
101+#include "frame.h"
102+#include "trad-frame.h"
103+#include "symtab.h"
104+#include "value.h"
105+#include "gdbcmd.h"
106+#include "breakpoint.h"
107+#include "inferior.h"
108+#include "regcache.h"
109+#include "target.h"
110+#include "frame.h"
111+#include "frame-base.h"
112+#include "frame-unwind.h"
113+#include "dwarf2-frame.h"
114+#include "osabi.h"
115+
116+#include "gdb_assert.h"
117+#include "gdb_string.h"
118+#include "target-descriptions.h"
119+#include "opcodes/microblaze-opcm.h"
120+#include "opcodes/microblaze-dis.h"
121+
122+#include "linux-nat.h"
123+#include "target-descriptions.h"
124+
125+#include <sys/user.h>
126+#include <sys/utsname.h>
127+#include <sys/procfs.h>
128+#include <sys/ptrace.h>
129+
130+/* Prototypes for supply_gregset etc. */
131+#include "gregset.h"
132+
133+#include "microblaze-tdep.h"
134+
135+#include <elf/common.h>
136+#include "auxv.h"
137+
138+/* Defines ps_err_e, struct ps_prochandle. */
139+#include "gdb_proc_service.h"
140+
141+/* On GNU/Linux, threads are implemented as pseudo-processes, in which
142+ case we may be tracing more than one process at a time. In that
143+ case, inferior_ptid will contain the main process ID and the
144+ individual thread (process) ID. get_thread_id () is used to get
145+ the thread id if it's available, and the process id otherwise. */
146+
147+int
148+get_thread_id (ptid_t ptid)
149+{
150+ int tid = TIDGET (ptid);
151+ if (0 == tid)
152+ tid = PIDGET (ptid);
153+ return tid;
154+}
155+
156+#define GET_THREAD_ID(PTID) get_thread_id (PTID)
157+
158+/* Non-zero if our kernel may support the PTRACE_GETREGS and
159+ PTRACE_SETREGS requests, for reading and writing the
160+ general-purpose registers. Zero if we've tried one of
161+ them and gotten an error. */
162+int have_ptrace_getsetregs = 1;
163+
164+static int
165+microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
166+{
167+ int u_addr = -1;
168+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
169+ /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
170+ interface, and not the wordsize of the program's ABI. */
171+ int wordsize = sizeof (long);
172+
173+ /* General purpose registers occupy 1 slot each in the buffer. */
174+ if (regno >= MICROBLAZE_R0_REGNUM
175+ && regno <= MICROBLAZE_FSR_REGNUM)
176+ u_addr = (regno * wordsize);
177+
178+ return u_addr;
179+}
180+
181+
182+static void
183+fetch_register (struct regcache *regcache, int tid, int regno)
184+{
185+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
186+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
187+ /* This isn't really an address. But ptrace thinks of it as one. */
188+ CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
189+ int bytes_transferred;
190+ unsigned int offset; /* Offset of registers within the u area. */
191+ char buf[MAX_REGISTER_SIZE];
192+
193+ if (regaddr == -1)
194+ {
195+ memset (buf, '\0', register_size (gdbarch, regno)); /* Supply zeroes */
196+ regcache_raw_supply (regcache, regno, buf);
197+ return;
198+ }
199+
200+ /* Read the raw register using sizeof(long) sized chunks. On a
201+ 32-bit platform, 64-bit floating-point registers will require two
202+ transfers. */
203+ for (bytes_transferred = 0;
204+ bytes_transferred < register_size (gdbarch, regno);
205+ bytes_transferred += sizeof (long))
206+ {
207+ long l;
208+
209+ errno = 0;
210+ l = ptrace (PTRACE_PEEKUSER, tid, (PTRACE_TYPE_ARG3) regaddr, 0);
211+ regaddr += sizeof (long);
212+ if (errno != 0)
213+ {
214+ char message[128];
215+ sprintf (message, "reading register %s (#%d)",
216+ gdbarch_register_name (gdbarch, regno), regno);
217+ perror_with_name (message);
218+ }
219+ memcpy (&buf[bytes_transferred], &l, sizeof (l));
220+ }
221+
222+ /* Now supply the register. Keep in mind that the regcache's idea
223+ of the register's size may not be a multiple of sizeof
224+ (long). */
225+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
226+ {
227+ /* Little-endian values are always found at the left end of the
228+ bytes transferred. */
229+ regcache_raw_supply (regcache, regno, buf);
230+ }
231+ else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
232+ {
233+ /* Big-endian values are found at the right end of the bytes
234+ transferred. */
235+ size_t padding = (bytes_transferred - register_size (gdbarch, regno));
236+ regcache_raw_supply (regcache, regno, buf + padding);
237+ }
238+ else
239+ internal_error (__FILE__, __LINE__,
240+ _("fetch_register: unexpected byte order: %d"),
241+ gdbarch_byte_order (gdbarch));
242+}
243+
244+/* This function actually issues the request to ptrace, telling
245+ it to get all general-purpose registers and put them into the
246+ specified regset.
247+
248+ If the ptrace request does not exist, this function returns 0
249+ and properly sets the have_ptrace_* flag. If the request fails,
250+ this function calls perror_with_name. Otherwise, if the request
251+ succeeds, then the regcache gets filled and 1 is returned. */
252+static int
253+fetch_all_gp_regs (struct regcache *regcache, int tid)
254+{
255+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
256+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
257+ gdb_gregset_t gregset;
258+
259+ if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
260+ {
261+ if (errno == EIO)
262+ {
263+ have_ptrace_getsetregs = 0;
264+ return 0;
265+ }
266+ perror_with_name (_("Couldn't get general-purpose registers."));
267+ }
268+
269+ supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
270+
271+ return 1;
272+}
273+
274+
275+/* This is a wrapper for the fetch_all_gp_regs function. It is
276+ responsible for verifying if this target has the ptrace request
277+ that can be used to fetch all general-purpose registers at one
278+ shot. If it doesn't, then we should fetch them using the
279+ old-fashioned way, which is to iterate over the registers and
280+ request them one by one. */
281+static void
282+fetch_gp_regs (struct regcache *regcache, int tid)
283+{
284+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
285+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
286+ int i;
287+
288+ if (have_ptrace_getsetregs)
289+ if (fetch_all_gp_regs (regcache, tid))
290+ return;
291+
292+ /* If we've hit this point, it doesn't really matter which
293+ architecture we are using. We just need to read the
294+ registers in the "old-fashioned way". */
295+ for (i = MICROBLAZE_R0_REGNUM; i <= MICROBLAZE_FSR_REGNUM; i++)
296+ fetch_register (regcache, tid, i);
297+}
298+
299+
300+static void
301+store_register (const struct regcache *regcache, int tid, int regno)
302+{
303+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
304+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
305+ /* This isn't really an address. But ptrace thinks of it as one. */
306+ CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
307+ int i;
308+ size_t bytes_to_transfer;
309+ char buf[MAX_REGISTER_SIZE];
310+
311+ if (regaddr == -1)
312+ return;
313+
314+ /* First collect the register. Keep in mind that the regcache's
315+ idea of the register's size may not be a multiple of sizeof
316+ (long). */
317+ memset (buf, 0, sizeof buf);
318+ bytes_to_transfer = align_up (register_size (gdbarch, regno), sizeof (long));
319+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
320+ {
321+ /* Little-endian values always sit at the left end of the buffer. */
322+ regcache_raw_collect (regcache, regno, buf);
323+ }
324+ else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
325+ {
326+ /* Big-endian values sit at the right end of the buffer. */
327+ size_t padding = (bytes_to_transfer - register_size (gdbarch, regno));
328+ regcache_raw_collect (regcache, regno, buf + padding);
329+ }
330+
331+ for (i = 0; i < bytes_to_transfer; i += sizeof (long))
332+ {
333+ long l;
334+
335+ memcpy (&l, &buf[i], sizeof (l));
336+ errno = 0;
337+ ptrace (PTRACE_POKEUSER, tid, (PTRACE_TYPE_ARG3) regaddr, l);
338+ regaddr += sizeof (long);
339+
340+ if (errno != 0)
341+ {
342+ char message[128];
343+ sprintf (message, "writing register %s (#%d)",
344+ gdbarch_register_name (gdbarch, regno), regno);
345+ perror_with_name (message);
346+ }
347+ }
348+}
349+
350+/* This function actually issues the request to ptrace, telling
351+ it to store all general-purpose registers present in the specified
352+ regset.
353+
354+ If the ptrace request does not exist, this function returns 0
355+ and properly sets the have_ptrace_* flag. If the request fails,
356+ this function calls perror_with_name. Otherwise, if the request
357+ succeeds, then the regcache is stored and 1 is returned. */
358+static int
359+store_all_gp_regs (const struct regcache *regcache, int tid, int regno)
360+{
361+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
362+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
363+ gdb_gregset_t gregset;
364+
365+ if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
366+ {
367+ if (errno == EIO)
368+ {
369+ have_ptrace_getsetregs = 0;
370+ return 0;
371+ }
372+ perror_with_name (_("Couldn't get general-purpose registers."));
373+ }
374+
375+ fill_gregset (regcache, &gregset, regno);
376+
377+ if (ptrace (PTRACE_SETREGS, tid, 0, (void *) &gregset) < 0)
378+ {
379+ if (errno == EIO)
380+ {
381+ have_ptrace_getsetregs = 0;
382+ return 0;
383+ }
384+ perror_with_name (_("Couldn't set general-purpose registers."));
385+ }
386+
387+ return 1;
388+}
389+
390+/* This is a wrapper for the store_all_gp_regs function. It is
391+ responsible for verifying if this target has the ptrace request
392+ that can be used to store all general-purpose registers at one
393+ shot. If it doesn't, then we should store them using the
394+ old-fashioned way, which is to iterate over the registers and
395+ store them one by one. */
396+static void
397+store_gp_regs (const struct regcache *regcache, int tid, int regno)
398+{
399+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
400+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
401+ int i;
402+
403+ if (have_ptrace_getsetregs)
404+ if (store_all_gp_regs (regcache, tid, regno))
405+ return;
406+
407+ /* If we hit this point, it doesn't really matter which
408+ architecture we are using. We just need to store the
409+ registers in the "old-fashioned way". */
410+ for (i = MICROBLAZE_R0_REGNUM; i <= MICROBLAZE_FSR_REGNUM; i++)
411+ store_register (regcache, tid, i);
412+}
413+
414+
415+/* Fetch registers from the child process. Fetch all registers if
416+ regno == -1, otherwise fetch all general registers or all floating
417+ point registers depending upon the value of regno. */
418+
419+static void
420+microblaze_linux_fetch_inferior_registers (struct target_ops *ops,
421+ struct regcache *regcache, int regno)
422+{
423+ /* Get the thread id for the ptrace call. */
424+ int tid = GET_THREAD_ID (inferior_ptid);
425+
426+ if (regno == -1)
427+ fetch_gp_regs (regcache, tid);
428+ else
429+ fetch_register (regcache, tid, regno);
430+}
431+
432+/* Store registers back into the inferior. Store all registers if
433+ regno == -1, otherwise store all general registers or all floating
434+ point registers depending upon the value of regno. */
435+
436+static void
437+microblaze_linux_store_inferior_registers (struct target_ops *ops,
438+ struct regcache *regcache, int regno)
439+{
440+ /* Get the thread id for the ptrace call. */
441+ int tid = GET_THREAD_ID (inferior_ptid);
442+
443+ if (regno >= 0)
444+ store_register (regcache, tid, regno);
445+ else
446+ store_gp_regs (regcache, tid, -1);
447+}
448+
449+/* Wrapper functions for the standard regset handling, used by
450+ thread debugging. */
451+
452+void
453+fill_gregset (const struct regcache *regcache,
454+ gdb_gregset_t *gregsetp, int regno)
455+{
456+ microblaze_collect_gregset (NULL, regcache, regno, gregsetp);
457+}
458+
459+void
460+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
461+{
462+ microblaze_supply_gregset (NULL, regcache, -1, gregsetp);
463+}
464+
465+void
466+fill_fpregset (const struct regcache *regcache,
467+ gdb_fpregset_t *fpregsetp, int regno)
468+{
469+ /* FIXME. */
470+}
471+
472+void
473+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
474+{
475+ /* FIXME. */
476+}
477+
478+static const struct target_desc *
479+microblaze_linux_read_description (struct target_ops *ops)
480+{
481+ CORE_ADDR microblaze_hwcap = 0;
482+
483+ if (target_auxv_search (ops, AT_HWCAP, &microblaze_hwcap) != 1)
484+ return NULL;
485+
486+ return NULL;
487+}
488+
489+
490+void _initialize_microblaze_linux_nat (void);
491+
492+void
493+_initialize_microblaze_linux_nat (void)
494+{
495+ struct target_ops *t;
496+
497+ /* Fill in the generic GNU/Linux methods. */
498+ t = linux_target ();
499+
500+ /* Add our register access methods. */
501+ t->to_fetch_registers = microblaze_linux_fetch_inferior_registers;
502+ t->to_store_registers = microblaze_linux_store_inferior_registers;
503+
504+ t->to_read_description = microblaze_linux_read_description;
505+
506+ /* Register the target. */
507+ linux_nat_add_target (t);
508+}
509--
5102.17.1
511
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0039-Fixing-the-issues-related-to-GDB-7.12.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0039-Fixing-the-issues-related-to-GDB-7.12.patch
new file mode 100644
index 00000000..b8fb68bc
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0039-Fixing-the-issues-related-to-GDB-7.12.patch
@@ -0,0 +1,309 @@
1From e3e7d58035fb75b6cf33689352c6e22309c6dbde Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 17 Feb 2017 14:09:40 +0530
4Subject: [PATCH 39/43] Fixing the issues related to GDB-7.12 added all the
5 required function which are new in 7.12 and removed few deprecated functions
6 from 7.6
7
8---
9 gdb/config/microblaze/linux.mh | 4 +-
10 gdb/gdbserver/configure.srv | 3 +-
11 gdb/gdbserver/linux-microblaze-low.c | 97 ++++++++++++++++++++++++----
12 gdb/microblaze-linux-tdep.c | 68 +++++++++++++++++--
13 gdb/microblaze-tdep.h | 1 +
14 5 files changed, 153 insertions(+), 20 deletions(-)
15
16diff --git a/gdb/config/microblaze/linux.mh b/gdb/config/microblaze/linux.mh
17index a4eaf540e1..74a53b854a 100644
18--- a/gdb/config/microblaze/linux.mh
19+++ b/gdb/config/microblaze/linux.mh
20@@ -1,9 +1,11 @@
21 # Host: Microblaze, running Linux
22
23+#linux-nat.o linux-waitpid.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
24 NAT_FILE= config/nm-linux.h
25 NATDEPFILES= inf-ptrace.o fork-child.o \
26 microblaze-linux-nat.o proc-service.o linux-thread-db.o \
27- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
28+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
29+ linux-waitpid.o linux-personality.o linux-namespaces.o
30 NAT_CDEPS = $(srcdir)/proc-service.list
31
32 LOADLIBES = -ldl $(RDYNAMIC)
33diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
34index 153dcb4c71..201b7ae190 100644
35--- a/gdb/gdbserver/configure.srv
36+++ b/gdb/gdbserver/configure.srv
37@@ -211,8 +211,7 @@ case "${target}" in
38 srv_linux_thread_db=yes
39 ;;
40 microblaze*-*-linux*) srv_regobj=microblaze-linux.o
41- srv_tgtobj="linux-low.o linux-osdata.o linux-microblaze-low.o "
42- srv_tgtobj="${srv_tgtobj} linux-procfs.o linux-ptrace.o"
43+ srv_tgtobj="$srv_linux_obj linux-microblaze-low.o "
44 srv_linux_regsets=yes
45 srv_linux_usrregs=yes
46 srv_linux_thread_db=yes
47diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c
48index cba5d6fc58..a2733f3c21 100644
49--- a/gdb/gdbserver/linux-microblaze-low.c
50+++ b/gdb/gdbserver/linux-microblaze-low.c
51@@ -39,10 +39,11 @@ static int microblaze_regmap[] =
52 PT_FSR
53 };
54
55-#define microblaze_num_regs (sizeof microblaze_regmap / sizeof microblaze_regmap[0])
56+#define microblaze_num_regs (sizeof (microblaze_regmap) / sizeof (microblaze_regmap[0]))
57
58 /* Defined in auto-generated file microblaze-linux.c. */
59 void init_registers_microblaze (void);
60+extern const struct target_desc *tdesc_microblaze;
61
62 static int
63 microblaze_cannot_store_register (int regno)
64@@ -81,6 +82,15 @@ microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
65 static const unsigned long microblaze_breakpoint = 0xba0c0018;
66 #define microblaze_breakpoint_len 4
67
68+/* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
69+
70+static const gdb_byte *
71+microblaze_sw_breakpoint_from_kind (int kind, int *size)
72+{
73+ *size = microblaze_breakpoint_len;
74+ return (const gdb_byte *) &microblaze_breakpoint;
75+}
76+
77 static int
78 microblaze_breakpoint_at (CORE_ADDR where)
79 {
80@@ -107,7 +117,7 @@ microblaze_reinsert_addr (struct regcache *regcache)
81 static void
82 microblaze_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
83 {
84- int size = register_size (regno);
85+ int size = register_size (regcache->tdesc, regno);
86
87 memset (buf, 0, sizeof (long));
88
89@@ -121,7 +131,7 @@ static void
90 microblaze_supply_ptrace_register (struct regcache *regcache,
91 int regno, const char *buf)
92 {
93- int size = register_size (regno);
94+ int size = register_size (regcache->tdesc, regno);
95
96 if (regno == 0) {
97 unsigned long regbuf_0 = 0;
98@@ -157,33 +167,94 @@ microblaze_store_gregset (struct regcache *regcache, const void *buf)
99
100 #endif /* HAVE_PTRACE_GETREGS */
101
102-struct regset_info target_regsets[] = {
103+static struct regset_info microblaze_regsets[] = {
104 #ifdef HAVE_PTRACE_GETREGS
105 { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
106- { 0, 0, 0, -1, -1, NULL, NULL },
107+ { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
108 #endif /* HAVE_PTRACE_GETREGS */
109- { 0, 0, 0, -1, -1, NULL, NULL }
110+ { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
111+ NULL_REGSET
112 };
113
114+static struct usrregs_info microblaze_usrregs_info =
115+ {
116+ microblaze_num_regs,
117+ microblaze_regmap,
118+ };
119+
120+static struct regsets_info microblaze_regsets_info =
121+ {
122+ microblaze_regsets, /* regsets */
123+ 0, /* num_regsets */
124+ NULL, /* disabled_regsets */
125+ };
126+
127+static struct regs_info regs_info =
128+ {
129+ NULL, /* regset_bitmap */
130+ &microblaze_usrregs_info,
131+ &microblaze_regsets_info
132+ };
133+
134+static const struct regs_info *
135+microblaze_regs_info (void)
136+{
137+ return &regs_info;
138+}
139+
140+/* Support for hardware single step. */
141+
142+static int
143+microblaze_supports_hardware_single_step (void)
144+{
145+ return 1;
146+}
147+
148+
149+static void
150+microblaze_arch_setup (void)
151+{
152+ current_process ()->tdesc = tdesc_microblaze;
153+}
154+
155 struct linux_target_ops the_low_target = {
156- init_registers_microblaze,
157- microblaze_num_regs,
158- microblaze_regmap,
159- NULL,
160+ microblaze_arch_setup,
161+ microblaze_regs_info,
162 microblaze_cannot_fetch_register,
163 microblaze_cannot_store_register,
164 NULL, /* fetch_register */
165 microblaze_get_pc,
166 microblaze_set_pc,
167- (const unsigned char *) &microblaze_breakpoint,
168- microblaze_breakpoint_len,
169- microblaze_reinsert_addr,
170+ NULL,
171+ microblaze_sw_breakpoint_from_kind,
172+ NULL,
173 0,
174 microblaze_breakpoint_at,
175 NULL,
176 NULL,
177 NULL,
178 NULL,
179+ NULL,
180 microblaze_collect_ptrace_register,
181 microblaze_supply_ptrace_register,
182+ NULL, /* siginfo_fixup */
183+ NULL, /* new_process */
184+ NULL, /* new_thread */
185+ NULL, /* new_fork */
186+ NULL, /* prepare_to_resume */
187+ NULL, /* process_qsupported */
188+ NULL, /* supports_tracepoints */
189+ NULL, /* get_thread_area */
190+ NULL, /* install_fast_tracepoint_jump_pad */
191+ NULL, /* emit_ops */
192+ NULL, /* get_min_fast_tracepoint_insn_len */
193+ NULL, /* supports_range_stepping */
194+ NULL, /* breakpoint_kind_from_current_state */
195+ microblaze_supports_hardware_single_step,
196 };
197+
198+void
199+initialize_low_arch (void)
200+{
201+ init_registers_microblaze ();
202+}
203diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
204index e2225d778a..011e513941 100644
205--- a/gdb/microblaze-linux-tdep.c
206+++ b/gdb/microblaze-linux-tdep.c
207@@ -29,13 +29,76 @@
208 #include "regcache.h"
209 #include "value.h"
210 #include "osabi.h"
211-#include "regset.h"
212 #include "solib-svr4.h"
213 #include "microblaze-tdep.h"
214 #include "trad-frame.h"
215 #include "frame-unwind.h"
216 #include "tramp-frame.h"
217 #include "linux-tdep.h"
218+#include "glibc-tdep.h"
219+
220+#include "gdb_assert.h"
221+
222+#ifndef REGSET_H
223+#define REGSET_H 1
224+
225+struct gdbarch;
226+struct regcache;
227+
228+/* Data structure for the supported register notes in a core file. */
229+struct core_regset_section
230+{
231+ const char *sect_name;
232+ int size;
233+ const char *human_name;
234+};
235+
236+/* Data structure describing a register set. */
237+
238+typedef void (supply_regset_ftype) (const struct regset *, struct regcache *,
239+ int, const void *, size_t);
240+typedef void (collect_regset_ftype) (const struct regset *,
241+ const struct regcache *,
242+ int, void *, size_t);
243+
244+struct regset
245+{
246+ /* Data pointer for private use by the methods below, presumably
247+ providing some sort of description of the register set. */
248+ const void *descr;
249+
250+ /* Function supplying values in a register set to a register cache. */
251+ supply_regset_ftype *supply_regset;
252+
253+ /* Function collecting values in a register set from a register cache. */
254+ collect_regset_ftype *collect_regset;
255+
256+ /* Architecture associated with the register set. */
257+ struct gdbarch *arch;
258+};
259+
260+#endif
261+
262+/* Allocate a fresh 'struct regset' whose supply_regset function is
263+ SUPPLY_REGSET, and whose collect_regset function is COLLECT_REGSET.
264+ If the regset has no collect_regset function, pass NULL for
265+ COLLECT_REGSET.
266+
267+ The object returned is allocated on ARCH's obstack. */
268+
269+struct regset *
270+regset_alloc (struct gdbarch *arch,
271+ supply_regset_ftype *supply_regset,
272+ collect_regset_ftype *collect_regset)
273+{
274+ struct regset *regset = GDBARCH_OBSTACK_ZALLOC (arch, struct regset);
275+
276+ regset->arch = arch;
277+ regset->supply_regset = supply_regset;
278+ regset->collect_regset = collect_regset;
279+
280+ return regset;
281+}
282
283 static int microblaze_debug_flag = 0;
284
285@@ -207,9 +270,6 @@ microblaze_linux_init_abi (struct gdbarch_info info,
286 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
287 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
288
289- set_gdbarch_regset_from_core_section (gdbarch,
290- microblaze_regset_from_core_section);
291-
292 /* Enable TLS support. */
293 set_gdbarch_fetch_tls_load_module_address (gdbarch,
294 svr4_fetch_objfile_link_map);
295diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
296index 02650f61d9..3777cbb6a8 100644
297--- a/gdb/microblaze-tdep.h
298+++ b/gdb/microblaze-tdep.h
299@@ -24,6 +24,7 @@
300 /* Microblaze architecture-specific information. */
301 struct microblaze_gregset
302 {
303+ microblaze_gregset() {}
304 unsigned int gregs[32];
305 unsigned int fpregs[32];
306 unsigned int pregs[16];
307--
3082.17.1
309
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0040-Patch-microblaze-Adding-64-bit-MB-support.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0040-Patch-microblaze-Adding-64-bit-MB-support.patch
new file mode 100644
index 00000000..e89d4049
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0040-Patch-microblaze-Adding-64-bit-MB-support.patch
@@ -0,0 +1,1110 @@
1From ecaa548038df1ebf653ef3c3429e49c207461b19 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 31 Jan 2019 14:36:00 +0530
4Subject: [PATCH 40/43] [Patch, microblaze]: Adding 64 bit MB support Added new
5 architecture to Microblaze 64-bit support to GDB Signed-off-by :Nagaraju
6 Mekala <nmekala@xilix.com>
7
8Merged on top of binutils work.
9
10Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
11---
12 bfd/archures.c | 2 +
13 bfd/bfd-in2.h | 2 +
14 bfd/cpu-microblaze.c | 12 +-
15 bfd/elf32-microblaze.c | 93 +-------
16 gdb/Makefile.in | 2 +-
17 gdb/features/Makefile | 3 +
18 gdb/features/microblaze-core.xml | 6 +-
19 gdb/features/microblaze-stack-protect.xml | 4 +-
20 gdb/features/microblaze-with-stack-protect.c | 8 +-
21 gdb/features/microblaze.c | 6 +-
22 gdb/features/microblaze64-core.xml | 69 ++++++
23 gdb/features/microblaze64-stack-protect.xml | 12 +
24 .../microblaze64-with-stack-protect.c | 79 +++++++
25 .../microblaze64-with-stack-protect.xml | 12 +
26 gdb/features/microblaze64.c | 77 +++++++
27 gdb/features/microblaze64.xml | 11 +
28 gdb/microblaze-tdep.c | 207 ++++++++++++++++--
29 gdb/microblaze-tdep.h | 8 +-
30 .../microblaze-with-stack-protect.dat | 4 +-
31 opcodes/microblaze-opc.h | 1 -
32 22 files changed, 504 insertions(+), 134 deletions(-)
33 create mode 100644 gdb/features/microblaze64-core.xml
34 create mode 100644 gdb/features/microblaze64-stack-protect.xml
35 create mode 100644 gdb/features/microblaze64-with-stack-protect.c
36 create mode 100644 gdb/features/microblaze64-with-stack-protect.xml
37 create mode 100644 gdb/features/microblaze64.c
38 create mode 100644 gdb/features/microblaze64.xml
39
40diff --git a/bfd/archures.c b/bfd/archures.c
41index 647cf0d8d4..3fdf7c3c0e 100644
42--- a/bfd/archures.c
43+++ b/bfd/archures.c
44@@ -512,6 +512,8 @@ DESCRIPTION
45 . bfd_arch_lm32, {* Lattice Mico32. *}
46 .#define bfd_mach_lm32 1
47 . bfd_arch_microblaze,{* Xilinx MicroBlaze. *}
48+.#define bfd_mach_microblaze 1
49+.#define bfd_mach_microblaze64 2
50 . bfd_arch_tilepro, {* Tilera TILEPro. *}
51 . bfd_arch_tilegx, {* Tilera TILE-Gx. *}
52 .#define bfd_mach_tilepro 1
53diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
54index 33c9cb62d9..db624c62b9 100644
55--- a/bfd/bfd-in2.h
56+++ b/bfd/bfd-in2.h
57@@ -2411,6 +2411,8 @@ enum bfd_architecture
58 bfd_arch_lm32, /* Lattice Mico32. */
59 #define bfd_mach_lm32 1
60 bfd_arch_microblaze,/* Xilinx MicroBlaze. */
61+#define bfd_mach_microblaze 1
62+#define bfd_mach_microblaze64 2
63 bfd_arch_tilepro, /* Tilera TILEPro. */
64 bfd_arch_tilegx, /* Tilera TILE-Gx. */
65 #define bfd_mach_tilepro 1
66diff --git a/bfd/cpu-microblaze.c b/bfd/cpu-microblaze.c
67index c91ba46f75..8e7bcead28 100644
68--- a/bfd/cpu-microblaze.c
69+++ b/bfd/cpu-microblaze.c
70@@ -30,8 +30,8 @@ const bfd_arch_info_type bfd_microblaze_arch[] =
71 64, /* 32 bits in a word. */
72 64, /* 32 bits in an address. */
73 8, /* 8 bits in a byte. */
74- bfd_arch_microblaze, /* Architecture. */
75- 0, /* Machine number - 0 for now. */
76+ bfd_arch_microblaze, /* Architecture. */
77+ bfd_mach_microblaze64, /* 64 bit Machine */
78 "microblaze", /* Architecture name. */
79 "MicroBlaze", /* Printable name. */
80 3, /* Section align power. */
81@@ -46,7 +46,7 @@ const bfd_arch_info_type bfd_microblaze_arch[] =
82 32, /* 32 bits in an address. */
83 8, /* 8 bits in a byte. */
84 bfd_arch_microblaze, /* Architecture. */
85- 0, /* Machine number - 0 for now. */
86+ bfd_mach_microblaze, /* 32 bit Machine */
87 "microblaze", /* Architecture name. */
88 "MicroBlaze", /* Printable name. */
89 3, /* Section align power. */
90@@ -62,7 +62,7 @@ const bfd_arch_info_type bfd_microblaze_arch[] =
91 32, /* 32 bits in an address. */
92 8, /* 8 bits in a byte. */
93 bfd_arch_microblaze, /* Architecture. */
94- 0, /* Machine number - 0 for now. */
95+ bfd_mach_microblaze, /* 32 bit Machine */
96 "microblaze", /* Architecture name. */
97 "MicroBlaze", /* Printable name. */
98 3, /* Section align power. */
99@@ -76,8 +76,8 @@ const bfd_arch_info_type bfd_microblaze_arch[] =
100 64, /* 32 bits in a word. */
101 64, /* 32 bits in an address. */
102 8, /* 8 bits in a byte. */
103- bfd_arch_microblaze, /* Architecture. */
104- 0, /* Machine number - 0 for now. */
105+ bfd_arch_microblaze, /* Architecture. */
106+ bfd_mach_microblaze64, /* 64 bit Machine */
107 "microblaze", /* Architecture name. */
108 "MicroBlaze", /* Printable name. */
109 3, /* Section align power. */
110diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
111index c280431df6..f9996eae12 100644
112--- a/bfd/elf32-microblaze.c
113+++ b/bfd/elf32-microblaze.c
114@@ -767,87 +767,6 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
115 return _bfd_elf_is_local_label_name (abfd, name);
116 }
117
118-/* Support for core dump NOTE sections. */
119-static bfd_boolean
120-microblaze_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
121-{
122- int offset;
123- unsigned int size;
124-
125- switch (note->descsz)
126- {
127- default:
128- return FALSE;
129-
130- case 228: /* Linux/MicroBlaze */
131- /* pr_cursig */
132- elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
133-
134- /* pr_pid */
135- elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
136-
137- /* pr_reg */
138- offset = 72;
139- size = 50 * 4;
140-
141- break;
142- }
143-
144- /* Make a ".reg/999" section. */
145- return _bfd_elfcore_make_pseudosection (abfd, ".reg",
146- size, note->descpos + offset);
147-}
148-
149-static bfd_boolean
150-microblaze_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
151-{
152- switch (note->descsz)
153- {
154- default:
155- return FALSE;
156-
157- case 128: /* Linux/MicroBlaze elf_prpsinfo */
158- elf_tdata (abfd)->core->program
159- = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
160- elf_tdata (abfd)->core->command
161- = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
162- }
163-
164- /* Note that for some reason, a spurious space is tacked
165- onto the end of the args in some (at least one anyway)
166- implementations, so strip it off if it exists. */
167-
168- {
169- char *command = elf_tdata (abfd)->core->command;
170- int n = strlen (command);
171-
172- if (0 < n && command[n - 1] == ' ')
173- command[n - 1] = '\0';
174- }
175-
176- return TRUE;
177-}
178-
179-/* The microblaze linker (like many others) needs to keep track of
180- the number of relocs that it decides to copy as dynamic relocs in
181- check_relocs for each symbol. This is so that it can later discard
182- them if they are found to be unnecessary. We store the information
183- in a field extending the regular ELF linker hash table. */
184-
185-struct elf32_mb_dyn_relocs
186-{
187- struct elf32_mb_dyn_relocs *next;
188-
189- /* The input section of the reloc. */
190- asection *sec;
191-
192- /* Total number of relocs copied for the input section. */
193- bfd_size_type count;
194-
195- /* Number of pc-relative relocs copied for the input section. */
196- bfd_size_type pc_count;
197-};
198-
199 /* ELF linker hash entry. */
200
201 struct elf32_mb_link_hash_entry
202@@ -3683,6 +3602,14 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
203 return TRUE;
204 }
205
206+
207+static bfd_boolean
208+elf_microblaze_object_p (bfd *abfd)
209+{
210+ /* Set the right machine number for an s390 elf32 file. */
211+ return bfd_default_set_arch_mach (abfd, bfd_arch_microblaze, bfd_mach_microblaze);
212+}
213+
214 /* Hook called by the linker routine which adds symbols from an object
215 file. We use it to put .comm items in .sbss, and not .bss. */
216
217@@ -3752,8 +3679,6 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
218 #define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
219 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
220 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
221-
222-#define elf_backend_grok_prstatus microblaze_elf_grok_prstatus
223-#define elf_backend_grok_psinfo microblaze_elf_grok_psinfo
224+#define elf_backend_object_p elf_microblaze_object_p
225
226 #include "elf32-target.h"
227diff --git a/gdb/Makefile.in b/gdb/Makefile.in
228index d620580498..69b003f8cb 100644
229--- a/gdb/Makefile.in
230+++ b/gdb/Makefile.in
231@@ -2265,7 +2265,7 @@ ALLDEPFILES = \
232 m68k-tdep.c \
233 microblaze-linux-tdep.c \
234 microblaze-tdep.c \
235- microblaze-linux-nat.c \
236+ microblaze-linux-nat.c \
237 mingw-hdep.c \
238 mips-fbsd-nat.c \
239 mips-fbsd-tdep.c \
240diff --git a/gdb/features/Makefile b/gdb/features/Makefile
241index 3d84ca09a1..fdeec19753 100644
242--- a/gdb/features/Makefile
243+++ b/gdb/features/Makefile
244@@ -64,6 +64,7 @@ WHICH = aarch64 \
245 i386/x32-avx-avx512-linux \
246 mips-linux mips-dsp-linux \
247 microblaze-with-stack-protect \
248+ microblaze64-with-stack-protect \
249 mips64-linux mips64-dsp-linux \
250 nios2-linux \
251 rs6000/powerpc-32 \
252@@ -135,7 +136,9 @@ XMLTOC = \
253 arm/arm-with-vfpv2.xml \
254 arm/arm-with-vfpv3.xml \
255 microblaze-with-stack-protect.xml \
256+ microblaze64-with-stack-protect.xml \
257 microblaze.xml \
258+ microblaze64.xml \
259 mips-dsp-linux.xml \
260 mips-linux.xml \
261 mips64-dsp-linux.xml \
262diff --git a/gdb/features/microblaze-core.xml b/gdb/features/microblaze-core.xml
263index 88c93e5d66..5bc3e49f84 100644
264--- a/gdb/features/microblaze-core.xml
265+++ b/gdb/features/microblaze-core.xml
266@@ -8,7 +8,7 @@
267 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
268 <feature name="org.gnu.gdb.microblaze.core">
269 <reg name="r0" bitsize="32" regnum="0"/>
270- <reg name="r1" bitsize="32" type="data_ptr"/>
271+ <reg name="r1" bitsize="32"/>
272 <reg name="r2" bitsize="32"/>
273 <reg name="r3" bitsize="32"/>
274 <reg name="r4" bitsize="32"/>
275@@ -39,7 +39,7 @@
276 <reg name="r29" bitsize="32"/>
277 <reg name="r30" bitsize="32"/>
278 <reg name="r31" bitsize="32"/>
279- <reg name="rpc" bitsize="32" type="code_ptr"/>
280+ <reg name="rpc" bitsize="32"/>
281 <reg name="rmsr" bitsize="32"/>
282 <reg name="rear" bitsize="32"/>
283 <reg name="resr" bitsize="32"/>
284@@ -64,4 +64,6 @@
285 <reg name="rtlbsx" bitsize="32"/>
286 <reg name="rtlblo" bitsize="32"/>
287 <reg name="rtlbhi" bitsize="32"/>
288+ <reg name="slr" bitsize="32"/>
289+ <reg name="shr" bitsize="32"/>
290 </feature>
291diff --git a/gdb/features/microblaze-stack-protect.xml b/gdb/features/microblaze-stack-protect.xml
292index 870c148bb0..a7f27b903c 100644
293--- a/gdb/features/microblaze-stack-protect.xml
294+++ b/gdb/features/microblaze-stack-protect.xml
295@@ -7,6 +7,6 @@
296
297 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
298 <feature name="org.gnu.gdb.microblaze.stack-protect">
299- <reg name="rslr" bitsize="32"/>
300- <reg name="rshr" bitsize="32"/>
301+ <reg name="slr" bitsize="32"/>
302+ <reg name="shr" bitsize="32"/>
303 </feature>
304diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c
305index b39aa19887..609934e2b4 100644
306--- a/gdb/features/microblaze-with-stack-protect.c
307+++ b/gdb/features/microblaze-with-stack-protect.c
308@@ -14,7 +14,7 @@ initialize_tdesc_microblaze_with_stack_protect (void)
309
310 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core");
311 tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
312- tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "data_ptr");
313+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
314 tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
315 tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int");
316 tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int");
317@@ -45,7 +45,7 @@ initialize_tdesc_microblaze_with_stack_protect (void)
318 tdesc_create_reg (feature, "r29", 29, 1, NULL, 32, "int");
319 tdesc_create_reg (feature, "r30", 30, 1, NULL, 32, "int");
320 tdesc_create_reg (feature, "r31", 31, 1, NULL, 32, "int");
321- tdesc_create_reg (feature, "rpc", 32, 1, NULL, 32, "code_ptr");
322+ tdesc_create_reg (feature, "rpc", 32, 1, NULL, 32, "int");
323 tdesc_create_reg (feature, "rmsr", 33, 1, NULL, 32, "int");
324 tdesc_create_reg (feature, "rear", 34, 1, NULL, 32, "int");
325 tdesc_create_reg (feature, "resr", 35, 1, NULL, 32, "int");
326@@ -72,8 +72,8 @@ initialize_tdesc_microblaze_with_stack_protect (void)
327 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
328
329 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.stack-protect");
330- tdesc_create_reg (feature, "rslr", 57, 1, NULL, 32, "int");
331- tdesc_create_reg (feature, "rshr", 58, 1, NULL, 32, "int");
332+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 32, "int");
333+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 32, "int");
334
335 tdesc_microblaze_with_stack_protect = result;
336 }
337diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c
338index 6c86fc0770..ceb98ca8b8 100644
339--- a/gdb/features/microblaze.c
340+++ b/gdb/features/microblaze.c
341@@ -14,7 +14,7 @@ initialize_tdesc_microblaze (void)
342
343 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core");
344 tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
345- tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "data_ptr");
346+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
347 tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
348 tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int");
349 tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int");
350@@ -45,7 +45,7 @@ initialize_tdesc_microblaze (void)
351 tdesc_create_reg (feature, "r29", 29, 1, NULL, 32, "int");
352 tdesc_create_reg (feature, "r30", 30, 1, NULL, 32, "int");
353 tdesc_create_reg (feature, "r31", 31, 1, NULL, 32, "int");
354- tdesc_create_reg (feature, "rpc", 32, 1, NULL, 32, "code_ptr");
355+ tdesc_create_reg (feature, "rpc", 32, 1, NULL, 32, "int");
356 tdesc_create_reg (feature, "rmsr", 33, 1, NULL, 32, "int");
357 tdesc_create_reg (feature, "rear", 34, 1, NULL, 32, "int");
358 tdesc_create_reg (feature, "resr", 35, 1, NULL, 32, "int");
359@@ -70,6 +70,8 @@ initialize_tdesc_microblaze (void)
360 tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
361 tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
362 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
363+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
364+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
365
366 tdesc_microblaze = result;
367 }
368diff --git a/gdb/features/microblaze64-core.xml b/gdb/features/microblaze64-core.xml
369new file mode 100644
370index 0000000000..96e99e2fb2
371--- /dev/null
372+++ b/gdb/features/microblaze64-core.xml
373@@ -0,0 +1,69 @@
374+<?xml version="1.0"?>
375+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
376+
377+ Copying and distribution of this file, with or without modification,
378+ are permitted in any medium without royalty provided the copyright
379+ notice and this notice are preserved. -->
380+
381+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
382+<feature name="org.gnu.gdb.microblaze64.core">
383+ <reg name="r0" bitsize="64" regnum="0"/>
384+ <reg name="r1" bitsize="64"/>
385+ <reg name="r2" bitsize="64"/>
386+ <reg name="r3" bitsize="64"/>
387+ <reg name="r4" bitsize="64"/>
388+ <reg name="r5" bitsize="64"/>
389+ <reg name="r6" bitsize="64"/>
390+ <reg name="r7" bitsize="64"/>
391+ <reg name="r8" bitsize="64"/>
392+ <reg name="r9" bitsize="64"/>
393+ <reg name="r10" bitsize="64"/>
394+ <reg name="r11" bitsize="64"/>
395+ <reg name="r12" bitsize="64"/>
396+ <reg name="r13" bitsize="64"/>
397+ <reg name="r14" bitsize="64"/>
398+ <reg name="r15" bitsize="64"/>
399+ <reg name="r16" bitsize="64"/>
400+ <reg name="r17" bitsize="64"/>
401+ <reg name="r18" bitsize="64"/>
402+ <reg name="r19" bitsize="64"/>
403+ <reg name="r20" bitsize="64"/>
404+ <reg name="r21" bitsize="64"/>
405+ <reg name="r22" bitsize="64"/>
406+ <reg name="r23" bitsize="64"/>
407+ <reg name="r24" bitsize="64"/>
408+ <reg name="r25" bitsize="64"/>
409+ <reg name="r26" bitsize="64"/>
410+ <reg name="r27" bitsize="64"/>
411+ <reg name="r28" bitsize="64"/>
412+ <reg name="r29" bitsize="64"/>
413+ <reg name="r30" bitsize="64"/>
414+ <reg name="r31" bitsize="64"/>
415+ <reg name="rpc" bitsize="64"/>
416+ <reg name="rmsr" bitsize="32"/>
417+ <reg name="rear" bitsize="64"/>
418+ <reg name="resr" bitsize="32"/>
419+ <reg name="rfsr" bitsize="32"/>
420+ <reg name="rbtr" bitsize="64"/>
421+ <reg name="rpvr0" bitsize="32"/>
422+ <reg name="rpvr1" bitsize="32"/>
423+ <reg name="rpvr2" bitsize="32"/>
424+ <reg name="rpvr3" bitsize="32"/>
425+ <reg name="rpvr4" bitsize="32"/>
426+ <reg name="rpvr5" bitsize="32"/>
427+ <reg name="rpvr6" bitsize="32"/>
428+ <reg name="rpvr7" bitsize="32"/>
429+ <reg name="rpvr8" bitsize="64"/>
430+ <reg name="rpvr9" bitsize="64"/>
431+ <reg name="rpvr10" bitsize="32"/>
432+ <reg name="rpvr11" bitsize="32"/>
433+ <reg name="redr" bitsize="32"/>
434+ <reg name="rpid" bitsize="32"/>
435+ <reg name="rzpr" bitsize="32"/>
436+ <reg name="rtlbx" bitsize="32"/>
437+ <reg name="rtlbsx" bitsize="32"/>
438+ <reg name="rtlblo" bitsize="32"/>
439+ <reg name="rtlbhi" bitsize="32"/>
440+ <reg name="slr" bitsize="64"/>
441+ <reg name="shr" bitsize="64"/>
442+</feature>
443diff --git a/gdb/features/microblaze64-stack-protect.xml b/gdb/features/microblaze64-stack-protect.xml
444new file mode 100644
445index 0000000000..1bbf5fc3ce
446--- /dev/null
447+++ b/gdb/features/microblaze64-stack-protect.xml
448@@ -0,0 +1,12 @@
449+<?xml version="1.0"?>
450+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
451+
452+ Copying and distribution of this file, with or without modification,
453+ are permitted in any medium without royalty provided the copyright
454+ notice and this notice are preserved. -->
455+
456+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
457+<feature name="org.gnu.gdb.microblaze64.stack-protect">
458+ <reg name="slr" bitsize="64"/>
459+ <reg name="shr" bitsize="64"/>
460+</feature>
461diff --git a/gdb/features/microblaze64-with-stack-protect.c b/gdb/features/microblaze64-with-stack-protect.c
462new file mode 100644
463index 0000000000..f448c9a749
464--- /dev/null
465+++ b/gdb/features/microblaze64-with-stack-protect.c
466@@ -0,0 +1,79 @@
467+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
468+ Original: microblaze-with-stack-protect.xml */
469+
470+#include "defs.h"
471+#include "osabi.h"
472+#include "target-descriptions.h"
473+
474+struct target_desc *tdesc_microblaze64_with_stack_protect;
475+static void
476+initialize_tdesc_microblaze64_with_stack_protect (void)
477+{
478+ struct target_desc *result = allocate_target_description ();
479+ struct tdesc_feature *feature;
480+
481+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.core");
482+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64");
483+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64");
484+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64");
485+ tdesc_create_reg (feature, "r3", 3, 1, NULL, 64, "uint64");
486+ tdesc_create_reg (feature, "r4", 4, 1, NULL, 64, "uint64");
487+ tdesc_create_reg (feature, "r5", 5, 1, NULL, 64, "uint64");
488+ tdesc_create_reg (feature, "r6", 6, 1, NULL, 64, "uint64");
489+ tdesc_create_reg (feature, "r7", 7, 1, NULL, 64, "uint64");
490+ tdesc_create_reg (feature, "r8", 8, 1, NULL, 64, "uint64");
491+ tdesc_create_reg (feature, "r9", 9, 1, NULL, 64, "uint64");
492+ tdesc_create_reg (feature, "r10", 10, 1, NULL, 64, "uint64");
493+ tdesc_create_reg (feature, "r11", 11, 1, NULL, 64, "uint64");
494+ tdesc_create_reg (feature, "r12", 12, 1, NULL, 64, "uint64");
495+ tdesc_create_reg (feature, "r13", 13, 1, NULL, 64, "uint64");
496+ tdesc_create_reg (feature, "r14", 14, 1, NULL, 64, "uint64");
497+ tdesc_create_reg (feature, "r15", 15, 1, NULL, 64, "uint64");
498+ tdesc_create_reg (feature, "r16", 16, 1, NULL, 64, "uint64");
499+ tdesc_create_reg (feature, "r17", 17, 1, NULL, 64, "uint64");
500+ tdesc_create_reg (feature, "r18", 18, 1, NULL, 64, "uint64");
501+ tdesc_create_reg (feature, "r19", 19, 1, NULL, 64, "uint64");
502+ tdesc_create_reg (feature, "r20", 20, 1, NULL, 64, "uint64");
503+ tdesc_create_reg (feature, "r21", 21, 1, NULL, 64, "uint64");
504+ tdesc_create_reg (feature, "r22", 22, 1, NULL, 64, "uint64");
505+ tdesc_create_reg (feature, "r23", 23, 1, NULL, 64, "uint64");
506+ tdesc_create_reg (feature, "r24", 24, 1, NULL, 64, "uint64");
507+ tdesc_create_reg (feature, "r25", 25, 1, NULL, 64, "uint64");
508+ tdesc_create_reg (feature, "r26", 26, 1, NULL, 64, "uint64");
509+ tdesc_create_reg (feature, "r27", 27, 1, NULL, 64, "uint64");
510+ tdesc_create_reg (feature, "r28", 28, 1, NULL, 64, "uint64");
511+ tdesc_create_reg (feature, "r29", 29, 1, NULL, 64, "uint64");
512+ tdesc_create_reg (feature, "r30", 30, 1, NULL, 64, "uint64");
513+ tdesc_create_reg (feature, "r31", 31, 1, NULL, 64, "uint64");
514+ tdesc_create_reg (feature, "rpc", 32, 1, NULL, 64, "uint64");
515+ tdesc_create_reg (feature, "rmsr", 33, 1, NULL, 32, "int");
516+ tdesc_create_reg (feature, "rear", 34, 1, NULL, 64, "int");
517+ tdesc_create_reg (feature, "resr", 35, 1, NULL, 32, "int");
518+ tdesc_create_reg (feature, "rfsr", 36, 1, NULL, 32, "int");
519+ tdesc_create_reg (feature, "rbtr", 37, 1, NULL, 64, "uint64");
520+ tdesc_create_reg (feature, "rpvr0", 38, 1, NULL, 32, "int");
521+ tdesc_create_reg (feature, "rpvr1", 39, 1, NULL, 32, "int");
522+ tdesc_create_reg (feature, "rpvr2", 40, 1, NULL, 32, "int");
523+ tdesc_create_reg (feature, "rpvr3", 41, 1, NULL, 32, "int");
524+ tdesc_create_reg (feature, "rpvr4", 42, 1, NULL, 32, "int");
525+ tdesc_create_reg (feature, "rpvr5", 43, 1, NULL, 32, "int");
526+ tdesc_create_reg (feature, "rpvr6", 44, 1, NULL, 32, "int");
527+ tdesc_create_reg (feature, "rpvr7", 45, 1, NULL, 32, "int");
528+ tdesc_create_reg (feature, "rpvr8", 46, 1, NULL, 64, "uint64");
529+ tdesc_create_reg (feature, "rpvr9", 47, 1, NULL, 64, "uint64");
530+ tdesc_create_reg (feature, "rpvr10", 48, 1, NULL, 32, "int");
531+ tdesc_create_reg (feature, "rpvr11", 49, 1, NULL, 32, "int");
532+ tdesc_create_reg (feature, "redr", 50, 1, NULL, 32, "int");
533+ tdesc_create_reg (feature, "rpid", 51, 1, NULL, 32, "int");
534+ tdesc_create_reg (feature, "rzpr", 52, 1, NULL, 32, "int");
535+ tdesc_create_reg (feature, "rtlbx", 53, 1, NULL, 32, "int");
536+ tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
537+ tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
538+ tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
539+
540+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.stack-protect");
541+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
542+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
543+
544+ tdesc_microblaze64_with_stack_protect = result;
545+}
546diff --git a/gdb/features/microblaze64-with-stack-protect.xml b/gdb/features/microblaze64-with-stack-protect.xml
547new file mode 100644
548index 0000000000..0e9f01611f
549--- /dev/null
550+++ b/gdb/features/microblaze64-with-stack-protect.xml
551@@ -0,0 +1,12 @@
552+<?xml version="1.0"?>
553+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
554+
555+ Copying and distribution of this file, with or without modification,
556+ are permitted in any medium without royalty provided the copyright
557+ notice and this notice are preserved. -->
558+
559+<!DOCTYPE target SYSTEM "gdb-target.dtd">
560+<target>
561+ <xi:include href="microblaze64-core.xml"/>
562+ <xi:include href="microblaze64-stack-protect.xml"/>
563+</target>
564diff --git a/gdb/features/microblaze64.c b/gdb/features/microblaze64.c
565new file mode 100644
566index 0000000000..1aa37c4512
567--- /dev/null
568+++ b/gdb/features/microblaze64.c
569@@ -0,0 +1,77 @@
570+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
571+ Original: microblaze.xml */
572+
573+#include "defs.h"
574+#include "osabi.h"
575+#include "target-descriptions.h"
576+
577+struct target_desc *tdesc_microblaze64;
578+static void
579+initialize_tdesc_microblaze64 (void)
580+{
581+ struct target_desc *result = allocate_target_description ();
582+ struct tdesc_feature *feature;
583+
584+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.core");
585+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64");
586+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64");
587+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64");
588+ tdesc_create_reg (feature, "r3", 3, 1, NULL, 64, "uint64");
589+ tdesc_create_reg (feature, "r4", 4, 1, NULL, 64, "uint64");
590+ tdesc_create_reg (feature, "r5", 5, 1, NULL, 64, "uint64");
591+ tdesc_create_reg (feature, "r6", 6, 1, NULL, 64, "uint64");
592+ tdesc_create_reg (feature, "r7", 7, 1, NULL, 64, "uint64");
593+ tdesc_create_reg (feature, "r8", 8, 1, NULL, 64, "uint64");
594+ tdesc_create_reg (feature, "r9", 9, 1, NULL, 64, "uint64");
595+ tdesc_create_reg (feature, "r10", 10, 1, NULL, 64, "uint64");
596+ tdesc_create_reg (feature, "r11", 11, 1, NULL, 64, "uint64");
597+ tdesc_create_reg (feature, "r12", 12, 1, NULL, 64, "uint64");
598+ tdesc_create_reg (feature, "r13", 13, 1, NULL, 64, "uint64");
599+ tdesc_create_reg (feature, "r14", 14, 1, NULL, 64, "uint64");
600+ tdesc_create_reg (feature, "r15", 15, 1, NULL, 64, "uint64");
601+ tdesc_create_reg (feature, "r16", 16, 1, NULL, 64, "uint64");
602+ tdesc_create_reg (feature, "r17", 17, 1, NULL, 64, "uint64");
603+ tdesc_create_reg (feature, "r18", 18, 1, NULL, 64, "uint64");
604+ tdesc_create_reg (feature, "r19", 19, 1, NULL, 64, "uint64");
605+ tdesc_create_reg (feature, "r20", 20, 1, NULL, 64, "uint64");
606+ tdesc_create_reg (feature, "r21", 21, 1, NULL, 64, "uint64");
607+ tdesc_create_reg (feature, "r22", 22, 1, NULL, 64, "uint64");
608+ tdesc_create_reg (feature, "r23", 23, 1, NULL, 64, "uint64");
609+ tdesc_create_reg (feature, "r24", 24, 1, NULL, 64, "uint64");
610+ tdesc_create_reg (feature, "r25", 25, 1, NULL, 64, "uint64");
611+ tdesc_create_reg (feature, "r26", 26, 1, NULL, 64, "uint64");
612+ tdesc_create_reg (feature, "r27", 27, 1, NULL, 64, "uint64");
613+ tdesc_create_reg (feature, "r28", 28, 1, NULL, 64, "uint64");
614+ tdesc_create_reg (feature, "r29", 29, 1, NULL, 64, "uint64");
615+ tdesc_create_reg (feature, "r30", 30, 1, NULL, 64, "uint64");
616+ tdesc_create_reg (feature, "r31", 31, 1, NULL, 64, "uint64");
617+ tdesc_create_reg (feature, "rpc", 32, 1, NULL, 64, "uint64");
618+ tdesc_create_reg (feature, "rmsr", 33, 1, NULL, 32, "int");
619+ tdesc_create_reg (feature, "rear", 34, 1, NULL, 64, "uint64");
620+ tdesc_create_reg (feature, "resr", 35, 1, NULL, 32, "int");
621+ tdesc_create_reg (feature, "rfsr", 36, 1, NULL, 32, "int");
622+ tdesc_create_reg (feature, "rbtr", 37, 1, NULL, 64, "uint64");
623+ tdesc_create_reg (feature, "rpvr0", 38, 1, NULL, 32, "int");
624+ tdesc_create_reg (feature, "rpvr1", 39, 1, NULL, 32, "int");
625+ tdesc_create_reg (feature, "rpvr2", 40, 1, NULL, 32, "int");
626+ tdesc_create_reg (feature, "rpvr3", 41, 1, NULL, 32, "int");
627+ tdesc_create_reg (feature, "rpvr4", 42, 1, NULL, 32, "int");
628+ tdesc_create_reg (feature, "rpvr5", 43, 1, NULL, 32, "int");
629+ tdesc_create_reg (feature, "rpvr6", 44, 1, NULL, 32, "int");
630+ tdesc_create_reg (feature, "rpvr7", 45, 1, NULL, 32, "int");
631+ tdesc_create_reg (feature, "rpvr8", 46, 1, NULL, 64, "uint64");
632+ tdesc_create_reg (feature, "rpvr9", 47, 1, NULL, 64, "uint64");
633+ tdesc_create_reg (feature, "rpvr10", 48, 1, NULL, 32, "int");
634+ tdesc_create_reg (feature, "rpvr11", 49, 1, NULL, 32, "int");
635+ tdesc_create_reg (feature, "redr", 50, 1, NULL, 32, "int");
636+ tdesc_create_reg (feature, "rpid", 51, 1, NULL, 32, "int");
637+ tdesc_create_reg (feature, "rzpr", 52, 1, NULL, 32, "int");
638+ tdesc_create_reg (feature, "rtlbx", 53, 1, NULL, 32, "int");
639+ tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
640+ tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
641+ tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
642+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
643+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
644+
645+ tdesc_microblaze64 = result;
646+}
647diff --git a/gdb/features/microblaze64.xml b/gdb/features/microblaze64.xml
648new file mode 100644
649index 0000000000..515d18e65c
650--- /dev/null
651+++ b/gdb/features/microblaze64.xml
652@@ -0,0 +1,11 @@
653+<?xml version="1.0"?>
654+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
655+
656+ Copying and distribution of this file, with or without modification,
657+ are permitted in any medium without royalty provided the copyright
658+ notice and this notice are preserved. -->
659+
660+<!DOCTYPE target SYSTEM "gdb-target.dtd">
661+<target>
662+ <xi:include href="microblaze64-core.xml"/>
663+</target>
664diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
665index 49713ea9b1..0605283c9e 100644
666--- a/gdb/microblaze-tdep.c
667+++ b/gdb/microblaze-tdep.c
668@@ -40,7 +40,9 @@
669 #include "remote.h"
670
671 #include "features/microblaze-with-stack-protect.c"
672+#include "features/microblaze64-with-stack-protect.c"
673 #include "features/microblaze.c"
674+#include "features/microblaze64.c"
675
676 /* Instruction macros used for analyzing the prologue. */
677 /* This set of instruction macros need to be changed whenever the
678@@ -75,12 +77,13 @@ static const char *microblaze_register_names[] =
679 "rpvr0", "rpvr1", "rpvr2", "rpvr3", "rpvr4", "rpvr5", "rpvr6",
680 "rpvr7", "rpvr8", "rpvr9", "rpvr10", "rpvr11",
681 "redr", "rpid", "rzpr", "rtlbx", "rtlbsx", "rtlblo", "rtlbhi",
682- "rslr", "rshr"
683+ "slr", "shr"
684 };
685
686 #define MICROBLAZE_NUM_REGS ARRAY_SIZE (microblaze_register_names)
687
688 static unsigned int microblaze_debug_flag = 0;
689+int reg_size = 4;
690
691 static void ATTRIBUTE_PRINTF (1, 2)
692 microblaze_debug (const char *fmt, ...)
693@@ -145,6 +148,7 @@ microblaze_store_arguments (struct regcache *regcache, int nargs,
694 error (_("store_arguments not implemented"));
695 return sp;
696 }
697+#if 0
698 static int
699 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
700 struct bp_target_info *bp_tgt)
701@@ -154,7 +158,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
702 int val;
703 int bplen;
704 gdb_byte old_contents[BREAKPOINT_MAX];
705- struct cleanup *cleanup;
706+ //struct cleanup *cleanup;
707
708 /* Determine appropriate breakpoint contents and size for this address. */
709 bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
710@@ -162,7 +166,8 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
711 error (_("Software breakpoints not implemented for this target."));
712
713 /* Make sure we see the memory breakpoints. */
714- cleanup = make_show_memory_breakpoints_cleanup (1);
715+ scoped_restore
716+ cleanup = make_scoped_restore_show_memory_breakpoints (1);
717 val = target_read_memory (addr, old_contents, bplen);
718
719 /* If our breakpoint is no longer at the address, this means that the
720@@ -178,6 +183,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
721 return val;
722 }
723
724+#endif
725 /* Allocate and initialize a frame cache. */
726
727 static struct microblaze_frame_cache *
728@@ -570,17 +576,16 @@ microblaze_extract_return_value (struct type *type, struct regcache *regcache,
729 gdb_byte *valbuf)
730 {
731 gdb_byte buf[8];
732-
733 /* Copy the return value (starting) in RETVAL_REGNUM to VALBUF. */
734 switch (TYPE_LENGTH (type))
735 {
736 case 1: /* return last byte in the register. */
737 regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf);
738- memcpy(valbuf, buf + MICROBLAZE_REGISTER_SIZE - 1, 1);
739+ memcpy(valbuf, buf + reg_size - 1, 1);
740 return;
741 case 2: /* return last 2 bytes in register. */
742 regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf);
743- memcpy(valbuf, buf + MICROBLAZE_REGISTER_SIZE - 2, 2);
744+ memcpy(valbuf, buf + reg_size - 2, 2);
745 return;
746 case 4: /* for sizes 4 or 8, copy the required length. */
747 case 8:
748@@ -647,7 +652,119 @@ microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
749 return (TYPE_LENGTH (type) == 16);
750 }
751
752-
753+#if 0
754+static std::vector<CORE_ADDR>
755+microblaze_software_single_step (struct regcache *regcache)
756+{
757+// struct gdbarch *arch = get_frame_arch(frame);
758+ struct gdbarch *arch = get_regcache_arch (regcache);
759+ struct address_space *aspace = get_regcache_aspace (regcache);
760+// struct address_space *aspace = get_frame_address_space (frame);
761+ struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
762+ static char le_breakp[] = MICROBLAZE_BREAKPOINT_LE;
763+ static char be_breakp[] = MICROBLAZE_BREAKPOINT;
764+ enum bfd_endian byte_order = gdbarch_byte_order (arch);
765+ char *breakp = byte_order == BFD_ENDIAN_BIG ? be_breakp : le_breakp;
766+ std::vector<CORE_ADDR> ret = 0;
767+
768+ /* Save the address and the values of the next_pc and the target */
769+ static struct sstep_breaks
770+ {
771+ CORE_ADDR address;
772+ bfd_boolean valid;
773+ /* Shadow contents. */
774+ char data[INST_WORD_SIZE];
775+ } stepbreaks[2];
776+ int ii;
777+
778+ if (1)
779+ {
780+ CORE_ADDR pc;
781+ std::vector<CORE_ADDR> *next_pcs = NULL;
782+ long insn;
783+ enum microblaze_instr minstr;
784+ bfd_boolean isunsignednum;
785+ enum microblaze_instr_type insn_type;
786+ short delay_slots;
787+ int imm;
788+ bfd_boolean immfound = FALSE;
789+
790+ /* Set a breakpoint at the next instruction */
791+ /* If the current instruction is an imm, set it at the inst after */
792+ /* If the instruction has a delay slot, skip the delay slot */
793+ pc = regcache_read_pc (regcache);
794+ insn = microblaze_fetch_instruction (pc);
795+ minstr = get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
796+ if (insn_type == immediate_inst)
797+ {
798+ int rd, ra, rb;
799+ immfound = TRUE;
800+ minstr = microblaze_decode_insn (insn, &rd, &ra, &rb, &imm);
801+ pc = pc + INST_WORD_SIZE;
802+ insn = microblaze_fetch_instruction (pc);
803+ minstr = get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
804+ }
805+ stepbreaks[0].address = pc + (delay_slots * INST_WORD_SIZE) + INST_WORD_SIZE;
806+ if (insn_type != return_inst) {
807+ stepbreaks[0].valid = TRUE;
808+ } else {
809+ stepbreaks[0].valid = FALSE;
810+ }
811+
812+ microblaze_debug ("single-step insn_type=%x insn=%x\n", insn_type, insn);
813+ /* Now check for branch or return instructions */
814+ if (insn_type == branch_inst || insn_type == return_inst) {
815+ int limm;
816+ int lrd, lra, lrb;
817+ int ra, rb;
818+ bfd_boolean targetvalid;
819+ bfd_boolean unconditionalbranch;
820+ microblaze_decode_insn(insn, &lrd, &lra, &lrb, &limm);
821+ if (lra >= 0 && lra < MICROBLAZE_NUM_REGS)
822+ ra = regcache_raw_get_unsigned(regcache, lra);
823+ else
824+ ra = 0;
825+ if (lrb >= 0 && lrb < MICROBLAZE_NUM_REGS)
826+ rb = regcache_raw_get_unsigned(regcache, lrb);
827+ else
828+ rb = 0;
829+ stepbreaks[1].address = microblaze_get_target_address (insn, immfound, imm, pc, ra, rb, &targetvalid, &unconditionalbranch);
830+ microblaze_debug ("single-step uncondbr=%d targetvalid=%d target=%x\n", unconditionalbranch, targetvalid, stepbreaks[1].address);
831+ if (unconditionalbranch)
832+ stepbreaks[0].valid = FALSE; /* This is a unconditional branch: will not come to the next address */
833+ if (targetvalid && (stepbreaks[0].valid == FALSE ||
834+ (stepbreaks[0].address != stepbreaks[1].address))
835+ && (stepbreaks[1].address != pc)) {
836+ stepbreaks[1].valid = TRUE;
837+ } else {
838+ stepbreaks[1].valid = FALSE;
839+ }
840+ } else {
841+ stepbreaks[1].valid = FALSE;
842+ }
843+
844+ /* Insert the breakpoints */
845+ for (ii = 0; ii < 2; ++ii)
846+ {
847+
848+ /* ignore invalid breakpoint. */
849+ if (stepbreaks[ii].valid) {
850+ VEC_safe_push (CORE_ADDR, next_pcs, stepbreaks[ii].address);;
851+// insert_single_step_breakpoint (arch, aspace, stepbreaks[ii].address);
852+ ret = next_pcs;
853+ }
854+ }
855+ }
856+ return ret;
857+}
858+#endif
859+
860+static void
861+microblaze_write_pc (struct regcache *regcache, CORE_ADDR pc)
862+{
863+ regcache_cooked_write_unsigned (regcache, MICROBLAZE_PC_REGNUM, pc);
864+}
865+
866 static int dwarf2_to_reg_map[78] =
867 { 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */
868 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */
869@@ -682,13 +799,14 @@ microblaze_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg)
870 static void
871 microblaze_register_g_packet_guesses (struct gdbarch *gdbarch)
872 {
873+
874 register_remote_g_packet_guess (gdbarch,
875- 4 * MICROBLAZE_NUM_CORE_REGS,
876- tdesc_microblaze);
877+ 4 * MICROBLAZE_NUM_REGS,
878+ tdesc_microblaze64);
879
880 register_remote_g_packet_guess (gdbarch,
881 4 * MICROBLAZE_NUM_REGS,
882- tdesc_microblaze_with_stack_protect);
883+ tdesc_microblaze64_with_stack_protect);
884 }
885
886 void
887@@ -696,15 +814,15 @@ microblaze_supply_gregset (const struct microblaze_gregset *gregset,
888 struct regcache *regcache,
889 int regnum, const void *gregs)
890 {
891- unsigned int *regs = gregs;
892+ const gdb_byte *regs = (const gdb_byte *) gregs;
893 if (regnum >= 0)
894- regcache_raw_supply (regcache, regnum, regs + regnum);
895+ regcache->raw_supply (regnum, regs + regnum);
896
897 if (regnum == -1) {
898 int i;
899
900 for (i = 0; i < 50; i++) {
901- regcache_raw_supply (regcache, i, regs + i);
902+ regcache->raw_supply (regnum, regs + i);
903 }
904 }
905 }
906@@ -755,6 +873,17 @@ microblaze_regset_from_core_section (struct gdbarch *gdbarch,
907 }
908
909
910+static void
911+make_regs (struct gdbarch *arch)
912+{
913+ struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
914+ int mach = gdbarch_bfd_arch_info (arch)->mach;
915+
916+ if (mach == bfd_mach_microblaze64)
917+ {
918+ set_gdbarch_ptr_bit (arch, 64);
919+ }
920+}
921
922 static struct gdbarch *
923 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
924@@ -769,8 +898,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
925 if (arches != NULL)
926 return arches->gdbarch;
927 if (tdesc == NULL)
928- tdesc = tdesc_microblaze;
929-
930+ {
931+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64)
932+ {
933+ tdesc = tdesc_microblaze64;
934+ reg_size = 8;
935+ }
936+ else
937+ tdesc = tdesc_microblaze;
938+ }
939 /* Check any target description for validity. */
940 if (tdesc_has_registers (tdesc))
941 {
942@@ -778,27 +914,35 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
943 int valid_p;
944 int i;
945
946- feature = tdesc_find_feature (tdesc,
947+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64)
948+ feature = tdesc_find_feature (tdesc,
949+ "org.gnu.gdb.microblaze64.core");
950+ else
951+ feature = tdesc_find_feature (tdesc,
952 "org.gnu.gdb.microblaze.core");
953 if (feature == NULL)
954 return NULL;
955 tdesc_data = tdesc_data_alloc ();
956
957 valid_p = 1;
958- for (i = 0; i < MICROBLAZE_NUM_CORE_REGS; i++)
959+ for (i = 0; i < MICROBLAZE_NUM_REGS; i++)
960 valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
961 microblaze_register_names[i]);
962- feature = tdesc_find_feature (tdesc,
963+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64)
964+ feature = tdesc_find_feature (tdesc,
965+ "org.gnu.gdb.microblaze64.stack-protect");
966+ else
967+ feature = tdesc_find_feature (tdesc,
968 "org.gnu.gdb.microblaze.stack-protect");
969 if (feature != NULL)
970 {
971 valid_p = 1;
972 valid_p &= tdesc_numbered_register (feature, tdesc_data,
973 MICROBLAZE_SLR_REGNUM,
974- "rslr");
975+ "slr");
976 valid_p &= tdesc_numbered_register (feature, tdesc_data,
977 MICROBLAZE_SHR_REGNUM,
978- "rshr");
979+ "shr");
980 }
981
982 if (!valid_p)
983@@ -806,6 +950,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
984 tdesc_data_cleanup (tdesc_data);
985 return NULL;
986 }
987+
988 }
989
990 /* Allocate space for the new architecture. */
991@@ -825,7 +970,17 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
992 /* Register numbers of various important registers. */
993 set_gdbarch_sp_regnum (gdbarch, MICROBLAZE_SP_REGNUM);
994 set_gdbarch_pc_regnum (gdbarch, MICROBLAZE_PC_REGNUM);
995+
996+ /* Register set.
997+ make_regs (gdbarch); */
998+ switch (info.bfd_arch_info->mach)
999+ {
1000+ case bfd_mach_microblaze64:
1001+ set_gdbarch_ptr_bit (gdbarch, 64);
1002+ break;
1003+ }
1004
1005+
1006 /* Map Dwarf2 registers to GDB registers. */
1007 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum);
1008
1009@@ -845,13 +1000,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1010 microblaze_breakpoint::kind_from_pc);
1011 set_gdbarch_sw_breakpoint_from_kind (gdbarch,
1012 microblaze_breakpoint::bp_from_kind);
1013- set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint);
1014+// set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint);
1015+
1016+// set_gdbarch_software_single_step (gdbarch, microblaze_software_single_step);
1017
1018 set_gdbarch_frame_args_skip (gdbarch, 8);
1019
1020 set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc);
1021
1022- microblaze_register_g_packet_guesses (gdbarch);
1023+ //microblaze_register_g_packet_guesses (gdbarch);
1024
1025 frame_base_set_default (gdbarch, &microblaze_frame_base);
1026
1027@@ -866,11 +1023,11 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1028 tdesc_use_registers (gdbarch, tdesc, tdesc_data);
1029 //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer);
1030
1031- /* If we have register sets, enable the generic core file support. */
1032+ /* If we have register sets, enable the generic core file support.
1033 if (tdep->gregset) {
1034 set_gdbarch_regset_from_core_section (gdbarch,
1035 microblaze_regset_from_core_section);
1036- }
1037+ }*/
1038
1039 return gdbarch;
1040 }
1041@@ -882,6 +1039,8 @@ _initialize_microblaze_tdep (void)
1042
1043 initialize_tdesc_microblaze_with_stack_protect ();
1044 initialize_tdesc_microblaze ();
1045+ initialize_tdesc_microblaze64_with_stack_protect ();
1046+ initialize_tdesc_microblaze64 ();
1047 /* Debug this files internals. */
1048 add_setshow_zuinteger_cmd ("microblaze", class_maintenance,
1049 &microblaze_debug_flag, _("\
1050diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
1051index 3777cbb6a8..55f5dd1962 100644
1052--- a/gdb/microblaze-tdep.h
1053+++ b/gdb/microblaze-tdep.h
1054@@ -27,7 +27,7 @@ struct microblaze_gregset
1055 microblaze_gregset() {}
1056 unsigned int gregs[32];
1057 unsigned int fpregs[32];
1058- unsigned int pregs[16];
1059+ unsigned int pregs[18];
1060 };
1061
1062 struct gdbarch_tdep
1063@@ -101,9 +101,9 @@ enum microblaze_regnum
1064 MICROBLAZE_RTLBSX_REGNUM,
1065 MICROBLAZE_RTLBLO_REGNUM,
1066 MICROBLAZE_RTLBHI_REGNUM,
1067- MICROBLAZE_SLR_REGNUM, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_SLR_REGNUM,
1068+ MICROBLAZE_SLR_REGNUM,
1069 MICROBLAZE_SHR_REGNUM,
1070- MICROBLAZE_NUM_REGS
1071+ MICROBLAZE_NUM_REGS, MICROBLAZE_NUM_CORE_REGS = MICROBLAZE_NUM_REGS
1072 };
1073
1074 struct microblaze_frame_cache
1075@@ -128,7 +128,7 @@ struct microblaze_frame_cache
1076 struct trad_frame_saved_reg *saved_regs;
1077 };
1078 /* All registers are 32 bits. */
1079-#define MICROBLAZE_REGISTER_SIZE 4
1080+//#define MICROBLAZE_REGISTER_SIZE 8
1081
1082 /* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used.
1083 Only used for native debugging. */
1084diff --git a/gdb/regformats/microblaze-with-stack-protect.dat b/gdb/regformats/microblaze-with-stack-protect.dat
1085index 8040a7b3fd..450e321d49 100644
1086--- a/gdb/regformats/microblaze-with-stack-protect.dat
1087+++ b/gdb/regformats/microblaze-with-stack-protect.dat
1088@@ -60,5 +60,5 @@ expedite:r1,rpc
1089 32:rtlbsx
1090 32:rtlblo
1091 32:rtlbhi
1092-32:rslr
1093-32:rshr
1094+32:slr
1095+32:shr
1096diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
1097index bd9d91cd57..12d4456bc2 100644
1098--- a/opcodes/microblaze-opc.h
1099+++ b/opcodes/microblaze-opc.h
1100@@ -134,7 +134,6 @@
1101 #define ORLI_MASK 0xA0000000
1102 #define XORLI_MASK 0xA8000000
1103
1104-
1105 /* New Mask for msrset, msrclr insns. */
1106 #define OPCODE_MASK_H23N 0xFC1F8000 /* High 6 and bits 11 - 16. */
1107 /* Mask for mbar insn. */
1108--
11092.17.1
1110
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0041-patch-MicroBlaze-porting-GDB-for-linux.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0041-patch-MicroBlaze-porting-GDB-for-linux.patch
new file mode 100644
index 00000000..7d63e63e
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0041-patch-MicroBlaze-porting-GDB-for-linux.patch
@@ -0,0 +1,155 @@
1From 3f830717572e074a21840549b48265ec00d67bd1 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 12 Dec 2019 14:56:17 +0530
4Subject: [PATCH 41/43] [patch,MicroBlaze] : porting GDB for linux
5
6---
7 gdb/features/microblaze-linux.xml | 12 ++++++++++
8 gdb/gdbserver/Makefile.in | 2 ++
9 gdb/gdbserver/configure.srv | 3 ++-
10 gdb/microblaze-linux-tdep.c | 39 ++++++++++++++++++++++++-------
11 4 files changed, 47 insertions(+), 9 deletions(-)
12 create mode 100644 gdb/features/microblaze-linux.xml
13
14diff --git a/gdb/features/microblaze-linux.xml b/gdb/features/microblaze-linux.xml
15new file mode 100644
16index 0000000000..8983e66eb3
17--- /dev/null
18+++ b/gdb/features/microblaze-linux.xml
19@@ -0,0 +1,12 @@
20+<?xml version="1.0"?>
21+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
22+
23+ Copying and distribution of this file, with or without modification,
24+ are permitted in any medium without royalty provided the copyright
25+ notice and this notice are preserved. -->
26+
27+<!DOCTYPE target SYSTEM "gdb-target.dtd">
28+<target>
29+ <osabi>GNU/Linux</osabi>
30+ <xi:include href="microblaze-core.xml"/>
31+</target>
32diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
33index 73ca5fd7c5..f5d8663ec8 100644
34--- a/gdb/gdbserver/Makefile.in
35+++ b/gdb/gdbserver/Makefile.in
36@@ -639,6 +639,8 @@ common/%.o: ../common/%.c
37
38 %-generated.c: ../regformats/rs6000/%.dat | $(regdat_sh)
39 $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $< $@
40+microblaze-linux.c : $(srcdir)/../regformats/reg-microblaze.dat $(regdat_sh)
41+ $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-microblaze.dat microblaze-linux.c
42
43 #
44 # Dependency tracking.
45diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
46index 201b7ae190..e5ed6498a8 100644
47--- a/gdb/gdbserver/configure.srv
48+++ b/gdb/gdbserver/configure.srv
49@@ -210,8 +210,9 @@ case "${target}" in
50 srv_linux_usrregs=yes
51 srv_linux_thread_db=yes
52 ;;
53- microblaze*-*-linux*) srv_regobj=microblaze-linux.o
54+ microblaze*-*-linux*) srv_regobj="microblaze-linux.o"
55 srv_tgtobj="$srv_linux_obj linux-microblaze-low.o "
56+ srv_xmlfiles="microblaze-linux.xml"
57 srv_linux_regsets=yes
58 srv_linux_usrregs=yes
59 srv_linux_thread_db=yes
60diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
61index 011e513941..e3d2a7508d 100644
62--- a/gdb/microblaze-linux-tdep.c
63+++ b/gdb/microblaze-linux-tdep.c
64@@ -41,7 +41,7 @@
65
66 #ifndef REGSET_H
67 #define REGSET_H 1
68-
69+int MICROBLAZE_REGISTER_SIZE=4;
70 struct gdbarch;
71 struct regcache;
72
73@@ -115,7 +115,7 @@ microblaze_debug (const char *fmt, ...)
74 va_end (args);
75 }
76 }
77-
78+#if 0
79 static int
80 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
81 struct bp_target_info *bp_tgt)
82@@ -131,7 +131,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
83 bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
84
85 /* Make sure we see the memory breakpoints. */
86- cleanup = make_show_memory_breakpoints_cleanup (1);
87+ cleanup = make_scoped_restore_show_memory_breakpoints (1);
88 val = target_read_memory (addr, old_contents, bplen);
89
90 /* If our breakpoint is no longer at the address, this means that the
91@@ -146,6 +146,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
92 do_cleanups (cleanup);
93 return val;
94 }
95+#endif
96
97 static void
98 microblaze_linux_sigtramp_cache (struct frame_info *next_frame,
99@@ -248,8 +249,8 @@ microblaze_linux_init_abi (struct gdbarch_info info,
100
101 linux_init_abi (info, gdbarch);
102
103- set_gdbarch_memory_remove_breakpoint (gdbarch,
104- microblaze_linux_memory_remove_breakpoint);
105+// set_gdbarch_memory_remove_breakpoint (gdbarch,
106+// microblaze_linux_memory_remove_breakpoint);
107
108 /* Shared library handling. */
109 set_solib_svr4_fetch_link_map_offsets (gdbarch,
110@@ -261,10 +262,30 @@ microblaze_linux_init_abi (struct gdbarch_info info,
111
112 /* BFD target for core files. */
113 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
114- set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblaze");
115+ {
116+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64) {
117+ set_gdbarch_gcore_bfd_target (gdbarch, "elf64-microblaze");
118+ MICROBLAZE_REGISTER_SIZE=8;
119+ }
120+ else
121+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblaze");
122+ }
123 else
124- set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblazeel");
125+ {
126+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64) {
127+ set_gdbarch_gcore_bfd_target (gdbarch, "elf64-microblazeel");
128+ MICROBLAZE_REGISTER_SIZE=8;
129+ }
130+ else
131+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-microblazeel");
132+ }
133
134+ switch (info.bfd_arch_info->mach)
135+ {
136+ case bfd_mach_microblaze64:
137+ set_gdbarch_ptr_bit (gdbarch, 64);
138+ break;
139+ }
140
141 /* Shared library handling. */
142 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
143@@ -278,6 +299,8 @@ microblaze_linux_init_abi (struct gdbarch_info info,
144 void
145 _initialize_microblaze_linux_tdep (void)
146 {
147- gdbarch_register_osabi (bfd_arch_microblaze, 0, GDB_OSABI_LINUX,
148+ gdbarch_register_osabi (bfd_arch_microblaze, bfd_mach_microblaze, GDB_OSABI_LINUX,
149+ microblaze_linux_init_abi);
150+ gdbarch_register_osabi (bfd_arch_microblaze, bfd_mach_microblaze64, GDB_OSABI_LINUX,
151 microblaze_linux_init_abi);
152 }
153--
1542.17.1
155
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch
new file mode 100644
index 00000000..06e63f3c
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0042-Correcting-the-register-names-from-slr-shr-to-rslr-r.patch
@@ -0,0 +1,146 @@
1From 746453e0f35fd669cfacabfe223b8e7007a99797 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 19 Dec 2019 12:22:04 +0530
4Subject: [PATCH 42/43] Correcting the register names from slr & shr to rslr &
5 rshr
6
7---
8 gdb/features/microblaze-core.xml | 4 ++--
9 gdb/features/microblaze-stack-protect.xml | 4 ++--
10 gdb/features/microblaze-with-stack-protect.c | 4 ++--
11 gdb/features/microblaze.c | 4 ++--
12 gdb/features/microblaze64-core.xml | 4 ++--
13 gdb/features/microblaze64-stack-protect.xml | 4 ++--
14 gdb/features/microblaze64-with-stack-protect.c | 4 ++--
15 gdb/features/microblaze64.c | 4 ++--
16 gdb/microblaze-tdep.c | 2 +-
17 9 files changed, 17 insertions(+), 17 deletions(-)
18
19diff --git a/gdb/features/microblaze-core.xml b/gdb/features/microblaze-core.xml
20index 5bc3e49f84..6f73f4eb84 100644
21--- a/gdb/features/microblaze-core.xml
22+++ b/gdb/features/microblaze-core.xml
23@@ -64,6 +64,6 @@
24 <reg name="rtlbsx" bitsize="32"/>
25 <reg name="rtlblo" bitsize="32"/>
26 <reg name="rtlbhi" bitsize="32"/>
27- <reg name="slr" bitsize="32"/>
28- <reg name="shr" bitsize="32"/>
29+ <reg name="rslr" bitsize="32"/>
30+ <reg name="rshr" bitsize="32"/>
31 </feature>
32diff --git a/gdb/features/microblaze-stack-protect.xml b/gdb/features/microblaze-stack-protect.xml
33index a7f27b903c..870c148bb0 100644
34--- a/gdb/features/microblaze-stack-protect.xml
35+++ b/gdb/features/microblaze-stack-protect.xml
36@@ -7,6 +7,6 @@
37
38 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
39 <feature name="org.gnu.gdb.microblaze.stack-protect">
40- <reg name="slr" bitsize="32"/>
41- <reg name="shr" bitsize="32"/>
42+ <reg name="rslr" bitsize="32"/>
43+ <reg name="rshr" bitsize="32"/>
44 </feature>
45diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c
46index 609934e2b4..ab162fd258 100644
47--- a/gdb/features/microblaze-with-stack-protect.c
48+++ b/gdb/features/microblaze-with-stack-protect.c
49@@ -72,8 +72,8 @@ initialize_tdesc_microblaze_with_stack_protect (void)
50 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
51
52 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.stack-protect");
53- tdesc_create_reg (feature, "slr", 57, 1, NULL, 32, "int");
54- tdesc_create_reg (feature, "shr", 58, 1, NULL, 32, "int");
55+ tdesc_create_reg (feature, "rslr", 57, 1, NULL, 32, "int");
56+ tdesc_create_reg (feature, "rshr", 58, 1, NULL, 32, "int");
57
58 tdesc_microblaze_with_stack_protect = result;
59 }
60diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c
61index ceb98ca8b8..7919ac96e6 100644
62--- a/gdb/features/microblaze.c
63+++ b/gdb/features/microblaze.c
64@@ -70,8 +70,8 @@ initialize_tdesc_microblaze (void)
65 tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
66 tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
67 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
68- tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
69- tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
70+ tdesc_create_reg (feature, "rslr", 57, 1, NULL, 64, "uint64");
71+ tdesc_create_reg (feature, "rshr", 58, 1, NULL, 64, "uint64");
72
73 tdesc_microblaze = result;
74 }
75diff --git a/gdb/features/microblaze64-core.xml b/gdb/features/microblaze64-core.xml
76index 96e99e2fb2..b9adadfade 100644
77--- a/gdb/features/microblaze64-core.xml
78+++ b/gdb/features/microblaze64-core.xml
79@@ -64,6 +64,6 @@
80 <reg name="rtlbsx" bitsize="32"/>
81 <reg name="rtlblo" bitsize="32"/>
82 <reg name="rtlbhi" bitsize="32"/>
83- <reg name="slr" bitsize="64"/>
84- <reg name="shr" bitsize="64"/>
85+ <reg name="rslr" bitsize="64"/>
86+ <reg name="rshr" bitsize="64"/>
87 </feature>
88diff --git a/gdb/features/microblaze64-stack-protect.xml b/gdb/features/microblaze64-stack-protect.xml
89index 1bbf5fc3ce..9d7ea8b9fd 100644
90--- a/gdb/features/microblaze64-stack-protect.xml
91+++ b/gdb/features/microblaze64-stack-protect.xml
92@@ -7,6 +7,6 @@
93
94 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
95 <feature name="org.gnu.gdb.microblaze64.stack-protect">
96- <reg name="slr" bitsize="64"/>
97- <reg name="shr" bitsize="64"/>
98+ <reg name="rslr" bitsize="64"/>
99+ <reg name="rshr" bitsize="64"/>
100 </feature>
101diff --git a/gdb/features/microblaze64-with-stack-protect.c b/gdb/features/microblaze64-with-stack-protect.c
102index f448c9a749..249cb534da 100644
103--- a/gdb/features/microblaze64-with-stack-protect.c
104+++ b/gdb/features/microblaze64-with-stack-protect.c
105@@ -72,8 +72,8 @@ initialize_tdesc_microblaze64_with_stack_protect (void)
106 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
107
108 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.stack-protect");
109- tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
110- tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
111+ tdesc_create_reg (feature, "rslr", 57, 1, NULL, 64, "uint64");
112+ tdesc_create_reg (feature, "rshr", 58, 1, NULL, 64, "uint64");
113
114 tdesc_microblaze64_with_stack_protect = result;
115 }
116diff --git a/gdb/features/microblaze64.c b/gdb/features/microblaze64.c
117index 1aa37c4512..5d3e2c8cd9 100644
118--- a/gdb/features/microblaze64.c
119+++ b/gdb/features/microblaze64.c
120@@ -70,8 +70,8 @@ initialize_tdesc_microblaze64 (void)
121 tdesc_create_reg (feature, "rtlbsx", 54, 1, NULL, 32, "int");
122 tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
123 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
124- tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
125- tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
126+ tdesc_create_reg (feature, "rslr", 57, 1, NULL, 64, "uint64");
127+ tdesc_create_reg (feature, "rshr", 58, 1, NULL, 64, "uint64");
128
129 tdesc_microblaze64 = result;
130 }
131diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
132index 0605283c9e..7a0c2527f4 100644
133--- a/gdb/microblaze-tdep.c
134+++ b/gdb/microblaze-tdep.c
135@@ -77,7 +77,7 @@ static const char *microblaze_register_names[] =
136 "rpvr0", "rpvr1", "rpvr2", "rpvr3", "rpvr4", "rpvr5", "rpvr6",
137 "rpvr7", "rpvr8", "rpvr9", "rpvr10", "rpvr11",
138 "redr", "rpid", "rzpr", "rtlbx", "rtlbsx", "rtlblo", "rtlbhi",
139- "slr", "shr"
140+ "rslr", "rshr"
141 };
142
143 #define MICROBLAZE_NUM_REGS ARRAY_SIZE (microblaze_register_names)
144--
1452.17.1
146
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch
new file mode 100644
index 00000000..0b6cae62
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0043-Removing-the-header-gdb_assert.h-from-MB-target-file.patch
@@ -0,0 +1,24 @@
1From 8cb6a265c2108ff7117c07e106604b46238c6ae7 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Fri, 17 Jan 2020 15:45:48 +0530
4Subject: [PATCH 43/43] Removing the header "gdb_assert.h" from MB target file
5
6---
7 gdb/microblaze-linux-tdep.c | 1 -
8 1 file changed, 1 deletion(-)
9
10diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
11index e3d2a7508d..5ef937219c 100644
12--- a/gdb/microblaze-linux-tdep.c
13+++ b/gdb/microblaze-linux-tdep.c
14@@ -37,7 +37,6 @@
15 #include "linux-tdep.h"
16 #include "glibc-tdep.h"
17
18-#include "gdb_assert.h"
19
20 #ifndef REGSET_H
21 #define REGSET_H 1
22--
232.17.1
24
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb/0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch b/meta-microblaze/recipes-microblaze/gdb/gdb/0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch
new file mode 100644
index 00000000..ace6aabd
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb/0044-gdb-microblaze-linux-nat.c-Fix-target-compilation-of.patch
@@ -0,0 +1,363 @@
1From 8d75e232d3513a184180d797ef20bf53d3543fa7 Mon Sep 17 00:00:00 2001
2From: Mark Hatle <mark.hatle@xilinx.com>
3Date: Mon, 20 Jan 2020 12:48:13 -0800
4Subject: [PATCH] gdb/microblaze-linux-nat.c: Fix target compilation of gdb
5
6Add the nat to the configure file
7
8Remove gdb_assert.h and gdb_string.h.
9
10Adjust include for opcodes as well.
11
12Update to match latest style of components, similar to ppc-linux-nat.c
13
14Update:
15 get_regcache_arch(regcache) to regcache->arch()
16 regcache_raw_supply(regcache, ...) to regcache->raw_supply(...)
17 regcache_raw_collect(regcache, ...) to regcache->raw_collect(...)
18
19Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
20---
21 gdb/configure.nat | 4 +
22 gdb/microblaze-linux-nat.c | 149 +++++++++++++------------------------
23 gdb/microblaze-tdep.c | 3 +-
24 3 files changed, 57 insertions(+), 99 deletions(-)
25
26diff --git a/gdb/configure.nat b/gdb/configure.nat
27index 64ee101d83..f0f6c2f5bc 100644
28--- a/gdb/configure.nat
29+++ b/gdb/configure.nat
30@@ -261,6 +261,10 @@ case ${gdb_host} in
31 # Host: Motorola m68k running GNU/Linux.
32 NATDEPFILES="${NATDEPFILES} m68k-linux-nat.o"
33 ;;
34+ microblaze*)
35+ # Host: Microblaze, running Linux
36+ NATDEPFILES="${NATDEPFILES} microblaze-linux-nat.o"
37+ ;;
38 mips)
39 # Host: Linux/MIPS
40 NATDEPFILES="${NATDEPFILES} linux-nat-trad.o \
41diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c
42index e9b8c9c522..e09a86bb3f 100644
43--- a/gdb/microblaze-linux-nat.c
44+++ b/gdb/microblaze-linux-nat.c
45@@ -36,11 +36,9 @@
46 #include "dwarf2-frame.h"
47 #include "osabi.h"
48
49-#include "gdb_assert.h"
50-#include "gdb_string.h"
51 #include "target-descriptions.h"
52-#include "opcodes/microblaze-opcm.h"
53-#include "opcodes/microblaze-dis.h"
54+#include "../opcodes/microblaze-opcm.h"
55+#include "../opcodes/microblaze-dis.h"
56
57 #include "linux-nat.h"
58 #include "target-descriptions.h"
59@@ -61,34 +59,27 @@
60 /* Defines ps_err_e, struct ps_prochandle. */
61 #include "gdb_proc_service.h"
62
63-/* On GNU/Linux, threads are implemented as pseudo-processes, in which
64- case we may be tracing more than one process at a time. In that
65- case, inferior_ptid will contain the main process ID and the
66- individual thread (process) ID. get_thread_id () is used to get
67- the thread id if it's available, and the process id otherwise. */
68-
69-int
70-get_thread_id (ptid_t ptid)
71-{
72- int tid = TIDGET (ptid);
73- if (0 == tid)
74- tid = PIDGET (ptid);
75- return tid;
76-}
77-
78-#define GET_THREAD_ID(PTID) get_thread_id (PTID)
79-
80 /* Non-zero if our kernel may support the PTRACE_GETREGS and
81 PTRACE_SETREGS requests, for reading and writing the
82 general-purpose registers. Zero if we've tried one of
83 them and gotten an error. */
84 int have_ptrace_getsetregs = 1;
85
86+struct microblaze_linux_nat_target final : public linux_nat_target
87+{
88+ /* Add our register access methods. */
89+ void fetch_registers (struct regcache *, int) override;
90+ void store_registers (struct regcache *, int) override;
91+
92+ const struct target_desc *read_description () override;
93+};
94+
95+static microblaze_linux_nat_target the_microblaze_linux_nat_target;
96+
97 static int
98 microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
99 {
100 int u_addr = -1;
101- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
102 /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
103 interface, and not the wordsize of the program's ABI. */
104 int wordsize = sizeof (long);
105@@ -105,18 +96,16 @@ microblaze_register_u_addr (struct gdbarch *gdbarch, int regno)
106 static void
107 fetch_register (struct regcache *regcache, int tid, int regno)
108 {
109- struct gdbarch *gdbarch = get_regcache_arch (regcache);
110- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
111+ struct gdbarch *gdbarch = regcache->arch();
112 /* This isn't really an address. But ptrace thinks of it as one. */
113 CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
114 int bytes_transferred;
115- unsigned int offset; /* Offset of registers within the u area. */
116- char buf[MAX_REGISTER_SIZE];
117+ char buf[sizeof(long)];
118
119 if (regaddr == -1)
120 {
121 memset (buf, '\0', register_size (gdbarch, regno)); /* Supply zeroes */
122- regcache_raw_supply (regcache, regno, buf);
123+ regcache->raw_supply (regno, buf);
124 return;
125 }
126
127@@ -149,14 +138,14 @@ fetch_register (struct regcache *regcache, int tid, int regno)
128 {
129 /* Little-endian values are always found at the left end of the
130 bytes transferred. */
131- regcache_raw_supply (regcache, regno, buf);
132+ regcache->raw_supply (regno, buf);
133 }
134 else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
135 {
136 /* Big-endian values are found at the right end of the bytes
137 transferred. */
138 size_t padding = (bytes_transferred - register_size (gdbarch, regno));
139- regcache_raw_supply (regcache, regno, buf + padding);
140+ regcache->raw_supply (regno, buf + padding);
141 }
142 else
143 internal_error (__FILE__, __LINE__,
144@@ -175,8 +164,6 @@ fetch_register (struct regcache *regcache, int tid, int regno)
145 static int
146 fetch_all_gp_regs (struct regcache *regcache, int tid)
147 {
148- struct gdbarch *gdbarch = get_regcache_arch (regcache);
149- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
150 gdb_gregset_t gregset;
151
152 if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
153@@ -204,8 +191,6 @@ fetch_all_gp_regs (struct regcache *regcache, int tid)
154 static void
155 fetch_gp_regs (struct regcache *regcache, int tid)
156 {
157- struct gdbarch *gdbarch = get_regcache_arch (regcache);
158- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
159 int i;
160
161 if (have_ptrace_getsetregs)
162@@ -219,17 +204,29 @@ fetch_gp_regs (struct regcache *regcache, int tid)
163 fetch_register (regcache, tid, i);
164 }
165
166+/* Fetch registers from the child process. Fetch all registers if
167+ regno == -1, otherwise fetch all general registers or all floating
168+ point registers depending upon the value of regno. */
169+void
170+microblaze_linux_nat_target::fetch_registers (struct regcache *regcache, int regno)
171+{
172+ pid_t tid = get_ptrace_pid (regcache->ptid ());
173+
174+ if (regno == -1)
175+ fetch_gp_regs (regcache, tid);
176+ else
177+ fetch_register (regcache, tid, regno);
178+}
179
180 static void
181 store_register (const struct regcache *regcache, int tid, int regno)
182 {
183- struct gdbarch *gdbarch = get_regcache_arch (regcache);
184- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
185+ struct gdbarch *gdbarch = regcache->arch();
186 /* This isn't really an address. But ptrace thinks of it as one. */
187 CORE_ADDR regaddr = microblaze_register_u_addr (gdbarch, regno);
188 int i;
189 size_t bytes_to_transfer;
190- char buf[MAX_REGISTER_SIZE];
191+ char buf[sizeof(long)];
192
193 if (regaddr == -1)
194 return;
195@@ -242,13 +239,13 @@ store_register (const struct regcache *regcache, int tid, int regno)
196 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
197 {
198 /* Little-endian values always sit at the left end of the buffer. */
199- regcache_raw_collect (regcache, regno, buf);
200+ regcache->raw_collect (regno, buf);
201 }
202 else if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
203 {
204 /* Big-endian values sit at the right end of the buffer. */
205 size_t padding = (bytes_to_transfer - register_size (gdbarch, regno));
206- regcache_raw_collect (regcache, regno, buf + padding);
207+ regcache->raw_collect (regno, buf + padding);
208 }
209
210 for (i = 0; i < bytes_to_transfer; i += sizeof (long))
211@@ -281,8 +278,6 @@ store_register (const struct regcache *regcache, int tid, int regno)
212 static int
213 store_all_gp_regs (const struct regcache *regcache, int tid, int regno)
214 {
215- struct gdbarch *gdbarch = get_regcache_arch (regcache);
216- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
217 gdb_gregset_t gregset;
218
219 if (ptrace (PTRACE_GETREGS, tid, 0, (void *) &gregset) < 0)
220@@ -319,8 +314,6 @@ store_all_gp_regs (const struct regcache *regcache, int tid, int regno)
221 static void
222 store_gp_regs (const struct regcache *regcache, int tid, int regno)
223 {
224- struct gdbarch *gdbarch = get_regcache_arch (regcache);
225- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
226 int i;
227
228 if (have_ptrace_getsetregs)
229@@ -335,33 +328,10 @@ store_gp_regs (const struct regcache *regcache, int tid, int regno)
230 }
231
232
233-/* Fetch registers from the child process. Fetch all registers if
234- regno == -1, otherwise fetch all general registers or all floating
235- point registers depending upon the value of regno. */
236-
237-static void
238-microblaze_linux_fetch_inferior_registers (struct target_ops *ops,
239- struct regcache *regcache, int regno)
240-{
241- /* Get the thread id for the ptrace call. */
242- int tid = GET_THREAD_ID (inferior_ptid);
243-
244- if (regno == -1)
245- fetch_gp_regs (regcache, tid);
246- else
247- fetch_register (regcache, tid, regno);
248-}
249-
250-/* Store registers back into the inferior. Store all registers if
251- regno == -1, otherwise store all general registers or all floating
252- point registers depending upon the value of regno. */
253-
254-static void
255-microblaze_linux_store_inferior_registers (struct target_ops *ops,
256- struct regcache *regcache, int regno)
257+void
258+microblaze_linux_nat_target::store_registers (struct regcache *regcache, int regno)
259 {
260- /* Get the thread id for the ptrace call. */
261- int tid = GET_THREAD_ID (inferior_ptid);
262+ pid_t tid = get_ptrace_pid (regcache->ptid ());
263
264 if (regno >= 0)
265 store_register (regcache, tid, regno);
266@@ -373,59 +343,44 @@ microblaze_linux_store_inferior_registers (struct target_ops *ops,
267 thread debugging. */
268
269 void
270-fill_gregset (const struct regcache *regcache,
271- gdb_gregset_t *gregsetp, int regno)
272+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
273 {
274- microblaze_collect_gregset (NULL, regcache, regno, gregsetp);
275+ microblaze_supply_gregset (NULL, regcache, -1, gregsetp);
276 }
277
278 void
279-supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
280+fill_gregset (const struct regcache *regcache,
281+ gdb_gregset_t *gregsetp, int regno)
282 {
283- microblaze_supply_gregset (NULL, regcache, -1, gregsetp);
284+ microblaze_collect_gregset (NULL, regcache, regno, gregsetp);
285 }
286
287 void
288-fill_fpregset (const struct regcache *regcache,
289- gdb_fpregset_t *fpregsetp, int regno)
290+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
291 {
292 /* FIXME. */
293+ return;
294 }
295
296 void
297-supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
298+fill_fpregset (const struct regcache *regcache,
299+ gdb_fpregset_t *fpregsetp, int regno)
300 {
301 /* FIXME. */
302+ return;
303 }
304
305-static const struct target_desc *
306-microblaze_linux_read_description (struct target_ops *ops)
307+const struct target_desc *
308+microblaze_linux_nat_target::read_description ()
309 {
310- CORE_ADDR microblaze_hwcap = 0;
311-
312- if (target_auxv_search (ops, AT_HWCAP, &microblaze_hwcap) != 1)
313- return NULL;
314-
315 return NULL;
316 }
317
318-
319-void _initialize_microblaze_linux_nat (void);
320-
321 void
322 _initialize_microblaze_linux_nat (void)
323 {
324- struct target_ops *t;
325-
326- /* Fill in the generic GNU/Linux methods. */
327- t = linux_target ();
328-
329- /* Add our register access methods. */
330- t->to_fetch_registers = microblaze_linux_fetch_inferior_registers;
331- t->to_store_registers = microblaze_linux_store_inferior_registers;
332-
333- t->to_read_description = microblaze_linux_read_description;
334+ linux_target = &the_microblaze_linux_nat_target;
335
336 /* Register the target. */
337- linux_nat_add_target (t);
338+ add_inf_child_target (linux_target);
339 }
340diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
341index 7a0c2527f4..23deb24d26 100644
342--- a/gdb/microblaze-tdep.c
343+++ b/gdb/microblaze-tdep.c
344@@ -657,7 +657,7 @@ static std::vector<CORE_ADDR>
345 microblaze_software_single_step (struct regcache *regcache)
346 {
347 // struct gdbarch *arch = get_frame_arch(frame);
348- struct gdbarch *arch = get_regcache_arch (regcache);
349+ struct gdbarch *arch = regcache->arch();
350 struct address_space *aspace = get_regcache_aspace (regcache);
351 // struct address_space *aspace = get_frame_address_space (frame);
352 struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
353@@ -876,7 +876,6 @@ microblaze_regset_from_core_section (struct gdbarch *gdbarch,
354 static void
355 make_regs (struct gdbarch *arch)
356 {
357- struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
358 int mach = gdbarch_bfd_arch_info (arch)->mach;
359
360 if (mach == bfd_mach_microblaze64)
361--
3622.17.1
363
diff --git a/meta-microblaze/recipes-microblaze/gdb/gdb_%.bbappend b/meta-microblaze/recipes-microblaze/gdb/gdb_%.bbappend
new file mode 100644
index 00000000..ceb7b02b
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/gdb/gdb_%.bbappend
@@ -0,0 +1,4 @@
1MICROBLAZEPATCHES = ""
2MICROBLAZEPATCHES_microblaze = "gdb-microblaze.inc"
3
4require ${MICROBLAZEPATCHES}
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch b/meta-microblaze/recipes-microblaze/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch
new file mode 100644
index 00000000..950e0b30
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch
@@ -0,0 +1,91 @@
1From 4926aec8897dc574d442e5a87b2576ab80046b10 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:27:25 +0530
4Subject: [PATCH 01/11] [Patch, microblaze]: Add config/microblaze.mt for
5 target_makefile_frag Mirror MIPS method of creating copy of default.mt which
6 drops the compilation of generic sbrk.c to instead continue using the
7 microblaze provided version.
8
9[Libgloss]
10
11Changelog
12
132013-07-15 David Holsgrove <david.holsgrove@xilinx.com>
14
15 * config/microblaze.mt: New file.
16 * microblaze/configure.in: Switch default.mt to microblaze.mt.
17 * microblaze/configure: Likewise.
18
19Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
20---
21 libgloss/config/microblaze.mt | 30 ++++++++++++++++++++++++++++++
22 libgloss/microblaze/configure | 2 +-
23 libgloss/microblaze/configure.in | 2 +-
24 3 files changed, 32 insertions(+), 2 deletions(-)
25 create mode 100644 libgloss/config/microblaze.mt
26
27diff --git a/libgloss/config/microblaze.mt b/libgloss/config/microblaze.mt
28new file mode 100644
29index 0000000..e8fb922
30--- /dev/null
31+++ b/libgloss/config/microblaze.mt
32@@ -0,0 +1,30 @@
33+#
34+# Match default.mt to compile generic objects but continue building
35+# MicroBlaze specific sbrk.c
36+#
37+close.o: ${srcdir}/../close.c
38+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
39+fstat.o: ${srcdir}/../fstat.c
40+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
41+getpid.o: ${srcdir}/../getpid.c
42+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
43+isatty.o: ${srcdir}/../isatty.c
44+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
45+kill.o: ${srcdir}/../kill.c
46+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
47+lseek.o: ${srcdir}/../lseek.c
48+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
49+open.o: ${srcdir}/../open.c
50+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
51+print.o: ${srcdir}/../print.c
52+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
53+putnum.o: ${srcdir}/../putnum.c
54+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
55+read.o: ${srcdir}/../read.c
56+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
57+stat.o: ${srcdir}/../stat.c
58+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
59+unlink.o: ${srcdir}/../unlink.c
60+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
61+write.o: ${srcdir}/../write.c
62+ $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $?
63diff --git a/libgloss/microblaze/configure b/libgloss/microblaze/configure
64index 9b2bc7a..01f0fb2 100644
65--- a/libgloss/microblaze/configure
66+++ b/libgloss/microblaze/configure
67@@ -2020,7 +2020,7 @@ LIB_AM_PROG_AS
68
69
70 host_makefile_frag=${srcdir}/../config/default.mh
71-target_makefile_frag=${srcdir}/../config/default.mt
72+target_makefile_frag=${srcdir}/../config/microblaze.mt
73
74 host_makefile_frag_path=$host_makefile_frag
75
76diff --git a/libgloss/microblaze/configure.in b/libgloss/microblaze/configure.in
77index 77aa769..5d179fd 100644
78--- a/libgloss/microblaze/configure.in
79+++ b/libgloss/microblaze/configure.in
80@@ -35,7 +35,7 @@ LIB_AM_PROG_AS
81 AC_SUBST(bsp_prefix)
82
83 host_makefile_frag=${srcdir}/../config/default.mh
84-target_makefile_frag=${srcdir}/../config/default.mt
85+target_makefile_frag=${srcdir}/../config/microblaze.mt
86
87 dnl We have to assign the same value to other variables because autoconf
88 dnl doesn't provide a mechanism to substitute a replacement keyword with
89--
902.7.4
91
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch b/meta-microblaze/recipes-microblaze/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch
new file mode 100644
index 00000000..51785d9a
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0002-Patch-microblaze-Modified-_exceptional_handler.patch
@@ -0,0 +1,25 @@
1From ee559eb522edcb793e4df62f61849748445a056e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:30:02 +0530
4Subject: [PATCH 02/11] [Patch, microblaze]: Modified _exceptional_handler
5 Modified the _exceptional_handler to support the changes made in GCC related
6 to Superviosry call
7
8Signed-off-by:Nagaraju Mekala<nmekala@xilix.com>
9---
10 libgloss/microblaze/_exception_handler.S | 1 -
11 1 file changed, 1 deletion(-)
12
13diff --git a/libgloss/microblaze/_exception_handler.S b/libgloss/microblaze/_exception_handler.S
14index 59385ad..7a91a78 100644
15--- a/libgloss/microblaze/_exception_handler.S
16+++ b/libgloss/microblaze/_exception_handler.S
17@@ -36,5 +36,4 @@
18 .type _exception_handler, @function
19
20 _exception_handler:
21- addi r11,r11,8
22 bra r11
23--
242.7.4
25
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch b/meta-microblaze/recipes-microblaze/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch
new file mode 100644
index 00000000..21c55800
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch
@@ -0,0 +1,28 @@
1From 829dcc7967bd2a99b583fba1129ae71dbe8335ff Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:39:45 +0530
4Subject: [PATCH 03/11] [LOCAL]: Add missing declarations for xil_printf to
5 stdio.h for inclusion in toolchain and use in c++ apps
6
7Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
8---
9 newlib/libc/include/stdio.h | 3 +++
10 1 file changed, 3 insertions(+)
11
12diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
13index 164d95b..7bb729c 100644
14--- a/newlib/libc/include/stdio.h
15+++ b/newlib/libc/include/stdio.h
16@@ -245,6 +245,9 @@ int sprintf (char *__restrict, const char *__restrict, ...)
17 _ATTRIBUTE ((__format__ (__printf__, 2, 3)));
18 int remove (const char *);
19 int rename (const char *, const char *);
20+void xil_printf (const char*, ...);
21+void putnum (unsigned int );
22+void print (const char* );
23 #ifdef _COMPILING_NEWLIB
24 int _rename (const char *, const char *);
25 #endif
26--
272.7.4
28
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch b/meta-microblaze/recipes-microblaze/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch
new file mode 100644
index 00000000..f56f6187
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch
@@ -0,0 +1,304 @@
1From 379f231f0afb5e10cd82bc6346e4a6776df3e21e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:42:11 +0530
4Subject: [PATCH 04/11] [Local]: deleting the xil_printf.c file as now it part
5 of BSP
6
7---
8 libgloss/microblaze/xil_printf.c | 284 ---------------------------------------
9 1 file changed, 284 deletions(-)
10 delete mode 100644 libgloss/microblaze/xil_printf.c
11
12diff --git a/libgloss/microblaze/xil_printf.c b/libgloss/microblaze/xil_printf.c
13deleted file mode 100644
14index f18ee84..0000000
15--- a/libgloss/microblaze/xil_printf.c
16+++ /dev/null
17@@ -1,284 +0,0 @@
18-/* Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved.
19- *
20- * Redistribution and use in source and binary forms, with or without
21- * modification, are permitted provided that the following conditions are
22- * met:
23- *
24- * 1. Redistributions source code must retain the above copyright notice,
25- * this list of conditions and the following disclaimer.
26- *
27- * 2. Redistributions in binary form must reproduce the above copyright
28- * notice, this list of conditions and the following disclaimer in the
29- * documentation and/or other materials provided with the distribution.
30- *
31- * 3. Neither the name of Xilinx nor the names of its contributors may be
32- * used to endorse or promote products derived from this software without
33- * specific prior written permission.
34- *
35- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
36- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
37- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
38- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39- * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
41- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
42- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46- */
47-
48-#include <ctype.h>
49-#include <string.h>
50-#include <stdarg.h>
51-
52-extern void outbyte (char);
53-
54-/*----------------------------------------------------*/
55-/* Use the following parameter passing structure to */
56-/* make xil_printf re-entrant. */
57-/*----------------------------------------------------*/
58-typedef struct params_s {
59- int len;
60- int num1;
61- int num2;
62- char pad_character;
63- int do_padding;
64- int left_flag;
65-} params_t;
66-
67-/*---------------------------------------------------*/
68-/* The purpose of this routine is to output data the */
69-/* same as the standard printf function without the */
70-/* overhead most run-time libraries involve. Usually */
71-/* the printf brings in many kilobytes of code and */
72-/* that is unacceptable in most embedded systems. */
73-/*---------------------------------------------------*/
74-
75-typedef char* charptr;
76-typedef int (*func_ptr)(int c);
77-
78-/*---------------------------------------------------*/
79-/* */
80-/* This routine puts pad characters into the output */
81-/* buffer. */
82-/* */
83-static void padding( const int l_flag, params_t *par)
84-{
85- int i;
86-
87- if (par->do_padding && l_flag && (par->len < par->num1))
88- for (i=par->len; i<par->num1; i++)
89- outbyte( par->pad_character);
90-}
91-
92-/*---------------------------------------------------*/
93-/* */
94-/* This routine moves a string to the output buffer */
95-/* as directed by the padding and positioning flags. */
96-/* */
97-static void outs( charptr lp, params_t *par)
98-{
99- /* pad on left if needed */
100- par->len = strlen( lp);
101- padding( !(par->left_flag), par);
102-
103- /* Move string to the buffer */
104- while (*lp && (par->num2)--)
105- outbyte( *lp++);
106-
107- /* Pad on right if needed */
108- /* CR 439175 - elided next stmt. Seemed bogus. */
109- /* par->len = strlen( lp); */
110- padding( par->left_flag, par);
111-}
112-
113-/*---------------------------------------------------*/
114-/* */
115-/* This routine moves a number to the output buffer */
116-/* as directed by the padding and positioning flags. */
117-/* */
118-
119-static void outnum( const long n, const long base, params_t *par)
120-{
121- charptr cp;
122- int negative;
123- char outbuf[32];
124- const char digits[] = "0123456789ABCDEF";
125- unsigned long num;
126-
127- /* Check if number is negative */
128- if (base == 10 && n < 0L) {
129- negative = 1;
130- num = -(n);
131- }
132- else{
133- num = (n);
134- negative = 0;
135- }
136-
137- /* Build number (backwards) in outbuf */
138- cp = outbuf;
139- do {
140- *cp++ = digits[(int)(num % base)];
141- } while ((num /= base) > 0);
142- if (negative)
143- *cp++ = '-';
144- *cp-- = 0;
145-
146- /* Move the converted number to the buffer and */
147- /* add in the padding where needed. */
148- par->len = strlen(outbuf);
149- padding( !(par->left_flag), par);
150- while (cp >= outbuf)
151- outbyte( *cp--);
152- padding( par->left_flag, par);
153-}
154-
155-/*---------------------------------------------------*/
156-/* */
157-/* This routine gets a number from the format */
158-/* string. */
159-/* */
160-static int getnum( charptr* linep)
161-{
162- int n;
163- charptr cp;
164-
165- n = 0;
166- cp = *linep;
167- while (isdigit(*cp))
168- n = n*10 + ((*cp++) - '0');
169- *linep = cp;
170- return(n);
171-}
172-
173-/*---------------------------------------------------*/
174-/* */
175-/* This routine operates just like a printf/sprintf */
176-/* routine. It outputs a set of data under the */
177-/* control of a formatting string. Not all of the */
178-/* standard C format control are supported. The ones */
179-/* provided are primarily those needed for embedded */
180-/* systems work. Primarily the floaing point */
181-/* routines are omitted. Other formats could be */
182-/* added easily by following the examples shown for */
183-/* the supported formats. */
184-/* */
185-
186-/* void esp_printf( const func_ptr f_ptr,
187- const charptr ctrl1, ...) */
188-void xil_printf( const charptr ctrl1, ...)
189-{
190-
191- int long_flag;
192- int dot_flag;
193-
194- params_t par;
195-
196- char ch;
197- va_list argp;
198- charptr ctrl = ctrl1;
199-
200- va_start( argp, ctrl1);
201-
202- for ( ; *ctrl; ctrl++) {
203-
204- /* move format string chars to buffer until a */
205- /* format control is found. */
206- if (*ctrl != '%') {
207- outbyte(*ctrl);
208- continue;
209- }
210-
211- /* initialize all the flags for this format. */
212- dot_flag = long_flag = par.left_flag = par.do_padding = 0;
213- par.pad_character = ' ';
214- par.num2=32767;
215-
216- try_next:
217- ch = *(++ctrl);
218-
219- if (isdigit(ch)) {
220- if (dot_flag)
221- par.num2 = getnum(&ctrl);
222- else {
223- if (ch == '0')
224- par.pad_character = '0';
225-
226- par.num1 = getnum(&ctrl);
227- par.do_padding = 1;
228- }
229- ctrl--;
230- goto try_next;
231- }
232-
233- switch (tolower(ch)) {
234- case '%':
235- outbyte( '%');
236- continue;
237-
238- case '-':
239- par.left_flag = 1;
240- break;
241-
242- case '.':
243- dot_flag = 1;
244- break;
245-
246- case 'l':
247- long_flag = 1;
248- break;
249-
250- case 'd':
251- if (long_flag || ch == 'D') {
252- outnum( va_arg(argp, long), 10L, &par);
253- continue;
254- }
255- else {
256- outnum( va_arg(argp, int), 10L, &par);
257- continue;
258- }
259- case 'x':
260- outnum((long)va_arg(argp, int), 16L, &par);
261- continue;
262-
263- case 's':
264- outs( va_arg( argp, charptr), &par);
265- continue;
266-
267- case 'c':
268- outbyte( va_arg( argp, int));
269- continue;
270-
271- case '\\':
272- switch (*ctrl) {
273- case 'a':
274- outbyte( 0x07);
275- break;
276- case 'h':
277- outbyte( 0x08);
278- break;
279- case 'r':
280- outbyte( 0x0D);
281- break;
282- case 'n':
283- outbyte( 0x0D);
284- outbyte( 0x0A);
285- break;
286- default:
287- outbyte( *ctrl);
288- break;
289- }
290- ctrl++;
291- break;
292-
293- default:
294- continue;
295- }
296- goto try_next;
297- }
298- va_end( argp);
299-}
300-
301-/*---------------------------------------------------*/
302--
3032.7.4
304
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch b/meta-microblaze/recipes-microblaze/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch
new file mode 100644
index 00000000..6e32e177
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch
@@ -0,0 +1,25 @@
1From 96e6a596356fa605bbe00f7f69afb52f80329eb6 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 23 Jan 2017 15:44:17 +0530
4Subject: [PATCH 05/11] [Local]: deleting the xil_printf.o from MAKEFILE
5
6---
7 libgloss/microblaze/Makefile.in | 2 +-
8 1 file changed, 1 insertion(+), 1 deletion(-)
9
10diff --git a/libgloss/microblaze/Makefile.in b/libgloss/microblaze/Makefile.in
11index fe04a08..32aafda 100644
12--- a/libgloss/microblaze/Makefile.in
13+++ b/libgloss/microblaze/Makefile.in
14@@ -81,7 +81,7 @@ GENOBJS = fstat.o getpid.o isatty.o kill.o lseek.o print.o putnum.o stat.o unlin
15 open.o close.o read.o write.o
16 OBJS = ${GENOBJS} sbrk.o timer.o _exception_handler.o _hw_exception_handler.o \
17 _interrupt_handler.o _program_clean.o _program_init.o \
18- xil_malloc.o xil_sbrk.o xil_printf.o
19+ xil_malloc.o xil_sbrk.o
20 SCRIPTS = xilinx.ld
21
22 # Tiny Linux BSP.
23--
242.7.4
25
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0006-MB-X-intial-commit.patch b/meta-microblaze/recipes-microblaze/newlib/files/0006-MB-X-intial-commit.patch
new file mode 100644
index 00000000..18b78f09
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0006-MB-X-intial-commit.patch
@@ -0,0 +1,194 @@
1From bb9e95aa1da6c1f8974702685db9b8486210ac5c Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 27 Jul 2018 16:10:36 +0530
4Subject: [PATCH 06/11] MB-X intial commit
5
6---
7 libgloss/microblaze/crt0.S | 2 +-
8 libgloss/microblaze/crt1.S | 2 +-
9 libgloss/microblaze/crt2.S | 2 +-
10 libgloss/microblaze/crt3.S | 2 +-
11 libgloss/microblaze/crt4.S | 2 +-
12 libgloss/microblaze/crtinit.S | 4 ++--
13 libgloss/microblaze/pgcrtinit.S | 4 ++--
14 libgloss/microblaze/sim-crtinit.S | 4 ++--
15 libgloss/microblaze/sim-pgcrtinit.S | 4 ++--
16 newlib/libc/machine/microblaze/strcmp.c | 8 ++++----
17 10 files changed, 17 insertions(+), 17 deletions(-)
18
19diff --git a/libgloss/microblaze/crt0.S b/libgloss/microblaze/crt0.S
20index b39ea90..865a8c2 100644
21--- a/libgloss/microblaze/crt0.S
22+++ b/libgloss/microblaze/crt0.S
23@@ -84,7 +84,7 @@ _vector_hw_exception:
24 _start1:
25 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
26 la r2, r0, _SDA2_BASE_
27- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
28+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
29
30 brlid r15, _crtinit /* Initialize BSS and run program */
31 nop
32diff --git a/libgloss/microblaze/crt1.S b/libgloss/microblaze/crt1.S
33index 20323ff..a8bf749 100644
34--- a/libgloss/microblaze/crt1.S
35+++ b/libgloss/microblaze/crt1.S
36@@ -75,7 +75,7 @@ _vector_hw_exception:
37 _start:
38 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
39 la r2, r0, _SDA2_BASE_
40- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
41+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
42
43 brlid r15, _crtinit /* Initialize BSS and run program */
44 nop
45diff --git a/libgloss/microblaze/crt2.S b/libgloss/microblaze/crt2.S
46index e3fb15b..34d9f95 100644
47--- a/libgloss/microblaze/crt2.S
48+++ b/libgloss/microblaze/crt2.S
49@@ -73,7 +73,7 @@ _vector_hw_exception:
50 _start:
51 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
52 la r2, r0, _SDA2_BASE_
53- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
54+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
55
56 brlid r15, _crtinit /* Initialize BSS and run program */
57 nop
58diff --git a/libgloss/microblaze/crt3.S b/libgloss/microblaze/crt3.S
59index 452ea52..ebcf207 100644
60--- a/libgloss/microblaze/crt3.S
61+++ b/libgloss/microblaze/crt3.S
62@@ -59,7 +59,7 @@
63 _start:
64 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
65 la r2, r0, _SDA2_BASE_
66- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
67+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
68
69 brlid r15, _crtinit /* Initialize BSS and run program */
70 nop
71diff --git a/libgloss/microblaze/crt4.S b/libgloss/microblaze/crt4.S
72index 475acec..4cf0b01 100644
73--- a/libgloss/microblaze/crt4.S
74+++ b/libgloss/microblaze/crt4.S
75@@ -59,7 +59,7 @@
76 _start:
77 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
78 la r2, r0, _SDA2_BASE_
79- la r1, r0, _stack-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */
80+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
81
82 brlid r15, _crtinit /* Initialize BSS and run program */
83 nop
84diff --git a/libgloss/microblaze/crtinit.S b/libgloss/microblaze/crtinit.S
85index 78eb76d..86c6dfc 100644
86--- a/libgloss/microblaze/crtinit.S
87+++ b/libgloss/microblaze/crtinit.S
88@@ -33,7 +33,7 @@
89 .ent _crtinit
90 .type _crtinit, @function
91 _crtinit:
92- addi r1, r1, -20 /* Save Link register */
93+ addi r1, r1, -40 /* Save Link register */
94 swi r15, r1, 0
95
96 addi r6, r0, __sbss_start /* clear SBSS */
97@@ -82,6 +82,6 @@ _crtinit:
98
99 addik r3, r19, 0 /* Restore return value */
100 rtsd r15, 8
101- addi r1, r1, 20
102+ addi r1, r1, 40
103 .end _crtinit
104
105diff --git a/libgloss/microblaze/pgcrtinit.S b/libgloss/microblaze/pgcrtinit.S
106index fca1bc4..2593082 100644
107--- a/libgloss/microblaze/pgcrtinit.S
108+++ b/libgloss/microblaze/pgcrtinit.S
109@@ -33,7 +33,7 @@
110 .ent _crtinit
111
112 _crtinit:
113- addi r1, r1, -20 /* Save Link register */
114+ addi r1, r1, -40 /* Save Link register */
115 swi r15, r1, 0
116
117 addi r6, r0, __sbss_start /* clear SBSS */
118@@ -87,6 +87,6 @@ _crtinit:
119 lw r15, r1, r0 /* Return back to CRT */
120 addik r3, r19, 0 /* Restore return value */
121 rtsd r15, 8
122- addi r1, r1, 20
123+ addi r1, r1, 40
124 .end _crtinit
125
126diff --git a/libgloss/microblaze/sim-crtinit.S b/libgloss/microblaze/sim-crtinit.S
127index d2f59fe..74586d9 100644
128--- a/libgloss/microblaze/sim-crtinit.S
129+++ b/libgloss/microblaze/sim-crtinit.S
130@@ -39,7 +39,7 @@
131 .ent _crtinit
132
133 _crtinit:
134- addi r1, r1, -20 /* Save Link register */
135+ addi r1, r1, -40 /* Save Link register */
136 swi r15, r1, 0
137
138 brlid r15, _program_init /* Initialize the program */
139@@ -64,6 +64,6 @@ _crtinit:
140 lw r15, r1, r0 /* Return back to CRT */
141 addik r3, r19, 0 /* Restore return value */
142 rtsd r15, 8
143- addi r1, r1, 20
144+ addi r1, r1, 40
145 .end _crtinit
146
147diff --git a/libgloss/microblaze/sim-pgcrtinit.S b/libgloss/microblaze/sim-pgcrtinit.S
148index 3c6ba83..82ebcca 100644
149--- a/libgloss/microblaze/sim-pgcrtinit.S
150+++ b/libgloss/microblaze/sim-pgcrtinit.S
151@@ -39,7 +39,7 @@
152 .ent _crtinit
153
154 _crtinit:
155- addi r1, r1, -20 /* Save Link register */
156+ addi r1, r1, -40 /* Save Link register */
157 swi r15, r1, 0
158
159 brlid r15, _program_init /* Initialize the program */
160@@ -67,6 +67,6 @@ _crtinit:
161
162 lw r15, r1, r0 /* Return back to CRT */
163 rtsd r15, 8
164- addi r1, r1, 20
165+ addi r1, r1, 40
166 .end _crtinit
167
168diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c
169index 434195e..3119d82 100644
170--- a/newlib/libc/machine/microblaze/strcmp.c
171+++ b/newlib/libc/machine/microblaze/strcmp.c
172@@ -96,15 +96,15 @@ strcmp (const char *s1,
173
174 return (*(unsigned char *) s1) - (*(unsigned char *) s2);
175 #else
176- unsigned long *a1;
177- unsigned long *a2;
178+ unsigned int *a1;
179+ unsigned int *a2;
180
181 /* If s1 or s2 are unaligned, then compare bytes. */
182 if (!UNALIGNED (s1, s2))
183 {
184 /* If s1 and s2 are word-aligned, compare them a word at a time. */
185- a1 = (unsigned long*)s1;
186- a2 = (unsigned long*)s2;
187+ a1 = (unsigned int*)s1;
188+ a2 = (unsigned int*)s2;
189 while (*a1 == *a2)
190 {
191 /* To get here, *a1 == *a2, thus if we find a null in *a1,
192--
1932.7.4
194
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch b/meta-microblaze/recipes-microblaze/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch
new file mode 100644
index 00000000..c62a9919
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch
@@ -0,0 +1,1137 @@
1From eab8d664224d134b2c4d638d9c6bebb84ae777ad Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 11 Sep 2018 14:32:20 +0530
4Subject: [PATCH 07/11] [Patch, Microblaze]: newlib port for microblaze m64
5 flag...
6
7Conflicts:
8 libgloss/microblaze/_hw_exception_handler.S
9 libgloss/microblaze/_interrupt_handler.S
10---
11 libgloss/microblaze/_exception_handler.S | 6 +-
12 libgloss/microblaze/_hw_exception_handler.S | 7 +-
13 libgloss/microblaze/_interrupt_handler.S | 7 +-
14 libgloss/microblaze/_program_clean.S | 6 +-
15 libgloss/microblaze/_program_init.S | 6 +-
16 libgloss/microblaze/crt0.S | 53 ++++++++++--
17 libgloss/microblaze/crt1.S | 54 +++++++++++--
18 libgloss/microblaze/crt2.S | 52 ++++++++++--
19 libgloss/microblaze/crt3.S | 32 +++++++-
20 libgloss/microblaze/crt4.S | 37 +++++++--
21 libgloss/microblaze/crtinit.S | 120 ++++++++++++++++++++--------
22 libgloss/microblaze/linux-crt0.S | 60 +++++++++++---
23 libgloss/microblaze/linux-syscalls.S | 15 +++-
24 libgloss/microblaze/pgcrtinit.S | 59 +++++++++++++-
25 libgloss/microblaze/sim-crtinit.S | 31 +++++++
26 libgloss/microblaze/sim-pgcrtinit.S | 31 +++++++
27 newlib/libc/machine/microblaze/longjmp.S | 45 +++++++++--
28 newlib/libc/machine/microblaze/setjmp.S | 33 +++++++-
29 18 files changed, 563 insertions(+), 91 deletions(-)
30
31diff --git a/libgloss/microblaze/_exception_handler.S b/libgloss/microblaze/_exception_handler.S
32index 7a91a78..0fdff3f 100644
33--- a/libgloss/microblaze/_exception_handler.S
34+++ b/libgloss/microblaze/_exception_handler.S
35@@ -30,7 +30,11 @@
36 */
37
38 .text
39- .align 2
40+#ifdef __arch64__
41+ .align 3
42+#else
43+ .align 2
44+#endif
45 .weakext _exception_handler
46 .ent _exception_handler
47 .type _exception_handler, @function
48diff --git a/libgloss/microblaze/_hw_exception_handler.S b/libgloss/microblaze/_hw_exception_handler.S
49index 47df945..b951a63 100644
50--- a/libgloss/microblaze/_hw_exception_handler.S
51+++ b/libgloss/microblaze/_hw_exception_handler.S
52@@ -32,8 +32,11 @@
53 .text
54 .weakext _hw_exception_handler # HW Exception Handler Label
55 .type _hw_exception_handler, %function
56- .align 2
57-
58+#ifdef __arch64__
59+ .align 3
60+#else
61+ .align 2
62+#endif
63 _hw_exception_handler:
64 rted r17, 0
65 nop
66diff --git a/libgloss/microblaze/_interrupt_handler.S b/libgloss/microblaze/_interrupt_handler.S
67index 5bb7329..a0ef92d 100644
68--- a/libgloss/microblaze/_interrupt_handler.S
69+++ b/libgloss/microblaze/_interrupt_handler.S
70@@ -32,8 +32,11 @@
71 .text
72 .weakext _interrupt_handler # Interrupt Handler Label
73 .type _interrupt_handler, %function
74- .align 2
75-
76+#ifdef __arch64__
77+ .align 3
78+#else
79+ .align 2
80+#endif
81 _interrupt_handler:
82 rtid r14, 0
83 nop
84diff --git a/libgloss/microblaze/_program_clean.S b/libgloss/microblaze/_program_clean.S
85index c460594..0d55d8a 100644
86--- a/libgloss/microblaze/_program_clean.S
87+++ b/libgloss/microblaze/_program_clean.S
88@@ -33,7 +33,11 @@
89 #
90
91 .text
92- .align 2
93+#ifdef __arch64__
94+ .align 3
95+#else
96+ .align 2
97+#endif
98 .globl _program_clean
99 .ent _program_clean
100 _program_clean:
101diff --git a/libgloss/microblaze/_program_init.S b/libgloss/microblaze/_program_init.S
102index 0daa42e..862ef78 100644
103--- a/libgloss/microblaze/_program_init.S
104+++ b/libgloss/microblaze/_program_init.S
105@@ -32,7 +32,11 @@
106 # Dummy file to be replaced by LibGen
107
108 .text
109- .align 2
110+#ifdef __arch64__
111+ .align 3
112+#else
113+ .align 2
114+#endif
115 .globl _program_init
116 .ent _program_init
117 _program_init:
118diff --git a/libgloss/microblaze/crt0.S b/libgloss/microblaze/crt0.S
119index 865a8c2..e4df73b 100644
120--- a/libgloss/microblaze/crt0.S
121+++ b/libgloss/microblaze/crt0.S
122@@ -54,7 +54,11 @@
123
124 .globl _start
125 .section .vectors.reset, "ax"
126- .align 2
127+#ifdef __arch64__
128+ .align 3
129+#else
130+ .align 2
131+#endif
132 .ent _start
133 .type _start, @function
134 _start:
135@@ -62,36 +66,64 @@ _start:
136 .end _start
137
138 .section .vectors.sw_exception, "ax"
139+#ifdef __arch64__
140+ .align 3
141+#else
142 .align 2
143+#endif
144 _vector_sw_exception:
145 brai _exception_handler
146
147 .section .vectors.interrupt, "ax"
148+#ifdef __arch64__
149+ .align 3
150+#else
151 .align 2
152+#endif
153+
154 _vector_interrupt:
155 brai _interrupt_handler
156
157 .section .vectors.hw_exception, "ax"
158+#ifdef __arch64__
159+ .align 3
160+#else
161 .align 2
162+#endif
163+
164 _vector_hw_exception:
165 brai _hw_exception_handler
166
167 .section .text
168 .globl _start1
169+#ifdef __arch64__
170+ .align 3
171+#else
172 .align 2
173+#endif
174+
175 .ent _start1
176 .type _start1, @function
177 _start1:
178+#ifdef __arch64__
179+ lli r13, r0, _SDA_BASE_
180+ lli r2, r0, _SDA2_BASE_
181+ lli r1, r0, _stack-32
182+ brealid r15, _crtinit
183+ nop
184+ addlik r5, r3, 0
185+ brealid r15, exit
186+ nop
187+#else
188 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
189 la r2, r0, _SDA2_BASE_
190 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
191-
192 brlid r15, _crtinit /* Initialize BSS and run program */
193 nop
194
195- brlid r15, exit /* Call exit with the return value of main */
196- addik r5, r3, 0
197-
198+ brlid r15, exit /* Call exit with the return value of main */
199+ addik r5, r3, 0
200+#endif
201 /* Control does not reach here */
202 .end _start1
203
204@@ -101,9 +133,18 @@ _start1:
205 Our simple _exit
206 */
207 .globl _exit
208+#ifdef __arch64__
209+ .align 3
210+#else
211 .align 2
212+#endif
213+
214 .ent _exit
215 .type _exit, @function
216 _exit:
217- bri 0
218+#ifdef __arch64__
219+ breai 0
220+#else
221+ bri 0
222+#endif
223 .end _exit
224diff --git a/libgloss/microblaze/crt1.S b/libgloss/microblaze/crt1.S
225index a8bf749..b24eeb5 100644
226--- a/libgloss/microblaze/crt1.S
227+++ b/libgloss/microblaze/crt1.S
228@@ -53,36 +53,67 @@
229
230
231 .section .vectors.sw_exception, "ax"
232- .align 2
233+#ifdef __arch64__
234+ .align 3
235+#else
236+ .align 2
237+#endif
238+
239 _vector_sw_exception:
240 brai _exception_handler
241
242 .section .vectors.interrupt, "ax"
243- .align 2
244+#ifdef __arch64__
245+ .align 3
246+#else
247+ .align 2
248+#endif
249+
250 _vector_interrupt:
251 brai _interrupt_handler
252
253 .section .vectors.hw_exception, "ax"
254- .align 2
255+#ifdef __arch64__
256+ .align 3
257+#else
258+ .align 2
259+#endif
260+
261 _vector_hw_exception:
262 brai _hw_exception_handler
263
264 .section .text
265 .globl _start
266- .align 2
267+#ifdef __arch64__
268+ .align 3
269+#else
270+ .align 2
271+#endif
272+
273 .ent _start
274 .type _start, @function
275 _start:
276+#ifdef __arch64__
277+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
278+ lli r2, r0, _SDA2_BASE_
279+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
280+
281+ brealid r15, _crtinit /* Initialize BSS and run program */
282+ nop
283+ addlik r5, r3, 0
284+ brealid r15, exit
285+ nop
286+#else
287 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
288 la r2, r0, _SDA2_BASE_
289- la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
290+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
291
292 brlid r15, _crtinit /* Initialize BSS and run program */
293 nop
294
295 brlid r15, exit /* Call exit with the return value of main */
296 addik r5, r3, 0
297-
298+#endif
299 /* Control does not reach here */
300 .end _start
301
302@@ -92,11 +123,18 @@ _start:
303 Our simple _exit
304 */
305 .globl _exit
306- .align 2
307+#ifdef __arch64__
308+ .align 3
309+#else
310+ .align 2
311+#endif
312 .ent _exit
313 .type _exit, @function
314 _exit:
315+#ifdef __arch64__
316+ addl r3, r0, r5
317+#else
318 add r3, r0, r5
319+#endif
320 brki r16, 0x4 /* Return to hook in XMDSTUB */
321 .end _exit
322-
323diff --git a/libgloss/microblaze/crt2.S b/libgloss/microblaze/crt2.S
324index 34d9f95..ae4c89e 100644
325--- a/libgloss/microblaze/crt2.S
326+++ b/libgloss/microblaze/crt2.S
327@@ -51,26 +51,56 @@
328 */
329
330 .section .vectors.sw_exception, "ax"
331- .align 2
332+#ifdef __arch64__
333+ .align 3
334+#else
335+ .align 2
336+#endif
337+
338 _vector_sw_exception:
339 brai _exception_handler
340
341 .section .vectors.interrupt, "ax"
342- .align 2
343+#ifdef __arch64__
344+ .align 3
345+#else
346+ .align 2
347+#endif
348+
349 _vector_interrupt:
350 brai _interrupt_handler
351
352 .section .vectors.hw_exception, "ax"
353- .align 2
354+#ifdef __arch64__
355+ .align 3
356+#else
357+ .align 2
358+#endif
359+
360 _vector_hw_exception:
361 brai _hw_exception_handler
362
363 .section .text
364 .globl _start
365- .align 2
366+#ifdef __arch64__
367+ .align 3
368+#else
369+ .align 2
370+#endif
371+
372 .ent _start
373 .type _start, @function
374 _start:
375+#ifdef __arch64__
376+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
377+ lli r2, r0, _SDA2_BASE_
378+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
379+ brealid r15, _crtinit /* Initialize BSS and run program */
380+ nop
381+ addlik r5, r3, 0
382+ brealid r15, exit
383+ nop
384+#else
385 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
386 la r2, r0, _SDA2_BASE_
387 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
388@@ -80,7 +110,7 @@ _start:
389
390 brlid r15, exit /* Call exit with the return value of main */
391 addik r5, r3, 0
392-
393+#endif
394 /* Control does not reach here */
395
396 .end _start
397@@ -90,9 +120,17 @@ _start:
398 Our simple _exit
399 */
400 .globl _exit
401- .align 2
402+#ifdef __arch64__
403+ .align 3
404+#else
405+ .align 2
406+#endif
407 .ent _exit
408 .type _exit, @function
409 _exit:
410- bri 0
411+#ifdef __arch64__
412+ breai 0
413+#else
414+ bri 0
415+#endif
416 .end _exit
417diff --git a/libgloss/microblaze/crt3.S b/libgloss/microblaze/crt3.S
418index ebcf207..a8bc783 100644
419--- a/libgloss/microblaze/crt3.S
420+++ b/libgloss/microblaze/crt3.S
421@@ -53,10 +53,26 @@
422
423 .section .text
424 .globl _start
425- .align 2
426+#ifdef __arch64__
427+ .align 3
428+#else
429+ .align 2
430+#endif
431 .ent _start
432 .type _start, @function
433 _start:
434+#ifdef __arch64__
435+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
436+ lli r2, r0, _SDA2_BASE_
437+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
438+
439+ brealid r15, _crtinit /* Initialize BSS and run program */
440+ nop
441+
442+ addlik r5, r3, 0
443+ brealid r15, exit /* Call exit with the return value of main */
444+ nop
445+#else
446 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
447 la r2, r0, _SDA2_BASE_
448 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
449@@ -66,7 +82,7 @@ _start:
450
451 brlid r15, exit /* Call exit with the return value of main */
452 addik r5, r3, 0
453-
454+#endif
455 /* Control does not reach here */
456 .end _start
457
458@@ -76,9 +92,17 @@ _start:
459 Our simple _exit
460 */
461 .globl _exit
462- .align 2
463+#ifdef __arch64__
464+ .align 3
465+#else
466+ .align 2
467+#endif
468 .ent _exit
469 .type _exit, @function
470 _exit:
471- bri 0
472+#ifdef __arch64__
473+ breai 0
474+#else
475+ bri 0
476+#endif
477 .end _exit
478diff --git a/libgloss/microblaze/crt4.S b/libgloss/microblaze/crt4.S
479index 4cf0b01..54ba473 100644
480--- a/libgloss/microblaze/crt4.S
481+++ b/libgloss/microblaze/crt4.S
482@@ -53,10 +53,27 @@
483
484 .section .text
485 .globl _start
486- .align 2
487+#ifdef __arch64__
488+ .align 3
489+#else
490+ .align 2
491+#endif
492+
493 .ent _start
494 .type _start, @function
495 _start:
496+#ifdef __arch64__
497+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
498+ lli r2, r0, _SDA2_BASE_
499+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
500+
501+ brealid r15, _crtinit /* Initialize BSS and run program */
502+ nop
503+
504+ addlik r5, r3, 0
505+ brealid r15, exit /* Call exit with the return value of main */
506+ nop
507+#else
508 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
509 la r2, r0, _SDA2_BASE_
510 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
511@@ -68,19 +85,27 @@ _start:
512 addik r5, r3, 0
513
514 /* Control does not reach here */
515-
516+#endif
517 .end _start
518
519-
520 /*
521 _exit
522 Our simple _exit
523 */
524 .globl _exit
525- .align 2
526+#ifdef __arch64__
527+ .align 3
528+#else
529+ .align 2
530+#endif
531 .ent _exit
532 .type _exit, @function
533 _exit:
534- brlid r15,elf_process_exit
535- nop
536+#ifdef __arch64__
537+ brealid r15,elf_process_exit
538+ nop
539+#else
540+ brlid r15,elf_process_exit
541+ nop
542+#endif
543 .end _exit
544diff --git a/libgloss/microblaze/crtinit.S b/libgloss/microblaze/crtinit.S
545index 86c6dfc..8541175 100644
546--- a/libgloss/microblaze/crtinit.S
547+++ b/libgloss/microblaze/crtinit.S
548@@ -29,59 +29,115 @@
549 */
550
551 .globl _crtinit
552+#ifdef __arch64__
553+ .align 3
554+#else
555 .align 2
556+#endif
557 .ent _crtinit
558 .type _crtinit, @function
559 _crtinit:
560- addi r1, r1, -40 /* Save Link register */
561- swi r15, r1, 0
562+#ifdef __arch64__
563+ addli r1, r1, -40 /* Save Link register */
564+ sli r15, r1, 0
565
566- addi r6, r0, __sbss_start /* clear SBSS */
567- addi r7, r0, __sbss_end
568- rsub r18, r6, r7
569- blei r18, .Lendsbss
570+ addli r6, r0, __sbss_start /* clear SBSS */
571+ addli r7, r0, __sbss_end
572+ rsubl r18, r6, r7
573+ bealei r18, .Lendsbss
574
575 .Lloopsbss:
576- swi r0, r6, 0
577- addi r6, r6, 4
578- rsub r18, r6, r7
579- bgti r18, .Lloopsbss
580+ sli r0, r6, 0
581+ addli r6, r6, 4
582+ rsubl r18, r6, r7
583+ beagti r18, .Lloopsbss
584 .Lendsbss:
585-
586- addi r6, r0, __bss_start /* clear BSS */
587- addi r7, r0, __bss_end
588- rsub r18, r6, r7
589- blei r18, .Lendbss
590+ addli r6, r0, __bss_start /* clear BSS */
591+ addli r7, r0, __bss_end
592+ rsubl r18, r6, r7
593+ bealei r18, .Lendbss
594 .Lloopbss:
595- swi r0, r6, 0
596- addi r6, r6, 4
597- rsub r18, r6, r7
598- bgti r18, .Lloopbss
599+ sli r0, r6, 0
600+ addli r6, r6, 4
601+ rsubl r18, r6, r7
602+ beagti r18, .Lloopbss
603 .Lendbss:
604
605- brlid r15, _program_init /* Initialize the program */
606+ brealid r15, _program_init /* Initialize the program */
607+ nop
608+ brealid r15, __init /* Invoke language initialization functions */
609+ nop
610+
611+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
612+ addli r7, r0, 0
613+ addli r5, r0, 0
614+ brealid r15, main /* Execute the program */
615 nop
616+ addlik r19, r3, 0 /* Save return value */
617+
618+ brealid r15, __fini /* Invoke language cleanup functions */
619+ nop
620+
621+ brealid r15, _program_clean /* Cleanup the program */
622+ nop
623+
624+ ll r15, r1, r0 /* Return back to CRT */
625+
626+ addlik r3, r19, 0 /* Restore return value */
627+ addli r1, r1, 40
628+ rtsd r15, 8
629+ nop
630+#else
631+ addi r1, r1, -40 /* Save Link register */
632+ swi r15, r1, 0
633+
634+ addi r6, r0, __sbss_start /* clear SBSS */
635+ addi r7, r0, __sbss_end
636+ rsub r18, r6, r7
637+ blei r18, .Lendsbss
638+
639+.Lloopsbss:
640+ swi r0, r6, 0
641+ addi r6, r6, 4
642+ rsub r18, r6, r7
643+ bgti r18, .Lloopsbss
644+.Lendsbss:
645+
646+ addi r6, r0, __bss_start /* clear BSS */
647+ addi r7, r0, __bss_end
648+ rsub r18, r6, r7
649+ blei r18, .Lendbss
650+.Lloopbss:
651+ swi r0, r6, 0
652+ addi r6, r6, 4
653+ rsub r18, r6, r7
654+ bgti r18, .Lloopbss
655+.Lendbss:
656+
657+ brlid r15, _program_init /* Initialize the program */
658+ nop
659
660 brlid r15, __init /* Invoke language initialization functions */
661 nop
662-
663- addi r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
664- addi r7, r0, 0
665- brlid r15, main /* Execute the program */
666- addi r5, r0, 0
667+
668+ addi r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
669+ addi r7, r0, 0
670+ brlid r15, main /* Execute the program */
671+ addi r5, r0, 0
672
673 addik r19, r3, 0 /* Save return value */
674-
675+
676 brlid r15, __fini /* Invoke language cleanup functions */
677 nop
678-
679- brlid r15, _program_clean /* Cleanup the program */
680- nop
681
682- lw r15, r1, r0 /* Return back to CRT */
683+ brlid r15, _program_clean /* Cleanup the program */
684+ nop
685+
686+ lw r15, r1, r0 /* Return back to CRT */
687
688 addik r3, r19, 0 /* Restore return value */
689- rtsd r15, 8
690- addi r1, r1, 40
691+ rtsd r15, 8
692+ addi r1, r1, 40
693+#endif
694 .end _crtinit
695
696diff --git a/libgloss/microblaze/linux-crt0.S b/libgloss/microblaze/linux-crt0.S
697index 8650bb5..503439b 100644
698--- a/libgloss/microblaze/linux-crt0.S
699+++ b/libgloss/microblaze/linux-crt0.S
700@@ -18,26 +18,50 @@
701 .ent _start
702 .type _start, @function
703 _start:
704- la r13, r0, _SDA_BASE_
705- la r2, r0, _SDA2_BASE_
706+#ifdef __arch64__
707+ lli r13, r0, _SDA_BASE_
708+ lli r2, r0, _SDA2_BASE_
709
710- brlid r15, __init
711+ brealid r15, __init
712 nop
713
714- lwi r5, r1, 0
715- addik r6, r1, 4
716+ lli r5, r1, 0
717+ addlik r6, r1, 4
718
719 # Add argc * 4.
720- addk r7, r5, r5
721- addk r7, r7, r7
722+ addlk r7, r5, r5
723+ addlk r7, r7, r7
724
725- brlid r15, main
726 # Now add 4 + r1 (i.e r6) in the delayslot.
727- addk r7, r7, r6
728+ addlk r7, r7, r6
729+ brealid r15, main
730+ nop
731+ addlik r5, r3, 0
732+ brealid r15, exit
733+ nop
734+ .size _start, . - _start
735+#else
736+ la r13, r0, _SDA_BASE_
737+ la r2, r0, _SDA2_BASE_
738+
739+ brlid r15, __init
740+ nop
741+
742+ lwi r5, r1, 0
743+ addik r6, r1, 4
744
745- brlid r15, exit
746+ # Add argc * 4.
747+ addk r7, r5, r5
748+ addk r7, r7, r7
749+
750+ brlid r15, main
751+ # Now add 4 + r1 (i.e r6) in the delayslot.
752+ addk r7, r7, r6
753+
754+ brlid r15, exit
755 addik r5, r3, 0
756- .size _start, . - _start
757+ .size _start, . - _start
758+#endif
759 .end _start
760
761 /* Replacement for the GCC provided crti.S. This one avoids the
762@@ -45,14 +69,28 @@ _start:
763 insn exceptions when running in user-space). */
764 .section .init, "ax"
765 .global __init
766+#ifdef __arch64__
767+ .align 3
768+__init:
769+ addlik r1, r1, -8
770+ sl r15, r0, r1
771+#else
772 .align 2
773 __init:
774 addik r1, r1, -8
775 sw r15, r0, r1
776
777+#endif
778 .section .fini, "ax"
779 .global __fini
780+#ifdef __arch64__
781+ .align 3
782+__fini:
783+ addlik r1, r1, -8
784+ sl r15, r0, r1
785+#else
786 .align 2
787 __fini:
788 addik r1, r1, -8
789 sw r15, r0, r1
790+#endif
791diff --git a/libgloss/microblaze/linux-syscalls.S b/libgloss/microblaze/linux-syscalls.S
792index 506de78..8594f13 100644
793--- a/libgloss/microblaze/linux-syscalls.S
794+++ b/libgloss/microblaze/linux-syscalls.S
795@@ -20,8 +20,9 @@
796 #define GLOBAL(name) .global name; FUNC(name)
797 #define SIZE(name) .size name, .-name
798
799+#ifdef __arch64__
800 # define SYSCALL_BODY(name) \
801- addik r12, r0, SYS_ ## name; \
802+ addlik r12, r0, SYS_ ## name; \
803 brki r14, 8; \
804 rtsd r15, 8; \
805 nop;
806@@ -31,6 +32,18 @@
807 SYSCALL_BODY(name); \
808 SIZE(_ ## name)
809
810+#else
811+# define SYSCALL_BODY(name) \
812+ addik r12, r0, SYS_ ## name; \
813+ brki r14, 8; \
814+ rtsd r15, 8; \
815+ nop;
816+
817+# define SYSCALL(name) \
818+ GLOBAL(_ ## name); \
819+ SYSCALL_BODY(name); \
820+ SIZE(_ ## name)
821+#endif
822 SYSCALL(brk)
823 SYSCALL(exit)
824 SYSCALL(read)
825diff --git a/libgloss/microblaze/pgcrtinit.S b/libgloss/microblaze/pgcrtinit.S
826index 2593082..638dbd3 100644
827--- a/libgloss/microblaze/pgcrtinit.S
828+++ b/libgloss/microblaze/pgcrtinit.S
829@@ -29,10 +29,66 @@
830
831
832 .globl _crtinit
833+#ifdef __arch64__
834+ .align 3
835+#else
836 .align 2
837+#endif
838 .ent _crtinit
839
840 _crtinit:
841+#ifdef __arch64__
842+
843+ addli r1, r1, -40 /* Save Link register */
844+ sli r15, r1, 0
845+
846+ addli r6, r0, __sbss_start /* clear SBSS */
847+ addli r7, r0, __sbss_end
848+ rsubl r18, r6, r7
849+ bealei r18, .Lendsbss
850+.Lloopsbss:
851+ sli r0, r6, 0
852+ addli r6, r6, 4
853+ rsubl r18, r6, r7
854+ beagti r18, .Lloopsbss
855+.Lendsbss:
856+
857+ addli r6, r0, __bss_start /* clear BSS */
858+ addli r7, r0, __bss_end
859+ rsubl r18, r6, r7
860+ bealei r18, .Lendbss
861+.Lloopbss:
862+ sli r0, r6, 0
863+ addli r6, r6, 4
864+ rsubl r18, r6, r7
865+ beagti r18, .Lloopbss
866+.Lendbss:
867+
868+ brealid r15, _program_init /* Initialize the program */
869+ nop
870+ brealid r15, _profile_init /* Initialize profiling library */
871+ nop
872+ brealid r15, __init /* Invoke language initialization functions */
873+ nop
874+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
875+ addli r7, r0, 0
876+ addli r5, r0, 0
877+ brealid r15, main /* Execute the program */
878+ nop
879+ addlik r19, r3, 0 /* Save return value */
880+
881+ brealid r15, __fini /* Invoke language cleanup functions */
882+ nop
883+ brealid r15, _profile_clean /* Cleanup profiling library */
884+ nop
885+ brealid r15, _program_clean /* Cleanup the program */
886+ nop
887+ ll r15, r1, r0 /* Return back to CRT */
888+ addlik r3, r19, 0 /* Restore return value */
889+ addli r1, r1, 40
890+ rtsd r15, 8
891+ nop
892+#else
893 addi r1, r1, -40 /* Save Link register */
894 swi r15, r1, 0
895
896@@ -86,7 +142,8 @@ _crtinit:
897
898 lw r15, r1, r0 /* Return back to CRT */
899 addik r3, r19, 0 /* Restore return value */
900- rtsd r15, 8
901+ rtsd r15, 8
902 addi r1, r1, 40
903+#endif
904 .end _crtinit
905
906diff --git a/libgloss/microblaze/sim-crtinit.S b/libgloss/microblaze/sim-crtinit.S
907index 74586d9..9892cb0 100644
908--- a/libgloss/microblaze/sim-crtinit.S
909+++ b/libgloss/microblaze/sim-crtinit.S
910@@ -35,10 +35,39 @@
911 #
912
913 .globl _crtinit
914+#ifdef __arch64__
915+ .align 3
916+#else
917 .align 2
918+#endif
919 .ent _crtinit
920
921 _crtinit:
922+#ifdef __arch64__
923+ addli r1, r1, -40 /* Save Link register */
924+ sli r15, r1, 0
925+
926+ brealid r15, _program_init /* Initialize the program */
927+ nop
928+ brealid r15, __init /* Invoke language initialization functions */
929+ nop
930+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
931+ addli r7, r0, 0
932+ addli r5, r0, 0
933+ brealid r15, main /* Execute the program */
934+ nop
935+ addlik r19, r3, 0 /* Save return value */
936+
937+ brealid r15, __fini /* Invoke language cleanup functions */
938+ nop
939+ brealid r15, _program_clean /* Cleanup the program */
940+ nop
941+ ll r15, r1, r0 /* Return back to CRT */
942+ addlik r3, r19, 0 /* Restore return value */
943+ addli r1, r1, 40
944+ rtsd r15, 8
945+ nop
946+#else
947 addi r1, r1, -40 /* Save Link register */
948 swi r15, r1, 0
949
950@@ -63,7 +92,9 @@ _crtinit:
951
952 lw r15, r1, r0 /* Return back to CRT */
953 addik r3, r19, 0 /* Restore return value */
954+
955 rtsd r15, 8
956 addi r1, r1, 40
957+#endif
958 .end _crtinit
959
960diff --git a/libgloss/microblaze/sim-pgcrtinit.S b/libgloss/microblaze/sim-pgcrtinit.S
961index 82ebcca..939f537 100644
962--- a/libgloss/microblaze/sim-pgcrtinit.S
963+++ b/libgloss/microblaze/sim-pgcrtinit.S
964@@ -35,10 +35,40 @@
965 #
966
967 .globl _crtinit
968+#ifdef __arch64__
969+ .align 3
970+#else
971 .align 2
972+#endif
973 .ent _crtinit
974
975 _crtinit:
976+#ifdef __arch64__
977+ addli r1, r1, -40 /* Save Link register */
978+ sli r15, r1, 0
979+
980+ brealid r15, _program_init /* Initialize the program */
981+ nop
982+ brealid r15, _profile_init /* Initialize profiling library */
983+ nop
984+ brealid r15, __init /* Invoke language initialization functions */
985+ nop
986+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
987+ addli r7, r0, 0
988+ addli r5, r0, 0
989+ brealid r15, main /* Execute the program */
990+ nop
991+ brealid r15, __fini /* Invoke language cleanup functions */
992+ nop
993+ brealid r15, _profile_clean /* Cleanup profiling library */
994+ nop
995+ brealid r15, _program_clean /* Cleanup the program */
996+ nop
997+ ll r15, r1, r0 /* Return back to CRT */
998+ addli r1, r1, 40
999+ rtsd r15, 8
1000+ nop
1001+#else
1002 addi r1, r1, -40 /* Save Link register */
1003 swi r15, r1, 0
1004
1005@@ -68,5 +98,6 @@ _crtinit:
1006 lw r15, r1, r0 /* Return back to CRT */
1007 rtsd r15, 8
1008 addi r1, r1, 40
1009+#endif
1010 .end _crtinit
1011
1012diff --git a/newlib/libc/machine/microblaze/longjmp.S b/newlib/libc/machine/microblaze/longjmp.S
1013index f972bbd..5ed1c26 100644
1014--- a/newlib/libc/machine/microblaze/longjmp.S
1015+++ b/newlib/libc/machine/microblaze/longjmp.S
1016@@ -51,16 +51,46 @@
1017
1018 .globl longjmp
1019 .section .text
1020-.align 2
1021+#ifdef __arch64__
1022+.align 3
1023+#else
1024+.align 2
1025+#endif
1026 .ent longjmp
1027 longjmp:
1028+#ifdef __arch64__
1029+ lli r1, r5, 0
1030+ lli r13, r5, 4
1031+ lli r14, r5, 8
1032+ lli r15, r5, 12
1033+ lli r16, r5, 16
1034+ lli r17, r5, 20
1035+ lli r18, r5, 24
1036+ lli r19, r5, 28
1037+ lli r20, r5, 32
1038+ lli r21, r5, 36
1039+ lli r22, r5, 40
1040+ lli r23, r5, 44
1041+ lli r24, r5, 48
1042+ lli r25, r5, 52
1043+ lli r26, r5, 56
1044+ lli r27, r5, 60
1045+ lli r28, r5, 64
1046+ lli r29, r5, 68
1047+ lli r30, r5, 72
1048+ lli r31, r5, 76
1049+
1050+ or r3, r0, r6
1051+ rtsd r15, 8
1052+ nop
1053+#else
1054 lwi r1, r5, 0
1055 lwi r13, r5, 4
1056 lwi r14, r5, 8
1057- lwi r15, r5, 12
1058+ lwi r15, r5, 12
1059 lwi r16, r5, 16
1060 lwi r17, r5, 20
1061- lwi r18, r5, 24
1062+ lwi r18, r5, 24
1063 lwi r19, r5, 28
1064 lwi r20, r5, 32
1065 lwi r21, r5, 36
1066@@ -69,12 +99,13 @@ longjmp:
1067 lwi r24, r5, 48
1068 lwi r25, r5, 52
1069 lwi r26, r5, 56
1070- lwi r27, r5, 60
1071- lwi r28, r5, 64
1072- lwi r29, r5, 68
1073+ lwi r27, r5, 60
1074+ lwi r28, r5, 64
1075+ lwi r29, r5, 68
1076 lwi r30, r5, 72
1077- lwi r31, r5, 76
1078+ lwi r31, r5, 76
1079
1080 rtsd r15, 8
1081 or r3, r0, r6
1082+#endif
1083 .end longjmp
1084diff --git a/newlib/libc/machine/microblaze/setjmp.S b/newlib/libc/machine/microblaze/setjmp.S
1085index cdd87c7..971862b 100644
1086--- a/newlib/libc/machine/microblaze/setjmp.S
1087+++ b/newlib/libc/machine/microblaze/setjmp.S
1088@@ -50,9 +50,39 @@
1089
1090 .globl setjmp
1091 .section .text
1092-.align 2
1093+#ifdef __arch64__
1094+.align 3
1095+#else
1096+.align 2
1097+#endif
1098 .ent setjmp
1099 setjmp:
1100+#ifdef __arch64__
1101+ sli r1, r5, 0
1102+ sli r13, r5, 4
1103+ sli r14, r5, 8
1104+ sli r15, r5, 12
1105+ sli r16, r5, 16
1106+ sli r17, r5, 20
1107+ sli r18, r5, 24
1108+ sli r19, r5, 28
1109+ sli r20, r5, 32
1110+ sli r21, r5, 36
1111+ sli r22, r5, 40
1112+ sli r23, r5, 44
1113+ sli r24, r5, 48
1114+ sli r25, r5, 52
1115+ sli r26, r5, 56
1116+ sli r27, r5, 60
1117+ sli r28, r5, 64
1118+ sli r29, r5, 68
1119+ sli r30, r5, 72
1120+ sli r31, r5, 76
1121+
1122+ or r3, r0, r0
1123+ rtsd r15, 8
1124+ nop
1125+#else
1126 swi r1, r5, 0
1127 swi r13, r5, 4
1128 swi r14, r5, 8
1129@@ -76,4 +106,5 @@ setjmp:
1130
1131 rtsd r15, 8
1132 or r3, r0, r0
1133+#endif
1134 .end setjmp
1135--
11362.7.4
1137
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch b/meta-microblaze/recipes-microblaze/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch
new file mode 100644
index 00000000..9f27cd60
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch
@@ -0,0 +1,102 @@
1From 1c7a9150b63089baf3f63c64bf3dbb4d73c814f5 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 28 Sep 2018 12:07:43 +0530
4Subject: [PATCH 08/11] fixing the bug in crt files, added addlik instead of
5 lli insn
6
7---
8 libgloss/microblaze/crt0.S | 6 +++---
9 libgloss/microblaze/crt1.S | 6 +++---
10 libgloss/microblaze/crt2.S | 6 +++---
11 libgloss/microblaze/crt3.S | 6 +++---
12 libgloss/microblaze/crt4.S | 6 +++---
13 5 files changed, 15 insertions(+), 15 deletions(-)
14
15diff --git a/libgloss/microblaze/crt0.S b/libgloss/microblaze/crt0.S
16index e4df73b..25e7c4a 100644
17--- a/libgloss/microblaze/crt0.S
18+++ b/libgloss/microblaze/crt0.S
19@@ -106,9 +106,9 @@ _vector_hw_exception:
20 .type _start1, @function
21 _start1:
22 #ifdef __arch64__
23- lli r13, r0, _SDA_BASE_
24- lli r2, r0, _SDA2_BASE_
25- lli r1, r0, _stack-32
26+ addlik r13, r0, _SDA_BASE_
27+ addlik r2, r0, _SDA2_BASE_
28+ addlik r1, r0, _stack-32
29 brealid r15, _crtinit
30 nop
31 addlik r5, r3, 0
32diff --git a/libgloss/microblaze/crt1.S b/libgloss/microblaze/crt1.S
33index b24eeb5..38440c9 100644
34--- a/libgloss/microblaze/crt1.S
35+++ b/libgloss/microblaze/crt1.S
36@@ -94,9 +94,9 @@ _vector_hw_exception:
37 .type _start, @function
38 _start:
39 #ifdef __arch64__
40- lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
41- lli r2, r0, _SDA2_BASE_
42- lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
43+ addlik r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
44+ addlik r2, r0, _SDA2_BASE_
45+ addlik r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
46
47 brealid r15, _crtinit /* Initialize BSS and run program */
48 nop
49diff --git a/libgloss/microblaze/crt2.S b/libgloss/microblaze/crt2.S
50index ae4c89e..352927d 100644
51--- a/libgloss/microblaze/crt2.S
52+++ b/libgloss/microblaze/crt2.S
53@@ -92,9 +92,9 @@ _vector_hw_exception:
54 .type _start, @function
55 _start:
56 #ifdef __arch64__
57- lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
58- lli r2, r0, _SDA2_BASE_
59- lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
60+ addlik r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
61+ addlik r2, r0, _SDA2_BASE_
62+ addlik r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
63 brealid r15, _crtinit /* Initialize BSS and run program */
64 nop
65 addlik r5, r3, 0
66diff --git a/libgloss/microblaze/crt3.S b/libgloss/microblaze/crt3.S
67index a8bc783..bc32cda 100644
68--- a/libgloss/microblaze/crt3.S
69+++ b/libgloss/microblaze/crt3.S
70@@ -62,9 +62,9 @@
71 .type _start, @function
72 _start:
73 #ifdef __arch64__
74- lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
75- lli r2, r0, _SDA2_BASE_
76- lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
77+ addlik r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
78+ addlik r2, r0, _SDA2_BASE_
79+ addlik r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
80
81 brealid r15, _crtinit /* Initialize BSS and run program */
82 nop
83diff --git a/libgloss/microblaze/crt4.S b/libgloss/microblaze/crt4.S
84index 54ba473..a25c847 100644
85--- a/libgloss/microblaze/crt4.S
86+++ b/libgloss/microblaze/crt4.S
87@@ -63,9 +63,9 @@
88 .type _start, @function
89 _start:
90 #ifdef __arch64__
91- lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
92- lli r2, r0, _SDA2_BASE_
93- lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
94+ addlik r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
95+ addlik r2, r0, _SDA2_BASE_
96+ addlik r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
97
98 brealid r15, _crtinit /* Initialize BSS and run program */
99 nop
100--
1012.7.4
102
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch b/meta-microblaze/recipes-microblaze/newlib/files/0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch
new file mode 100644
index 00000000..38508b55
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch
@@ -0,0 +1,227 @@
1From 19d7b2a34f3c69d62f570ac9d0f6bc3cd584b496 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 14 Mar 2019 18:16:32 +0530
4Subject: [PATCH 09/11] Added MB-64 support to strcmp/strcpy/strlen files
5
6---
7 newlib/libc/machine/microblaze/strcmp.c | 61 ++++++++++++++++++++++++++++++++-
8 newlib/libc/machine/microblaze/strcpy.c | 57 ++++++++++++++++++++++++++++++
9 newlib/libc/machine/microblaze/strlen.c | 38 ++++++++++++++++++++
10 3 files changed, 155 insertions(+), 1 deletion(-)
11
12diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c
13index 3119d82..dac64da 100644
14--- a/newlib/libc/machine/microblaze/strcmp.c
15+++ b/newlib/libc/machine/microblaze/strcmp.c
16@@ -133,6 +133,65 @@ strcmp (const char *s1,
17
18 #include "mb_endian.h"
19
20+#ifdef __arch64__
21+ asm volatile (" \n\
22+ orl r9, r0, r0 /* Index register */\n\
23+check_alignment: \n\
24+ andli r3, r5, 3 \n\
25+ andli r4, r6, 3 \n\
26+ beanei r3, try_align_args \n\
27+ beanei r4, regular_strcmp /* At this point we don't have a choice */ \n\
28+cmp_loop: \n"
29+ LOAD4BYTES("r3", "r5", "r9")
30+ LOAD4BYTES("r4", "r6", "r9")
31+" \n\
32+ pcmplbf r7, r3, r0 /* See if there is Null byte */ \n\
33+ beanei r7, end_cmp_loop /* IF yes (r7 > 0) use byte compares in end_cmp_loop */ \n\
34+ cmplu r7, r4, r3 /* ELSE compare whole word */ \n\
35+ beanei r7, end_cmp \n\
36+ addlik r9, r9, 4 /* delay slot */ \n\
37+ breaid cmp_loop \n\
38+ nop /* delay slot */ \n\
39+end_cmp_loop: \n\
40+ lbu r3, r5, r9 /* byte compare loop */ \n\
41+ lbu r4, r6, r9 \n\
42+ cmplu r7, r4, r3 /* Compare bytes */ \n\
43+ beanei r7, end_cmp_early \n\
44+ addlik r9, r9, 1 /* delay slot */ \n\
45+ beaneid r3, end_cmp_loop /* If reached null on one string, terminate */ \n\
46+ nop \n\
47+end_cmp_early: \n\
48+ or r3, r0, r7 /* delay slot */ \n\
49+ rtsd r15, 8 \n\
50+ nop \n\
51+try_align_args: \n\
52+ xorl r7, r4, r3 \n\
53+ beanei r7, regular_strcmp /* cannot align args */ \n\
54+ rsublik r10, r3, 4 /* Number of initial bytes to align */ \n\
55+align_loop: \n\
56+ lbu r3, r5, r9 \n\
57+ lbu r4, r6, r9 \n\
58+ cmpu r7, r4, r3 \n\
59+ beanei r7, end_cmp \n\
60+ beaeqi r3, end_cmp \n\
61+ addlik r10, r10, -1 \n\
62+ addlik r9, r9, 1 \n\
63+ beaeqid r10, cmp_loop \n\
64+ nop \n\
65+ breai align_loop \n\
66+regular_strcmp: \n\
67+ lbu r3, r5, r9 \n\
68+ lbu r4, r6, r9 \n\
69+ cmplu r7, r4, r3 \n\
70+ beanei r7, end_cmp \n\
71+ beaeqi r3, end_cmp \n\
72+ breaid regular_strcmp \n\
73+ addlik r9, r9, 1 \n\
74+end_cmp: \n\
75+ or r3, r0, r7 \n\
76+ rtsd r15, 8 \n\
77+ nop /* Return strcmp result */");
78+#else
79 asm volatile (" \n\
80 or r9, r0, r0 /* Index register */\n\
81 check_alignment: \n\
82@@ -181,11 +240,11 @@ regular_strcmp:
83 bnei r7, end_cmp \n\
84 beqi r3, end_cmp \n\
85 brid regular_strcmp \n\
86- addik r9, r9, 1 \n\
87 end_cmp: \n\
88 rtsd r15, 8 \n\
89 or r3, r0, r7 /* Return strcmp result */");
90
91+#endif
92 #endif /* ! HAVE_HW_PCMP */
93 }
94
95diff --git a/newlib/libc/machine/microblaze/strcpy.c b/newlib/libc/machine/microblaze/strcpy.c
96index 62072fa..6dbc60d 100644
97--- a/newlib/libc/machine/microblaze/strcpy.c
98+++ b/newlib/libc/machine/microblaze/strcpy.c
99@@ -125,6 +125,62 @@ strcpy (char *__restrict dst0,
100 #else
101
102 #include "mb_endian.h"
103+#ifdef __arch64__
104+
105+ asm volatile (" \n\
106+ orl r9, r0, r0 /* Index register */ \n\
107+check_alignment: \n\
108+ andli r3, r5, 3 \n\
109+ andli r4, r6, 3 \n\
110+ beanei r3, try_align_args \n\
111+ beanei r4, regular_strcpy /* At this point we dont have a choice */ \n\
112+cpy_loop: \n"
113+ LOAD4BYTES("r3", "r6", "r9")
114+" \n\
115+ pcmplbf r4, r0, r3 \n\
116+ beanei r4, cpy_bytes /* If r4 != 0, then null present within string */\n"
117+ STORE4BYTES("r3", "r5", "r9")
118+" \n\
119+ addlik r9, r9, 4 \n\
120+ breaid cpy_loop \n\
121+ nop \n\
122+cpy_bytes: \n\
123+ lbu r3, r6, r9 \n\
124+ sb r3, r5, r9 \n\
125+ addlik r4, r4, -1 \n\
126+ addlik r9, r9, 1 /* delay slot */\n\
127+ beaneid r4, cpy_bytes \n\
128+ nop \n\
129+cpy_null: \n\
130+ orl r3, r0, r5 /* Return strcpy result */\n\
131+ rtsd r15, 8 \n\
132+ nop \n\
133+try_align_args: \n\
134+ xorl r7, r4, r3 \n\
135+ beanei r7, regular_strcpy /* cannot align args */\n\
136+ rsublik r10, r3, 4 /* Number of initial bytes to align */\n\
137+align_loop: \n\
138+ lbu r3, r6, r9 \n\
139+ sb r3, r5, r9 \n\
140+ addlik r10, r10, -1 \n\
141+ beaeqid r3, end_cpy /* Break if we have seen null character */\n\
142+ nop \n\
143+ addlik r9, r9, 1 \n\
144+ beaneid r10, align_loop \n\
145+ nop \n\
146+ breai cpy_loop \n\
147+regular_strcpy: \n\
148+ lbu r3, r6, r9 \n\
149+ sb r3, r5, r9 \n\
150+ addlik r9, r9, 1 \n\
151+ beaneid r3, regular_strcpy \n\
152+ nop \n\
153+end_cpy: \n\
154+ orl r3, r0, r5 \n\
155+ rtsd r15, 8 \n\
156+ nop /* Return strcpy result */");
157+
158+#else
159
160 asm volatile (" \n\
161 or r9, r0, r0 /* Index register */ \n\
162@@ -171,6 +227,7 @@ regular_strcpy: \n\
163 end_cpy: \n\
164 rtsd r15, 8 \n\
165 or r3, r0, r5 /* Return strcpy result */");
166+#endif
167 #endif /* ! HAVE_HW_PCMP */
168 }
169
170diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c
171index acb4464..c04fa4f 100644
172--- a/newlib/libc/machine/microblaze/strlen.c
173+++ b/newlib/libc/machine/microblaze/strlen.c
174@@ -116,6 +116,43 @@ strlen (const char *str)
175
176 #include "mb_endian.h"
177
178+#ifdef __arch64__
179+ asm volatile (" \n\
180+ orl r9, r0, r0 /* Index register */ \n\
181+check_alignment: \n\
182+ andli r3, r5, 3 \n\
183+ beanei r3, align_arg \n\
184+len_loop: \n"
185+ LOAD4BYTES("r3", "r5", "r9")
186+" \n\
187+ pcmplbf r4, r3, r0 \n\
188+ beanei r4, end_len \n\
189+ addik r9, r9, 4 \n\
190+ breaid len_loop \n\
191+ nop \n\
192+end_len: \n\
193+ lbu r3, r5, r9 \n\
194+ beaeqi r3, done_len \n\
195+ addik r9, r9, 1 \n\
196+ breaid end_len \n\
197+ nop \n\
198+done_len: \n\
199+ orl r3, r0, r9 /* Return len */ \n\
200+ rtsd r15, 8 \n\
201+ nop \n\
202+align_arg: \n\
203+ rsublik r10, r3, 4 \n\
204+align_loop: \n\
205+ lbu r3, r5, r9 \n\
206+ addlik r10, r10, -1 \n\
207+ beaeqid r3, done_len \n\
208+ nop \n\
209+ addlik r9, r9, 1 \n\
210+ beaneid r10, align_loop \n\
211+ nop \n\
212+ breai len_loop");
213+
214+#else
215 asm volatile (" \n\
216 or r9, r0, r0 /* Index register */ \n\
217 check_alignment: \n\
218@@ -146,5 +183,6 @@ align_loop: \n\
219 addik r9, r9, 1 \n\
220 bri len_loop");
221
222+#endif
223 #endif /* ! HAVE_HW_PCMP */
224 }
225--
2262.7.4
227
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch b/meta-microblaze/recipes-microblaze/newlib/files/0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch
new file mode 100644
index 00000000..d1f19a74
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch
@@ -0,0 +1,87 @@
1From 70281e45fa433ec854f60b43fef019ebc8ca0649 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 3 Apr 2019 11:52:50 +0530
4Subject: [PATCH 10/11] [Patch,MicroBlaze] : typos in string functions
5 microblaze 64 bit port.fixed the issues.
6
7---
8 newlib/libc/machine/microblaze/strcmp.c | 12 +++++++-----
9 newlib/libc/machine/microblaze/strlen.c | 4 ++--
10 2 files changed, 9 insertions(+), 7 deletions(-)
11
12diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c
13index dac64da..acfe4cd 100644
14--- a/newlib/libc/machine/microblaze/strcmp.c
15+++ b/newlib/libc/machine/microblaze/strcmp.c
16@@ -135,7 +135,7 @@ strcmp (const char *s1,
17
18 #ifdef __arch64__
19 asm volatile (" \n\
20- orl r9, r0, r0 /* Index register */\n\
21+ orl r9, r0, r0 /* Index register */ \n\
22 check_alignment: \n\
23 andli r3, r5, 3 \n\
24 andli r4, r6, 3 \n\
25@@ -161,7 +161,7 @@ end_cmp_loop:
26 beaneid r3, end_cmp_loop /* If reached null on one string, terminate */ \n\
27 nop \n\
28 end_cmp_early: \n\
29- or r3, r0, r7 /* delay slot */ \n\
30+ orl r3, r0, r7 /* delay slot */ \n\
31 rtsd r15, 8 \n\
32 nop \n\
33 try_align_args: \n\
34@@ -171,7 +171,7 @@ try_align_args:
35 align_loop: \n\
36 lbu r3, r5, r9 \n\
37 lbu r4, r6, r9 \n\
38- cmpu r7, r4, r3 \n\
39+ cmplu r7, r4, r3 \n\
40 beanei r7, end_cmp \n\
41 beaeqi r3, end_cmp \n\
42 addlik r10, r10, -1 \n\
43@@ -185,10 +185,11 @@ regular_strcmp:
44 cmplu r7, r4, r3 \n\
45 beanei r7, end_cmp \n\
46 beaeqi r3, end_cmp \n\
47- breaid regular_strcmp \n\
48 addlik r9, r9, 1 \n\
49+ breaid regular_strcmp \n\
50+ nop \n\
51 end_cmp: \n\
52- or r3, r0, r7 \n\
53+ orl r3, r0, r7 \n\
54 rtsd r15, 8 \n\
55 nop /* Return strcmp result */");
56 #else
57@@ -240,6 +241,7 @@ regular_strcmp:
58 bnei r7, end_cmp \n\
59 beqi r3, end_cmp \n\
60 brid regular_strcmp \n\
61+ addik r9, r9, 1 \n\
62 end_cmp: \n\
63 rtsd r15, 8 \n\
64 or r3, r0, r7 /* Return strcmp result */");
65diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c
66index c04fa4f..b6f2d3c 100644
67--- a/newlib/libc/machine/microblaze/strlen.c
68+++ b/newlib/libc/machine/microblaze/strlen.c
69@@ -127,13 +127,13 @@ len_loop: \n"
70 " \n\
71 pcmplbf r4, r3, r0 \n\
72 beanei r4, end_len \n\
73- addik r9, r9, 4 \n\
74+ addlik r9, r9, 4 \n\
75 breaid len_loop \n\
76 nop \n\
77 end_len: \n\
78 lbu r3, r5, r9 \n\
79 beaeqi r3, done_len \n\
80- addik r9, r9, 1 \n\
81+ addlik r9, r9, 1 \n\
82 breaid end_len \n\
83 nop \n\
84 done_len: \n\
85--
862.7.4
87
diff --git a/meta-microblaze/recipes-microblaze/newlib/files/0011-Removing-the-Assembly-implementation-of-64bit-string.patch b/meta-microblaze/recipes-microblaze/newlib/files/0011-Removing-the-Assembly-implementation-of-64bit-string.patch
new file mode 100644
index 00000000..c8d13af0
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/files/0011-Removing-the-Assembly-implementation-of-64bit-string.patch
@@ -0,0 +1,332 @@
1From b35b582ef3f6575447097585174302fde1761078 Mon Sep 17 00:00:00 2001
2From: Nagaraju <nmekala@xilinx.com>
3Date: Wed, 24 Apr 2019 23:29:21 +0530
4Subject: [PATCH 11/11] Removing the Assembly implementation of 64bit string
5 function. Revisit in next release and fix it
6
7---
8 newlib/libc/machine/microblaze/mb_endian.h | 4 ++
9 newlib/libc/machine/microblaze/strcmp.c | 93 ++++++++++--------------------
10 newlib/libc/machine/microblaze/strcpy.c | 82 ++++++++------------------
11 newlib/libc/machine/microblaze/strlen.c | 59 +++++++------------
12 4 files changed, 81 insertions(+), 157 deletions(-)
13
14diff --git a/newlib/libc/machine/microblaze/mb_endian.h b/newlib/libc/machine/microblaze/mb_endian.h
15index fb217ec..17772c8 100644
16--- a/newlib/libc/machine/microblaze/mb_endian.h
17+++ b/newlib/libc/machine/microblaze/mb_endian.h
18@@ -8,8 +8,12 @@
19 #ifdef __LITTLE_ENDIAN__
20 #define LOAD4BYTES(rD,rA,rB) "\tlwr\t" rD ", " rA ", " rB "\n"
21 #define STORE4BYTES(rD,rA,rB) "\tswr\t" rD ", " rA ", " rB "\n"
22+#define LOAD8BYTES(rD,rA,rB) "\tllr\t" rD ", " rA ", " rB "\n"
23+#define STORE8BYTES(rD,rA,rB) "\tslr\t" rD ", " rA ", " rB "\n"
24 #else
25 #define LOAD4BYTES(rD,rA,rB) "\tlw\t" rD ", " rA ", " rB "\n"
26 #define STORE4BYTES(rD,rA,rB) "\tsw\t" rD ", " rA ", " rB "\n"
27+#define LOAD8BYTES(rD,rA,rB) "\tll\t" rD ", " rA ", " rB "\n"
28+#define STORE8BYTES(rD,rA,rB) "\tsl\t" rD ", " rA ", " rB "\n"
29 #endif
30 #endif
31diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c
32index acfe4cd..e34c64a 100644
33--- a/newlib/libc/machine/microblaze/strcmp.c
34+++ b/newlib/libc/machine/microblaze/strcmp.c
35@@ -129,70 +129,42 @@ strcmp (const char *s1,
36 return (*(unsigned char *) s1) - (*(unsigned char *) s2);
37 #endif /* not PREFER_SIZE_OVER_SPEED */
38
39+#elif __arch64__
40+ unsigned int *a1;
41+ unsigned int *a2;
42+
43+ /* If s1 or s2 are unaligned, then compare bytes. */
44+ if (!UNALIGNED (s1, s2))
45+ {
46+ /* If s1 and s2 are word-aligned, compare them a word at a time. */
47+ a1 = (unsigned int*)s1;
48+ a2 = (unsigned int*)s2;
49+ while (*a1 == *a2)
50+ {
51+ /* To get here, *a1 == *a2, thus if we find a null in *a1,
52+ then the strings must be equal, so return zero. */
53+ if (DETECTNULL (*a1))
54+ return 0;
55+
56+ a1++;
57+ a2++;
58+ }
59+
60+ /* A difference was detected in last few bytes of s1, so search bytewise */
61+ s1 = (char*)a1;
62+ s2 = (char*)a2;
63+ }
64+
65+ while (*s1 != '\0' && *s1 == *s2)
66+ {
67+ s1++;
68+ s2++;
69+ }
70+ return (*(unsigned char *) s1) - (*(unsigned char *) s2);
71 #else
72
73 #include "mb_endian.h"
74
75-#ifdef __arch64__
76- asm volatile (" \n\
77- orl r9, r0, r0 /* Index register */ \n\
78-check_alignment: \n\
79- andli r3, r5, 3 \n\
80- andli r4, r6, 3 \n\
81- beanei r3, try_align_args \n\
82- beanei r4, regular_strcmp /* At this point we don't have a choice */ \n\
83-cmp_loop: \n"
84- LOAD4BYTES("r3", "r5", "r9")
85- LOAD4BYTES("r4", "r6", "r9")
86-" \n\
87- pcmplbf r7, r3, r0 /* See if there is Null byte */ \n\
88- beanei r7, end_cmp_loop /* IF yes (r7 > 0) use byte compares in end_cmp_loop */ \n\
89- cmplu r7, r4, r3 /* ELSE compare whole word */ \n\
90- beanei r7, end_cmp \n\
91- addlik r9, r9, 4 /* delay slot */ \n\
92- breaid cmp_loop \n\
93- nop /* delay slot */ \n\
94-end_cmp_loop: \n\
95- lbu r3, r5, r9 /* byte compare loop */ \n\
96- lbu r4, r6, r9 \n\
97- cmplu r7, r4, r3 /* Compare bytes */ \n\
98- beanei r7, end_cmp_early \n\
99- addlik r9, r9, 1 /* delay slot */ \n\
100- beaneid r3, end_cmp_loop /* If reached null on one string, terminate */ \n\
101- nop \n\
102-end_cmp_early: \n\
103- orl r3, r0, r7 /* delay slot */ \n\
104- rtsd r15, 8 \n\
105- nop \n\
106-try_align_args: \n\
107- xorl r7, r4, r3 \n\
108- beanei r7, regular_strcmp /* cannot align args */ \n\
109- rsublik r10, r3, 4 /* Number of initial bytes to align */ \n\
110-align_loop: \n\
111- lbu r3, r5, r9 \n\
112- lbu r4, r6, r9 \n\
113- cmplu r7, r4, r3 \n\
114- beanei r7, end_cmp \n\
115- beaeqi r3, end_cmp \n\
116- addlik r10, r10, -1 \n\
117- addlik r9, r9, 1 \n\
118- beaeqid r10, cmp_loop \n\
119- nop \n\
120- breai align_loop \n\
121-regular_strcmp: \n\
122- lbu r3, r5, r9 \n\
123- lbu r4, r6, r9 \n\
124- cmplu r7, r4, r3 \n\
125- beanei r7, end_cmp \n\
126- beaeqi r3, end_cmp \n\
127- addlik r9, r9, 1 \n\
128- breaid regular_strcmp \n\
129- nop \n\
130-end_cmp: \n\
131- orl r3, r0, r7 \n\
132- rtsd r15, 8 \n\
133- nop /* Return strcmp result */");
134-#else
135 asm volatile (" \n\
136 or r9, r0, r0 /* Index register */\n\
137 check_alignment: \n\
138@@ -246,7 +218,6 @@ end_cmp:
139 rtsd r15, 8 \n\
140 or r3, r0, r7 /* Return strcmp result */");
141
142-#endif
143 #endif /* ! HAVE_HW_PCMP */
144 }
145
146diff --git a/newlib/libc/machine/microblaze/strcpy.c b/newlib/libc/machine/microblaze/strcpy.c
147index 6dbc60d..ddb6922 100644
148--- a/newlib/libc/machine/microblaze/strcpy.c
149+++ b/newlib/libc/machine/microblaze/strcpy.c
150@@ -121,67 +121,36 @@ strcpy (char *__restrict dst0,
151 ;
152 return dst0;
153 #endif /* not PREFER_SIZE_OVER_SPEED */
154+#elif __arch64__
155+ char *dst = dst0;
156+ const char *src = src0;
157+ long *aligned_dst;
158+ const long *aligned_src;
159
160-#else
161+ /* If SRC or DEST is unaligned, then copy bytes. */
162+ if (!UNALIGNED (src, dst))
163+ {
164+ aligned_dst = (long*)dst;
165+ aligned_src = (long*)src;
166
167-#include "mb_endian.h"
168-#ifdef __arch64__
169+ /* SRC and DEST are both "long int" aligned, try to do "long int"
170+ sized copies. */
171+ while (!DETECTNULL(*aligned_src))
172+ {
173+ *aligned_dst++ = *aligned_src++;
174+ }
175
176- asm volatile (" \n\
177- orl r9, r0, r0 /* Index register */ \n\
178-check_alignment: \n\
179- andli r3, r5, 3 \n\
180- andli r4, r6, 3 \n\
181- beanei r3, try_align_args \n\
182- beanei r4, regular_strcpy /* At this point we dont have a choice */ \n\
183-cpy_loop: \n"
184- LOAD4BYTES("r3", "r6", "r9")
185-" \n\
186- pcmplbf r4, r0, r3 \n\
187- beanei r4, cpy_bytes /* If r4 != 0, then null present within string */\n"
188- STORE4BYTES("r3", "r5", "r9")
189-" \n\
190- addlik r9, r9, 4 \n\
191- breaid cpy_loop \n\
192- nop \n\
193-cpy_bytes: \n\
194- lbu r3, r6, r9 \n\
195- sb r3, r5, r9 \n\
196- addlik r4, r4, -1 \n\
197- addlik r9, r9, 1 /* delay slot */\n\
198- beaneid r4, cpy_bytes \n\
199- nop \n\
200-cpy_null: \n\
201- orl r3, r0, r5 /* Return strcpy result */\n\
202- rtsd r15, 8 \n\
203- nop \n\
204-try_align_args: \n\
205- xorl r7, r4, r3 \n\
206- beanei r7, regular_strcpy /* cannot align args */\n\
207- rsublik r10, r3, 4 /* Number of initial bytes to align */\n\
208-align_loop: \n\
209- lbu r3, r6, r9 \n\
210- sb r3, r5, r9 \n\
211- addlik r10, r10, -1 \n\
212- beaeqid r3, end_cpy /* Break if we have seen null character */\n\
213- nop \n\
214- addlik r9, r9, 1 \n\
215- beaneid r10, align_loop \n\
216- nop \n\
217- breai cpy_loop \n\
218-regular_strcpy: \n\
219- lbu r3, r6, r9 \n\
220- sb r3, r5, r9 \n\
221- addlik r9, r9, 1 \n\
222- beaneid r3, regular_strcpy \n\
223- nop \n\
224-end_cpy: \n\
225- orl r3, r0, r5 \n\
226- rtsd r15, 8 \n\
227- nop /* Return strcpy result */");
228+ dst = (char*)aligned_dst;
229+ src = (char*)aligned_src;
230+ }
231
232-#else
233+ while (*dst++ = *src++)
234+ ;
235+ return dst0;
236+
237+#else
238
239+#include "mb_endian.h"
240 asm volatile (" \n\
241 or r9, r0, r0 /* Index register */ \n\
242 check_alignment: \n\
243@@ -227,7 +196,6 @@ regular_strcpy: \n\
244 end_cpy: \n\
245 rtsd r15, 8 \n\
246 or r3, r0, r5 /* Return strcpy result */");
247-#endif
248 #endif /* ! HAVE_HW_PCMP */
249 }
250
251diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c
252index b6f2d3c..9407539 100644
253--- a/newlib/libc/machine/microblaze/strlen.c
254+++ b/newlib/libc/machine/microblaze/strlen.c
255@@ -112,47 +112,29 @@ strlen (const char *str)
256 return str - start;
257 #endif /* not PREFER_SIZE_OVER_SPEED */
258
259-#else
260-
261-#include "mb_endian.h"
262+#elif __arch64__
263+ const char *start = str;
264+ unsigned long *aligned_addr;
265
266-#ifdef __arch64__
267- asm volatile (" \n\
268- orl r9, r0, r0 /* Index register */ \n\
269-check_alignment: \n\
270- andli r3, r5, 3 \n\
271- beanei r3, align_arg \n\
272-len_loop: \n"
273- LOAD4BYTES("r3", "r5", "r9")
274-" \n\
275- pcmplbf r4, r3, r0 \n\
276- beanei r4, end_len \n\
277- addlik r9, r9, 4 \n\
278- breaid len_loop \n\
279- nop \n\
280-end_len: \n\
281- lbu r3, r5, r9 \n\
282- beaeqi r3, done_len \n\
283- addlik r9, r9, 1 \n\
284- breaid end_len \n\
285- nop \n\
286-done_len: \n\
287- orl r3, r0, r9 /* Return len */ \n\
288- rtsd r15, 8 \n\
289- nop \n\
290-align_arg: \n\
291- rsublik r10, r3, 4 \n\
292-align_loop: \n\
293- lbu r3, r5, r9 \n\
294- addlik r10, r10, -1 \n\
295- beaeqid r3, done_len \n\
296- nop \n\
297- addlik r9, r9, 1 \n\
298- beaneid r10, align_loop \n\
299- nop \n\
300- breai len_loop");
301+ if (!UNALIGNED (str))
302+ {
303+ /* If the string is word-aligned, we can check for the presence of
304+ a null in each word-sized block. */
305+ aligned_addr = (unsigned long*)str;
306+ while (!DETECTNULL (*aligned_addr))
307+ aligned_addr++;
308
309+ /* Once a null is detected, we check each byte in that block for a
310+ precise position of the null. */
311+ str = (char*)aligned_addr;
312+ }
313+
314+ while (*str)
315+ str++;
316+ return str - start;
317 #else
318+
319+#include "mb_endian.h"
320 asm volatile (" \n\
321 or r9, r0, r0 /* Index register */ \n\
322 check_alignment: \n\
323@@ -183,6 +165,5 @@ align_loop: \n\
324 addik r9, r9, 1 \n\
325 bri len_loop");
326
327-#endif
328 #endif /* ! HAVE_HW_PCMP */
329 }
330--
3312.7.4
332
diff --git a/meta-microblaze/recipes-microblaze/newlib/libgloss_3.3.%.bbappend b/meta-microblaze/recipes-microblaze/newlib/libgloss_3.3.%.bbappend
new file mode 100644
index 00000000..3dee0f06
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/libgloss_3.3.%.bbappend
@@ -0,0 +1,6 @@
1require microblaze-newlib.inc
2
3do_configure_prepend_microblaze() {
4 # hack for microblaze, which needs xilinx.ld to literally do any linking (its hard coded in its LINK_SPEC)
5 export CC="${CC} -L${S}/libgloss/microblaze"
6}
diff --git a/meta-microblaze/recipes-microblaze/newlib/microblaze-newlib.inc b/meta-microblaze/recipes-microblaze/newlib/microblaze-newlib.inc
new file mode 100644
index 00000000..c3b6acdc
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/microblaze-newlib.inc
@@ -0,0 +1,15 @@
1# Add MicroBlaze Patches
2FILESEXTRAPATHS_append_microblaze := ":${THISDIR}/files"
3SRC_URI_append_microblaze = " \
4 file://0001-Patch-microblaze-Add-config-microblaze.mt-for-target.patch \
5 file://0002-Patch-microblaze-Modified-_exceptional_handler.patch \
6 file://0003-LOCAL-Add-missing-declarations-for-xil_printf-to-std.patch \
7 file://0004-Local-deleting-the-xil_printf.c-file-as-now-it-part-.patch \
8 file://0005-Local-deleting-the-xil_printf.o-from-MAKEFILE.patch \
9 file://0006-MB-X-intial-commit.patch \
10 file://0007-Patch-Microblaze-newlib-port-for-microblaze-m64-flag.patch \
11 file://0008-fixing-the-bug-in-crt-files-added-addlik-instead-of-.patch \
12 file://0009-Added-MB-64-support-to-strcmp-strcpy-strlen-files.patch \
13 file://0010-Patch-MicroBlaze-typos-in-string-functions-microblaz.patch \
14 file://0011-Removing-the-Assembly-implementation-of-64bit-string.patch \
15 "
diff --git a/meta-microblaze/recipes-microblaze/newlib/newlib_3.3.%.bbappend b/meta-microblaze/recipes-microblaze/newlib/newlib_3.3.%.bbappend
new file mode 100644
index 00000000..d459bf19
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/newlib/newlib_3.3.%.bbappend
@@ -0,0 +1,7 @@
1require microblaze-newlib.inc
2
3do_configure_prepend_microblaze() {
4 # hack for microblaze, which needs xilinx.ld to literally do any linking (its hard coded in its LINK_SPEC)
5 export CC="${CC} -L${S}/libgloss/microblaze"
6}
7
diff --git a/meta-microblaze/recipes-microblaze/qemu/qemu_%.bbappend b/meta-microblaze/recipes-microblaze/qemu/qemu_%.bbappend
new file mode 100644
index 00000000..3d3a54fe
--- /dev/null
+++ b/meta-microblaze/recipes-microblaze/qemu/qemu_%.bbappend
@@ -0,0 +1,2 @@
1QEMU_TARGETS += "microblazeel microblaze"
2