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
1
vote
1 answer

How to implement this subclass specifically to get around appending object file?

I was having trouble appending object file in my program. I found this SO answer. However, I do not know how to subclass an AppendableObjectOutputStream. Can anyone kindly teach me how in more detail?
LulalaBoss
  • 127
  • 1
  • 9
1
vote
2 answers

NASM 'org' directive with '-fobj'

Why doesn't NASM compile to an object file with the org directive? org 0x7C00 nop mov ax, ax nop If I compile this with: nasm -O0 -fobj temp.asm NASM gives me an error for whatever reason: temp.asm:1: error: parser: instruction expected
Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
1
vote
2 answers

How to check if a macro exists in an object file in C?

For example, I define a macro: #ifdef VERSION //.... do something #endif How can I check if VERSION exist in my object file or not? I tried to disassemble it with objdump, but found no actual value of my macro VERSION. VERSION is defined in…
Amumu
  • 17,924
  • 31
  • 84
  • 131
0
votes
2 answers

Include static lib in shared object?

I would like to compile a bunch of static libs into a shared object. So far I have g++ -Wl -shared -fPIC -o myshared.so objs/*.o Where the objs/*.o above contains all the object files extracted from the various static libs using ar. UPDATE:…
chriskirk
  • 761
  • 1
  • 11
  • 22
0
votes
1 answer

Difference of Sizes of Various Fields Between Object File and Executable File

I got the following information using the size command in linux, for a sample c++ program. text data bss dec hex filename 1908 304 152 2364 93c test 346 4 1 351 15f test.o I have read that…
Izza
  • 2,389
  • 8
  • 38
  • 60
0
votes
1 answer

Extracting a single procedure from an object file?

I have a 64-bit COFF object file (no source code or debug info) from which I need to extract a single procedure. The procedure is relatively short, and its only dependencies are: One global variable. A couple of imported procedure. I have already…
user541686
  • 205,094
  • 128
  • 528
  • 886
0
votes
2 answers

Is there a way to compile the program without assembly in GCC?

Possible Duplicate: Using GCC to produce readable assembly? For example, when I try: gcc -c myprogram it will give me an object file, which is in binary form. What I would like to get is just an assembly file (right before it is processed by an…
user188276
0
votes
1 answer

LWJGL .OBJ File reader sometimes disforming or not rendering the file

I am working on a game with some friends, and to make life easier I decided all out 3D models are going to be made using .obj files, exported in programs like 3DSMax, Maya, and Blender3D. So I have written a .obj file reader and tried it out in a…
D3_JMultiply
  • 1,022
  • 2
  • 12
  • 22
0
votes
1 answer

how to debug fortran program with multiple object files?

I have a fortran program that calls some dependent .o object files. I would like to be able to step across files when debugging, is this possible? the compilation routine goes something like this: gfortran -g -o analyze.x analyze.o active.o…
ejang
  • 3,982
  • 8
  • 44
  • 70
0
votes
1 answer

symtab entries in a .o file of elf format

i am learning about linking.. i wrote the following code in c and made .o using gcc int f() { static int x=0; return x; } extern int z; int g() { static int x=10; return x; } static int y; static int y=9; int main() { return 0; } then i made…
AvinashK
  • 3,309
  • 8
  • 43
  • 94
0
votes
3 answers

One-to-one linking in C

Is there any way to implement linking of object files in C, in such a way that certain objects can only be linked together with each other? Eg. Trying to link Object 1 and Object 2 will work and produce a working executable, but trying to link…
evol
  • 103
  • 3
0
votes
0 answers

gcc ld objdump. What tool should I use in order to have an the section of an object file having all three permissions read write and execute?

I am using g++ on ubuntu. I compile some code and I need to unify the code section ".text" with the data section ".data" regarding a specific compilation unit ( object file ). I already managed using directives like attribute((section(".mydata")))…
George Kourtis
  • 2,381
  • 3
  • 18
  • 28
0
votes
3 answers

Why the Class definition does compile one way and not the other?

I simplified the code to 2 files compiled independently and linked together. file: main.cpp class A{ public: int value; A(int); }; #include using namespace std; int main(int argc, char **argv) { A a{7}; …
George Kourtis
  • 2,381
  • 3
  • 18
  • 28
0
votes
0 answers

Add an object file(.obj) into a shared library file(.so)

I am using an open source program and there is a shared library file(.so). And I would like to add my object file(.obj) into the .so file, but I do not know how to do it. Could anyone let me know how to add mycode.obj to lib.so in Ubuntu? I have…
0
votes
1 answer

Reverse engineering C object files

I'm practicing reverse engineering C object files. Suppose I have an object file of the C program: #include #include int main (int argc, char ** argv) { char * input = argv[1]; int result = strcmp(input,…
Said Hamed
  • 15
  • 5