CITS2002 Systems Programming  
prev
CITS2002 CITS2002 schedule  

On the interpretation of data, continued

As an example of how bytes may be interpreted in different ways, consider the first few hundred bytes of the disk file /bin/ls. We know this to be a program, and we expect the operating system to interpret its contents to be a program, and request the processor to execute its contents (a mixture of instructions and data).

However, another program could read the bytes from /bin/ls and interpret them in other ways, e.g. as 32-bit integers:

prompt> od -i /bin/ls 0000000 1179403647 65793 0 0 0000020 196610 1 134518416 52 0000040 66628 0 2097204 2621447 0000060 1638426 6 52 134512692 0000100 134512692 224 224 5 0000120 4 3 276 134512916 0000140 134512916 19 19 4 0000160 1 1 0 134512640 .......

or as octal (8-bit) bytes:

prompt> od -b /bin/ls 0000000 177 105 114 106 001 001 001 000 000 000 000 000 000 000 000 000 0000020 002 000 003 000 001 000 000 000 220 226 004 010 064 000 000 000 0000040 104 004 001 000 000 000 000 000 064 000 040 000 007 000 050 000 0000060 032 000 031 000 006 000 000 000 064 000 000 000 064 200 004 010 0000100 064 200 004 010 340 000 000 000 340 000 000 000 005 000 000 000 0000120 004 000 000 000 003 000 000 000 024 001 000 000 024 201 004 010 0000140 024 201 004 010 023 000 000 000 023 000 000 000 004 000 000 000 0000160 001 000 000 000 001 000 000 000 000 000 000 000 000 200 004 010 .......

or as ASCII characters:

prompt> od -c /bin/ls 0000000 177 E L F 001 001 001 \0 \0 \0 \0 \0 \0 \0 \0 \0 0000020 002 \0 003 \0 001 \0 \0 \0 220 226 004 \b 4 \0 \0 \0 0000040 D 004 001 \0 \0 \0 \0 \0 4 \0 \0 \a \0 ( \0 0000060 032 \0 031 \0 006 \0 \0 \0 4 \0 \0 \0 4 200 004 \b 0000100 4 200 004 \b 340 \0 \0 \0 340 \0 \0 \0 005 \0 \0 \0 0000120 004 \0 \0 \0 003 \0 \0 \0 024 001 \0 \0 024 201 004 \b 0000140 024 201 004 \b 023 \0 \0 \0 023 \0 \0 \0 004 \0 \0 \0 0000160 001 \0 \0 \0 001 \0 \0 \0 \0 \0 \0 \0 \0 200 004 \b .......

And each interpretation could be correct, depending on context.

 


CITS2002 Systems Programming, Lecture 6, p10, 7th August 2024.