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
3
votes
0 answers

What is a long section (fragment)? #pragma section (".rdata$T", long, read)

What does long and short mean in the context of sections in the object file? It seems to refer to its size, but there is no documentation on it. Here we see the section name .rdata$T is long, but I don't know what that means, and whether it applies…
Lewis Kelsey
  • 4,129
  • 1
  • 32
  • 42
3
votes
1 answer

What are the meanings of callq command parameters?

I'm aware what the callq instruction does; it is described in this answer. The instruction should have one parameter, which should be the address of the function called. However, when disassembling an object file I see the following line showing a…
Edward
  • 333
  • 2
  • 12
3
votes
3 answers

Hiding non-API symbols in library

Suppose I have a library foo which consists of the modules foo and util and has the following source tree: foo/ foo.c foo.h util.c util.h The public API of the library is defined in foo.h and all global identifiers are properly…
August Karlstrom
  • 10,773
  • 7
  • 38
  • 60
3
votes
3 answers

gcc linking object files with warning/optimization flags

We are compiling a piece of software using generics where files are first made into object files, they are built like so: arm-unknown-linux-gnu-gcc -c -O2 -Wstrict-prototypes -Wdeclaration-after-statement -fsigned-char -I/opt/tm-sdk/include …
Kyle s
  • 484
  • 5
  • 14
3
votes
1 answer

Linking object files from different C compilers

Say I have two compilers, or even a single compiler with two different option sets. Each compiler compiles some C code into an object and I try to link the two .o files with a common linker. Will this succeed? My initial thought is: not always. If…
dls
  • 4,146
  • 2
  • 24
  • 26
3
votes
3 answers

objdump: Can't use supplied machine MIPS

I'm getting following error for the disassembling of the object with below command. Object file was generated for MIPS platform. $objdump -D -m MIPS myobjfile.o Error: objdump: Can't use supplied machine MIPS The snippet I'm attaching for…
Ramesh K
  • 77
  • 1
  • 6
3
votes
2 answers

What exactly is in a .o / .a / .so file?

I was wondering what exactly is stored in a .o or a .so file that results from compiling a C++ program. This post gives a quite good overview of the compilation process and the function of a .o file in it, and as far as I understand from this post,…
PieterNuyts
  • 496
  • 5
  • 20
3
votes
2 answers

Which Delphi Version supports which object file format?

I am searching for a list of supported object file formats for each delphi version. Object files should be linked with something like: {$L lib/object.o}. The Reason for this is a linker error in Delphi7 for a project i maintain. The error does not…
Hugie
  • 455
  • 5
  • 17
3
votes
1 answer

How do you get the initialized value of a global variable out of an object file?

If you have an object file, how do you get the initialized value of a global variable in that object file's data segment? For example, say I've done the following: # I'm interested in the variable foo inside bar.o in libbar.a: $ ar -x libbar.a…
Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
3
votes
2 answers

Knowing the size of a C function in the compiled objectfile

It is easy to get the starting address of a function in C, but not its size. So I am currently doing an "nm" over the object file in order to locate my function and THEN locate the starting address of the next function. I need to do the "nm" because…
3
votes
3 answers

Is there any way to know which symbols are exported in a object file?

Hi I'm working in a Linux environment and I have to link to a object file already compiled which offers me some services (services.o) and I know some of them, but I'd like to know which are all of the exported symbols of it. Is there any way to…
Ana Pazos
  • 33
  • 2
3
votes
2 answers

Linking C and C++ object files

I have the following setup: main.c: extern void sol(); int main(){ sol(); } sol.cc: #include using namespace std; void sol(){ cout<<"HW!!\n"; } I compile to separate object files: $gcc main.c -c $g++ sol.cc -c But when I try to…
Ivan
  • 63
  • 1
  • 5
3
votes
1 answer

Which object file contains the following static templatized "member variable"?

Say I have the following template class with a static member function that itself instantiates a static variable (which is functionally a static member variable instantiated the first time its containing routine is called): template
fbrereto
  • 35,429
  • 19
  • 126
  • 178
3
votes
1 answer

ELF reserved section

I'm currently working on object files in the ELF format generated from some C source files (I don't have, only the object files are available). As I wrote a small tool which extracts all the undefined symbols, I came across some symbols which have…
Franz Xaver
  • 81
  • 1
  • 3
3
votes
1 answer

Avoid duplicate object files using subdir structure with qmake

I have a game with two separate projects for the application itself and the tests. I'm building all of the projects in-source. Here's a shortened version of my project structure: game game.pro app app.pro Entity.h …
Mitch
  • 23,716
  • 9
  • 83
  • 122