From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.40.134 with SMTP id o128mr1527966ioo.85.1515004761856; Wed, 03 Jan 2018 10:39:21 -0800 (PST) X-Received: by 10.157.46.130 with SMTP id w2mr136089ota.10.1515004761735; Wed, 03 Jan 2018 10:39:21 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!g80no328093itg.0!news-out.google.com!b73ni1219ita.0!nntp.google.com!i6no330106itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 3 Jan 2018 10:39:21 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.208.22; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.208.22 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6042baa6-7743-48aa-8237-87181ab41a02@googlegroups.com> Subject: Linker_Alias From: Jere Injection-Date: Wed, 03 Jan 2018 18:39:21 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Body-CRC: 2416103994 X-Received-Bytes: 3259 Xref: reader02.eternal-september.org comp.lang.ada:49731 Date: 2018-01-03T10:39:21-08:00 List-Id: 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).