From: jhb.games@gmail.com
Subject: Re: Linker_Alias
Date: Thu, 4 Jan 2018 13:09:57 -0800 (PST)
Date: 2018-01-04T13:09:57-08:00 [thread overview]
Message-ID: <7c41ec78-ba73-4f85-a7a7-837c3d582fa0@googlegroups.com> (raw)
In-Reply-To: <lypo6qd2oj.fsf@pushface.org>
On Wednesday, January 3, 2018 at 4:59:11 PM UTC-5, Simon Wright wrote:
> Jere 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.
Thanks!
I tried that but ran into the same problem. I added:
procedure Target_Op_2
with
Convention => Ada,
Export,
External_Name => "t2",
Link_Name => "t2";
pragma Weak_External(Target_Op_2);
to Operations.ads, and
procedure Target_Op_2 is
begin
Put_Line("t2");
end Target_Op_2;
to Operations.adb but still got the same exception when calling
from the entry procedure:
with Ada.Text_IO; use Ada.Text_IO;
with Operations;
procedure Main is
begin
Put_Line("Hello");
Operations.Target_Op_2;
end Main;
********************
Hello
raised PROGRAM_ERROR : EXCEPTION_ACCESS_VIOLATION
********************
So it looks like it still isn't defaulting the procedure.
Note
that I am testing this in the standard windows GNAT GPL
version as opposed to the cross compiler. I'll get to
that, but I had to redo my environment for it. I just
wanted to test out the functionality.
Any thoughts?
next prev parent reply other threads:[~2018-01-04 21:09 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 ` Linker_Alias Simon Wright
2018-01-04 21:09 ` jhb.games [this message]
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