Gentoo Archives: gentoo-embedded

From: Christopher Friedt <chrisfriedt@×××××.com>
To: gentoo-embedded@l.g.o
Subject: Re: [gentoo-embedded] gcc question - entry point problem in small, static app
Date: Tue, 31 Mar 2009 11:25:22
Message-Id: 3ea34a000903310425g2cd0dd2k96df26d165eb82c5@mail.gmail.com
In Reply to: Re: [gentoo-embedded] gcc question - entry point problem in small, static app by Mike Frysinger
1 Hi Mike,
2
3 On Tue, Mar 31, 2009 at 10:07 AM, Mike Frysinger <vapier@g.o> wrote:
4 > then you cant use any libraries/files from glibc or gcc because they're
5 > assuming a Linux environment.  that means you need to use -nostdlib.  then you
6 > need to provide code to setup the C runtime environment (the "start" symbol
7 > entry point) which will tail off to the main() function.
8 >
9 > also, the default linker script is targetting a Linux environment which means
10 > you'll probably also have to write your own linker script.
11
12 Thanks for your input. I built myself a toolchain for
13 arm-softfloat-elf, and using that toolchain, my binary is compiling
14 without errors with -nostdlib -nodefaultlibs -nosystemfiles -nostdinc
15 -nostartfiles.
16
17 In the end, I'm hoping to port Linux to a new device, but for now, I
18 would settle for printing out a few characters to the std. uart, to
19 verify that it's working.
20
21 I've tried using a WinCE executable that I wrote, but no dice. I've
22 tried probing some of the registers and flipping the required bits
23 using HaRET as well, still no results when I write to the STD_TXD.
24
25 My next attempt involves running my elf binary (test_uart) from HaRET
26 as if it were a kernel image, but placing the binary at the proper
27 entry point (specified from gcc with -e) is currently impossible with
28 HaRET, because it decides where to load based on the availability of
29 contiguous pages of memory. I'll have to add a custom environment
30 variable to specify exactly where to load the kernel image (something
31 like ENTRYADDR or LOADADDR).
32
33 HaRET is pretty useful for porting Linux (and subsequently Gentoo or
34 Android!) to devices that run WinCE. It's a WinCE app though, which
35 means that you can only compile the source with cegcc (or mingw32ce).
36 There are binaries available for i686, and I've created a couple of
37 ebuilds and overlay if anyone here is interested.
38
39 layman -f -o http://virtb.visibleassets.com:2080/layman.conf -a cegcc
40
41 Cheers,
42
43 Chris