Object files are produced by an assembler, compiler, or other language translator, and used as input to the linker.
Question 1: An assembler converts assembly language code (MOV A, B ADD C) to machine code. In case of high-level language like C++, that is generated by linker above. So assembler is not used anywhere. So how can it create an object file as written above? Intermediate code is generated to make the code run on different architectures. Question 2: Are *.class (bytecode) files created by java compiler object files? If yes, then can we say that the JVM that runs them is a type of linker (however its not creating the executable)? Question 3: When we compile a C++ program in Turbo C++, we get *.obj files which are the object files. Can we use them to generate the executable in some other architecture?
Asked By : Shashwat
Answered By : Vor
source codes --(preprocessing)--> "bare" *.c without # stuff --(compiling)------> assembler files --(assembling)-----> object files --(linking)--------> executable
Nowadays all these steps are usually “hidden” (and not necessarily performed by distinct programs) and the user simply click “compile” on his favourite IDE. However you can set some options on the compiler and see all the intermediate files like object files. Question 2: a JVM is an interpreter so you can think of .class files like object codes (bytecode) that are loaded, linked and executed (interpreted) at the same time by the JVM. Question 3: though in principle one can convert an object file to a different target architecture the practical answer is no: it’s much easier to start from the source code and run the entire compiling process targeting a different architecture.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/6506 Ask a Question Download Related Notes/Documents