As Professor Falken said, it depends on the compiler / system ... but ... Linux, Windows, Mac, popular / primary toolchains:
The compiler takes a high-level source and makes an assembly from it, the assembler turns it into an object. The object decides what relative addresses it can, but leaves the keys to the linker.
The linker ... links ... it takes objects, their binary blobs, organizes them into the binary address space that is mentioned, it selects addresses for things like global and functions. These are mostly places .text, .data and .bss.
Then there is mmu in the hardware, this greatly simplified life, you can, for example, compile each program, for example, the address 0x8000 as an entry point, and have many programs all running at 0x8000 at the same time. Because they all think that they are at this address, because they are in the virtual address space on the virtual side of mmu. On the physical side, they all actually live at different addresses, but in general, only the operating system should take care of this.
Therefore, compilers today usually place functions in the order in which we wrote them in the source code in the object, in the .data and .bss files that they sometimes rebuild. Usually linkers work the way they are told, and who tells them? Ultimately, we programmers, but the tool binding provided to you has default values ββ(for example, automatic assembly of compiled code into an object and automatic binding), including boot code and default linker script. This default linker script for this compiler for this target operating system is configured according to the rules of this operating system.
The above is what you usually see with gcc and other primary compilers for the leading windows, mac and * nix operating systems. This does not mean that there arent toolchains that do something else, compiling directly to the final binaries or collectors that go directly to the final binary, and not to the object. Of course, historically this was not always the case. Until you get into these corner cases, I assume that you will have the above experience when you get into the tools.