comp.lang.ada
 help / color / mirror / Atom feed
* Linker_Alias
@ 2018-01-03 18:39 Jere
  2018-01-03 21:59 ` Linker_Alias Simon Wright
  0 siblings, 1 reply; 7+ messages in thread
From: Jere @ 2018-01-03 18:39 UTC (permalink / 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).


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-01-06 20:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-03 18:39 Linker_Alias Jere
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox