Page MenuHomeFreeBSD

elf.5: Document .init_array and .fini_array
ClosedPublic

Authored by emaste on May 16 2025, 4:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 3, 10:48 AM
Unknown Object (File)
Mon, Sep 29, 1:17 PM
Unknown Object (File)
Thu, Sep 25, 7:10 PM
Unknown Object (File)
Sep 18 2025, 8:39 PM
Unknown Object (File)
Sep 14 2025, 5:10 AM
Unknown Object (File)
Sep 11 2025, 7:12 AM
Unknown Object (File)
Sep 1 2025, 9:07 AM
Unknown Object (File)
Sep 1 2025, 9:02 AM
Subscribers

Details

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

You might want to mention that for dynamic binaries rtld selects which init model to use based on the presence of the FreeBSD note NOINIT.

mention that for dynamic binaries rtld selects which init model to use

We do describe NT_FREEBSD_NOINIT_TAG in here already. If we add more documentation should it be here or in rtld(1) with an explicit cross reference?

Old binaries: .init and .ctors, called by csu
New binaries with NT_FREEBSD_NOINIT_TAG: .init, .ctors, and .init_array, called by rtld

mention that for dynamic binaries rtld selects which init model to use

We do describe NT_FREEBSD_NOINIT_TAG in here already. If we add more documentation should it be here or in rtld(1) with an explicit cross reference?

Old binaries: .init and .ctors, called by csu
New binaries with NT_FREEBSD_NOINIT_TAG: .init, .ctors, and .init_array, called by rtld

rtld(1) main subject is the rtld use, e.g. env vars affecting the runtime linker, defaults and other user-tweakable stuff. There we describe the binaries format, and IMO there is the right place to add a sentence to point to the NOINIT note.

OK, we already describe NT_FREEBSD_NOINIT_TAG in this man page (elf.5) so perhaps just a mention there?

 .It Dv NT_FREEBSD_NOINIT_TAG Pq Value: 2
 Indicates that the C startup does not call initialization routines, and thus
 .Xr rtld 1
 must do so.
 .Va desc
 is ignored.
+This note must be present for the .init_array and .fini_array sections to be
+processed.

OK, we already describe NT_FREEBSD_NOINIT_TAG in this man page (elf.5) so perhaps just a mention there?

 .It Dv NT_FREEBSD_NOINIT_TAG Pq Value: 2
 Indicates that the C startup does not call initialization routines, and thus
 .Xr rtld 1
 must do so.
 .Va desc
 is ignored.
+This note must be present for the .init_array and .fini_array sections to be
+processed.

IMO it would be redundant. I suggested to mention the note near description of the section (really it should be dyn tags, but ok) to provide a cross-reference.
Otherwise whole man page needs to be memoized to make the right conclusion.

So just a reference to the description of NT_FREEBSD_NOINIT_TAG later in this page?

So just a reference to the description of NT_FREEBSD_NOINIT_TAG later in this page?

Yes.

add rtld and elf note mention

share/man/man5/elf.5
967
971
emaste marked an inline comment as done.

rework NOINIT_TAG reference

I didn't want to have to repeat the description of rtld/NOINIT_TAG twice for .fini_array and .init_array so just put a reference to the existing NOINIT_TAG description.

kib added inline comments.
share/man/man5/elf.5
970

I would put the sentence last in the paragraph.

This revision is now accepted and ready to land.May 24 2025, 3:00 AM
This revision was automatically updated to reflect the committed changes.