comp.lang.ada
 help / color / mirror / Atom feed
From: Jere <jhb.chat@gmail.com>
Subject: Linker_Alias
Date: Wed, 3 Jan 2018 10:39:21 -0800 (PST)
Date: 2018-01-03T10:39:21-08:00	[thread overview]
Message-ID: <6042baa6-7743-48aa-8237-87181ab41a02@googlegroups.com> (raw)

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.  


code is as follows:
************************************************************

package Operations is
   
   -- Will be called by the client
   procedure Target_Op
      with
         Import,
         Convention    => C,
         External_Name => "target",
         Link_Name     => "target";
   
   pragma Weak_External(Target_Op);
   pragma Linker_Alias
      (Entity => Target_Op,
       Target => "default_target");
   
private
   
   -- default operation if none supplied
   procedure Default
      with
         Export,
         Convention    => C,
         External_Name => "default_target",
         Link_Name     => "default_target";
   
end Operations;

with Ada.Text_IO; use Ada.Text_IO;

package body Operations is
   
   procedure Default is
   begin
      Put_Line("Default Operation");
   end Default;
 
end Operations;

with Ada.Text_IO; use Ada.Text_IO;
with Operations;

procedure Main is
begin
   Put_Line("Hello");
   Operations.Target_Op;
end Main;

************************************************************

It compiles fine but generates a runtime error that indicates
it cannot find any valid symbols.  The output is:

Hello

raised PROGRAM_ERROR : EXCEPTION_ACCESS_VIOLATION
[2018-01-03 13:25:34] process exited with status 1, elapsed time: 00.22s



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).


             reply	other threads:[~2018-01-03 18:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03 18:39 Jere [this message]
2018-01-03 21:59 ` Linker_Alias Simon Wright
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