From: Simon Wright <simon@pushface.org>
Subject: Re: Linker_Alias
Date: Wed, 03 Jan 2018 21:59:08 +0000
Date: 2018-01-03T21:59:08+00:00 [thread overview]
Message-ID: <lypo6qd2oj.fsf@pushface.org> (raw)
In-Reply-To: 6042baa6-7743-48aa-8237-87181ab41a02@googlegroups.com
Jere <jhb.chat@gmail.com> writes:
> I know this is more of a GNAT question than an Ada question
> but was hoping someone else had some insight to this pragma.
>
> I am trying to use pragma Linker_Alias to set up a default
> operation for an operation defined with pragma Weak_External.
[...]
> The intent is that GNAT links in a default operation unless
> the client exports a procedure with the intended link name.
>
> The use case is for ZFP runtimes where I don't have access
> to protected procedures. I want to supply a dummy ISR
> unless the client decides to override it.
>
> I know GCC itself supports this (I tested it in another
> language just to make sure), but I cannot figure out how
> to get GNAT to support it.
>
> Am I setting up the pragma's wrong? I've tried a few different
> combinations, but with no luck.
>
> I'm on Windows 10 using GNAT GPL 2017 (same problem on 2015 and 2016).
On macOS with GCC8 it failed to link (symbol "target" missing).
I never came across pragma Linker_Alias (and the description isn't easy
to get my head round). I had a similar problem in Cortex GNAT RTS: the
default was
procedure HardFault_Handler
with Export, Convention => Ada, External_Name => "HardFault_Handler";
pragma Weak_External (HardFault_Handler);
procedure HardFault_Handler is
begin
loop
null;
end loop;
end HardFault_Handler;
and then, if required, override by providing a package containing
procedure Handler
with
Export,
Convention => Asm,
External_Name => "HardFault_Handler";
pragma Machine_Attribute (Handler, "naked");
whose body works out which stack is in use and sets up for debugging.
One thing that confused me for a while was that you have to ensure that
the overriding package actually gets linked; my comment says
-- Normally, we'd mark this unit as preelaborable, but that would
-- mean that the binder-generated code wouldn't reference it, so
-- it wouldn't get referenced at all (because the weak symbol in
-- startup.o would satisfy the link).
https://github.com/simonjwright/cortex-gnat-rts/blob/master/common/hardfault_handling.ads
(and .adb).
next prev parent reply other threads:[~2018-01-03 21:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 18:39 Linker_Alias Jere
2018-01-03 21:59 ` Simon Wright [this message]
2018-01-04 21:09 ` Linker_Alias jhb.games
2018-01-04 22:56 ` Linker_Alias Simon Wright
2018-01-06 14:46 ` Linker_Alias Jere
2018-01-06 16:58 ` Linker_Alias Simon Wright
2018-01-06 20:16 ` Linker_Alias Jere
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox