Problem in loading a 64 bit driver using GCC on Solaris 8

Problem in loading a 64 bit driver using GCC on Solaris 8

Post by Kirti Khandelw » Fri, 02 May 2003 20:03:49



Hi,

I am trying to create a 64 bit driver on Solaris 8

If  I use cc compiler with options "-xarch=v9 -xregs=no%appl", then I am
able to successfully create the driver, add and attach it to the system

But if I use gcc compiler with options
"-mcpu=v9 -mtune=ultrasparc -m64 -mno-app-regs", I am able to create the
driver. But on loading the driver using add_drv, it bombs.

if I do "dmesg", I am getting the following errors:
May  1 15:17:18 ipksun09 krtld: [ID 995402 kern.notice]
/usr/kernel/drv/sparcv9/oe: undefined symbol 'memcpy'
May  1 15:17:18 ipksun09 krtld: [ID 472681 kern.notice] WARNING: mod_load:
cannot load module 'oe'

May be, I am not using the correct combination of the gcc SPARC machine
dependent options.

Any idea how to fix this ??

Regards,
Kirti Khandelwal
Infosys Technologies Ltd.
Bangalore

 
 
 

Problem in loading a 64 bit driver using GCC on Solaris 8

Post by Rich Tee » Sat, 03 May 2003 00:37:54



Quote:> If  I use cc compiler with options "-xarch=v9 -xregs=no%appl", then I am
> able to successfully create the driver, add and attach it to the system

> But if I use gcc compiler with options
> "-mcpu=v9 -mtune=ultrasparc -m64 -mno-app-regs", I am able to create the
> driver. But on loading the driver using add_drv, it bombs.

Essentially, gcc's 64-bit support is, umm, not that good.  I
wouldn't use if for kernel driver, or ANY commercial 64-bit
application.

Quote:> Any idea how to fix this ??

Use Sun's compiler.

--
Rich Teer, SCNA

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net

 
 
 

Problem in loading a 64 bit driver using GCC on Solaris 8

Post by Richard L. Hamilt » Sat, 03 May 2003 07:55:25




Quote:> Hi,

> I am trying to create a 64 bit driver on Solaris 8

> If  I use cc compiler with options "-xarch=v9 -xregs=no%appl", then I am
> able to successfully create the driver, add and attach it to the system

> But if I use gcc compiler with options
> "-mcpu=v9 -mtune=ultrasparc -m64 -mno-app-regs", I am able to create the
> driver. But on loading the driver using add_drv, it bombs.

I've done ok with -D_KERNEL -m64 -mno-app-regs; do _not_ use flags for pic
(won't work); ipfilter also uses -mcmodel=medlow, but I've never needed it
for stuff I wrote.  You may also want -fno-builtin to avoid conflicts
between gcc builtins and stuff appearing in a header file or elsewhere.
And of course you have a -c in there to get one or more .o files; once you
have them, you produce a relocatable with

ld -r *.o -o driver

[...]

But you would be better off using Sun's compiler; I really wouldn't
recommend gcc as particularly safe for 64-bit SPARC; I'm not sure the
code it generates for that is all that reliable (or efficient).

--

 
 
 

Problem in loading a 64 bit driver using GCC on Solaris 8

Post by Kirti Khandelw » Sat, 03 May 2003 21:52:23





> > Hi,

> > I am trying to create a 64 bit driver on Solaris 8

> > If  I use cc compiler with options "-xarch=v9 -xregs=no%appl", then I am
> > able to successfully create the driver, add and attach it to the system

> > But if I use gcc compiler with options
> > "-mcpu=v9 -mtune=ultrasparc -m64 -mno-app-regs", I am able to create the
> > driver. But on loading the driver using add_drv, it bombs.

> I've done ok with -D_KERNEL -m64 -mno-app-regs; do _not_ use flags for pic
> (won't work); ipfilter also uses -mcmodel=medlow, but I've never needed it
> for stuff I wrote.  You may also want -fno-builtin to avoid conflicts
> between gcc builtins and stuff appearing in a header file or elsewhere.
> And of course you have a -c in there to get one or more .o files; once you
> have them, you produce a relocatable with

> ld -r *.o -o driver

> [...]

> But you would be better off using Sun's compiler; I really wouldn't
> recommend gcc as particularly safe for 64-bit SPARC; I'm not sure the
> code it generates for that is all that reliable (or efficient).

gcc compiler with version 3.2.2 can generate 64 bit code. 3.2 and
below are not capable of that. I tried  using the -fno-builtin option,
but still was not able to load the drivers.
Then I tried adding -D_KERNEL option.....
while compiling with this option...I am facing issues like:

/bnr/gsmomc/3rdParty/nSDM/g++3.2/bin/gcc -w -m64 -mno-app-regs -c  
-I/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/inc
-I/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/inc/SL28_SPv9_SSap
-D_REENTRANT -D_SUN_TPI_VERSION=2 -D_KERNEL -DSOLARIS -DSOLARIS28
-DSSPARCv9 -DNOSCHEDD
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/oei/oei_fatal.c
In file included from /usr/include/sys/procset.h:120,
                 from /usr/include/signal.h:73,
                 from
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/inc/SL28_SPv9_SSap/oe_local.h:89,
                 from
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/oei/oei_fatal.c:10:
/usr/include/sys/proc.h:472: conflicting types for `signal'
/usr/include/iso/signal_iso.h:48: previous declaration of `signal'
In file included from
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/inc/SL28_SPv9_SSap/oe_local.h:89,
                 from
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/oei/oei_fatal.c:10:
/usr/include/signal.h:77: conflicting types for `sigsendset'
/usr/include/sys/procset.h:126: previous declaration of `sigsendset'

I am not sure whether this problem is occuring becos _POSIX_SOURCE
or _XOPEN_SOURCE or __STDC__.

This is the code in signal.h from where procset.h is getting called.

#if defined(__EXTENSIONS__) || (__STDC__ == 0 && \
        !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
#include <sys/procset.h>
extern int gsignal(int);
extern int (*ssignal(int, int (*)(int)))(int);
extern int sigsend(idtype_t, id_t, int);
extern int sigsendset(const procset_t *, int);
extern int sig2str(int, char *);
extern int str2sig(const char *, int *);
#define SIG2STR_MAX     32
#endif /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */

Do I need to use some sort of precompile option?
If anyone can help me doing this, it will be really great.

Regards,
Kirti Khandelwal

 
 
 

Problem in loading a 64 bit driver using GCC on Solaris 8

Post by Kirti Khandelw » Sat, 03 May 2003 22:19:59





> > Hi,

> > I am trying to create a 64 bit driver on Solaris 8

> > If  I use cc compiler with options "-xarch=v9 -xregs=no%appl", then I am
> > able to successfully create the driver, add and attach it to the system

> > But if I use gcc compiler with options
> > "-mcpu=v9 -mtune=ultrasparc -m64 -mno-app-regs", I am able to create the
> > driver. But on loading the driver using add_drv, it bombs.

> I've done ok with -D_KERNEL -m64 -mno-app-regs; do _not_ use flags for pic
> (won't work); ipfilter also uses -mcmodel=medlow, but I've never needed it
> for stuff I wrote.  You may also want -fno-builtin to avoid conflicts
> between gcc builtins and stuff appearing in a header file or elsewhere.
> And of course you have a -c in there to get one or more .o files; once you
> have them, you produce a relocatable with

> ld -r *.o -o driver

> [...]

> But you would be better off using Sun's compiler; I really wouldn't
> recommend gcc as particularly safe for 64-bit SPARC; I'm not sure the
> code it generates for that is all that reliable (or efficient).

Regarding the gcc compiler, version 3.2.1 and above are capable of
generating 64 bit code.

I tried using the -fno-builtin option, but it also doesnt seem to
work. I am trying to compile using -D_KERNEL flag.
But I am facing some of the issues:

/bnr/gsmomc/3rdParty/nSDM/g++3.2/bin/gcc -w -m64 -mno-app-regs -c  
-I/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/inc
-I/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/inc/SL28_SPv9_SSap
-D_REENTRANT -D_SUN_TPI_VERSION=2 -D_KERNEL -DSOLARIS -DSOLARIS28
-DSSPARCv9 -DNOSCHEDD -DNOSCHEDD  
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/oei/oei_fatal.c
In file included from /usr/include/sys/procset.h:120,
                 from /usr/include/signal.h:73,
                 from
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/inc/SL28_SPv9_SSap/oe_local.h:89,
                 from
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/oei/oei_fatal.c:10:
/usr/include/sys/proc.h:472: conflicting types for `signal'
/usr/include/iso/signal_iso.h:48: previous declaration of `signal'

In file included from
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/inc/SL28_SPv9_SSap/oe_local.h:89,
                 from
/nortel/proj/wireless/users/kirtikh/ftam/SunOs/test/oe/oei/oei_fatal.c:10:
/usr/include/signal.h:77: conflicting types for `sigsendset'
/usr/include/sys/procset.h:126: previous declaration of `sigsendset'
*** Error code 1

This is the code from signal.h where procset.h is getting included
#if defined(__EXTENSIONS__) || (__STDC__ == 0 && \
        !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
#include <sys/procset.h>
extern int gsignal(int);
extern int (*ssignal(int, int (*)(int)))(int);
extern int sigsend(idtype_t, id_t, int);
extern int sigsendset(const procset_t *, int);
extern int sig2str(int, char *);
extern int str2sig(const char *, int *);
#define SIG2STR_MAX     32
#endif /* defined(__EXTENSIONS__) || (__STDC__ == 0 ... */

I am not sure whether this is due to _POSIX_C_SOURCE or _XOPEN_SOURCE
or __STDC__. It looks as if _KERNEL and the _POSIX_C_SOURCE or
_XOPEN_SOURCE or __STDC__ doesnt go together.

Do I need to use the precompile option?
I am not sure as what to do for this. If anyone can throw some light
on this, it will be great.

Regards,
Kirti Khandelwal

 
 
 

Problem in loading a 64 bit driver using GCC on Solaris 8

Post by Joseph Reut » Sun, 04 May 2003 00:41:37



> Hi,

> I am trying to create a 64 bit driver on Solaris 8

> If  I use cc compiler with options "-xarch=v9 -xregs=no%appl", then I am
> able to successfully create the driver, add and attach it to the system

Most people recommend the Sun cc compiler. I _have_ written Solaris
drivers using gcc (32-bit). But I did encounter a "gotcha" or two.

Quote:> But if I use gcc compiler with options
> "-mcpu=v9 -mtune=ultrasparc -m64 -mno-app-regs", I am able to create the
> driver. But on loading the driver using add_drv, it bombs.

> if I do "dmesg", I am getting the following errors:
> May  1 15:17:18 ipksun09 krtld: [ID 995402 kern.notice]
> /usr/kernel/drv/sparcv9/oe: undefined symbol 'memcpy'

This is one of the gotchas. A driver is a relocatable object module
which is dynamically linked with the kernel. Thus, the only external
references that are permitted are those defined in the kernel. The
kernel defines printf(), so you can use it -- but its internals are
very different from the one in libc. The kernel does _not_ define
memcpy, so you can't use it!!! It does define the similar routine
bcopy(), which you can use.

Unfortunately, you may not have called memcpy yourself -- it may have
been generated by gcc, e.g. to copy one structure to another. If that
is the case, you have to figure out an alternate way of doing things
that does not generate the reference, or else include your own
definition of memcpy().

Quote:> May  1 15:17:18 ipksun09 krtld: [ID 472681 kern.notice] WARNING: mod_load:
> cannot load module 'oe'

> May be, I am not using the correct combination of the gcc SPARC machine
> dependent options.

> Any idea how to fix this ??

It's best to use the Sun compiler if you can. If you _must_ use gcc,
be prepared to learn more than you ever wanted to know about the SPARC
assembly code generated by gcc. And expect driver development to take
at least twice as long as you think it should.

Quote:

> Regards,
> Kirti Khandelwal
> Infosys Technologies Ltd.
> Bangalore

Joseph Reuter, Wizard-in-Training
 
 
 

1. Using gcc to build 64-bit device drivers on Solaris 8

I keep getting alignment errors from a basic  (i.e. empty) driver.
mdb indicates it's dying in the invocation of getinfo() during module
load.

I've tried this with:
- basic gcc 2.95.2
- various snapshots
- the egcs package on sunfreeware.com

All with the same basic result.

Has anyone succesfully built a 64 bit driver on solaris 8 with gcc?

Thanks

PJH

2. Strange syslogd messages

3. Loading driver on Solaris 8 64 bits

4. 3.2 Network Installation - problem

5. HALstation (64-bit processor running 64-bit Solaris) as webserver

6. [2.5][4/5] CPU Hotplug mm/

7. 32 bits drivers on 64 bits solaris

8. wireless hardware suggestions

9. How 32 bit driver can be ported to 64 bit driver?

10. 64-bit Solaris 7: wasn't Solaris 2.6 also 32-bit?

11. gcc 2.8.1 on Solaris 7 64 bits

12. gcc compiles 64-bit code on solaris?

13. 64-bit capable gcc-2.95 on Solaris 7