Skip to content

Commit fb018ea

Browse files
andrewrkFri3dNstuff
authored andcommitted
reject crti.o/crtn.o, embrace the future
crti.o/crtn.o is a legacy strategy for calling constructor functions upon object loading that has been superseded by the init_array/fini_array mechanism. Zig code depends on neither, since the language intentionally has no way to initialize data at runtime, but alas the Zig linker still must support this feature since popular languages depend on it. Anyway, the way it works is that crti.o has the machine code prelude of two functions called _init and _fini, each in their own section with the respective name. crtn.o has the machine code instructions comprising the exitlude for each function. In between, objects use the .init and .fini link section to populate the function body. This function is then expected to be called upon object initialization and deinitialization. This mechanism is depended on by libc, for example musl and glibc, but only for older ISAs. By the time the libcs gained support for newer ISAs, they had moved on to the init_array/fini_array mechanism instead. For the Zig linker, we are trying to move the linker towards order-independent objects which is incompatible with the legacy crti/crtn mechanism. Therefore, this commit drops support entirely for crti/crtn mechanism, which is necessary since the other commits in this branch make it nondeterministic in which order the libc objects and the other link inputs are sent to the linker. The linker is still expected to produce a deterministic output, however, by ignoring object input order for the purposes of symbol resolution.
1 parent c1c5c2c commit fb018ea

File tree

60 files changed

+7
-2346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+7
-2346
lines changed

lib/libc/glibc/sysdeps/aarch64/crti.S

Lines changed: 0 additions & 103 deletions
This file was deleted.

lib/libc/glibc/sysdeps/aarch64/crtn.S

Lines changed: 0 additions & 54 deletions
This file was deleted.

lib/libc/glibc/sysdeps/arm/crti.S

Lines changed: 0 additions & 97 deletions
This file was deleted.

lib/libc/glibc/sysdeps/arm/crtn.S

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)