Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanrossi committed Mar 18, 2018
1 parent db6e780 commit d0e57b4
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 80 deletions.
@@ -1,4 +1,4 @@
FILESEXTRAPATHS_append_microblaze := "${THISDIR}/binutils-2.29:"
FILESEXTRAPATHS_append_microblaze := "${THISDIR}/binutils-2.30:"
SRC_URI_append_microblaze = " \
file://0001-MicroBlaze-Add-wdc.ext.clear-and-wdc.ext.flush-insns.patch \
file://0002-MicroBlaze-add-mlittle-endian-and-mbig-endian-flags.patch \
Expand Down
@@ -1,4 +1,4 @@
From 0d5966951c379882b7557befaa229dc5def8dafe Mon Sep 17 00:00:00 2001
From 5f7434bc8292d8b5b5c6a02d54909de2e48bd6d9 Mon Sep 17 00:00:00 2001
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Date: Mon, 28 Aug 2017 19:53:55 -0700
Subject: [PATCH] Fix relaxation of assembler resolved references
Expand All @@ -12,13 +12,13 @@ Upstream-Status: Pending
2 files changed, 40 insertions(+)

diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index 265773675c..c3dbead48d 100644
index f1808bc445..5688e062a2 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -1901,6 +1901,45 @@ microblaze_elf_relax_section (bfd *abfd,
irelscanend = irelocs + o->reloc_count;
for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
{
@@ -1887,6 +1887,45 @@ microblaze_elf_relax_section (bfd *abfd,
irelscanend = irelocs + o->reloc_count;
for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
{
+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
+ {
+ unsigned int val;
Expand Down Expand Up @@ -58,11 +58,11 @@ index 265773675c..c3dbead48d 100644
+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
+ fprintf(stderr, "Unhandled NONE 64\n");
+ }
if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
{
isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
{
isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index d47793646b..1cfd441c19 100644
index 42dd7ae249..50dbfc77d3 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -2183,6 +2183,7 @@ md_apply_fix (fixS * fixP,
Expand All @@ -74,5 +74,5 @@ index d47793646b..1cfd441c19 100644
return;
}
--
2.15.0
2.16.1

@@ -1,4 +1,4 @@
From ef876d5062148e8555353e5e72da87c3a47dea8f Mon Sep 17 00:00:00 2001
From 69a1e63a3f6a5088a0b1801a169a9a7e6cea484f Mon Sep 17 00:00:00 2001
From: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
Date: Mon, 28 Aug 2017 19:53:56 -0700
Subject: [PATCH] Fixup MicroBlaze debug_loc sections after linker relaxation
Expand All @@ -17,19 +17,19 @@ Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
Upstream-Status: Pending
---
bfd/bfd-in2.h | 9 +++++++--
bfd/elf32-microblaze.c | 42 +++++++++++++++++++++++++++++++++++-------
bfd/elf32-microblaze.c | 44 +++++++++++++++++++++++++++++++++++++-------
bfd/libbfd.h | 1 +
bfd/reloc.c | 6 ++++++
binutils/readelf.c | 4 ++++
gas/config/tc-microblaze.c | 5 ++++-
include/elf/microblaze.h | 1 +
7 files changed, 58 insertions(+), 10 deletions(-)
7 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 1343780c8c..3456826f83 100644
index 4228603b69..1906195290 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -5809,10 +5809,15 @@ value relative to the read-write small data area anchor */
@@ -5826,10 +5826,15 @@ value relative to the read-write small data area anchor */
expressions of the form "Symbol Op Symbol" */
BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM,

Expand All @@ -48,30 +48,30 @@ index 1343780c8c..3456826f83 100644
/* This is a 64 bit reloc that stores the 32 bit pc relative
value in two words (with an imm instruction). The relocation is
diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index c3dbead48d..1d1f7e210a 100644
index 5688e062a2..c1222875ef 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -176,6 +176,20 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
0x0000ffff, /* Dest Mask. */
FALSE), /* PC relative offset? */
0x0000ffff, /* Dest Mask. */
FALSE), /* PC relative offset? */

+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
+ 0, /* Rightshift. */
+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
+ 32, /* Bitsize. */
+ TRUE, /* PC_relative. */
+ 0, /* Bitpos. */
+ complain_overflow_bitfield, /* Complain on overflow. */
+ NULL, /* Special Function. */
+ "R_MICROBLAZE_32_NONE",/* Name. */
+ FALSE, /* Partial Inplace. */
+ 0, /* Source Mask. */
+ 0, /* Dest Mask. */
+ FALSE), /* PC relative offset? */
+ 0, /* Rightshift. */
+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
+ 32, /* Bitsize. */
+ TRUE, /* PC_relative. */
+ 0, /* Bitpos. */
+ complain_overflow_bitfield, /* Complain on overflow. */
+ NULL, /* Special Function. */
+ "R_MICROBLAZE_32_NONE",/* Name. */
+ FALSE, /* Partial Inplace. */
+ 0, /* Source Mask. */
+ 0, /* Dest Mask. */
+ FALSE), /* PC relative offset? */
+
/* This reloc does nothing. Used for relaxation. */
/* This reloc does nothing. Used for relaxation. */
HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
0, /* Rightshift. */
0, /* Rightshift. */
@@ -532,6 +546,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
case BFD_RELOC_NONE:
microblaze_reloc = R_MICROBLAZE_NONE;
Expand All @@ -82,35 +82,37 @@ index c3dbead48d..1d1f7e210a 100644
case BFD_RELOC_MICROBLAZE_64_NONE:
microblaze_reloc = R_MICROBLAZE_64_NONE;
break;
@@ -1846,14 +1863,22 @@ microblaze_elf_relax_section (bfd *abfd,
}
@@ -1832,14 +1849,24 @@ microblaze_elf_relax_section (bfd *abfd,
}
break;
case R_MICROBLAZE_NONE:
+ case R_MICROBLAZE_32_NONE:
{
/* This was a PC-relative instruction that was
completely resolved. */
int sfix, efix;
+ unsigned int val;
bfd_vma target_address;
target_address = irel->r_addend + irel->r_offset;
sfix = calc_fixup (irel->r_offset, 0, sec);
efix = calc_fixup (target_address, 0, sec);
/* This was a PC-relative instruction that was
completely resolved. */
int sfix, efix;
+ unsigned int val;
bfd_vma target_address;
target_address = irel->r_addend + irel->r_offset;
sfix = calc_fixup (irel->r_offset, 0, sec);
efix = calc_fixup (target_address, 0, sec);
+ irel->r_addend -= (efix - sfix);
+
+ /* Validate the in-band val. */
+ val = bfd_get_32 (abfd, contents + irel->r_offset);
+ if (val != irel->r_addend && ELF32_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
+ }
irel->r_addend -= (efix - sfix);
/* Should use HOWTO. */
microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
@@ -1901,12 +1926,16 @@ microblaze_elf_relax_section (bfd *abfd,
irelscanend = irelocs + o->reloc_count;
for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
{
+ /* Validate the in-band val. */
+ val = bfd_get_32 (abfd, contents + irel->r_offset);
+ if (val != irel->r_addend && ELF32_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
+ fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
+ }
+
irel->r_addend -= (efix - sfix);
/* Should use HOWTO. */
microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
@@ -1887,12 +1914,16 @@ microblaze_elf_relax_section (bfd *abfd,
irelscanend = irelocs + o->reloc_count;
for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
{
- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
+ if (1 && ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
+ if (1 && ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
{
unsigned int val;

Expand All @@ -123,7 +125,7 @@ index c3dbead48d..1d1f7e210a 100644
/* This was a PC-relative instruction that was completely resolved. */
if (ocontents == NULL)
{
@@ -1931,15 +1960,14 @@ microblaze_elf_relax_section (bfd *abfd,
@@ -1917,15 +1948,14 @@ microblaze_elf_relax_section (bfd *abfd,
}
}

Expand All @@ -140,10 +142,10 @@ index c3dbead48d..1d1f7e210a 100644
- if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
- fprintf(stderr, "Unhandled NONE 64\n");
- }
if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
{
isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
@@ -1999,7 +2027,7 @@ microblaze_elf_relax_section (bfd *abfd,
if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
{
isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
@@ -1985,7 +2015,7 @@ microblaze_elf_relax_section (bfd *abfd,
elf_section_data (o)->this_hdr.contents = ocontents;
}
}
Expand All @@ -153,10 +155,10 @@ index c3dbead48d..1d1f7e210a 100644
0,
sec);
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index ae9bf76814..2091286c7c 100644
index 2f5f16e776..854bb0c37e 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -2847,6 +2847,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
@@ -2853,6 +2853,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_MICROBLAZE_32_ROSDA",
"BFD_RELOC_MICROBLAZE_32_RWSDA",
"BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
Expand All @@ -165,10 +167,10 @@ index ae9bf76814..2091286c7c 100644
"BFD_RELOC_MICROBLAZE_64_GOTPC",
"BFD_RELOC_MICROBLAZE_64_GOT",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index aa70fa5874..54d7f538ec 100644
index a1353a281b..4b57de770d 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -6860,6 +6860,12 @@ ENUM
@@ -6902,6 +6902,12 @@ ENUM
ENUMDOC
This is a 32 bit reloc for the microblaze to handle
expressions of the form "Symbol Op Symbol"
Expand All @@ -182,10 +184,10 @@ index aa70fa5874..54d7f538ec 100644
BFD_RELOC_MICROBLAZE_64_NONE
ENUMDOC
diff --git a/binutils/readelf.c b/binutils/readelf.c
index b2f75c0048..8a3226eba9 100644
index fed0387a94..92f655d2f4 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -12488,6 +12488,10 @@ is_none_reloc (unsigned int reloc_type)
@@ -12774,6 +12774,10 @@ is_none_reloc (Filedata * filedata, unsigned int reloc_type)
|| reloc_type == 32 /* R_AVR_DIFF32. */);
case EM_METAG:
return reloc_type == 3; /* R_METAG_NONE. */
Expand All @@ -197,7 +199,7 @@ index b2f75c0048..8a3226eba9 100644
return (reloc_type == 0 /* R_XTENSA_NONE. */
|| reloc_type == 204 /* R_NDS32_DIFF8. */
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index 1cfd441c19..e135547e62 100644
index 50dbfc77d3..d66e949c8f 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -2179,7 +2179,9 @@ md_apply_fix (fixS * fixP,
Expand All @@ -220,7 +222,7 @@ index 1cfd441c19..e135547e62 100644
case BFD_RELOC_32:
case BFD_RELOC_MICROBLAZE_32_LO:
diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h
index ccb47404c5..abcaea561b 100644
index ae98099d55..c8cc57ba9c 100644
--- a/include/elf/microblaze.h
+++ b/include/elf/microblaze.h
@@ -58,6 +58,7 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type)
Expand All @@ -232,5 +234,5 @@ index ccb47404c5..abcaea561b 100644
END_RELOC_NUMBERS (R_MICROBLAZE_max)

--
2.15.0
2.16.1

@@ -1,4 +1,4 @@
From b55dddad1303aafe249e2ba0ddf20460f8f035f6 Mon Sep 17 00:00:00 2001
From 565cdca8698f09722a9924e4c29c9fd8708d565b Mon Sep 17 00:00:00 2001
From: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
Date: Mon, 28 Aug 2017 19:53:58 -0700
Subject: [PATCH] Fix bug in MicroBlaze TLSTPREL Relocation
Expand All @@ -17,10 +17,10 @@ Upstream-Status: Pending
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index 1d1f7e210a..cc6e4b1fd9 100644
index c1222875ef..6e3516f4f2 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -1417,9 +1417,9 @@ microblaze_elf_relocate_section (bfd *output_bfd,
@@ -1402,9 +1402,9 @@ microblaze_elf_relocate_section (bfd *output_bfd,
relocation += addend;
relocation -= dtprel_base(info);
bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
Expand All @@ -33,5 +33,5 @@ index 1d1f7e210a..cc6e4b1fd9 100644
case (int) R_MICROBLAZE_64_PCREL :
case (int) R_MICROBLAZE_64:
--
2.15.0
2.16.1

@@ -1,4 +1,4 @@
From cff770a6f73b82db3259e9577e13b08a1bcd14e8 Mon Sep 17 00:00:00 2001
From 1bccb3180a5ad9dc26b61c3ff7bceaba8e378c94 Mon Sep 17 00:00:00 2001
From: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
Date: Mon, 28 Aug 2017 19:54:02 -0700
Subject: [PATCH] Fixing MicroBlaze IMM bug
Expand All @@ -13,19 +13,19 @@ Upstream-Status: Pending
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index cc6e4b1fd9..6fc475cbcd 100644
index 6e3516f4f2..5efcbd3f75 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -1803,8 +1803,7 @@ microblaze_elf_relax_section (bfd *abfd,
@@ -1789,8 +1789,7 @@ microblaze_elf_relax_section (bfd *abfd,
else
symval += irel->r_addend;

- if ((symval & 0xffff8000) == 0
- || (symval & 0xffff8000) == 0xffff8000)
+ if ((symval & 0xffff8000) == 0)
{
/* We can delete this instruction. */
/* We can delete this instruction. */
sec->relax[sec->relax_count].addr = irel->r_offset;
--
2.15.0
2.16.1

0 comments on commit d0e57b4

Please sign in to comment.