I can't seem to compile my code with the newlib libs. I am using an example posted by a forum user that contains both C and C++ code and assembly, while adding the newlib to it for my malloc calls and what not. This borrows from dwelch67's repository for syscalls.c and also uses code from the Baking Pi tutorials.
My error is this:
- Code: Select all
arm-none-eabi-gcc -c source/cppcode.cpp -o build/cppcode.o
arm-none-eabi-ld --no-undefined build/gpio.o build/main.o build/systemTimer.o build/ccode.o build/syscalls.o build/cppcode.o -Map kernel.map -o build/output.elf -L /Users/cmrigney/Developer/GNUArm/newlib/newlib-1.18.0/arm-none-eabi/newlib/ -lc -lg -lm -T kernel.ld
build/cppcode.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr1'
I believe the problem area may lie in the makefile?
- Code: Select all
###############################################################################
# makefile
# by Alex Chadwick
#
# A makefile script for generation of raspberry pi kernel images.
###############################################################################
# The toolchain to use. arm-none-eabi works, but there does exist
# arm-bcm2708-linux-gnueabi.
ARMGNU ?= arm-none-eabi
# The intermediate directory for compiled object files.
BUILD = build/
# The directory in which source files are stored.
SOURCE = source/
# The name of the output file to generate.
TARGET = kernel.img
# The name of the assembler listing file to generate.
LIST = kernel.list
# The name of the map file to generate.
MAP = kernel.map
LIB = -L /Users/cmrigney/Developer/GNUArm/newlib/newlib-1.18.0/arm-none-eabi/newlib/
# The name of the linker script to use.
LINKER = kernel.ld
# The names of all object files that must be generated. Deduced from the
# assembly code files in source.
OBJECTS := $(patsubst $(SOURCE)%.s,$(BUILD)%.o,$(wildcard $(SOURCE)*.s)) \
$(patsubst $(SOURCE)%.c,$(BUILD)%.o,$(wildcard $(SOURCE)*.c)) \
$(patsubst $(SOURCE)%.cpp,$(BUILD)%.o,$(wildcard $(SOURCE)*.cpp))
# Rule to make everything.
all: $(TARGET) $(LIST)
# Rule to remake everything. Does not include clean.
rebuild: all
# Rule to make the listing file.
$(LIST) : $(BUILD)output.elf
$(ARMGNU)-objdump -d $(BUILD)output.elf > $(LIST)
# Rule to make the image file.
$(TARGET) : $(BUILD)output.elf
$(ARMGNU)-objcopy $(BUILD)output.elf -O binary $(TARGET)
# Rule to make the elf file.
$(BUILD)output.elf : $(OBJECTS) $(LINKER)
$(ARMGNU)-ld --no-undefined $(OBJECTS) -Map $(MAP) -o $(BUILD)output.elf $(LIB) -lc -lg -lm -T $(LINKER)
# Rule to make the object files.
$(BUILD)%.o: $(SOURCE)%.s
$(ARMGNU)-as -I $(SOURCE) $< -o $@
# Rule to make the object files.
$(BUILD)%.o: $(SOURCE)%.c
$(ARMGNU)-gcc -c $< -o $@
# Rule to make the object files.
$(BUILD)%.o: $(SOURCE)%.cpp
$(ARMGNU)-gcc -c $< -o $@
# Rule to clean files.
clean :
-rm -f $(BUILD)*.o
-rm -f $(BUILD)output.elf
-rm -f $(TARGET)
-rm -f $(LIST)
-rm -f $(MAP)
If I remove the C++ code I believe the problem goes away. Any ideas?
Also here is my linker script:
- Code: Select all
MEMORY
{
ram : ORIGIN = 0x8000, LENGTH = 0x20000
}
SECTIONS
{
.text : { *(.text*) } > ram
.bss : { *(.bss*) } > ram
}
Thanks!