[U-Boot] [PATCH v6 12/20] sandbox: Force command sections to be 4-byte aligned

Simon Glass sjg at chromium.org
Mon Oct 10 20:22:25 CEST 2011


By default sections are 16-byte aligned on some architectures, but the
command name structure (struct cmd_tbl_s) does not have padding to
16 bytes. We use the linker to collect elements of an array of
these structures and then at run-time we want this array to be
accessible.

If the linker puts padding between elements then we cannot access the
array properly.

This change reduces the alignment to 4-bytes so that the command
table can be accessed correctly on any architecture.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v4:
- Add more info to command section alignment commit

 include/command.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/command.h b/include/command.h
index f1accd0..c270110 100644
--- a/include/command.h
+++ b/include/command.h
@@ -117,7 +117,8 @@ extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #define CMD_FLAG_REPEAT		0x0001	/* repeat last command		*/
 #define CMD_FLAG_BOOTD		0x0002	/* command is from bootd	*/
 
-#define Struct_Section  __attribute__ ((unused,section (".u_boot_cmd")))
+#define Struct_Section  __attribute__((unused, section(".u_boot_cmd"), \
+		aligned(4)))
 
 #ifdef CONFIG_AUTO_COMPLETE
 # define _CMD_COMPLETE(x) x,
-- 
1.7.3.1



More information about the U-Boot mailing list