Skip to content

Commit d60b34c

Browse files
authored
risc-v: Fix build flags and linker scripts (FreeRTOS#906)
1. miss debug info in assembly code RISC-V-spike-htif_GCC LDFLAGS add arch and abi info for linker for riscv64-unknown-elf multilib, if there is no arch and abi info, will link to default lib and have below error target emulation `elf32-littleriscv' does not match `elf64-littleriscv' use CFLAGS to replace ASFLAGS when compile assembly code because DEBUG flag is added in CFLAGS, if we use ASFLAGS to compile assembly code, there is no debug info in assembly code objfile 2. binutils 2.39 ld warn 'has a LOAD segment with RWX permissions' RISC-V-Qemu-virt_GCC RISC-V-spike-htif_GCC RISC-V_RV32_QEMU_VIRT_GCC 3. fix build fail RISC-V_RV32_QEMU_VIRT_GCC Signed-off-by: Eric Chan <e14002270@gmail.com>
1 parent f6f2b67 commit d60b34c

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

FreeRTOS/Demo/RISC-V-Qemu-virt_GCC/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LDFLAGS = -nostartfiles -Tfake_rom.lds \
2424
-march=rv32imac -mabi=ilp32 -mcmodel=medany \
2525
-Xlinker --gc-sections \
2626
-Xlinker --defsym=__stack_size=300 \
27-
-Xlinker -Map=RTOSDemo.map
27+
-Xlinker -Map=$(BUILD_DIR)/RTOSDemo.map
2828

2929
ifeq ($(DEBUG), 1)
3030
CFLAGS += -Og -ggdb3

FreeRTOS/Demo/RISC-V-Qemu-virt_GCC/fake_rom.lds

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ SECTIONS
3030
_etext = .;
3131
} >rom AT>rom
3232

33-
.rodata.align :
33+
.rodata.align ALIGN(4):
3434
{
35-
. = ALIGN(4);
3635
_rodata = .;
3736
} >rom AT>rom
3837

FreeRTOS/Demo/RISC-V-spike-htif_GCC/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ CFLAGS = -march=$(MARCH) -mabi=$(MABI) -mcmodel=medany \
3434
-ffunction-sections \
3535
-fdata-sections \
3636
-fno-builtin-printf
37-
ASFLAGS = -march=$(MARCH) -mabi=$(MABI) -mcmodel=medany
3837
LDFLAGS = -nostartfiles \
38+
-march=$(MARCH) -mabi=$(MABI) -mcmodel=medany \
3939
-Xlinker --gc-sections \
4040
-Xlinker --defsym=__stack_size=$(STACK_SIZE)
4141

@@ -76,7 +76,7 @@ $(BUILD_DIR)/%$(XLEN).o: %.c Makefile
7676

7777
$(BUILD_DIR)/%$(XLEN).o: %.S Makefile
7878
@mkdir -p $(@D)
79-
$(CC) $(CPPFLAGS) $(ASFLAGS) -MMD -MP -c $< -o $@
79+
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MP -c $< -o $@
8080

8181
# Run lds through the C preprocessor, to replace BASE_ADDRESS with the actual
8282
# value. It might be simpler to use sed instead.

FreeRTOS/Demo/RISC-V-spike-htif_GCC/fake_rom.lds

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ SECTIONS
3131
_etext = .;
3232
} >rom AT>rom
3333

34-
.rodata.align :
34+
.rodata.align ALIGN(4):
3535
{
36-
. = ALIGN(4);
3736
_rodata = .;
3837
} >rom AT>rom
3938

FreeRTOS/Demo/RISC-V_RV32_QEMU_VIRT_GCC/FreeRTOSConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ to exclude the API function. */
103103
format the raw data provided by the uxTaskGetSystemState() function in to human
104104
readable ASCII form. See the notes in the implementation of vTaskList() within
105105
FreeRTOS/Source/tasks.c for limitations. */
106-
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
106+
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
107107

108108
/* The QEMU target is capable of running all the tests tasks at the same
109109
* time. */

FreeRTOS/Demo/RISC-V_RV32_QEMU_VIRT_GCC/build/gcc/fake_rom.ld

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ SECTIONS
3030
_etext = .;
3131
} >rom AT>rom
3232

33-
.rodata.align :
33+
.rodata.align ALIGN(4):
3434
{
35-
. = ALIGN(4);
3635
_rodata = .;
3736
} >rom AT>rom
3837

0 commit comments

Comments
 (0)