avr-gcc-list
[Top][All Lists]
Advanced

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

RE: [avr-gcc-list] Forced Linking


From: Dean Ferreyra
Subject: RE: [avr-gcc-list] Forced Linking
Date: Thu, 6 Mar 2003 15:41:43 -0800

A kludge I've used to get around this in the past was to include some small
initialization code in the isr module, something like this:

uart-tx-sig.c:

  void uart_tx_init(void)
  {
      sbi(UCR, TXEN);
  }

  SIGNAL(SIG_UART_DATA)
  {
      // ...
  }

Then, calling uart_tx_init() from main() would automatically link in the isr
from the archive.  I included an inline version in a header file:

uart.h:

  // uart_tx_init()
  // Enables the transmit line and links in default ISR.
  void uart_tx_init(void);

  // uart_tx_init_no_isr()
  // Enables the transmit line.
  inline static void uart_tx_init_no_isr(void)
  {
      sbi(UCR, TXEN);
  }

This way, when I have an application that needs to provide a modifed version
of the isr, I call uart_tx_init_no_isr() from main, still get the
initialization, but the archive isr is _not_ linked in.

I can imagine other variations on this theme (e.g. using global variables).

Dean

-----Original Message-----
From: address@hidden
[mailto:address@hidden Behalf Of Keith Gudger
Sent: Thursday, March 06, 2003 3:18 PM
To: E. Weddington
Cc: address@hidden
Subject: Re: [avr-gcc-list] Forced Linking


The key to my problem is "AVR interrupt routines".  Interrupt functions
are not referenced by anything else, so the linker thinks they're not
needed.  Since the design requires the interrupts to work, the linked code
fails.  If I just include the .o file in the compile command, everything
works OK.  I don't want to do this, however.  I want the file in my
archive - I guess I'm too picky.

I already tried the -( option to fix the circular linking issues, and it
didn't work.  I now just list my archives twice:
lib1.a lib2.a lib1.a lib2.a
and it works fine.

Keith

On Thu, 6 Mar 2003, E. Weddington wrote:

> On 6 Mar 2003 at 13:47, Keith Gudger wrote:
>
> > I have some AVR interrupt routines in an archive file.  When I run the
> > linker, they get left out, as nothing in my source files refers to
> > them. Obviously, the linked code doesn't work.
> >
> > I've searched the linker manual and found no option to make it include
> > functions.  I've searched the ar and ranlib manuals to see if there's
> > a way to "flag" functions or included files as "must include".  I
> > couldn't find a way.
> >
> > Any ideas?  Thanks.
> >
>
> Looking through the ld manual, I see the --whole-archive option, but
> that's going to slurp in the whole thing.
>
> If you know beforehand that when a user links in x that y should
> always go with it, you can include both x and y in the same object
> file before you create the archive.
>
> Also from personal email with you, take a look at the -( option in
> ld. This would solve your circular reference issue with your 2 libs.
>
> Anyway, why do you need to link a function when it isn't being
> referenced in the code?
>
> Eric Weddington
>
>


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list




reply via email to

[Prev in Thread] Current Thread [Next in Thread]