This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, This patch tries to shrink the interrupt vector table by deleting unused 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 the number of interrupts actually used. This increases the size of the executable for archs (XMEGAs, for example), that have lots of interrupts (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 and the address of the last entry in the table that has a user defined handler, and deletes everything in between. It does it by hooking into linker relaxation for the .vectors section and doing the following: 1. It goes through the global symbols in the bfd and looks for those representing interrupt handlers. 2. For each such symbol found, it extracts the vector number from the name. It also finds out whether there is a definition available for the symbol from the symbol information available. 3. At the end of (2), symbol indices representing handlers for the last available interrupt for that arch, and the last used interrupt are available - they are the symbols with the max vector number, and the max vector number with a definition, respectively. 4. To find out the addresses of entries in the vector table for the last available interrupt and the last used interrupt, it walks the relocation entries for the section and looks for entries with symbol indices matching what was found in (3). The corresponding relocation offsets represent the addresses of the entries. 5. Bytes between the offsets obtained in (4) are deleted (excluding the defined entry's size), as are relocation entries pointing into the deleted area. Note that this ((1) and (2) relies on avr-libc's convention of naming interrupt handlers __vector_<n>, with n representing the interrupt number. Also, the patch kicks in only if --shrink-ivt is passed along with --relax, otherwise, the __vector_<n> symbols get defined to __bad_interrupt as usual. Thoughts? Regards Senthil
Attachment:
avr_link_relax.patch
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |