3 ms·
I worked with a.out on early unixes and elf on later ones - not addressed here is the main reason for switching: ELF allowed you manage pages contiguously on di
by Taniwha 5y ago
I worked with a.out on early unixes and elf on later ones - not addressed here is the main reason for switching: ELF allowed you manage pages contiguously on disk so that they could be paged in directly (stuff can be page aligned within the file at it's natural offsets), while a.out was designed for swapped kernels where you would just read() data into a text section, address 0 might be 32 bytes from the start of a file (disk space was more of a concern back then).
- colejohnson66 5y agoWhat’s the advantage of that? Would the kernel just load the entire file into contiguous memory and set up pages at the correct physical addresses?
- gumby 5y agoYou can load multiple pages in a single read operation, yes, and do less computation when trying to load/purge on a per-page basis (instead of a lookup table you just do a single addition)
- brandmeyer 5y agoThere are also segmentation differences. Only one copy of the read-only data and code (aka text) segments are mapped into all programs which load the library. However, each program instance gets its own unique pages of read-write data. Those pages are always located at a fixed offset from their code segment. That way, modern CPUs can execute PC-relative instructions to generate their addresses. The global data segments for a module are always located at a fixed offset relative to the code pages. See ARMv8 `adrp` (address of PC-relative page), RISC-V `auipc` (add upper immediate to program counter), and x86-64 PC-relative addressing for some modern examples. Then go backwards in time and see how ARMv7 does it (literal pools) and how some earlier RISCs did it (Itanium and Alpha global pointer aka "gp", PowerPC table-of-contents register).
- pjc50 5y agoMap the file into memory, but not actually load it, just set up the mapping and wait until it's used to pagefault it in.
- Taniwha 5y agoThat's what we did on the old swap based systems, on modern paged systems we don't read pages in untill there is a page fault, to do that efficiently we need to align page boundaries with disk block boundaries - elf (and coff before it) allowed you to do this while a.out doesn't
- pjmlp 5y agoAlthough Aix went the Windows way with XCOFF instead of ELF. It is a kind of funny feeling to deal with import libraries and definition files on an UNIX.