Solved

KVM on Solaris 8 (64bit OS)

Posted on 2002-06-13
17
391 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
ID: 7075096
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
ID: 7075106
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
ID: 7075109
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
ID: 7075155
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
ID: 7077002
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
ID: 7077052
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
ID: 7077531
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
ID: 7077749
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 7077817
> .. 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
ID: 7078329
there is a libkvm.so in /usr/lib/64
0
 

Author Comment

by:nsum
ID: 7082904
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
ID: 7083283
does this mean that they all produce the same error?
Then there is probably something wrong with the libs.
0
 

Author Comment

by:nsum
ID: 7084741
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
ID: 7084743
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
ID: 7086534
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
ID: 7091505
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
ID: 7091659
Thanks.
Feel free to com e back on this question if you need ..
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sumNumber challenge 16 111
withoutTen challenge 14 100
Correct syntax to upload file in a script using sftp 2 74
unix example issues 18 75
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

920 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

16 Experts available now in Live!

Get 1:1 Help Now