https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70713
Bug ID: 70713 Summary: msp430 interrupt attribute prevents overriding weak symbols Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: awygle at gmail dot com Target Milestone: --- Because the interrupt attribute in the msp430 port creates a .word directive inside of the generated assembly, thus: test.c: __attribute__((weak, interrupt(USCI_A1_VECTOR))) void TEST_WEAKNESS(void) { UCA1TXBUF = 'e'; } msp430-elf-gcc -mmcu=msp430fr6989 -S test.c test.s: .file "test.c" .text .balign 2 .weak TEST_WEAKNESS .section __interrupt_vector_43,"ax",@progbits .word TEST_WEAKNESS .text TEST_WEAKNESS: ; start of function ; attributes: interrupt ; framesize_regs: 0 ; framesize_locals: 0 ; framesize_outgoing: 0 ; framesize: 0 ; elim ap -> fp 2 ; elim fp -> sp 0 ; saved regs:(none) ; start of prologue ; end of prologue MOV.W #101, &UCA1TXBUF NOP ; start of epilogue RETI .size TEST_WEAKNESS, .-TEST_WEAKNESS When we compile and attempt to link with a non-weak symbol, thus: test2.c: __attribute__((interrupt(USCI_A1_VECTOR))) void TEST_WEAKNESS(void) { UCA1TXBUF = 'E'; } msp430-elf-gcc -mmcu=msp430fr6989 -S test2.c test2.s: .file "test2.c" .text .balign 2 .global TEST_WEAKNESS .section __interrupt_vector_43,"ax",@progbits .word TEST_WEAKNESS .text TEST_WEAKNESS: ; start of function ; attributes: interrupt ; framesize_regs: 0 ; framesize_locals: 0 ; framesize_outgoing: 0 ; framesize: 0 ; elim ap -> fp 2 ; elim fp -> sp 0 ; saved regs:(none) ; start of prologue ; end of prologue MOV.W #69, &UCA1TXBUF NOP ; start of epilogue RETI .size TEST_WEAKNESS, .-TEST_WEAKNESS The error: msp430-elf-gcc -mmcu=msp430fr6989 test.s test2.s -o test.elf msp430-elf/bin/ld: test.elf section `__interrupt_vector_43' will not fit in region `VECT43' msp430-elf/bin/ld: region `VECT43' overflowed by 2 bytes collect2: error: ld returned 1 exit status I was able to get this to work by making the section lines part of a comdat group, so that .section __interrupt_vector_43,"ax",@progbits becomes .section __interrupt_vector_43,"axG",@progbits,TEST_WEAKNESS,comdat in both cases. There seem to be no ill-effects from doing this (provided the group name is based on the function name), but I lack the gcc experience to say for sure, or to cause such code to be emitted.