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.142.84 with SMTP id q81mr576911iod.51.1515100197565; Thu, 04 Jan 2018 13:09:57 -0800 (PST) X-Received: by 10.157.82.108 with SMTP id q44mr37807otg.13.1515100197378; Thu, 04 Jan 2018 13:09:57 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!g80no68537itg.0!news-out.google.com!b73ni175ita.0!nntp.google.com!g80no68532itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 4 Jan 2018 13:09:57 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.208.22; posting-account=okr6MwkAAAA58xM6G2PLG3lOj8tIok0v NNTP-Posting-Host: 173.71.208.22 References: <6042baa6-7743-48aa-8237-87181ab41a02@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7c41ec78-ba73-4f85-a7a7-837c3d582fa0@googlegroups.com> Subject: Re: Linker_Alias From: jhb.games@gmail.com Injection-Date: Thu, 04 Jan 2018 21:09:57 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:49755 Date: 2018-01-04T13:09:57-08:00 List-Id: 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?