v1.52m
...
- Added option to optimize the interrupt vector table to reduce firmware size (Makefile: OPTIMIZE_VECTORS, thanks to Viktor Klimkovich).
...
This option doesn't work correctly with my avr-gcc version 8.3.0, version 5.4.0 (the debian stable default), 7.3.0, and 13.2.0 work as expected.
This is what I get with avr-gcc-8.3.0:
.section .vectors,"ax",@progbits
.global __vectors
.func __vectors
__vectors:
XJMP __init // __vectors[0]
0: 0c 94 23 0e jmp 0x1c46 ; 0x1c46 <__ctors_end>
.altmacro
.set i,1
.rept 127 // __vectors[1..127]
vector %i
.set i,i+1
.endr
4: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
8: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
c: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
10: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
14: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
18: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
1c: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
20: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
24: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
28: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
2c: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
30: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
34: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
38: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
3c: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
40: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__bad_interrupt>
00000044 <__trampolines_end>:
while e.g. ver 13 gives:
.section .vectors,"ax",@progbits
.global __vectors
.func __vectors
__vectors:
XJMP __init // __vectors[0]
0: 0c 94 23 0e jmp 0x1c46 ; 0x1c46 <__ctors_end>
00000004 <.Loc.1>:
.altmacro
.set i,1
.rept 127 // __vectors[1..127]
vector %i
4: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
8: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
c: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
10: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
14: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
18: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
1c: 0c 94 fb 2d jmp 0x5bf6 ; 0x5bf6 <__vector_7>
20: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
24: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
28: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
2c: 0c 94 17 2e jmp 0x5c2e ; 0x5c2e <__vector_11>
30: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
34: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
38: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
3c: 0c 94 55 2e jmp 0x5caa ; 0x5caa <__bad_interrupt>
40: 0c 94 05 2e jmp 0x5c0a ; 0x5c0a <__vector_16>
00000044 <Inductor_table>:
...
This change fixes the behaviour for ver 8.3.0:
diff --git a/gcrt1.S b/gcrt1.S
index 71689db..dad52e1 100644
--- a/gcrt1.S
+++ b/gcrt1.S
@@ -70,7 +70,7 @@
.macro vector i
.if (. - __vectors <= last_used_vector*4)
.weak __vector_\i
- .set __vector_\i, __bad_interrupt
+ // .set __vector_\i, __bad_interrupt
XJMP __vector_\i
.endif
.endm
EDIT: After this "fix" I get:
.section .vectors,"ax",@progbits
.global __vectors
.func __vectors
__vectors:
XJMP __init // __vectors[0]
0: 0c 94 23 0e jmp 0x1c46 ; 0x1c46 <__ctors_end>
.altmacro
.set i,1
.rept 127 // __vectors[1..127]
vector %i
.set i,i+1
.endr
4: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
8: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
c: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
10: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
14: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
18: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
1c: 0c 94 00 2e jmp 0x5c00 ; 0x5c00 <__vector_7>
20: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
24: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
28: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
2c: 0c 94 d8 2d jmp 0x5bb0 ; 0x5bb0 <__vector_11>
30: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
34: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
38: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
3c: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
40: 0c 94 ee 2d jmp 0x5bdc ; 0x5bdc <__vector_16>
00000044 <__trampolines_end>:
Slightly different, but not an issue b/c also "__bad_interrupt" jumps to address 0:
00005c64 <__bad_interrupt>:
.global __bad_interrupt
.func __bad_interrupt
__bad_interrupt:
.weak __vector_default
.set __vector_default, __vectors
XJMP __vector_default
5c64: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
This "fix" works with all my available avr-gcc versions 5.4.0, 7.3.0, 8.3.0, and 13.2.0
EDIT2: corrected the debian stable version (5.4.0)