Solved

KVM on Solaris 8 (64bit OS)

Posted on 2002-06-13
17
386 Views
Last Modified: 2013-12-20
Hi,

I'm writing a code on Solaris 8 OS to scaning the process environment area using the following code:
========================================================
  if (!(kd = kvm_open(NULL, NULL, NULL, O_RDONLY, argv[0]))) {
            perror("kvm_open");  
            exit(1);
         }

         kvm_setproc(kd);
         fndarg=0;cnt=0;
         while ((pCurProc = kvm_nextproc(kd)) != NULL)
         {
           if((pUsrEnv = kvm_getu(kd, pCurProc))!=NULL)
           {
             kvm_getcmd(kd, pCurProc, pUsrEnv, &usrArg,&env);
             sprintf(sbuf,"ppid=[%d]",pCurProc->p_ppid);
             strcpy(abbuf[cnt],usrArg[0]);
             strcat(abbuf[cnt],sbuf);
           }  
           ++cnt;
         }
         
   kvm_close(kd);
=======================================================


this code works on Sol2.6 but doesn't work in Sol 8   (sun4u sparc SUNW,Ultra-5_10).
I got an error of:
# ./procenv
./procenv: /dev/ksyms is not a 32-bit kernel namelist

I'm also using the following command line to compile:
gcc -o procenv procenv.c -lkvm

My question is:

How can I make this code run on Sol 8 or what are the compile option to use to make this code run of Sol 8.

Thanks in advance


 
0
Comment
Question by:nsum
  • 8
  • 6
  • 3
17 Comments
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
you need a libkvm.a or libkvm.so for 64-bit support, check with:

   find /usr/lib -name libkvm\*
   find /lib -name libkvm\*
0
 

Author Comment

by:nsum
Comment Utility
Hi ahoffmann,

Thanks for you prompt response. There is a 64-bit libkvm (I believe) under /usr/lib/64 but how can I point to this library during compilation. I have already tried using the option -L /usr/lib/64. Sorry I forgot to include in my question that I have looked and tried the /usr/lib/64/lib's

regards,
nsum





0
 

Author Comment

by:nsum
Comment Utility
Hi ahoffmann,

Thanks for you prompt response. There is a 64-bit libkvm (I believe) under /usr/lib/64 but how can I point to this library during compilation. I have already tried using the option -L /usr/lib/64. Sorry I forgot to include in my question that I have looked and tried the /usr/lib/64/lib's

regards,
nsum





0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
should work like this:

   gcc -o procenv procenv.c -L /usr/lib/64 -lkvm

or if it fails, try using lib exxplicitely:

   gcc -o procenv procenv.c /usr/lib/64/libkvm.a
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
The fast way to verifile the kvms are there or not, use:

pkginfo | grep kvm

you should see something like
   SUNkvm SUNkvmx as output.

than try ahoffmann's example above
0
 

Author Comment

by:nsum
Comment Utility
I've tried
gcc -o procenv procenv.c -L /usr/lib/64 -lkvm
and
gcc -o procenv procenv.c -L /usr/lib/sparcv9 -lkvm
in the first place.  BTW /usr/lib/64 is linked to /usr/lib/sparcv9.

I can't find /usr/lib/64/libkvm.a
Is there other way?

Thanks in advance
nsum
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
Sun does not ship a libkvm.a library. Theoretically, you could obtain the Solaris 8 source code and build your own libkvm.a for linking.

0
 

Author Comment

by:nsum
Comment Utility
There should be other way to compile using the /usr/lib/64/libkvm.  
Or do I need to change my "gcc" version I believe I'm using
gcc 2.7.2.1.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
> .. There is a 64-bit libkvm (I believe) under /usr/lib/64  ..
and what's the name of it?
use it as parameter to the gcc command as suggested before

IT#s a library, not a gcc problem.
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
there is a libkvm.so in /usr/lib/64
0
 

Author Comment

by:nsum
Comment Utility
I believe I've tried that before, here's the summary what I've already tried (But still didn't work):

1.) gcc -o procenv procenv.c -L /usr/lib/64 -lkvm
2.) gcc -o procenv procenv.c -L /usr/lib/sparcv9 -lkvm
3.) gcc -o procenv procenv.c /usr/lib/64/libkvm.a (no libkvm.a )
4.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so.1 5.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
does this mean that they all produce the same error?
Then there is probably something wrong with the libs.
0
 

Author Comment

by:nsum
Comment Utility
Sorry I have not given a little detailed:

1.) gcc -o procenv procenv.c -L /usr/lib/64 -lkvm
   error: Compilation OK, But will not work (
                 ./procenv: /dev/ksyms is not a 32-bit kernel namelist)

2.) gcc -o procenv procenv.c -L /usr/lib/sparcv9 -lkvm
    error: the same as number 1 result

3.) gcc -o procenv procenv.c /usr/lib/64/libkvm.a (no libkvm.a )
    error: libkvm.a not found, compilation not done.

4.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so.1
    error: Will not compile, lot of errors during compilation.

5.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so
     error: the same as number 4 result

6.) gcc -o procenv procenv.c -m64 -lkvm
      error: gcc -m64 -L /usr/lib/64 -lkvm -o procenv procenv.c
cc1: -m64 is not supported by this configuration
cc1: -mptr32 not allowed on -m64

I have also installed the GCC 3.1 just incase it will work (still the same problem) even I know that the problem is the lib. I'm already lost, I don't know what to do.
If only there's other way to compile using gcc and produce a 64bit executable.

I'll increase the points to 300
Please help I'm stack with this problem for days....

Regards,
nsum
0
 

Author Comment

by:nsum
Comment Utility
Sorry I have not given a little detailed:

1.) gcc -o procenv procenv.c -L /usr/lib/64 -lkvm
   error: Compilation OK, But will not work (
                 ./procenv: /dev/ksyms is not a 32-bit kernel namelist)

2.) gcc -o procenv procenv.c -L /usr/lib/sparcv9 -lkvm
    error: the same as number 1 result

3.) gcc -o procenv procenv.c /usr/lib/64/libkvm.a (no libkvm.a )
    error: libkvm.a not found, compilation not done.

4.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so.1
    error: Will not compile, lot of errors during compilation.

5.) gcc -o procenv procenv.c /usr/lib/sparcv9/libkvm.so
     error: the same as number 4 result

6.) gcc -o procenv procenv.c -m64 -lkvm
      error: gcc -m64 -L /usr/lib/64 -lkvm -o procenv procenv.c
cc1: -m64 is not supported by this configuration
cc1: -mptr32 not allowed on -m64

I have also installed the GCC 3.1 just incase it will work (still the same problem) even I know that the problem is the lib. I'm already lost, I don't know what to do.
If only there's other way to compile using gcc and produce a 64bit executable.

I'll increase the points to 300
Please help I'm stack with this problem for days....

Regards,
nsum
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 300 total points
Comment Utility
hmm, sounds to me that gcc does not produce compatible code for Sun's 64-bit libs.
Can you use Sun's bundled cc and ld?
Otherwise you have to find a propper compiler (gcc 3.1), sorry I have no experiance abozt "propper".
0
 

Author Comment

by:nsum
Comment Utility
I don't have bundled cc intalled.. I thnk I have to hold this question  until I find other options. Anyway, I'll accept these comments of ahoffmann for an answer for now.

Thanks everybody
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
Thanks.
Feel free to com e back on this question if you need ..
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now