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: 103376,63ac7dccda611bc3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!feeder.erje.net!fi.sn.net!newsfeed2.tdcnet.fi!news.song.fi!not-for-mail Date: Mon, 5 Apr 2010 15:27:18 +0300 From: Tero Koskinen Newsgroups: comp.lang.ada Subject: Re: Build raw binary on Windows Message-Id: <20100405152718.ec9668d0.tero.koskinen@iki.fi> References: X-Newsreader: Sylpheed 2.7.1 (GTK+ 2.18.6; x86_64-unknown-openbsd4.7) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Organization: NBL Networks Oy NNTP-Posting-Host: 217.30.184.161 X-Trace: 1270470452 news.nbl.fi 2529 217.30.184.161:32740 X-Complaints-To: abuse@nblnetworks.fi Xref: g2news1.google.com comp.lang.ada:9876 Date: 2010-04-05T15:27:18+03:00 List-Id: On Sun, 4 Apr 2010 05:44:36 -0700 (PDT) brian wrote: > I've been poring over megabytes of documentation until my eyes started > bleeding, but I just cannot figure out how to tell GNAT to create a > raw binary (no header) executable using GNAT hosted on Windows. I > need to write code that runs on x86/x64 bare metal (no operating > system). > > Any pointers would be greatly appreciated! For AVR, I use following commands: $ make ADA_PROJECT_PATH=/usr/local/avr/ada avr-gnatmake -XMCU=atmega328p -Phello.gpr --RTS=rts/atmega328p avr-gcc -c -gnatec=/usr/local/avr/ada/gnat.adc -gdwarf-2 -gnatwp -gnatwu -gnatn -gnatp -gnatVn -Os -gnatef -fverbose-asm -frename-registers -mmcu=atmega328p -gnateDMCU=atmega328p -fdata-sections -ffunction-sections --RTS=rts/atmega328p -I- -gnatA /home/tkoskine/work/arduino/hello/hello.adb avr-gnatbind -freestanding --RTS=rts/atmega328p -I- -x /home/tkoskine/work/arduino/hello/objects/hello.ali avr-gnatlink /home/tkoskine/work/arduino/hello/objects/hello.ali -Wl,--gc-sections -gdwarf-2 -Wl,--relax --GCC=avr-gcc -Os -mmcu=atmega328p --RTS=rts/atmega328p -fdata-sections -ffunction-sections -Wl,-Map=../hello.map,--cref -L/usr/local/avr/ada/avr_lib/atmega328p/lib -lavrada -o /home/tkoskine/work/arduino/hello/hello.elf avr-objcopy -O ihex -R .eeprom hello.elf hello.hex $ Resulting file is something like: $ cat hello.hex :1000000033C000004CC000004AC0000048C00000DF :1000100046C0000044C0000042C0000040C00000D4 :100020003EC000003CC000003AC0000038C00000E4 :1000300036C0000034C0000032C0000030C00000F4 :100040002EC000002CC000002AC0000028C0000004 :1000500026C0000024C0000022C0000020C0000014 :100060001EC000001CC0000011241FBECFEFD8E04E :10007000DEBFCDBF11E0A0E0B1E0EAEBF1E002C0ED :1000800005900D92A630B107D9F711E0A6E0B1E0D6 :1000900001C01D92A630B107E1F702D08CC0B0CFED :1000A00000D0BF92CF92DF92EF92FF920F931F93F7 :1000B00083E390E060E029D08FEF84B91AB88BB960 :1000C00085B920E2B22E9DE0C92E15B853D0D82EA6 :1000D000B5B860E971E080E090E053D080E0E82EB0 :1000E00081E0F82E04E011E0C801B70121D0E090D2 :1000F000C000E5FEFCCFD092C600D090C000D5FE77 :10010000FCCFC092C6002ED0E0CF9093C500809364 :10011000C400662321F082E08093C00002C01092E8 :10012000C00038E13093C10026E02093C20008955A :10013000FC0180819181482F50E0981790F0282F82 :10014000E22FF0E0E41BF50BE60FF71FE081809152 :10015000C00085FFFCCFE093C600291711F02F5F88 :10016000EFCF08958091C00085FFFCCF2AE0209357 :10017000C60008958091C00087FFFCCF8091C60023 :1001800008959B01AC01121613061406150694F48B :1001900081E090E0A0E0B0E060ED77E0FB01319716 :1001A000F1F782179307A407B50721F00196A11D67 :0A01B000B11DF4CF0895F894FFCFBD :0601BA00476F74200003F2 :00000001FF $ This was for AVR/AVR-Ada, but I think the idea applies to raw i386 programs also. By changing the target of -O parameter, you can probably get the output you want. > -Brian -- Tero Koskinen - http://iki.fi/tero.koskinen/