Questions tagged [object-files]

An object file is the real output from the compilation phase.

An object file is the real output from the compilation phase. It's mostly machine code, but has info that allows a linker to see what symbols are in it as well as symbols it requires in order to work. (For reference, "symbols" are basically names of global objects, functions, etc.)

A linker takes all these object files and combines them to form one executable (assuming that it can, ie: that there aren't any duplicate or undefined symbols). A lot of compilers will do this for you (read: they run the linker on their own) if you don't tell them to "just compile" using command-line options. (-c is a common "just compile; don't link" option.)

293 questions
8
votes
2 answers

Ambiguous behaviour of .bss segment in C program

I wrote the simple C program (test.c) below:- #include int main() { return 0; } and executed the follwing to understand size changes in .bss segment. gcc test.c -o test size test The output came out as:- text data bss dec…
Maharshi Roy
  • 358
  • 2
  • 11
8
votes
1 answer

How is standard library for programming language implemented?

I have problem understanding how are standard libraries for programming languages, other than C, written. As far as i understand, C standard libraries can be implemented in mixture of C and assembler, where assembler is needed so system calls can be…
7
votes
0 answers

Compiling 3rd party obj file in to 64 bit Delphi app - exception frames issue

I'm trying to use a 3rd party object file in my 64 bit Delphi app, however it simply crashes. Including their mod64.obj compiles and links OK and the functions in the obj can be called, but then the code crashes. The mod64.obj was assembled with…
David Rose
  • 130
  • 1
  • 8
7
votes
7 answers

My C++ object file is too big

I am working on a C++ program and the compiled object code from a single 1200-line file (which initializes a rather complex state machine) comes out to nearly a megabyte. What could be making the file so large? Is there a way I can find what takes…
zaratustra
  • 8,148
  • 8
  • 36
  • 42
7
votes
3 answers

Doubts in executable and relocatable object file

I have written a simple Hello World program. #include int main() { printf("Hello World"); return 0; } I wanted to understand how the relocatable object file and executable file look like. The object file corresponding…
bala1486
  • 1,039
  • 2
  • 14
  • 19
6
votes
2 answers

Difference between Executable and Linkable Format(.elf) and Object(.o) file

I was looking in the gcc manual on linux (man gcc), for the -c option (gcc -c infile) which states: -c: Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object…
Upgrade
  • 75
  • 1
  • 9
6
votes
2 answers

Where can I find the object file which contains the definition of printf function?

I am using gcc compiler and ubuntu 12.04 OS. I want to know where can I find the object file and under which directory, which contains the definition of printf function. Again I am not looking for the header file which contains prototype but the…
Ananda
  • 1,572
  • 7
  • 27
  • 54
5
votes
1 answer

How do the tries work that are used in the mmo object format's symbol tables?

I try to understand, how the mmo object file format works, which is used for Don Knuth's educational MMIX architecture. I have not bought MMIXware, so I have to guess most of the details from the literate source files of the assembler and…
fuz
  • 88,405
  • 25
  • 200
  • 352
5
votes
2 answers

C++ Multiple Definition of Struct

I have header util.hpp containing a simple struct: // util.hpp struct Point { float x; float y; }; Two cpp files, let's call them a.cpp and b.cpp, both include util.hpp: // a.cpp #include "util.hpp" void funcA(float _x, float _y) { Point…
Amplify
  • 865
  • 1
  • 8
  • 18
5
votes
1 answer

Object Files/Executables: What's the difference between a segment and a section?

I am confused at to whether there is a difference between "segment" and "section" when referring to object files/executables. According to https://en.wikipedia.org/wiki/Object_file: Most object file formats are structured as separate sections of…
Dean Leitersdorf
  • 1,303
  • 1
  • 11
  • 22
5
votes
5 answers

How can I see the 0s and 1s / machine code from a executable file / object file?

I already tried this, I opened a a.out file with a text editor but I get only a bunch of characters with some instructions in it like: üÙ
5
votes
1 answer

Error While Linking Multiple C Object files in Delphi 2007

I am new to delphi. I was trying to add C Object files in my Delphi project and link them directly since Delphi Supports C Object Linking. I got it working when i link a single Object file. But when i try to link multiple object files, i am getting…
Ramnish
  • 322
  • 3
  • 12
5
votes
0 answers

How to replace symbols in object files

I want to rewrite object files so that most of the functions' addresses are altered to a no-op function. How can I do this? More context: In C++ I want to auto-mock all functions by default. To go from having a() call a() {} and b() call b() {} to…
Mark
  • 3,806
  • 3
  • 21
  • 32
5
votes
1 answer

Disassemble Microsoft Visual Studio 2003 compiler output

I'm seeing what I think is strange behaviour from object files output by the Microsoft Visual Studio 2003 tools. The file utility tells me: asmfile.obj: 80386 COFF executable not stripped - version 30821 For objects created by the assembler, but…
Carl Norum
  • 219,201
  • 40
  • 422
  • 469
5
votes
1 answer

Copying compiled binaries to another machine using Flash Drive

This may be a stupid question, but if I compile a shared library using g++ on one distribution of Linux, and then move those libraries as object files via flash drive to another computer with the exact same Linux distro and version of g++ will I…
kjh
  • 3,407
  • 8
  • 42
  • 79
1 2
3
19 20