linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* sequence of steps that goes from compilation to execution
@ 2004-08-17 19:34 Sudheer Vutukuru
  2004-08-18 12:10 ` Jan-Benedict Glaw
  0 siblings, 1 reply; 3+ messages in thread
From: Sudheer Vutukuru @ 2004-08-17 19:34 UTC (permalink / raw)
  To: linux-c-programming

Hi all,

    Why a program which is compiled on linux does not execute on windows.. 
(though the machine architecture is same)..

 Also   Can u please suggest me references or help me in knowing the
details of what goes on, from compilation to execution (i.e how
loading,linking libraries is done.. how addresses
are known dynamically etc.. ).

 for string literals whether memory is allocated in heap or in code
segment only..
i.e char* ptr = "Hello World";
  the ptr points into code segement or heap..

  Thanks,

***************************************************************************
 V V N Sudheer,
 Master of Technology,
 Dept. of Computer Science,
 IIT Kanpur.
***************************************************************************

^ permalink raw reply	[flat|nested] 3+ messages in thread
* RE: sequence of steps that goes from compilation to execution
@ 2004-08-23 15:50 Huber, George K RDECOM CERDEC STCD SRI
  0 siblings, 0 replies; 3+ messages in thread
From: Huber, George K RDECOM CERDEC STCD SRI @ 2004-08-23 15:50 UTC (permalink / raw)
  To: 'Sudheer Vutukuru', linux-c-programming

>    Why a program which is compiled on linux does not execute on windows.. 
>(though the machine architecture is same)..

Different file formats.  Windows uses PE (portable executable) as its file
format with the first two bytes being `MZ' (or possibly `ZM') that 
designates it as a windows executable.  Linux uses ELF (executible linkable 
format) as its file format with the second, third and fourth bytes of the 
file being `ELF'.

> Also   Can u please suggest me references or help me in knowing the
>details of what goes on, from compilation to execution (i.e how
>loading,linking libraries is done.. how addresses
>are known dynamically etc.. ).

One of the best (only?) books on the subject "Linkers and Loaders" by John 
Levine.  It covers various file formats (from simple (i.e. DOS) up through
complex (PE and ELF)) and uses these formats to address all of the questions
that you ask.  In addition, the book is availble from the authors website:

http://www.iecc.com/linker/

as well as in printed format.

> for string literals whether memory is allocated in heap or in code
>segment only..
>i.e char* ptr = "Hello World";
>  the ptr points into code segement or heap..

In this case, I beleive that the C standard specifies that the string
literal 
will be a constant, and as such space will be reserved in a read-only
section 
of memory.  This is why a statement such as:

ptr[5]='i';

will fail.  Note however, that some compiles do not enforce this while
others
have flags that make string literals mutable.

George 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-08-23 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-17 19:34 sequence of steps that goes from compilation to execution Sudheer Vutukuru
2004-08-18 12:10 ` Jan-Benedict Glaw
  -- strict thread matches above, loose matches on Subject: below --
2004-08-23 15:50 Huber, George K RDECOM CERDEC STCD SRI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).