[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: RE: compiling
my question was basically what did the compiler included in the code from the unrelated file, ( i told rest
of things to tell that something was definately inserted ) plz can someone expand it a bit. can i get
some good links for a.out & elf formats .
At 10/31/00 10:05:00 AM, you wrote:
>#From: P k j ~ c K [mailto:deepak2000@xxxxxxxxxxxx]
>#Sent: Monday, October 30, 2000 11:55 PM
>#Subject: [LIP] compiling
>#i tried compiling a c program as
># & rename a.out to a.out1 . then i complied it with
>#cc myprog.c anotherfile.c
>As long as there is one main() and no clash of variables/scopes(loosely
>speaking) , compilation should run fine.. even if the programs are
>"unrelated". The compiler doesn't really understand "relationships"
># the file sizes of a.out & a.out1 differ .
>may be it is putting in some statically linked functions from anotherfile.c
>into the executable and hence the difference in size. This is not unusual.
># also the program
>#was written to show some pointer address .
>#exectable shows different addresses .
>When you load the executable image from the disk, it is put into memory and
>given its own virtual address space. A virtual address space is a flat
>CONTIGUOUS linear address space, which is mapped to the actual physical RAM
>by the OS/hardware. The technicalities is beyond the scope of this
>discussion. However, simply put, your process gets a big piece of linear,
>continous memory starting from 0 to a very large number in the range of 4
>GB. So whatever pointer stuff you see is NOT the physical memory but
>actually locations in this virtual memory.
>Since your executables are different , the memory being refereed two by the
>different executables can be different. It depoends on what variables you
>have put in anotherfile.c, how many of them are uninitialised, if you have
>done any malloc etc...
># if same executable is
>#run repeatedly , it shows same
>when the same executable is run repeatedly then you are getting the pictures
>of memory from the SAME virtual address sp-ace and will be same.
>Once you understand the relationship between Virtual Memory and the RAM ,
>then things will be easy for you to follow.
>You can check out the Unix Design of the Unix OS Book by Bach or some Book
>on Computer Architecture for a more elaborate an elegant discussion.
>#what info did a.out took from anotherfile.c ?
>That depends on the source code of the two files.
>Global Software Platforms
>GE Medical Systems
>A1 Golden Enclave, Airport Road, Bangalore, India 560 017
>Tel : +91-80-526 3121|3496 Ext 362
>Surf : www.gemedicalsystems.com | www.shourya.com
==== Ð ë ê þ ã K ----
have a great day
-- There's an old proverb that says just about whatever you want it to.