Re: Develop an assembler module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 23, 2005 at 07:16:02PM +0200, Jan Hudec wrote:
> On Tue, Aug 23, 2005 at 18:23:23 +0200, Garcia Jérémie wrote:
> > So how do I have to compile the module file (.c) and the assembler file (.S) : separatly or not? with what compile options?
> > Cause if I declare in my "module.c" the assembler function as "extern" how the link is done?
> > Please give some clues cause I do not have much time to achieve this...
> 
> Gcc compiles C to assembly. From which point they are both treated the same.
> 
> Now each assembly is assembled to object separately. It is always the case,
> even if you call gcc with multiple source arguments. So there is no question
> there.
> 
> The options are the same as when compiling C. Some options could be omitted,
> as they apply to the compilation proper, but gcc will ignore them if you pass
> them, so you can just pass the same options to all sources.
> 
> As they are different sources, you need to declare symbols you need from the
> other as extern. Note, that extern on function declaration has no effect, as
> function declarations are extern by default.
> 
> There is a bunch of assembly sources in kernel sources, in the arch
> directory, so have a look how the kernel Makefile handles them and how the
> symbols from them are accessed.

Also note that using assembly in drivers is a *very* bad idea cause it
makes the code non-portable. Until two years ago you could blissfully
ignore this and think "all the world is a 386", but with the number of
x86_64 machines growing every day this is no longer true. Face it,
Athlon64 machines are a reality.

Right now there are exactly *four* drivers that have an assembly part,
but all those drivers are for hardware that's intimately tied to a
certain architecture. Unless the OP has such hardware, there's no
reason to write a (part of a) driver in assembly.


Erik

-- 
Erik Mouw
J.A.K.Mouw@xxxxxxxxxxxxxx  mouw@xxxxxxxxxxxx

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux