[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: (no subject)



On Tue, 6 Jun 2000, Rajeev Jha wrote:


> 
> hi 
> that brings us to the next question, what is a binary file ? like i have
> some a.out which can be displayed  with 'od' ; now this dump is what is
> a.out or is it something more. specifically how the info contained in
> this file is relayed to the OS ?  
> 

A binary file is a sequence of instructions to the microprocessor
(Hereafter abbreviated mpu). A program has two components:
1. data to be acted upon
2. Sequence of instructions.

Data can be interpreted in the manner of ascii etc.  Now since the
binary files are also stored in the same way in the disk, only way
for the OS to know whether they are executables or not is the
presence of 'x' permission (or the suffix 'com' or 'exe' in case of 
windows/Dos). That being the case, The OS also needs
to know from where the instructions etc start in the file, where the
data is, etc.

Thus executables have a header which provides such information.
Using which, the OS executes the instructions. In Dos (Well, when I
studied this, I read a book on how x86 cpu does this on dos so I
don't have a idea how this is on linux) 'EXE' files have such
headers, while 'com' (which stands for command) do not, instructions
start from the first line.

Now why changing even a single byte in a binary file causes it to
misbehave ? simple. Assembly instructions have a fixed length. If
you change on byte, It may become a different instruction! with
some unexpected results.

Usually compiler also embeds information on which
function was called etc in the file. Which is what you see when you
do 'od'. Also, the instructions are interpreted by the mpu, *not*
the OS.

pallav.

___________________________________________________________________
O Sun of refulgent glory, I made you what you are.
					 - Mandakyo Upnishad
____________________________________________________________________
Pallav Nawani        |    Visit me at                              |
M-41,                |  http://www.angelfire.com/co/pallav         |           
IISc Bangalore       | --------------------------------------------| 
PIN 560012           |                                             |
Phone : 3092453      |                                             |
_____________________|_____________________________________________|