comp.lang.ada
 help / color / mirror / Atom feed
From: Tero Koskinen <tero.koskinen@iki.fi>
Subject: Re: Build raw binary on Windows
Date: Mon, 5 Apr 2010 15:27:18 +0300
Date: 2010-04-05T15:27:18+03:00	[thread overview]
Message-ID: <20100405152718.ec9668d0.tero.koskinen@iki.fi> (raw)
In-Reply-To: a55ca3ff-1b7c-4a5d-a939-973f101ab3da@y17g2000yqd.googlegroups.com

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/



  parent reply	other threads:[~2010-04-05 12:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-04 12:44 Build raw binary on Windows brian
2010-04-05  1:39 ` Stephen Leake
2010-04-05 12:01   ` brian
2010-04-05 12:27 ` Tero Koskinen [this message]
2010-04-05 14:06   ` brian
2010-04-05 14:30     ` Tero Koskinen
replies disabled

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