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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,5f14691e88205f0c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!newsfeed.straub-nv.de!eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Using GNAT in a C and assembly toolchain Date: Tue, 04 May 2010 20:50:27 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 4 May 2010 19:50:28 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="KCXegvZb5vh43D+f3BR6Ew"; logging-data="1160"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RL95qo0PGyNTuJ6KHA9PgkvYcmR32OJM=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (darwin) Cancel-Lock: sha1:Pg320I6rq0PeNGd0KMJgiUoxs1Q= sha1:sH/pG74SmQBa0Hfbzrx3Zf7cnUw= Xref: g2news2.google.com comp.lang.ada:11311 Date: 2010-05-04T20:50:27+01:00 List-Id: Tom writes: > On our particular application -- an automotive ECU -- we're locked > into a proprietary C-based flow. The operating system and hardware > abstraction layer come precompiled and the application code must be > compiled and linked with the established tool chain (GHS C, not Ada). > The application programmer defines a procedure, which is invoked by > the OS as a periodic rate. This procedure references global C > variables to access the hardware abstraction layer. I would have expected engine control software to require a pretty high degree of certification, if not for safety-related reasons then because fixing problems in deployed firmware is going to be expensive and possibly embarrassing, see Toyota, and part of that involves the tool chain. OK, I work on military systems, but my Software Design Authority would need A Whole Lot Of Convincing to change the tool chain in a way not supported by the tool vendor. > The question is how can I best use Ada and GNAT in such an > environment? One method that comes to mind is to compile Ada to > assembly code, which is then passed to GHS for assembling and linking > with the closed source OS and HAL. I don't see an assembly switch, > like GCC's -S. Would this mean I would need the compile Ada modules > individually with GCC instead of using gnatmake? Are there any > options to compile Ada down to C by chance? "gnatmake -c -S foo.adb" compiles the closure of foo to assembler (.s) files. Of course these are going to be in GNU assembler, which may or may not be that used by GHS. There is a tool created by Sofcheck called AdaMagic which generates C. GCC does not. (I'm not sure that Sofcheck is still in business? there was a discussion here recently). > And how does gnatbind fit into this picture? It appears to create > initialization code. Would I just need to insert this code such that > it is invoked at power up? I think you'd call gnatbind with -C (to generate C binder code rather than Ada) and -n (no Ada main program). The generated code includes an adainit() to be called to initialize the Ada runtime and an adafinal() to finalize it (not that I've ever had to call adafinal()).