Solaris 5.8 - BinaryFile - Endianness


 
Thread Tools Search this Thread
Operating Systems Solaris Solaris 5.8 - BinaryFile - Endianness
# 15  
Old 09-04-2009
Hi,
I am getting expected values with the way I wrote in my previous two posts. I think the source code (not available, as of now) which has written this binary file has been written like that. Else how is it possible to get the expected the values ?

---------- Post updated at 06:41 PM ---------- Previous update was at 06:38 PM ----------

Any thoughts on this behavior ?
# 16  
Old 09-04-2009
Quote:
Originally Posted by angshuman_ag
Hi,
Yes its correct.
I am getting expected values with the way I wrote in my previous two posts. I think the source code (not available, as of now) which has written this binary file has been written like that. Else how is it possible to get the expected the values ?

---------- Post updated at 06:41 PM ---------- Previous update was at 06:38 PM ----------

Any thoughts on this behavior ?
What is the exact data type at those locations? What is the source code you're using to read it? The more specific data you can present, the better.

Cross-platform coding is tedious. Literally every bit has to be accounted for. Which is why in cases where space and performance aren't too much of an issue I like to use portable formats like XML or even simple ASCII text.
# 17  
Old 09-04-2009
True.
I am inferring the exact datatypes at those locations by looking at the parser code bcos original BIN file generation source is not there. And, yes, this is very tedious ! That is why, as you said we have XMLs. But, we always have some legacy systems with which sometimes we have to adjust.
# 18  
Old 09-04-2009
It doesn't make sense for a binary file to contain both big and little endian values but this happens and sometimes there are even explanations about it.
However, if your Windows little endian code reads correctly say a 16bit or 32 bit integer value AND the very same code compiled on a big endian machine read the very same values at the same location without byte swapping, then you are just lucky enough to have a value that reads the same in both standards, like (assuming 16 bit unsigned integers) 0, 257, 514, 771, ..., 65535.
# 19  
Old 09-06-2009
What about 32-bit unsigned long ?
In the parser code it is tryng to read something like this -

unsigned long temp = *(unsigned long *) ptr;It gives a value like this "2030043136" which is not expected. Now I tried to swap 32-bits
like this -

unsigned long temp = Swap32Bits(*(unsigned long *) ptr);
but still not sure of the correct value ! How to test such cross-platform code ?

Last edited by angshuman_ag; 09-06-2009 at 04:56 AM..
# 20  
Old 09-06-2009
Not sure about how Swap32Bits is implemented but your value converts to 121 which looks a pretty valid number.
# 21  
Old 09-06-2009
Yes. That is the value I am getting using this operation :

(((data) >> 24) & 0x000000FF) | (((data) >> 8) & 0x0000FF00) | (((data) << 8) & 0x00FF0000) | (((data) << 24) & 0xFF000000) ;
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. AIX

IBM TDS/SDS (LDAP) - can I mix endianness among servers in an instance ?

I'd like to add some x/linux-based servers to my current AIX-based TDS/SDS server community. Reading the Fine Install Guide (rtfig ?) I believe this may be covered by the section "Upgrade an instance of a previous version to a different computer" i.e. I'm going to install latest/greatest SDS on a... (4 Replies)
Discussion started by: maraixadm
4 Replies

2. Solaris

How to add Solaris text console to Solaris grub2 menu?

Hi, I am new to sloaris and just instlled the solaris 11.2, i know little more about linux, i open the /boot/grub/grub.cfg in solaris and there is many other entries forl solaris 11.2 one of them is for 'Oracle Solaris 11.2 text console' but at boot grub2 only show the first default entry that... (1 Reply)
Discussion started by: shamsat
1 Replies

3. UNIX for Advanced & Expert Users

How to know endianness of a machine

hi I have a ubuntu machine and want to know the endianness of the system.... How would i get to know..... The information of my machine is: uname -a 42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 201 1 i686 i686 i386 GNU/Linux and lsb_release -a No LSB modules are available.... (6 Replies)
Discussion started by: Ankita Singlaa
6 Replies

4. Solaris

Unable to login using ssh,telnet onto my solaris machine with solaris 10 installed

Hi, I am unable to login into my terminal hosting Solaris 10 and get the below error message "Server refused to allocate pty ld.so.1: sh: fatal: libc.so.1: open failed: No such file or directory " Is there anyways i can get into my machine and what kind of changes are required to be... (7 Replies)
Discussion started by: sankasu
7 Replies

5. Solaris

application compiled on solaris 10 throwing error when executed on solaris 9

I have compiled my application on Solaris 10 with following description SunOS ldg1 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Blade-T6320 The compiler is Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25 But when installing the application on Solaris 9 SunOS odcarch02 5.9... (2 Replies)
Discussion started by: ash_bit2k2
2 Replies
Login or Register to Ask a Question