Is there a way to see, via hex editor or otherwise, if data in a binary file is aligned or packed, specifically for an HPUX system?
+1
A:
If you know what you are looking for and can recognize it in a hex dump, then you can make informed estimates about whether the data is aligned or not, or packed. But in many ways, your question is unanswerable. Where did the data come from? Why can't you ask the person (driving a program, presumably) how it was created?
If you are asking 'what tools could I use to view the data', then you can consider:
- od (octal dump - probably with the -c option too)
- hd (hex dump - not always available, and seems to be absent on HP-UX)
- sed l (that's a lower-case ell - it means list the data; not a good option unless the majority of the data is plain text)
Or you could do it in Perl. Once upon a long time ago (1987 or so), I wrote a program odx (octal dump in hex - weird) that I continue to use - it gives me a hex dump, 16 bytes per line, plus an image of the printable characters. This example isn't very exciting (odx run on itself - on a Sun Sparc):
Black JL: odx odx | sed 10q
0x0000: 7F 45 4C 46 01 02 01 00 00 00 00 00 00 00 00 00 .ELF............
0x0010: 00 02 00 12 00 00 00 01 00 01 0D 84 00 00 00 34 ...............4
0x0020: 00 00 77 9C 00 00 01 00 00 34 00 20 00 05 00 28 ..w......4. ...(
0x0030: 00 24 00 23 00 00 00 06 00 00 00 34 00 01 00 34 .$.#.......4...4
0x0040: 00 00 00 00 00 00 00 A0 00 00 00 A0 00 00 00 05 ................
0x0050: 00 00 00 00 00 00 00 03 00 00 00 D4 00 00 00 00 ................
0x0060: 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00 04 ................
0x0070: 00 00 00 00 00 00 00 01 00 00 00 00 00 01 00 00 ................
0x0080: 00 00 00 00 00 00 22 86 00 00 22 86 00 00 00 05 ......"...".....
0x0090: 00 01 00 00 00 00 00 01 00 00 22 88 00 02 22 88 .........."...".
Black JL:
Jonathan Leffler
2008-10-11 04:11:26