Skip to content

Commit

Permalink
arch: add big endian support
Browse files Browse the repository at this point in the history
This patch adds Big Endian architecture support.  Even if a compiler
generating big endian object files is used, our linker script, or
include/linker/linker-tool-gcc.h to be precise, has default output
format as little endian.

This patch adds a hidden config CONFIG_BIG_ENDIAN, which should be set
by big endian architectures or a SoC's, and adds an condition to
switch OUTPUT_FORMAT in our linker.cmd.

Signed-off-by: Yasushi SHOJI <[email protected]>
  • Loading branch information
yashi authored and nashif committed Oct 10, 2018
1 parent 325a9b3 commit 6fc0d77
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ if(CONFIG_GEN_ISR_TABLES)
--output-source isr_tables.c
--kernel $<TARGET_FILE:zephyr_prebuilt>
--intlist isrList.bin
$<$<BOOL:${CONFIG_BIG_ENDIAN}>:--big-endian>
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--debug>
${GEN_ISR_TABLE_EXTRA_ARG}
DEPENDS zephyr_prebuilt
Expand Down
11 changes: 11 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ module = MPU
module-str = mpu
source "subsys/logging/Kconfig.template.log_config"

config BIG_ENDIAN
bool
help
This option tells the build system that the target system is
big-endian. Little-endian architecture is the default and
should leave this option unselected. This option is selected
by arch/$ARCH/Kconfig, soc/**/Kconfig, or boards/**/Kconfig
and the user should generally avoid modifying it. The option
is used to select linker script OUTPUT_FORMAT and command
line option for gen_isr_tables.py.

config HW_STACK_PROTECTION
bool "Hardware Stack Protection"
depends on ARCH_HAS_STACK_PROTECTION
Expand Down
7 changes: 6 additions & 1 deletion include/linker/linker-tool-gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
#define ZEPHYR_INCLUDE_LINKER_LINKER_TOOL_GCC_H_

#if defined(CONFIG_ARM)
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
#if defined(CONFIG_BIG_ENDIAN)
#define OUTPUT_FORMAT_ "elf32-bigarm"
#else
#define OUTPUT_FORMAT_ "elf32-littlearm"
#endif
OUTPUT_FORMAT(OUTPUT_FORMAT_)
#elif defined(CONFIG_ARC)
OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc", "elf32-littlearc")
#elif defined(CONFIG_X86)
Expand Down

0 comments on commit 6fc0d77

Please sign in to comment.