This is the mail archive of the
mailing list for the binutils project.
RE: [Patch, avr] Shrink interrupt vector table down to last used entry
- From: "Weddington, Eric" <Eric dot Weddington at atmel dot com>
- To: "Selvaraj, Senthil_Kumar" <Senthil_Kumar dot Selvaraj at atmel dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>
- Cc: "avr-gcc-list at nongnu dot org" <avr-gcc-list at nongnu dot org>, "Wunsch, Joerg" <Joerg dot Wunsch at atmel dot com>
- Date: Thu, 14 Feb 2013 16:17:54 +0000
- Subject: RE: [Patch, avr] Shrink interrupt vector table down to last used entry
- References: <20130214104803.GA904@atmel.com>
> -----Original Message-----
> From: Selvaraj, Senthil_Kumar
> Sent: Thursday, February 14, 2013 3:48 AM
> To: email@example.com
> Cc: firstname.lastname@example.org; Weddington, Eric; Wunsch, Joerg
> Subject: [Patch, avr] Shrink interrupt vector table down to last used
> This patch tries to shrink the interrupt vector table by deleting
> entries at the end of the table as part of linker relaxation.
> The motivation for this patch is that, currently, the full interrupt
> vector table is being placed in the linked executable, regardless of
> number of interrupts actually used. This increases the size of the
> executable for archs (XMEGAs, for example), that have lots of
> (125 interrupts * 4 bytes for XMEGAs) if the user program only uses a
> few of them.
> At a high level, this patch figures out the size of the vector table
> the address of the last entry in the table that has a user defined
> handler, and deletes everything in between.
We (avr-libc developers) have considered this before and we rejected it for safety reasons.
IIRC, typically, the "unused" vectors will be filled in to jump to a "bad interrupt" service routine, which sits in a do-nothing loop forever. What this means is that if, for some reason, the end user has accidentally enabled other interrupts unintentionally (e.g., by writing certain values to the wrong register), then that interrupt would be handled in a safe way: it would be stuck in a loop that the user can view in a debugger, letting them determine quickly that somehow an interrupt was wrongly enabled. More importantly, wrong code is not executed that could harm the rest of the embedded system that the AVR devices are in.
If this "optimization" were put in place, then there is the potential that these wrongly-enable interrupts could vector off to some part of the application code, start executing it, without ever having a return from interrupt (RETI), and could wreak havoc with the rest of the system, and also making debugging such a system that much harder.
I would have to see evidence that these devices, especially the XMEGAs, which typically have more code space, are so constrained that such an optimization is warranted over the safety of the overall system. IMHO, it would be better to focus optimization efforts on improving the AVR backend in GCC and code generation, rather than potentially compromising the system in this way.
I'm sorry, but I'm going to have to reject this patch.
We can have further internal discussions about this if you want.