<html>
<head>
<base href="http://bugzilla.gdcproject.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:jens-bugzilla@gpio.dk" title="Jens Bauer <jens-bugzilla@gpio.dk>"> <span class="fn">Jens Bauer</span></a>
</span> changed
<a class="bz_bug_link
bz_status_NEW "
title="NEW - Add support for GCC's weak attribute"
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=172">bug 172</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>jens-bugzilla@gpio.dk
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Add support for GCC's weak attribute"
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=172#c1">Comment # 1</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Add support for GCC's weak attribute"
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=172">bug 172</a>
from <span class="vcard"><a class="email" href="mailto:jens-bugzilla@gpio.dk" title="Jens Bauer <jens-bugzilla@gpio.dk>"> <span class="fn">Jens Bauer</span></a>
</span></b>
<pre>Having support for this will be highly appreciated.
Especially weak,alias is important on microcontrollers, which have exception
vectors.
Small C Example (this one is for ARM Cortex-M microcontrollers):
---8<-----8<-----8<-----
#define WA(a) __attribute__((weak, alias(#a)))
#define WE WA(defaultExceptionHandler)
#define WR WA(defaultResetHandler)
typedef void (*const VectorFunc)(void);
static void defaultResetHandler(void) __attribute__((__interrupt__));
/* $0000 System Exception Vector Handlers: */
void WR Reset_Handler(void); /* 1 $0004 Reset */
void WE NMI_Handler(void); /* 2 $0008 Non Maskable Interrupt */
void WE HardFault_Handler(void); /* 3 $000c Hard Fault */
...
...
/* Vector Table */
__attribute__((section(".isr_vector"))) VectorFunc g_pfnVectors[] =
{
(VectorFunc)STACK_ADDRESS, /* 0 $0000 Initial Stack Pointer */
Reset_Handler, /* 1 $0004 Reset Vector */
NMI_Handler, /* 2 $0008 Non Maskable Interrupt Vector */
HardFault_Handler, /* 3 $000c Hard Fault Vector */
...
...
};
static void defaultResetHandler(void)
{
while(1){ asm volatile("wfi"); }
}
--->8----->8----->8-----
The above example demonstrates the use of the section attribute and the use of
the weak+alias attribute.
The weak+alias is used for having default implementations of all the exception
handlers (including Reset_Handler).
This means that the user can just start writing code, but allows customization
in case an implementation, which is either simpler or more advanced than the
provided one is required.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are watching all bug changes.</li>
</ul>
</body>
</html>