Generate Info From a Unix Binary

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support Generate Info From a Unix Binary
# 1  
Old 08-16-2010
Generate Info From a Unix Binary

We have a situation where a binary from our build system is failing in one specific flow but the same from dev works fine. We are sure that build system picks up the right libs and code, however we see a difference of 6000 bytes in both. (build - 6000 bytes = size of dev binary)

Hence we would like to know:
a. How we can compare two Unix Binaries when they differ only in terms of build boxes (ex dev and build)
b. Given a binary (not compiled with debug options) what are the information we can gather from it.

Thanks in advance.
# 2  
Old 08-16-2010
Please can you post information on the O/S, version and architecture ?
# 3  
Old 08-16-2010
O/S & Version - Red Hat Enterprise Linux Server release 5.4
Architecture - Linux xxxxx 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
# 4  
Old 08-16-2010
I would compare the build flags (debug builds often can "null" statically allocated memory whilst optimized builds do not)
I would do an "ldd" on the binary and find which libraries it is using.
Then for each of the libraries you can either use "rpm" to find the version installed, or use "sum" or "md5sum" to check they are the same on both hosts.
After all that I would "strace" the program running on both and compare the two outputs - this usually gives you an indication of where to start looking for failures.
I hope this helps...
# 5  
Old 08-21-2010
Sometime, define of file block are different, so same file will show different size in different servers.
# 6  
Old 08-21-2010
Hi.

The utility nm can extract linkage symbols from object files and executables (in most situations, e.g. where the executable has not been stripped).

You could use the lists from each version of the executable (or constituent object files) to compare for differences, although this would be at a large granularity.

See the recent post Fortran dependency checking for a use of nm ... cheers, drl
# 7  
Old 08-21-2010
Quote:
Originally Posted by uunniixx
We have a situation where a binary from our build system is failing in one specific flow but the same from dev works fine. We are sure that build system picks up the right libs and code, however we see a difference of 6000 bytes in both. (build - 6000 bytes = size of dev binary)

Hence we would like to know:
a. How we can compare two Unix Binaries when they differ only in terms of build boxes (ex dev and build)
b. Given a binary (not compiled with debug options) what are the information we can gather from it.

Thanks in advance.
A diff of 6000 bytes, itself tells that either the code or the lib used is not exactly same at both the build locations. You mentioned that you are confirmed that these things are same, how did you arrived at the conclusion?

---------- Post updated at 08:33 PM ---------- Previous update was at 08:27 PM ----------

Quote:
Originally Posted by citaylor
I would compare the build flags (debug builds often can "null" statically allocated memory whilst optimized builds do not)
I would do an "ldd" on the binary and find which libraries it is using.
Then for each of the libraries you can either use "rpm" to find the version installed, or use "sum" or "md5sum" to check they are the same on both hosts.
After all that I would "strace" the program running on both and compare the two outputs - this usually gives you an indication of where to start looking for failures.
I hope this helps...
Great suggestion!!! I'd have done similarly, eventhough a bit cumbursome, but bound to get results. Also the version control of the source should tell what's different in the recent time, should help narrow down the suspected libraries.

---------- Post updated at 08:48 PM ---------- Previous update was at 08:33 PM ----------

Lastly, I'd also have made sure, as a first step, that the build system itself does not have different versions. Apart need to make sure that the code does not have too much of flag based compilations like:

Code:
   #ifdef <flag>
      ...
   #else
      ...
   #endif <flag>

// OR
   #ifndef  xxxx
      ...
   #endif

If yes, then I'd also suggest to have a look at the environment variables in addition to the makefile flag definition.

Good Luck.

Last edited by Praveen_218; 08-21-2010 at 12:19 PM.. Reason: Fixed a typo error.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Binary pattern matching in UNIX

I think what I'm trying to do is pretty straightforward but I just can't find a way to do it. I'm trying to run a double pattern match in a three column file. If the first two columns match, I need to output the third. So in the file AAA BBB 1 BBC CCC 5 CCC DDD 7 DDD EEE 12 If the... (4 Replies)
Discussion started by: matthewndavies1
4 Replies

2. Shell Programming and Scripting

Ftp client softwares that will generate UNIX commands

Hi Folks, Please advise for FTP client softwares like winscp we use mostly to transfer the files to other unix box machines but any ftp software which in logs will also generate and show the unix commands parallely for ex if I create a directory graphically through ftp software then it will list... (1 Reply)
Discussion started by: punpun66
1 Replies

3. UNIX for Advanced & Expert Users

How to generate graph in unix?

Hi Friends, I need to generate a graph in on the basis of data available in csv file in unix. Please let me know how to generate the graph. Thanks Mayank (4 Replies)
Discussion started by: mayank2211
4 Replies

4. Shell Programming and Scripting

Unix random number generate in given range

Hi All, I have extracted some report from database for few activities done. Now I have a requirement to add some random time(In range of 10-35) in front of each activity. Can be generated random numbers in any bash/sh shell within a given number range, let's say in between 10-30. ... (10 Replies)
Discussion started by: gr8_usk
10 Replies

5. Shell Programming and Scripting

Unix - Binary File

Hi All, I am newbie to this forum. I am also new to shell script world. I don't understand the below shell script. File Name: sendFile.sh #!/bin/bash # # This script invokes the Connect:Direct UNIX CLI # and submits a process inline to copy a file to a remote # node. # $1 is... (3 Replies)
Discussion started by: karthi
3 Replies

6. Shell Programming and Scripting

Generate a mail when you add info to a txt file

Hi, I have an application's log file: /var/log/logfile which is feeded from time to time due to an application. This file contains data, what I want is: -Whenever some new data is copied to /var/log/logfileI want to generate an email to root BUT only with the new added data in the body.... (6 Replies)
Discussion started by: iga3725
6 Replies

7. Programming

Generate a binary file using make

Hi, i am trying to create a makefile for my C++ program. when i say "make" it should generate the binary file. and when i say make clean, it should delete all the bins and libs. can u please help me out. (5 Replies)
Discussion started by: sunshine23
5 Replies

8. Shell Programming and Scripting

Editing Binary Files in Unix

Hi, Is there a way to edit BINARY files in Unix. Or even are there any commands (shellscript/perl) through which I can replace all the occurences of a string inside a BINARY file with another string ?? (1 Reply)
Discussion started by: cool.aquarian
1 Replies

9. Shell Programming and Scripting

Binary and hex in unix

not much familiar with binary and hex calculation in script programming.... explaination: binary format control the parameter turned on or off in the program stored in hex mode, the question is: how to change 39e to 19e using the binary calculation(although i don't know the command for... (2 Replies)
Discussion started by: trynew
2 Replies

10. UNIX for Dummies Questions & Answers

UNIX PATH info required PLEASE HELP (I'm new to unix)

I need to know how to enter a unix path in a cgi script for a guest book: example: My URL is http://www.kitachi.info I have an html file in the main folder on my site, the file is called : gbook.html what would the correct unix path for this file be ??? the part of the script... (1 Reply)
Discussion started by: akitachi
1 Replies
Login or Register to Ask a Question