Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Mingw to generate ELF or raw binary

1,901 views
Skip to first unread message

yuge...@gmail.com

unread,
Jun 9, 2009, 7:06:55 PM6/9/09
to
I recently decided to try using GCC (previously used Watcom) as my
primary compiler. I am developing my OS on Windows and downloaded the
MingW version of GCC (for 64 bit binaries).

I am trying to generate ELF or raw binaries. I've tried the -b and --
format switches of the linker (LD), however, I still only seem to be
generating PE files.

Anyone know how I can get the 64 bit version of MingW to generate ELF
or raw binaries?

Thanks.

Yug3sh

unread,
Jun 10, 2009, 7:28:26 PM6/10/09
to


Anyone have any suggestions for this? Is anyone else using GCC on
Windows to generate 64 bit binaries (ELF, raw binary etc)?

Rod Pemberton

unread,
Jun 10, 2009, 8:34:11 PM6/10/09
to
"Yug3sh" <yuge...@gmail.com> wrote in message
news:162a135d-acf2-4d37...@d19g2000prh.googlegroups.com...

On Jun 9, 4:06 pm, yugesh...@gmail.com wrote:
> > I recently decided to try using GCC (previously used Watcom) as my
> > primary compiler. I am developing my OS on Windows and downloaded the
> > MingW version of GCC (for 64 bit binaries).
> >
> > I am trying to generate ELF or raw binaries. I've tried the -b and --
> > format switches of the linker (LD), however, I still only seem to be
> > generating PE files.
> >
> > Anyone know how I can get the 64 bit version of MingW to generate ELF
> > or raw binaries?
> >

No.

I do know that DJGPP (GCC + custom DOS C library) doesn't natively support
ELF although the GNU source code packages do. One must recompile them with
ELF support enabled or download them pre-compiled from someone who has.
IIRC, OBJDUMP, or maybe it's LD... , has flags indicating which file formats
are supported, i.e., enabled and compiled, for your platform.

> Anyone have any suggestions for this? Is anyone else using GCC on
> Windows to generate 64 bit binaries (ELF, raw binary etc)?

Sorry, not I. All I can do is direct you to the "odd binaries" links in the
AOD FAQ:

http://www.yeyan.cn/Programming/gcc-ld-compile-binary-formats.aspx
http://devpit.org/wiki/Compiler_Options_for_Creating_Odd_Binaries

AOD FAQ:
http://aodfaq.wikispaces.com/


RP


Rob Horvath

unread,
Jun 10, 2009, 10:50:05 PM6/10/09
to

It won't, neither will DJGPP. You need to install Cygwin, then build
a custom cross-compiler. Since you're doing OS dev, you won't need
any of the library support functions. Real simple way to do it is to
do Cygwin with the GCC 3.4xx branch (don't use 4.xx), then use the
Crosstool. It's very easy to use, and will build everything you need
to output the format/arch that you need.

Just make sure when you install Cygwin that you install the necessary
build tools for the Crosstool scripts. Standard toolchain, binutils,
gawk, sed, m4, libtool, make, autoconf, bison, etc..

I'm sure my list is partial, but I do a ton just to make sure the
build completes ok. The compiler is slower on Cygwin, but with
Crosstool, I've successfully sat down for an evening and build raw
(i.e. no OS support) cross-compilers for elf, elf64, i386, x86_64, and
PPC. It takes a while, but it'll work perfectly.

Yug3sh

unread,
Jun 11, 2009, 5:30:19 PM6/11/09
to

Great.. thanks for the pointers. I'll give that a try.

0 new messages