* [gentoo-embedded] gcc question - entry point problem in small, static app
@ 2009-03-30 8:44 99% Christopher Friedt
0 siblings, 0 replies; 1+ results
From: Christopher Friedt @ 2009-03-30 8:44 UTC (permalink / raw
To: gentoo-embedded
I'm sure many of you have run into this problem at some point, so here goes:
I'm writing code in C for a very small static binary, and the code
doesn't use any headers or rely on any other libraries. It's quite
tiny and only does a very specific job - it initializes a uart and
repeatedly prints a message out in an infinite loop. It's intended to
be run by the bootloader instead of a kernel to test out the uart
hardware.
When I'm compiling the code, I'm using
arm-softfloat-linux-gnueabi-gcc -Wall -fomit-frame-pointer -pipe -Os
-march=armv5te -static -o hello_uart hello_uart.c
That compiles fine, but I've noticed that there is a lot of static
libc junk built into my binary, several hundred kilobytes worth of
junk, and I know for a fact that I don't need it. However, when I
build my program with options like -nostdlib -nodefaultlibs
-nostartfiles, I get an error that says
warning: cannot find entry symbol _start; defaulting to 000000000000008074
How is a program like the one below supposed to be compiled in order
to get a static, executable chunk of arm machine code?
I guess main() shouldn't even be there. Do I need to write everything
in assembler, and just link some sort of entry in a .S file, and then
link main.o with func.o ? I was sort of hoping that it would "just
work" in C without having to resort to anything slightly more tedious.
Any thoughts would be appreciated
C
==================
// some defines used in the setup and puts functions
#define X 1
#define Y 2
static void uart_puts( char * s ) {
// puts code
}
static void uart_setup() {
// setup uart
}
int main() {
uart_setup();
while(1)
puts( "Hello, UART World!\n\r" );
// never really returns
return 0;
}
^ permalink raw reply [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2009-03-30 8:44 99% [gentoo-embedded] gcc question - entry point problem in small, static app Christopher Friedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox