From e5ee7247b636ae13cbe231306070108d1672b4bb Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 12 May 2017 17:32:00 -0700 Subject: force program header alignment to be smaller than 32kbytes GCC 5 and newer seem to choose higher alignment values in elf program headers than older versions. This causes issues when doing address translations with areas which have lower alignment: It moves the base address outside of memory base addresse (e.g. TCML memory base address is aligned to 32kiB). With 4K we use a safe and sensible value for alignment. With that all elf program headers are aligned with 0x1000. $ readelf -l debug/hello_world.elf Elf file type is EXEC (Executable file) Entry point 0x1fff8311 There are 3 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x001000 0x1fff8000 0x1fff8000 0x00240 0x00240 R 0x1000 LOAD 0x001240 0x1fff8240 0x1fff8240 0x03904 0x03904 RWE 0x1000 LOAD 0x005000 0x20000000 0x1fffbb44 0x00070 0x059b0 RW 0x1000 Signed-off-by: Stefan Agner --- examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt index 3942552..9dc58b4 100644 --- a/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt +++ b/examples/imx7_colibri_m4/demo_apps/hello_world/armgcc/CMakeLists.txt @@ -36,7 +36,7 @@ SET(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -MMD -MP -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -std=gnu99") # DEFAULT LD FLAGS -SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nano.specs -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -Xlinker muldefs") +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=nano.specs -Wall -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mthumb -mapcs -Xlinker --gc-sections -Xlinker -static -Xlinker -z -z max-page-size=4096 -Xlinker muldefs") # DEBUG ASM FLAGS SET(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} -g") -- cgit v1.2.3