Entry point C

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pepito

Entry point C

Post by pepito »

How can I calculate de 'entry point' of a C program, compiled using GCC-LD?

Thank you

pepito
knicos

RE:Entry point C

Post by knicos »

The entry point will be a function called _start. I usually write this in asm but i assume you can write it in C. Also, you can specify an offset for all addresses (ld -Ttext=0x00000000 ...). So the entry point should be the first byte, or if a program file header (PE or ELF) then they give entry point.
pepito

RE:Entry point C

Post by pepito »

Thank you,

bye

pepito
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

RE:Entry point C

Post by df »

the LD option -e {funcname} will define that as the start function.
-- Stu --
beyondsociety

RE:Entry point C

Post by beyondsociety »

You can also use a linker script to do the loading for you.

I, myself do this as it makes the compiling of my operating system easier. Eventually you will want to use a linker script if you decide to add certain features like paging which uses virtual addresses and physical ones, zeroing the .bss and .end of the linker script for c language, etc.

Hope this helps.
pepito

RE:Entry point C

Post by pepito »

Thank you all of you!

Exactly, I need to know the 'entry point' and 'stack pointer' values at RUN TIME i.e. the OS must know where the CODE, DATA and STACK sections are to correctly create the process.

pepito
Post Reply