summaryrefslogtreecommitdiff
path: root/tools/4.11/gdb/sparc/7.9/0023-sim-erc32-ELF-loading-could-fail-on-unaligned-sectio.patch
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2015-03-26 13:20:45 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2015-03-27 08:32:47 -0500
commitbfd2b7d8f4b966d65e681f9b81749c10a8d83a47 (patch)
tree877146eab084b0ab4edf7b7e35dacf7bc98b5e50 /tools/4.11/gdb/sparc/7.9/0023-sim-erc32-ELF-loading-could-fail-on-unaligned-sectio.patch
parentd499e6df8977c1da66504a7e4120814ee2dfe3d3 (diff)
Add Jiri Gaisler SIS patch set for gdb 7.9
This patch set adds a lot of new capability including support for the leon2 and leon3. It also eliminates the difference between the initial state of the simulated erc32 and the real hardware.
Diffstat (limited to '')
-rw-r--r--tools/4.11/gdb/sparc/7.9/0023-sim-erc32-ELF-loading-could-fail-on-unaligned-sectio.patch39
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/4.11/gdb/sparc/7.9/0023-sim-erc32-ELF-loading-could-fail-on-unaligned-sectio.patch b/tools/4.11/gdb/sparc/7.9/0023-sim-erc32-ELF-loading-could-fail-on-unaligned-sectio.patch
new file mode 100644
index 0000000..4a80399
--- /dev/null
+++ b/tools/4.11/gdb/sparc/7.9/0023-sim-erc32-ELF-loading-could-fail-on-unaligned-sectio.patch
@@ -0,0 +1,39 @@
+From 7cecef8c4569896ec7c16c6fc51ef0c5ce7aa7f1 Mon Sep 17 00:00:00 2001
+From: Jiri Gaisler <jiri@gaisler.se>
+Date: Sat, 21 Mar 2015 18:31:15 +0100
+Subject: [PATCH 23/23] sim/erc32: ELF loading could fail on unaligned
+ sections.
+
+Endian swapping on little-endian hosts could fail if ELF section
+length not a multiple of 4.
+
+ func.c (bfd_load): Pad section buffers with zeros and round
+ section size upwards towards nearest 4-multiple.
+---
+ sim/erc32/func.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/sim/erc32/func.c b/sim/erc32/func.c
+index 7a8a4e4..31948a6 100644
+--- a/sim/erc32/func.c
++++ b/sim/erc32/func.c
+@@ -1231,13 +1231,13 @@ bfd_load(fname)
+ uint32 *wbuffer = (uint32 *) buffer;
+
+ count = min(section_size, 1024);
+-
++ wbuffer[(count - 1) / 4] = 0; /* clear last word in buffer */
+ bfd_get_section_contents(pbfd, section, buffer, fptr, count);
+
+ #ifdef HOST_LITTLE_ENDIAN
+- for (i=0;i<count/4;i++) wbuffer[i] = ntohl(wbuffer[i]); // endian swap
++ for (i=0;i<(count+3)/4;i++) wbuffer[i] = ntohl(wbuffer[i]); // endian swap
+ #endif
+- ms->sis_memory_write(section_address, buffer, count);
++ ms->sis_memory_write(section_address, buffer, (count + 3) & ~3);
+
+ section_address += count;
+ fptr += count;
+--
+1.9.1
+