Yes, .o is a compiled but not linked program. There are a number of
compilers for various languages that will spit out a .o file.
You can't open them; they're not functional programs, merely the pieces
of one. You can find out what functions it contains using 'nm'. ie:
nm object.o
--
Brandon Hume - hume -> BOFH.Ca, http://WWW.BOFH.Ca/
Thanks for your reply . Can you please let me know how can I get help
on one of the functions it contain ?
Regards
Thanks for your reply . I want to try for my own . My server is
Solaris 8 and the target is running VxWorks 5.4.2 . Can you please let
me know what application packages do I need to install on my Solaris 8
to do the job ? I want to write my own function and put it inside
the .o compiled file and upload to the target to run.
You can't do that unless you have the original source file.
--
Ian Collins
Thank you for your help. I do not want to replace one of the functions
inside the original *.o file but rather want to try to write my own
sample code with a few functions inside. Actually , I want to replace
the original *.o file with my own compiled code . I need to know which
application packages I need to have on my Solaris 8 server to produce
the same *.o file format ,since my VxWorks target just reads *.o
executable files in his /compile/ppc folder . Please give me a hint on
this .
If you are cross-compiling for a VxWorks target, you need the
appropriate vendor tools. You should check with them.
--
Ian Collins
Thank you for your comment . But generally speaking , can you please
let me know which Solaris 8 compilers do produce *.o compiled file
output ?
Thank you for your reply . I checked on my Solaris 8 server for the
compiler packages :
bash-2.03# pkginfo |grep Compiler
system SUNWlibC Sun Workshop Compilers
Bundled libC
system SUNWmfdev Motif UIL Compiler
system SUNWscbcp SPARCompilers Binary
Compatibility Libraries
So it seems that I have SUN compilers installed . Can you please let
me know how can I make use of them to compile my C++ code into *.o
file ?
> they're GNU/open source. With Solaris 8, you're limited to the GNU
> compilers unless you bought the Sun compilers.
Sun Studio 11 runs on Solaris 8, and is free. You can still download it
from Sun^WOracle.
--
Chris
> So it seems that I have SUN compilers installed . Can you please let
> me know how can I make use of them to compile my C++ code into *.o
> file ?
Try reading the C++ compiler manual. Search docs.sun.com for "sun studio".
--
Chris
>Thank you for your reply . I checked on my Solaris 8 server for the
>compiler packages :
>bash-2.03# pkginfo |grep Compiler
>system SUNWlibC Sun Workshop Compilers Bundled libC
>system SUNWmfdev Motif UIL Compiler
>system SUNWscbcp SPARCompilers Binary Compatibility Libraries
>So it seems that I have SUN compilers installed . Can you please let
>me know how can I make use of them to compile my C++ code into *.o
>file ?
No, you're not; the three packages listed are the runtime packages
(plus the *motif* compiler).
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
All of them! That's what compilers do!
A C compiler is readily available. I've never tried to find Fortran for
Solaris but it's possible, even probable, that a Fortran compiler
exists. A BASIC interpreter may be available somewhere but I couldn't
say where.
Can you please let me know which other commands (like nm) can be used
to bring out useful information from the *.o compiled object file ?
>Can you please let me know which other commands (like nm) can be used
>to bring out useful information from the *.o compiled object file ?
nm will give you the best info you are going to get out of it.
dis may be helpful if you understand assembly language that the source
is actually assembled into before the assembler takes over and creates
the .o file, but then you'll have to reverse engineer what the code is doing.
Unless you have alot of time to reverse engineer, its usually quicker
and easier to rewrite everything from scratch. It takes quite a
special person to be able to do reverse engineering and get something usable.
The .o file has the minimal information left needed to get everything
into a program, this is not a file format that is close to the
original source, this is a file that is bare-bones machine level in
order to get a program to run on the machine.
> In article
> <4db6d75a-6a24-43e1...@d27g2000yqn.googlegroups.com>,
> hadi motamedi <motam...@gmail.com> wrote:
>
>> Can you please let me know which other commands (like nm) can be used
>> to bring out useful information from the *.o compiled object file ?
>
> .o files aren't intended for human use. They're for a link-editor (ld)
> to create a running program. AFAIK, nm is it.
/usr/ccs/bin/elfdump will also extract information from .o files.
--
Chris
Thanks for your reply . I found the 'dis' is very helpful . But how
can I extract the assembly language code by using it ?
I tried to install the gcc on my Solaris 8 , as the followings :
%gunzip gcc-3.2.2-sol8-sparc-local.gz |tar xvf –
%pkgadd –d gcc-3.2.2-sol8-sparc-local.pkg
But at the end , my Solaris 8 server returned as 'gcc command not
found' . Can you please let me know how can I make use of it ?
Thank you
Sorry to forgot to mention this :
During the package installation , it returned as 'The following files
are already installed on the system - conflict with a file - Do you
want to install these conflicting files?'
I answered as 'n' . Can you please let me know if it has caused this
problem to occur?
Thank you
Set your PATH to include the directory that package put gcc in. If that
package is from sunfreeware.com, I think it'll need /usr/local/bin.
--
Chris
Thank you very much . It got through . OR using full path name for the
gcc command.
What "useful information" are you looking for. A binary object file is
not well stocked with "information". It is usually input to the linker
where it is linked with other modules and library routines to form an
executable binary; e.g. a program that you can execute.
What exactly are you trying to accomplish? Is this all just a learning
exercise?
It DOES have a little of the flavor of a student trying to fish someone
into doing his homework for him. . . .
The output of dis *is* the assembly language code. Thats as human
readable as you are going to get.
> I tried to install the gcc on my Solaris 8 , as the followings :
> %gunzip gcc-3.2.2-sol8-sparc-local.gz |tar xvf ?
> %pkgadd ?d gcc-3.2.2-sol8-sparc-local.pkg
> But at the end , my Solaris 8 server returned as 'gcc command not
> found' . Can you please let me know how can I make use of it ?
> Thank you
It sounds like you need to pick up a good 'intro to Unix' book.
Also, start reading here:
http://docs.sun.com/app/docs/prod/solaris.8?l=en&a=view
Thanks for your reply . But the output of my 'dis mss.o' is like the
followings :
"38a8: 41 86 00 24 ???
38ac: 3d 20 00 00 ???
38b0: 39 69 00 00 ???
38b4: 80 6b 00 00 ???
38b8: 48 00 00 01 ???
38bc: 3d 20 00 00 ???
38c0: 39 69 00 00 ???
38c4: 38 00 ff ff ???
38c8: 90 0b 00 00 ???
38cc: 3d 20 00 00 ???
38d0: 39 69 00 00 ???
38d4: 80 0b 00 00 ???
38d8: 39 20 ff ff ???
38dc: 7c 80 48 00 ???
38e0: 41 86 00 24 ???
38e4: 3d 20 00 00 ???
38e8: 39 69 00 00 ???
38ec: 80 6b 00 00 ???
38f0: 48 00 00 01 ???
38f4: 3d 20 00 00 ???
38f8: 39 69 00 00 ???
38fc: 38 00 ff ff ???"
Can you please let me know why this is not readable in my case ?
This part of the file looks like it is just raw data. Could be
constants needed for operation, could be static pointers. Could static
ints, could be anything. .o files have both code and data in them.
Without reverse engineering the whole code, you'll never know. All the
structured information about it is gone by the time its an .o file. By
that level, the assembly language earlier on in the listing will be
referencing the data by raw data location.
It also could be that the .o file you have is for a different
architecture than what you are running on now. Ie. i386 code is
slightly different than x64, which is alot different than SPARC code,
is alot different than PPC code, is alot different than HP/PA code.
If you do have a PPC based .o file on an i386 box, there are other
tools to disassemble it, it could just be raw data as well that makes
no sense in any context.
Again, what are you trying to do? Where did you get this file? People
would be able to help you better if they could be sure this wasn't some
random file you accidentally downloaded.
Thank you for your reply . I have an SPARC Sun Solaris 8 platform that
will load the mss.o object file on an VxWork 5.2 target . According to
the 'nm mss.o' output , it contains the SS7 function that I want to
slightly modify it to accomodate with the new third party network
element received . To this end , I tried for 'dis mss.o' but as you
see the output is not readable . Can you please correct me ?
>Thank you for your reply . I have an SPARC Sun Solaris 8 platform that
>will load the mss.o object file on an VxWork 5.2 target . According to
>the 'nm mss.o' output , it contains the SS7 function that I want to
>slightly modify it to accomodate with the new third party network
>element received . To this end , I tried for 'dis mss.o' but as you
>see the output is not readable . Can you please correct me ?
Reverse engineering code from compiled object files takes a special
person that has a knack for it. Even so, it'll take longer by far to
reverse engineer from raw data back into usable code than it would
take to just write a new version from scratch.
What you are trying to acomplish isn't the right way to go about it,
there is nothing easy about what you are trying to do, learning how
the original module works and rewriting it from scratch would be easier.