Remove WEAK from handler prototypes

These prototypes affect functions defined by application code.  Only
the implementations in libopencm3 are supposed to be weak; the
functions in application code should definitely not be.  Otherwise,
you'll end up with two weak symbols being linked together, and
it's luck as to which one the linker picks.
This commit is contained in:
Jim Paris 2015-11-17 20:31:17 -05:00 committed by Karl Palsson
parent 1ebfc4b26e
commit 01f08c4638
4 changed files with 12 additions and 16 deletions

View File

@ -130,8 +130,6 @@ IRQ numbers -3 and -6 to -9 are reserved
* specific header file in the corresponding subfolder.
*/
#define WEAK __attribute__((weak))
#include <libopencm3/dispatch/nvic.h>
/* --- NVIC functions ------------------------------------------------------ */
@ -152,19 +150,19 @@ uint8_t nvic_get_active_irq(uint8_t irqn);
void nvic_generate_software_interrupt(uint16_t irqn);
#endif
void WEAK reset_handler(void);
void WEAK nmi_handler(void);
void WEAK hard_fault_handler(void);
void WEAK sv_call_handler(void);
void WEAK pend_sv_handler(void);
void WEAK sys_tick_handler(void);
void reset_handler(void);
void nmi_handler(void);
void hard_fault_handler(void);
void sv_call_handler(void);
void pend_sv_handler(void);
void sys_tick_handler(void);
/* Those defined only on ARMv7 and above */
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
void WEAK mem_manage_handler(void);
void WEAK bus_fault_handler(void);
void WEAK usage_fault_handler(void);
void WEAK debug_monitor_handler(void);
void mem_manage_handler(void);
void bus_fault_handler(void);
void usage_fault_handler(void);
void debug_monitor_handler(void);
#endif
END_DECLS

View File

@ -60,7 +60,7 @@ vector_table_t vector_table = {
}
};
void WEAK __attribute__ ((naked)) reset_handler(void)
void __attribute__ ((weak, naked)) reset_handler(void)
{
volatile unsigned *src, *dest;
funcp_t *fp;

View File

@ -23,8 +23,6 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#define WEAK __attribute__((weak))
#include <libopencm3/stm32/gpio.h>
/**@{*/

View File

@ -121,7 +121,7 @@ def convert(infile, outfile_nvic, outfile_vectornvic, outfile_cmsis):
data['irqcount'] = max([int(x) for x in data['irqs'].keys()]) + 1
data['irqdefinitions'] = "\n".join('#define NVIC_%s_IRQ %d'%(v.upper(),int(k)) for (k,v) in irq2name)
data['isrprototypes'] = "\n".join('void WEAK %s_isr(void);'%name.lower() for name in irqnames)
data['isrprototypes'] = "\n".join('void %s_isr(void);'%name.lower() for name in irqnames)
data['isrpragmas'] = "\n".join('#pragma weak %s_isr = blocking_handler'%name.lower() for name in irqnames)
data['vectortableinitialization'] = ', \\\n '.join('[NVIC_%s_IRQ] = %s_isr'%(name.upper(), name.lower()) for name in irqnames)
data['cmsisbends'] = "\n".join("#define %s_IRQHandler %s_isr"%(name.upper(), name.lower()) for name in irqnames)