public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* Re: Re: [ECOS] how to build a driver to a single library
@ 2005-07-19  1:01 Tianjun - zdk
  2005-07-19  7:15 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Tianjun - zdk @ 2005-07-19  1:01 UTC (permalink / raw)
  To: ecos-discuss

Hi,Andrew 

  so i should not to linked the library to extras.o?
and just to generate a libarery mylib.a use my favourite name?
and then use this command to link it in my Application

	compile  -lmylib mylib.a application.c

  can this working?


Sincerely yours,
Tian-Jun

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 >On Mon, Jul 18, 2005 at 04:19:06PM +0800, ZDC 0616 tianjun wrote:
>> hi, all
>> 
>> how to build a driver to a single library ,and can link it as : ecos + driver + app ?
>> and now i have built it in the ecos library ,i want to then  separate .
>
>Just so i understand you correctly:
>
>You have written a device driver which is currently part of the eCos
>tree. You now want to seperate it from the eCos tree into a library of
>its own. You then want to link this library with your application.
>
>OK. Nothing impossible here, but there is one thing to be careful of.
>
>Anyway, build your device driver library just like an eCos
>application, but instead of linking it to eCos just use ar to create a
>library from the object file. There is nothing special needed, so just
>look at normal examples for building libraries.
>
>To link the libarary to the application and eCos just add -lmylib to
>the command line when linking. ie nothing special or magical needed.
>
>OK, now the thing to be careful of. When building a device driver
>within the eCos tree there is normally a cdl option: 
>
>  compile       -library=libextras.a   foobar.c
>
>ie the object file is put into the library libextras.a not the normal
>libtarget.a. At the end of the build process libextras.a is linked to
>extras.o and this is then linked to your application, not
>libextras.a. This is becasue the linker throws away any symbols not
>referenced in libraries. Normally there is no reference to a device
>driver because of the use of linker tables. So if the device driver
>was inside a library it would not be pulled into the final application
>executable. 
>
>For your device driver in your library you cannot use the same
>trick. So instead your application must reference something in the
>device driver so that it is pulled in. Typically a device driver has a
>DEVTAB_ENTRY, eg
>
>DEVTAB_ENTRY(ebsa285_serial_io,
>             CYGDAT_IO_SERIAL_ARM_EBSA285_SERIAL_NAME,
>             0,                     // Does not depend on a lower level interface
>             &cyg_io_serial_devio,
>             ebsa285_serial_init,
>             ebsa285_serial_lookup,     // Serial driver may need initializing
>             &ebsa285_serial_channel
>    );
>
>Doing something like:
>
>  extern cyg_devtab_entry_t *ebsa285_serial_io;
>  ebsa285_serial_io = ebsa285_serial_io;
>
>will probably be enought.
>
>        Andrew
>
>-- 
>Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
>and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [ECOS] how to build a driver to a single library
  2005-07-19  1:01 Re: [ECOS] how to build a driver to a single library Tianjun - zdk
@ 2005-07-19  7:15 ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2005-07-19  7:15 UTC (permalink / raw)
  To: Tianjun - zdk; +Cc: ecos-discuss

On Tue, Jul 19, 2005 at 09:01:28AM +0800, Tianjun - zdk wrote:
> Hi,Andrew 
> 
>   so i should not to linked the library to extras.o?
> and just to generate a libarery mylib.a use my favourite name?
> and then use this command to link it in my Application
> 
> 	compile  -lmylib mylib.a application.c
> 
>   can this working?

There is no need to link your library to extras.o. Just link your
application with the library as normal, eg something like

    arm-elf-gcc -o foobar application.o -lmylib -nostartfiles  -Ttarget.ld

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [ECOS] how to build a driver to a single library
  2005-07-19  1:15 Tianjun - zdk
@ 2005-07-19  7:19 ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2005-07-19  7:19 UTC (permalink / raw)
  To: Tianjun - zdk; +Cc: ecos-discuss

On Tue, Jul 19, 2005 at 09:14:47AM +0800, Tianjun - zdk wrote:
> >For your device driver in your library you cannot use the same
> >trick. So instead your application must reference something in the
> >device driver so that it is pulled in. Typically a device driver has a
> >DEVTAB_ENTRY, eg
> >
> >DEVTAB_ENTRY(ebsa285_serial_io,
> >             CYGDAT_IO_SERIAL_ARM_EBSA285_SERIAL_NAME,
> >             0,                     // Does not depend on a lower level interface
> >             &cyg_io_serial_devio,
> >             ebsa285_serial_init,
> >             ebsa285_serial_lookup,     // Serial driver may need initializing
> >             &ebsa285_serial_channel
> >    );
> >
> >Doing something like:
> >
> >  extern cyg_devtab_entry_t *ebsa285_serial_io;
> >  ebsa285_serial_io = ebsa285_serial_io;

This is effectively a nop, a no operation. But the compiler will do
it, so forcing a reference to the symbol ebsa285_serial_io. This means
the linker is forced to include the symbol in the application.

You want to do something similar with your driver otherwise the link
may decide to not include it in the application.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [ECOS] how to build a driver to a single library
@ 2005-07-19  1:15 Tianjun - zdk
  2005-07-19  7:19 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Tianjun - zdk @ 2005-07-19  1:15 UTC (permalink / raw)
  To: ecos-discuss, Andrew Lunn

Hi, Andrew Lunn

    i have understood you very correctly.
but i also have a doubt:
	what this `ebsa285_serial_io = ebsa285_serial_io;'means?
why can i do that ?and they have the same name . 

Sincerely yours,
Tian-Jun

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 >On Mon, Jul 18, 2005 at 04:19:06PM +0800, ZDC 0616 tianjun wrote:
>> hi, all
>> 
>> how to build a driver to a single library ,and can link it as : ecos + driver + app ?
>> and now i have built it in the ecos library ,i want to then  separate .
>
>Just so i understand you correctly:
>
>You have written a device driver which is currently part of the eCos
>tree. You now want to seperate it from the eCos tree into a library of
>its own. You then want to link this library with your application.
>
>OK. Nothing impossible here, but there is one thing to be careful of.
>
>Anyway, build your device driver library just like an eCos
>application, but instead of linking it to eCos just use ar to create a
>library from the object file. There is nothing special needed, so just
>look at normal examples for building libraries.
>
>To link the libarary to the application and eCos just add -lmylib to
>the command line when linking. ie nothing special or magical needed.
>
>OK, now the thing to be careful of. When building a device driver
>within the eCos tree there is normally a cdl option: 
>
>  compile       -library=libextras.a   foobar.c
>
>ie the object file is put into the library libextras.a not the normal
>libtarget.a. At the end of the build process libextras.a is linked to
>extras.o and this is then linked to your application, not
>libextras.a. This is becasue the linker throws away any symbols not
>referenced in libraries. Normally there is no reference to a device
>driver because of the use of linker tables. So if the device driver
>was inside a library it would not be pulled into the final application
>executable. 
>
>For your device driver in your library you cannot use the same
>trick. So instead your application must reference something in the
>device driver so that it is pulled in. Typically a device driver has a
>DEVTAB_ENTRY, eg
>
>DEVTAB_ENTRY(ebsa285_serial_io,
>             CYGDAT_IO_SERIAL_ARM_EBSA285_SERIAL_NAME,
>             0,                     // Does not depend on a lower level interface
>             &cyg_io_serial_devio,
>             ebsa285_serial_init,
>             ebsa285_serial_lookup,     // Serial driver may need initializing
>             &ebsa285_serial_channel
>    );
>
>Doing something like:
>
>  extern cyg_devtab_entry_t *ebsa285_serial_io;
>  ebsa285_serial_io = ebsa285_serial_io;
>
>will probably be enought.
>
>        Andrew
>
>-- 
>Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
>and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-07-19  7:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-19  1:01 Re: [ECOS] how to build a driver to a single library Tianjun - zdk
2005-07-19  7:15 ` Andrew Lunn
2005-07-19  1:15 Tianjun - zdk
2005-07-19  7:19 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).