« Return to Thread: Function Address fixup missing?

Re: Function Address fixup missing?

by Mau Liste :: Rate this Message:

Reply to Author | View in Thread


Stu Bell wrote:
> Trampolines work only for statically linked functions, not function
> pointers.
Sorry, but I don't understand this.
I believe that there is no problem with statically linked functions.
GCC actually generates a call with the full address, and no 16 bit
pointers are involved, as in the following disassembly:

    butta = ButtamiViaSubito();
    4014: 0f 94 f5 06 call 0x20dea ; 0x20dea

Here I am calling the same function but directly, and GCC generates the
correct code for the AtMega2561.

Actually, as I told in my previous mail, I tried a small program
where it seems to work.

Here is the main:
    typedef void (*PPro)(void);
    PPro ppro1;

    extern void pro1(void) __attribute__ ((section ("spro1")));

    int main(void)
    {
      ppro1 = pro1;

      pro1();

      ppro1();
      while(1)
        ;
      return(0);
    }

Here is the function:
    __attribute__((section ("spro1"))) void pro1(void)
    {
      return;
    }

In the linker flags I added:
    -section-start=spro1=0x21000
to place the routine in the upper 128K.

and the relevant disassembly is:
...
000000cc <__trampolines_start>:
  cc: 0d 94 00 08 jmp 0x21000 ; 0x21000 <pro1>
...
  ppro1 = pro1;
 116: 86 e6       ldi r24, 0x66 ; 102
 118: 90 e0       ldi r25, 0x00 ; 0
 11a: 90 93 01 02 sts 0x0201, r25
 11e: 80 93 00 02 sts 0x0200, r24
...
  ppro1();
 126: e0 91 00 02 lds r30, 0x0200
 12a: f0 91 01 02 lds r31, 0x0201
 12e: 19 95       eicall





_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

 « Return to Thread: Function Address fixup missing?