Getting "collect2: error: ld returned 1 exit status" in C -
this makefile compiler.
cc = arm-none-eabi-gcc = arm-none-eabi-as ld = arm-none-eabi-ld od = arm-none-eabi-objdump cflags = -g -c -o1 -mcpu=cortex-m0 -mthumb aflags = -g -c -mcpu=cortex-m0 -mthumb ldflags = -g -mcpu=cortex-m0 -mthumb --specs=rdimon.specs -lc -lrdimon odflags = -d all: hw1.elf test: hw1.elf @ echo "...copying" qemu-system-arm -machine versatilepb -cpu cortex-m3 -nographic -monitor null -serial null -semihosting -k\ ernel hw1.elf hw1.elf: test.o t1.o $(cc) $(ldflags) test.o t1.o -o hw1.elf test.o: test.c t1.o @ echo ".compiling" $(cc) $(cflags) test.c t1.o -o test.o t1.o: t1.s @ echo ".assembling" $(as) $(aflags) t1.s -o t1.o clean: rm -rf t1.o test.o hw1.elf
when make all
, get
.assembling arm-none-eabi-as -g -c -mcpu=cortex-m0 -mthumb t1.s -o t1.o .compiling arm-none-eabi-gcc -g -c -o1 -mcpu=cortex-m0 -mthumb test.c t1.o -o test.o arm-none-eabi-gcc: warning: t1.o: linker input file unused because linking not done arm-none-eabi-ld -g -mcpu=cortex-m0 -mthumb --specs=rdimon.specs -lc -lrdimon test.o -o hw1.elf arm-none-eabi-ld: unrecognised emulation mode: thumb supported emulations: armelf make: *** [hw1.elf] error 1
i have looked @ numberous collect2 errors on stackoverflow , find there function either not defined or mislabeled.
i have entered directory in ~/.bashrc file call arm-none-eabi library functions. know error has nothing t1.s and/or test.c files , solely improper notation dealing makefile, i'm lost i'm doing wrong. know it's test.o
.
i provide test.c , t1.s in case there wrong them.
test.c
include <stdio.h> extern int inc(int); #define red_count 5 #define yellow_count 2 #define green_count 5 enum light_states {red, yellow, green}; static int state = red; void stop_light () { static int state_counter = 0; switch (state) { case red: printf("red\n"); if (++state_counter >= red_count) { state_counter = 0; state = green; } break; case green: printf("green\n"); if (++state_counter >= green_count) { state_counter = 0; state = yellow; } break; case yellow: printf("yellow\n"); if (++state_counter >= yellow_count) { state_counter = 0; state = red; } break; default: state = red; state_counter = 0; break; } } main(){ int i; while (i < 36) { stop_light(); = inc(i); } }
t1.s
.text .syntax unified .thumb .global inc .type inc, %function inc: adds r0,r0,#1 bx lr
edit 1: updated missing '-c' , getting new error regarding ld.
edit 2: updated ld error. fixed , answers helpful!
Comments
Post a Comment