Den 12-01-2011 12:42, Jonas Maebe skrev:

On 12 Jan 2011, at 06:29, Jeppe Johansen wrote:

While trying to find a nice solution for generating interrupt vector tables on ARM, I found that the usually employed solution is to generate weak references to symbols, that are initialized to a single handler. This way an application can override the weak reference, by declaring a new symbol with the same name. While it's possible to do that currently by using some external assembler code, I think a simpler solution could be made by using the weakexternal directive. The infrastructure is already there, but it's used in a slightly different way.

How is it normally done in C? At first sight, using the weakexternal directive to /define/ symbols seems like a wrong approach.


Jonas
With C it's done using compiler dependent attributes. With gcc you can do it using __attribute__((weak,alias("SomeFunction")));. Though often it'll just be done using assembler using the .weak and .set/thumb_set directives

The weakexternal directive already "defines" a symbol, it will exist at runtime, but it might be nil. The only difference is that if you set the initial value it'll resolve to something at link time
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to