Internal handling of interrupt vectors and jump table

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Internal handling of interrupt vectors and jump table

Klaus Rudolph
Hi,

can someone explain how interrupt vectors are handled in gcc internally?

OK, I saw that in  /opt/avr_5.2.0/lib/gcc/avr/5.2.0/../../../../avr/lib/avr5/crtatmega32.o

the empty vector table is included, like:

Disassembly of section .vectors:
00000000 <__vectors>:
0:   0c 94 00 00     jmp     0       ; 0x0 <__vectors>
4:   0c 94 00 00     jmp     0       ; 0x0 <__vectors>
8:   0c 94 00 00     jmp     0       ; 0x0 <__vectors>

And I also can see, that my code results in:

Disassembly of section .text:
00000000 <__vector_7>:
...

but where can I see that __vector_7 goes to the correct place in the table?

I can't see the relocations nor the symbols for that! Is this hardcoded somewhere in binutils?

It would be nice that someone can give me some hints to where I can find the details of getting the vectors into the table.

Thanks!

Klaus

_______________________________________________
AVR-GCC-list mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Reply | Threaded
Open this post in threaded view
|

Re: Internal handling of interrupt vectors and jump table

Georg-Johann Lay-2
Am 08/11/2015 um 12:04 PM schrieb Klaus Rudolph:
> can someone explain how interrupt vectors are handled in gcc internally?

ISR functions are implemented as function attributes, i.e. there are
avr-specific function attribute (__interrupt__, __signal__) which turn an
ordinary function into an ISR.  Main outcome of these attributes is that
./gcc/config/avr/avr.c::avr_expand_prologue() emits a different prologue for
ISRs.  Similar for avr_expand_epilogue().

Attribute handling like special diagnostics for ISRs is performed by
avr_set_current_function().


> OK, I saw that in  /opt/avr_5.2.0/lib/gcc/avr/5.2.0/../../../../avr/lib/avr5/crtatmega32.o
>
> the empty vector table is included, like:
>
> Disassembly of section .vectors:
> 00000000 <__vectors>:
> 0:   0c 94 00 00     jmp     0       ; 0x0 <__vectors>
> 4:   0c 94 00 00     jmp     0       ; 0x0 <__vectors>
> 8:   0c 94 00 00     jmp     0       ; 0x0 <__vectors>
>
> And I also can see, that my code results in:
>
> Disassembly of section .text:
> 00000000 <__vector_7>:

The .vectors section is implemented in AVR-LibC's gcrt1.S.
ISR and similar macros are provided by interrupt.h.


> but where can I see that __vector_7 goes to the correct place in the table?

To see the macros after expansion compile with -save-temps and read the
respective .i file (C) or .ii file (C++).

Johann


_______________________________________________
AVR-GCC-list mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Reply | Threaded
Open this post in threaded view
|

Re: Internal handling of interrupt vectors and jump table

Klaus Rudolph
In reply to this post by Klaus Rudolph

Hi Georg,

thanks for your info!

> > Disassembly of section .text:
> > 00000000 <__vector_7>:
>
> The .vectors section is implemented in AVR-LibC's gcrt1.S.
> ISR and similar macros are provided by interrupt.h.

Yes, I found the tricky part of the job.

.macro  vector name
.if (. - __vectors < _VECTORS_SIZE)
.weak   \name
.set    \name, __bad_interrupt
XJMP    \name  
.endif  
.endm  
 
.section .vectors,"ax",@progbits
.global __vectors
.func   __vectors
__vectors:
XJMP    __init
vector  __vector_1
vector  __vector_2

The resolution and assignment is only done by the name of the function. Quite simple after finding the stuff :-)

Thanks!
Klaus


_______________________________________________
AVR-GCC-list mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list