>So non-PIC binaries are of the type `reloctable once and fixed-up forever', >then? And thus the binaries emitted by `gcc' without any particular >flags don't assume a fixed base address, then?
Yes, for DSOs. It's not the case for application binaries; these do have a fixed-for-all-time base address which is set during the final link. >In the old NetBSD/arm32 1.0 world, I remember there was a stage when >a bunch of binaries needed a recompile to a different base addresses, >because more space was being made for the page maps (or something like >that). And that's where my assumption stuck. Yeah. It's a similar kind of story with the old a.out shared libraries. >Will stuff loaded by dlopen() and friends automatically get the benefit >of sharing if compiled with `-fPIC'? Yes. When you load a DSO, it's just mapped into your address space at some random location, and it starts off completely shared with any other instances. The dynamic linker then grovels through its relocation data to wire it into the environment it finds itself in. Any pages that it has to write to will be COW'd and stop being shared; for PIC code this is only the GOT, but for non-PIC it could well be every page of text because the relocs have to be fixed up in place. p.