Compiling and linking kernel symbols wiith GCC

Compiling and linking kernel symbols wiith GCC

Post by Rick Hunnicut » Thu, 26 Apr 2001 01:11:01



I'm trying to compile a device driver using a new install of GCC 2.95.3 on
Solaris 2.6. ld is returning an error because it cannot resolve any of the
kernel symbols (like the ddi_ calls). I have -D_KERNEL defined to gcc but
doesn't help with ld. If I take it out, then gcc has problems as well so I
know it's getting passed.

What am I missing? Any help is appreciated.

TIA,
Rick

 
 
 

Compiling and linking kernel symbols wiith GCC

Post by Bruce Adle » Thu, 26 Apr 2001 04:06:55



> I'm trying to compile a device driver using a new install of GCC 2.95.3 on
> Solaris 2.6. ld is returning an error because it cannot resolve any of the
> kernel symbols (like the ddi_ calls). I have -D_KERNEL defined to gcc but
> doesn't help with ld. If I take it out, then gcc has problems as well so I
> know it's getting passed.

Using gcc to compile a device driver isn't actually supported by
Solaris. But if you know your way around gcc you can probably
make it work. If you were using Sun's (supported) C compiler, the
documented command line is in the WDD:


You're probably not including any of the ld options. Even after
you fix that you might then have problems with a few gcc generatated
function calls that don't happen when using Sun's compiler and
therefore won't be resolved by the kernel's runtime linker.

 
 
 

Compiling and linking kernel symbols wiith GCC

Post by Piotr Kucharsk » Thu, 26 Apr 2001 05:00:00



> http://docs.sun.com/ab2/coll.45.13/DRIVER/

Perhaps you know more pages about that subject? I couldn't
trace down, what's wrong with my (really simple) kernel
module (which btw, compiled fine under gcc and suncc).

p.

 
 
 

Compiling and linking kernel symbols wiith GCC

Post by Rick Hunnicut » Thu, 26 Apr 2001 07:45:22


I think I'm missing some basic component here. I have an "ld -r -o xxx.o
xxx" in my makefile but I verified it's not getting called. ld is getting
called under the "xxx.o" rule.

.....

That's it! I was missing the -c option which tells gcc not to link! Then the
ld command did it's thing and I have my module!

Thank you, thank you all! I appreciate your inputs!



> > http://docs.sun.com/ab2/coll.45.13/DRIVER/

> Perhaps you know more pages about that subject? I couldn't
> trace down, what's wrong with my (really simple) kernel
> module (which btw, compiled fine under gcc and suncc).

> p.

 
 
 

Compiling and linking kernel symbols wiith GCC

Post by Casper H.S. Dik - Network Security Engine » Thu, 26 Apr 2001 16:41:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>This lists, beside others, e.g.
>  cc -D_KERNEL -xO3 xx1.c                                   # 32 bit
>  cc -D_KERNEL -xcg92 -xarch=v9 -xcode=abs32 -xO3 -c xx1.c  # 64 bit SPARC

>whereas "Notes on 64-bit Drivers and STREAMS -- A White Paper" lists:
>  cc -D_KERNEL -xarch=v9 -xcode=abs32 -xregs=no%appl -xO3 -c xx1.c  # 64 bit
>I wonder if -xregs=no%appl is required (Sun seems to use it even
>for the 32 bit kernel and for shared libraries) whose gcc equivalent
>seems to be -mno-app-regs.

-xregs=no%appl is not strictly required, but initial versions of
the Solaris 7 64 bit kernel woudl balk at the "REGSYMS" this generated
for global register usage.

In the 64 bit ABI, some global registers have been assigned for application
use; when the compiler generates them in code, it will output a "REGSYM"
telling the linker how it was used.  The linker can then flag conflicting
usage.

The -xregs=no%appl is *required* for libraries.  Libraries are not allowed
to use those global registers as they are "application reserved.

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.

 
 
 

Compiling and linking kernel symbols wiith GCC

Post by Bruce Adle » Thu, 26 Apr 2001 19:39:13




> > http://docs.sun.com/ab2/coll.45.13/DRIVER/

> Perhaps you know more pages about that subject? I couldn't
> trace down, what's wrong with my (really simple) kernel
> module (which btw, compiled fine under gcc and suncc).

No, I don't know of any pages that discuss using gcc to
compile kernel modules. I only know of pages that describe
how to use Sun's C compiler (all of which say effectively
the same thing as the link I already quoted).

Regardless, you're unlikely to make any progress unless
you include details about your particular problem.

 
 
 

Compiling and linking kernel symbols wiith GCC

Post by John D Groenve » Fri, 27 Apr 2001 01:17:20


Joerg Schilling's cdrecord and friends, http://www.cdrecord.org/
Andreas Maier's ANDIrand, http://www.cosy.sbg.ac.at/~andi/
Darren Reed's ipfilter, http://www.ipfilter.org/
Phillip Brown/Juergen Keil's sbpci, http://www.bolthole.com/solaris/sbpci/

Lots of examples of kernel modules which build with gcc.
John

 
 
 

1. gcc error 11 compiling kernel (gcc 2.7.0)

does anyone have a clue as to what
would possibly cause random error=11
messages when compiling the kernel (1.3.100,
2.0.9, 2.0.10) on my machine (Pentium 100 with
64 megs of EDO RAM - 430FX chipset, Adaptec
2940)... This machine runs fine with FreeBSD 2.1.5

I'm using gcc 2.7.0

--
Larry Snyder      Internet Access Group, Inc.

407-786-1145      Speeds from T3 to 28.8 including ISDN dialup
800-380-4IAG      ISDN dialup pool available TODAY!

2. grep freezes?

3. kernel compiling problems--kernel symbols not found

4. ftpd stops connecting few mins after xinetd restart ?!?

5. Problems linking gcc/sun : Undefined Symbol

6. using remote tape drive..

7. GCC linking unused symbols

8. extracting lvm-commands from current volume-config

9. HELP: GCC compiling error - "could not read symbols"

10. Duplicate symbol warnings when compiling shared library using gcc

11. gcc compile error: could not read symbols: Bad value

12. numerous undefined symbols while linking kernel

13. Kernel Extension link-editor duplicate symbol warnings