Skip to main content

All Questions

Filter by
Sorted by
Tagged with
-3 votes
3 answers
129 views

How does does compiler know the definition of pre defined function even before linker haven't linked object file and library file?

We know that definition of pre defined functions are in library files, and it is the job of linker to link that library code(which is already compiled) to our object file (which has been created after ...
Harsh Chaudhary's user avatar
2 votes
0 answers
240 views

reference to external function in disassembly code [duplicate]

I am trying to see everything in big picture regarding compilation and linking. I have below simple function implemented in add_caller.c : extern int add(int a, int b); int main(int argc, char **...
Abhishek Sagar's user avatar
8 votes
3 answers
653 views

Global const optimization and symbol interposition

I was experimenting with gcc and clang to see if they can optimize #define SCOPE static SCOPE const struct wrap_ { const int x; } ptr = { 42 /*==0x2a*/ }; SCOPE struct wrap { const struct wrap_ *ptr; ...
Petr Skocik's user avatar
  • 60.3k
3 votes
3 answers
472 views

How does linker handle variables with different linkages?

In C and C++ we can manipulate a variable's linkage. There are three kinds of linkage: no linkage, internal linkage, and external linkage. My question is probably related to why these are called "...
Leedehai's user avatar
  • 3,990
2 votes
1 answer
111 views

Can const variables be modified from elsewhere not known at compile time

If const is a compile time construct, it would mean that only the compiler will ensure that for example if a variable is declared as const, this variable is read only and it is not attempted to be ...
Engineer999's user avatar
  • 4,061
1 vote
1 answer
512 views

What's the necessity of .bss section in an object file? [duplicate]

Wikipedia mentions that .bss section occupies no actual space in the object file, and I indeed find a .bss entry with size 0 in the objdump information. So the question is what's the necessity of such ...
pedim's user avatar
  • 69
4 votes
1 answer
2k views

How does a linker work exactly (microcontroller context)?

I've been programming in C and C++ for quite a long time now, so I'm familiar with the linking process as a user: the preprocessor expands all prototypes and macros in each .c file which is then ...
Mister Mystère's user avatar
2 votes
0 answers
549 views

static compilation and got, plt sections.

I am writing a toy elf loader for some small project. To test my loader, I have been compiling my app statically. However, I realized even after static compilation, my app still contains .got and .got....
agent.smith's user avatar
  • 9,476
0 votes
2 answers
170 views

How linker creates executable files and links C keywords

I have created 2 C programs in Ubuntu(Linux 2.6) as below 1.c ---- main() { } 2.c ---- #include<stdio.h> main() { int a[500]; float f[1000]; double d[100000]; int i = 0; for(i = 0;i < 10000;...
Vijay's user avatar
  • 9
0 votes
2 answers
443 views

How a pointer initialization C statement in global space gets its assigned value during compile/link time?

The background of this question is to understand how the compiler/linker deals with the pointers when it is initialized in global space. For e.g. #include <stdio.h> int a = 8; int *p = &a;...
user3214692's user avatar
1 vote
1 answer
1k views

Relocating functions during run time - gcc

I'm working with 2 memories on my device, DDR and SRAM. The device is running a pre-OS code written in C and ARM. I would like to conduct a DDR calibration, for that I need to copy a few functions to ...
dear_tzvi's user avatar
  • 745
9 votes
3 answers
3k views

Why does inserting characters into an executable binary file cause it to "break"?

Why does inserting characters into an executable binary file cause it to "break" ? And, is there any way to add characters without breaking the compiled program? Background I've known for a ...
Steve Brown's user avatar
  • 1,426
3 votes
1 answer
702 views

How are variable and function references resolved (Linker & Compiler)? [closed]

I was reading this on SO when I actually started to wonder how the linker resolved especially adresses of symbols in an object file and how it would be organized inside the executable file outputted ...
xQuare's user avatar
  • 1,323
32 votes
4 answers
21k views

how do compilers assign memory addresses to variables?

I teach a course where students get to ask questions about programming (!): I got this question: Why does the machine choose were variables go in memory? Can we tell it where to store a variable? ...
Dervin Thunk's user avatar
  • 20.2k
4 votes
2 answers
3k views

How does the compiler know about the instruction set of my CPU? [closed]

I've read that The compiler converts code written in a human-readable programming language into a machine code representation which is understood by your processor. How does the compiler know ...
OnlyQuestions's user avatar

15 30 50 per page