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

Objcopy symbols are mixed or invalid in executable

As a simple example of my problem, let's say we have two data arrays to embed into an executable to be used in a C program: chars and shorts. These data arrays are stored on disk as chars.raw and shorts.raw. Using objcopy I can create object files…
pizzapants184
  • 172
  • 3
  • 8
0
votes
1 answer

Clang: compile IR, C files and apply opt in one line

I'm building an IR level Pass for LLVM which instrument the functions with calls to my runtime library. So far I have used the following lines to compile any C file with my pass and link it with the runtime library and guaranteeing that the runtime…
Nour
  • 1
0
votes
1 answer

Incorrect relative address using GNU LD w/ 16-bit x86

Firstly, my native system is amd64, Windows, using cygwin, and the GNU toolchain and binutils. I am writing an x86 bootloader but can't get ld to generate correct relative addresses. I've prepared this minimum reproducible…
Lolechi
  • 151
  • 1
  • 3
  • 20
0
votes
1 answer

When will used function not appear in object file symbol table

Sometimes some clearly called funtion in a translation unit (TU) is not in the compiled object file's symbol table (with nm -aC file.o). What could be the reason? The reason could be: (1) The call is optimized: not for the bellow example, it is the…
jw_
  • 1,663
  • 18
  • 32
0
votes
0 answers

*.o files in C++

Why are the files of C++ after compiling called object file? For example if I type in in the linux shell g++ -c .cpp I understood how they are working but the name confuse me a little bit. If I'm not mistaken *.o files are similar to *.class…
bilaljo
  • 358
  • 1
  • 6
  • 13
0
votes
1 answer

Dependency on object files which are created in different binary

There are some object files say a.o and b.o created when the binary engine is created. Makefile .PHONY all all: engine cars Now this second binary cars needs .o files a.o and b.o created while creating binary engine The problem here is I am using…
0
votes
1 answer

Are JVM heap/stack different than virtual address space heap/stack?

Memory is divided into "segments" called heap, stack, bss, data, and text. However, the JVM also has these concepts of stack and heap. So how are these two reconciled? Are they different levels of abstraction, where main memory is one or two levels…
heapoverflow
  • 153
  • 1
  • 8
0
votes
1 answer

Appending Items to an object file

I know there are similar questions but none of them have helped me as I tried their methods and it is simply not working. I would appreciate any advice on this topic I am having trouble appending objects to an object file. I am trying to do a…
0
votes
1 answer

What does an object file 'do' and why is it required?

Suppose I have the following asm program, exit.s: .section .text .globl _start _start: movl $1, %eax movl $0, %ebx int $0x80 When I run the following command to build the object file: $ as exit.s -o exit.o What exactly is this doing,…
user12050586
0
votes
1 answer

C Prototype Function - object file

When compiling a c source file in Linux how a prototype function is treated? Is the symbol stored in the object file (formatted as ELF file) or a signature is stored to make reference to it when linking? For example: #define MAX 32 typedef struct{ …
roger21
  • 45
  • 5
0
votes
1 answer

makefile compiles only the first source file

I have a list of two source files, but the makefile compiles the first source file twice. This is my makefile: Source = ../Src Source_Files = $(Source)/File_1.c \ $(Source)/File_2.c Obj = ./Obj Object_Files = $(notdir…
Daniel
  • 1
0
votes
1 answer

RISC-V: Size of code size in an object file which is not linked

I have a .i file which I have compiled but not linked using the SiFive risc-v compiler as follows: ../riscv64-unknown-elf-gcc-8.2.0-2019.05.3-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc clock.i However when I do a readelf -S on the compiled…
Har
  • 3,727
  • 10
  • 41
  • 75
0
votes
0 answers

Is it possible to make executable file, .exe, from object file in Windows?

I was accessing one of my old codes but the .cpp is not available. Only the .o is available. Other answers on Stackoverflow seem to only be for Linux terminal. Is it possible on Windows by any means?
0
votes
2 answers

Can static libraries that don't rely upon the C standard library be compiled on one OS, then moved to another?

I know that for full programs this is impossible because of executable file formats and syscalls, however if you had a file with: int add(int a, int b) { return a + b; } Could you compile it as an object file or static library on…
user11246901
0
votes
2 answers

Why do internally linked names appear in my object file's symbol table?

Why do internally linked names appear in my object file's symbol table? The question is not important. I am merely curious. Here is sample code: namespace { static int foo() {return 10;} } static int bar() {return 20;} Using GNU's readelf -s…
thb
  • 13,796
  • 3
  • 40
  • 68