- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: binary files differ by time
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 02:18 AM
03-10-2004 02:18 AM
binary files differ by time
Jun
cc hello.c
mv a.out b.out
cc hello.c
diff a.out b.out
Binary files a.out and b.out differ
# cksum a.out
1115578088 20732 a.out
# cksum b.out
2899230371 20732 b.out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 02:45 AM
03-10-2004 02:45 AM
Re: binary files differ by time
You can convince yourself of this by doing this:
cp a.out b.out
cksum a.out b.out
Eventhough the files have different timestamps (and even the owner/group could be different, if you like), the cksums are identical. Again, cksum, sum, and diff don't care about a file's metadata.
The timestamp that is giving you problems is embedded in the executable (and indeed in the object files that built the executable).
There is a struct within (file_time) the file header of every object file that carries
the time of assembly or linking. Because to cksum this is DATA rather than METADATA, your task is hopeless. You could write a c program to modify this file_time data but that is the only way to accomplish what you are trying to do.
Man a.out for details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 03:15 AM
03-10-2004 03:15 AM
Re: binary files differ by time
So far I saw only hpux has this problem.
Do you think compile cc or gcc from source make a difference? Or some insight about what HP did to make cksum see different things will be helpful.
Also what the difference between an elf file and the PA-RISC executable, or can one generate elf file instead of PA-RISC on hpux?
Same procedure on a linux machine I got perfect agreement for diff and cksum.
Jun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 03:48 AM
03-10-2004 03:48 AM
Re: binary files differ by time
Moreover, even if the executables are identical, that still does not mean that the run-times are identical because different versions of shared libraries might be employed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 04:18 AM
03-10-2004 04:18 AM
Re: binary files differ by time
cmp -l a.out b.out
you will see the 4 words of modification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 04:30 AM
03-10-2004 04:30 AM
Re: binary files differ by time
odump -auxheader a.out |grep when_linked
when_linked = Wed Mar 10 2004 06:15:31.000000000 MET
when_linked = Wed Jun 05 2002 19:39:30.000000000 METDST
odump -compunit a.out |grep Time
odump -compunit b.out |grep Time
The best to differenciate executables is to use a what string:
char ident[] = "@(#)identification information";
then you can differenciate with
what a.out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 06:41 AM
03-10-2004 06:41 AM
Re: binary files differ by time
is there a way that the difference could be eliminated? either after or during the compilation? This is actually my purpose when raised the question.
Jun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 08:02 AM
03-10-2004 08:02 AM
Re: binary files differ by time
Note that aux_headers come in many different "flavors" so this it a bit tricky. I suspect, though I haven't bother to test this, is that the real differences are in the aux header because using od (and assuming I can count bytes) it appears that the file_time values are zero'ed in the header.
Is this potentially dangerous? You bet. Is it in any sense useful? Beats me. Do the risks outweigh the benefits? I doubt it.
You need to man a.out and read it this time and then look at /usr/include/filehdr.h. That will get you started.
If this were me, I would put in the ident[] global string in one of the objects and trust it.
If you are determined to do this then I would rethink the whole deal. You need to come up with a "checkexe" command that is platform specific. On most platforms it might just be a cksum wrapper. On HP-UX, you might open the exe, read the header and from that learn how many bytes in aux_headers you have and skip to that offset. Read the file from the end of the aux_headers to EOF and pipe that output to cksum. Now you ought to have two cksums that do compare. This still sounds like far more trouble than it is worth and you are still not addressing shared libraries.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 08:31 AM
03-10-2004 08:31 AM
Re: binary files differ by time
char ident[] = "@(#)identification information";
into hello.c. After added it,
what a.out
just give me one more line, and same to b.out. Where is the further differentiation of the two?
Jun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 08:47 AM
03-10-2004 08:47 AM
Re: binary files differ by time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 08:51 AM
03-10-2004 08:51 AM
Re: binary files differ by time
myexe -V
When -V is supplied print the version on stdout and exit. You have to supply the code to process the -V and adopt a convention for setting and maintaining a Version string.
The -V convention also has the advantage that you can simply ask the user to execute a filename -V and read to you what it says.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2004 07:57 PM
03-10-2004 07:57 PM
Re: binary files differ by time
then cmp.
This may help for som files, but with no garanty
#!/usr/bin/ksh
F1=$1
F2=$2
F2TMP=${2}tmp$$
cp $F2 $F2TMP
odump -header $1 |grep -e aux_header -e compiler |while read a b c d
do
eval $(printf "dd bs=1 count=%d skip=%d of=%s if=%s\n" $c $b $a $F1)
eval $(printf "dd bs=1 seek=%d if=%s 1<>%s\n" $b $a $F2TMP)
done
if cmp $F1 $F2TMP
then
echo same
else
cmp -l $F1 $F2TMP
fi
rm $F2TMP
Laurent