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
4
votes
1 answer

C++ compiling of a .o file without the .cc file

I have a program were I was given the compiled .o file but I do not have the original .cc file and also I only have a half-way finished header file. The header file has all the method signatures but is lacking the private variable declarations. I…
user972276
  • 2,973
  • 9
  • 33
  • 46
4
votes
0 answers

Microsoft equivalent of ld --relocatable (link into new, relocatable object file)

GNU ld has an option -r / --relocatable to link a number of object files into a new object file. Do the Microsoft tools have a similar feature, either in link, in cl or in some other tool? I do not want to create an archive (because this file will…
user1544337
4
votes
1 answer

How to see the object file contents of a .so file

how to see what .o files constitute .so file? Means how to notice what are the object files are used to build the .so file from the .so file (If I have only the .so file)
MSD Paul
  • 1,648
  • 3
  • 13
  • 31
4
votes
2 answers

How to add object files to a project in Qt

Currently the linker in one project has problems linking to object files generated by source files in another project. Is there some way to manually add those object files to Qt?
wrongusername
  • 18,564
  • 40
  • 130
  • 214
4
votes
2 answers

Why does global symbol in the same file needed to be relocated?

I had a C program for test: a.c int a = 0; static int fa_local() { a = 78; int b; int c; } int fa_global() { a = 7777; fa_local(); } int test() { a = 6666; fa_global(); } This is its relocation table after…
Freeman
  • 61
  • 6
4
votes
2 answers

compiling the source into object files using gcc -c *.c

My OS is Windows 10. I'm using command prompt this time to compile. according to the book that I am reading, to compile all the source files and make it an object files, (in the current directory) do it by typing this command: gcc -c *.c it says…
Bicolano
  • 90
  • 10
4
votes
2 answers

Is there any way to rename the section name in a .o or .a file compiled by gcc?

I have a precompiled library compiled with a gcc-based compiler and I would like to move the functions from the default .text section to some other section name (let's say foo). Is there a way to do this using binutils without recompiling?
Jason S
  • 184,598
  • 164
  • 608
  • 970
4
votes
2 answers

Are object files architecture independent?

Let's say I created an object file from a hello.c on an x86 computer, then sent that file to an ARM computer. Would it be able to build an executable out of the received object file? Assuming we are using gcc. Note: I am aware of cross-compiling as…
Ahmed Farid
  • 127
  • 1
  • 11
4
votes
1 answer

Why do I need to manually link the C runtime library when creating an EXE out of static libraries without any object files?

I'm pretty new to working with libraries and I'm in the process of trying to understand some specifics regarding static libraries and object files. Summary The behavior I'm noticing is that I can link several objects to make an executable with no…
3
votes
1 answer

Generate object files ".o" while compiling project in Visual Studio C++

I'm trying to generate the ".o" output of my ".cpp" files of my project in Microsoft Visual Studio C++ 2010. I already found the answer that says that to compile without link you have to just press Ctrl+F7, however where is that object file…
3
votes
3 answers

Is there anyway to get the statically linked functions contained in a .exe and reuse them?

For example: Say I have linked myprogram.obj with myprogram.lib to make myprogam.exe If myprogram.lib had all sorts of special functions contained in it, and I had accidentally deleted it (and the source), is there a way I could dig into…
scruff
  • 49
  • 2
3
votes
0 answers

How do I mangle C++ names (for GCC-compiled objects on Linux)?

I want to programmatically mangle the name of a C++ function or variable - to get the symbol name which would appear in a compiled object file. I'm using Linux and GCC. Now, why is this not trivial? e.g. typeid(foo).name()? Because that doesn't do…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
3
votes
1 answer

Windows Executable file structure

I know that generally the object file has code, data, heap and stack sections. But I want to know how this is arranged in windows executables and Linux executables. I searched on internet and found some structure. I understood .text is for code and…
Harikrishnan
  • 3,664
  • 7
  • 48
  • 77
3
votes
0 answers

Function sizes including static data in other sections

Is there a convenient way to find the full size cost of a compiled function? Measuring function code sizes is simple (with objdump or nm), but what if a function generates in a non-text section static data such as jump tables from switches. How can…
Petr Skocik
  • 58,047
  • 6
  • 95
  • 142
3
votes
1 answer

Can I compile f90 without recreating .mod files

I am a newbie in fortran and I am trying to understand all I need for the compilation. Until now everything is good but there is something I don't get. Supposing that I modify the code but my modifications wouldn't change the content of the .mod…
supe345
  • 131
  • 6