I'm currently trying to understand how the linker assigns memory locations in a C project with two source files. One file contains static global, local global, and extern variables, while the other attempts to access an extern variable from the first file.
In terms of linkage, there are three types: external linkage (e.g., extern variables), internal linkage (e.g., static global variables), and variables with no linkage (e.g., local variables).
I'm trying to know whether it's the compiler or the linker that allocates memory. My current understanding is that the compiler initially allocates memory because source files are compiled separately, and then the linker updates the final memory locations. I would appreciate clarification on this process.
In terms of linkage, there are three types: external linkage (e.g., extern variables), internal linkage (e.g., static global variables), and variables with no linkage (e.g., local variables).
I'm trying to know whether it's the compiler or the linker that allocates memory. My current understanding is that the compiler initially allocates memory because source files are compiled separately, and then the linker updates the final memory locations. I would appreciate clarification on this process.