[U-Boot] [PATCH] Align linebuf to avoid misaligned aliases of it

Albert Aribaud albert.aribaud at free.fr
Sat Aug 14 10:11:13 CEST 2010


Commit  64419e47518bbba059c80b77558f93ad4804145c aliases
the uint16_t usp and uint32_t uip variables in print_buffer()
to uint8_t variable linebuf without aligning it to an uint32_t
address, thus causing data aborts on ARM when doing md.l on
32-bit wide area (and probably 16-bit wide as well).

Aligning linebuf fixes the issue.

Signed-off-by: Albert Aribaud <albert.aribaud at free.fr>
---
 lib/display_options.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/display_options.c b/lib/display_options.c
index 20319e6..c544777 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -101,7 +101,8 @@ void print_size(unsigned long long size, const char *s)
 #define DEFAULT_LINE_LENGTH_BYTES (16)
 int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
 {
-	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1];
+	uint8_t linebuf[MAX_LINE_LENGTH_BYTES + 1]
+		__attribute__((__aligned__(sizeof(uint32_t))));
 	uint32_t *uip = (void*)linebuf;
 	uint16_t *usp = (void*)linebuf;
 	uint8_t *ucp = (void*)linebuf;
-- 
1.7.1



More information about the U-Boot mailing list