LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I have a question about binary executables (https://www.linuxquestions.org/questions/linux-newbie-8/i-have-a-question-about-binary-executables-652071/)

trist007 06-27-2008 09:27 AM

I have a question about binary executables
 
I've been starting to use gcc in fedora 8 to compile and run programs in C. I have a dual boot system going with fedora 8 and win xp. My question is, since I compile the src code into an executable binary file (a.out) in fedora 8 using gcc, and since both OS are obviously running the same cpu architecture x86, theoretically, this a.out executable binary file should run in winxp, right? I don't need a cross compiler if the program is in binary machine code that my processor can understand. Is my understanding correct?

How would I go about running a.out in winxp? Is there some command in cmd?

cmnorton 06-27-2008 10:35 AM

Loading The Image
 
I believe this has to do with the linker and the instructions necessary to get your executable image loaded into memory and run. There is wine to go from Windows to Linux, and perhaps with the right libraries you might be able to run this under cygwin, but I've never tried it. I would conditionally compile the source for either OS.

trist007 06-27-2008 11:05 AM

I thought that since a.out is broken down into machine code(binary), that it isn't necessary to load libraries since the source code is already interpreted into machine language. Theoretically, it should work by simply loading into memory.

jschiwal 06-27-2008 11:11 AM

No it won't work. Not only are the system calls different, an elf file is different than a windows executable.

jomen 06-27-2008 11:11 AM

"a.out" is AFAIK a really old format - todays standard is "ELF"
No - a binary (or a library) compiled to run on linux is not going to run on windows.
Wether a.out or ELF - makes no difference there.

knudfl 06-27-2008 12:06 PM

jomen : a.out is just the object, you are getting from gcc,
when no object name is specified, still an ELF file.
I think, I read that it was changed in gcc-4.3 (released 18 days ago ?).

Rgds

jomen 06-27-2008 01:42 PM

Though I run Gentoo I don't know much of this except that I remember now that you are saying this - you are right.
But then again - isn't this just the name?

I guess I'm confused by the text I quite often read when configuring a new kernel:

Section: Executable file formats
[*] Kernel support for ELF binaries
< > Kernel support for a.out and ECOFF binaries
<*> Kernel support for MISC binaries

the help-texts on the second:
Quote:

A.out (Assembler.OUTput) is a set of formats for libraries and
executables used in the earliest versions of UNIX. Linux used
the a.out formats QMAGIC and ZMAGIC until they were replaced
with the ELF format.

The conversion to ELF started in 1995. This option is primarily
provided for historical interest and for the benefit of those
who need to run binaries from that era.

Most people should answer N here. If you think you may have
occasional use for this format, enable module support above
and answer M here to compile this support as a module called
binfmt_aout.

knudfl 06-28-2008 01:29 AM

Seems to be more than one explanation, googling a.out,
most say "old" and...
http://www.ncsa.uiuc.edu/UserInfo/Re...iles/a.out.htm

Rgds


All times are GMT -5. The time now is 10:58 PM.