I am writing software for a Cortex-A8 processor, and I need to write some ARM assembly code to access specific registers. I use gnu compilers and their associated tool chains, these tools are installed on the processor board (Freescale i.MX515) with Ubuntu. I connect to it from my PC (Windows) using WinSCP and PuTTY terminal.
As usual, I started with a simple C project with main.c and functions.s . I compile main.c using GCC , compile functions. Using the generated object files as well as the link , GCC is used again, but strange errors occur during this process.
The important conclusion is
Meanwhile, I found out that my build code may have some problems, because when I individually build it with the as -o functions.o functions.s command and try to run the generated .o function with the ./functions.o , the bash shell cannot recognize this file as an executable file (when you click on the functions.o tab, it does not receive selection / PuTTY does not select the file).
Can anyone suggest what is going on here? Are there any specific parameters that I have to send to GCC during the binding process? The errors that I see are strange and not in my understanding, I do not understand what GCC refers to.
I insert the contents of main.c, functions.s, Makefile and a list of errors here.
Help me please!!!
Recent bugs are included after the makfile has been edited as suggested by the guys here -
ubuntu@ubuntu-desktop :~/Documents/Project/Others/helloworld$ make gcc -c -mcpu=cortex-a8 main.c as -mcpu=cortex-a8 -o functions.o functions.s gcc -o hello main.o functions.o functions.o: In function `_start': (.text+0x0): multiple definition of `_start' /usr/lib/gcc/arm-linux-gnueabi/4.3.3/../../../crt1.o:init.c:(.text+0x0): first defined here collect2: ld returned 1 exit status make: *** [hello] Error 1
main.c
#include <stdio.h> #include <stdlib.h> int main(void) { puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */ return EXIT_SUCCESS; }
functions.s
* Main program */ .equ STACK_TOP, 0x20000800 .text .global _start .syntax unified _start: .word STACK_TOP, start .type start, function start: movs r0,
Makefile
all: hello hello: main.o functions.o gcc hello -o main.o functions.o
- hi was included here after the guys suggest on stackoverflow, but the problem still persists, I still get the same errors.
main.o: main.c gcc -c -mcpu=cortex-a8 main.c functions.o: functions.s as -mcpu=cortex-a8 -o functions.o functions.s
Mistakes
ubuntu@ubuntu-desktop :~/Documents/Project/Others/helloworld$ make gcc -c -mcpu=cortex-a8 main.c as -mcpu=cortex-a8 -o functions.o functions.s gcc -o main.o functions.o functions.o: In function `_start': (.text+0x0): multiple definition of `_start' /usr/lib/gcc/arm-linux-gnueabi/4.3.3/../../../crt1.o:init.c:(.text+0x0): first defined here /usr/lib/gcc/arm-linux-gnueabi/4.3.3/../../../crt1.o: In function `_start': init.c:(.text+0x30): undefined reference to `main' collect2: ld returned 1 exit status make: *** [hello] Error 1