Page MenuHomeFreeBSD

kernel: Fix defining of .init_array and .fini_array sections
ClosedPublic

Authored by zlei on May 14 2024, 4:24 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 5, 11:55 AM
Unknown Object (File)
Thu, Oct 31, 11:08 AM
Unknown Object (File)
Sun, Oct 20, 1:16 PM
Unknown Object (File)
Fri, Oct 18, 4:46 AM
Unknown Object (File)
Wed, Oct 9, 3:49 AM
Unknown Object (File)
Oct 3 2024, 2:47 PM
Unknown Object (File)
Sep 23 2024, 4:02 AM
Unknown Object (File)
Sep 18 2024, 9:39 PM
Subscribers

Details

Summary

These input sections can have decimal numbers as the priority suffix.
SORT is an alias for SORT_BY_NAME, hence will result in wrong order of
constructors / destructors in output sections. Fix by using the correct
sorting command SORT_BY_INIT_PRIORITY instead [1].

If the input section does not have a priority suffix, then it should be
treated as having a priority of 65535.

Currently these sections are not used, there should be no functional
change.

Note: As for the .ctors and .dtors sections, the priority suffix is in
the form of %05u so there is no semantic difference between SORT_BY_NAME
and SORT_BY_INIT_PRIORITY [2].

  1. https://sourceware.org/binutils/docs/ld/Input-Section-Wildcards.html
  2. https://reviews.llvm.org/D91187

In memoriam: hselasky
Obtained from: https://reviews.freebsd.org/D40467
MFC after: 1 week

Diff Detail

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

Event Timeline

zlei requested review of this revision.May 14 2024, 4:24 AM

Other arch? At the very least a lube in the commit about why not relevant there

This revision is now accepted and ready to land.May 14 2024, 12:54 PM

S/lube/line/. Stupid autocowrecked

In D45194#1030970, @imp wrote:

Other arch? At the very least a lube in the commit about why not relevant there

This is split from D40467 and is the FIX for existing amd64 and i386 arch. This is definitely the right fix so I'd expect it can be landed quickly.
I'm going to update D40467 to only add .init_array and .fini_array sections for other arch (but this fix).

Then a quick line in yhe commit messafe saying its a fix

zlei retitled this revision from kernel: Correctly define .init_array and .fini_array sections to kernel: Fix defining of .init_array and .fini_array sections.May 15 2024, 2:46 AM
In D45194#1031125, @imp wrote:

Then a quick line in yhe commit messafe saying its a fix

Is the commit message kernel: Fix defining of .init_array and .fini_array sections sufficient ?

sys/conf/ldscript.amd64
104

While I was about to commit this, I found this issue.

The functions referenced by section .fini_array is in the normal order, but been executed in the reverse order.

sys/conf/ldscript.amd64
104

And .init_array or .fini_array without init priority should be treated as same with having priority of 65535 .

zlei edited the summary of this revision. (Show Details)

Should ready to go.

This revision now requires review to proceed.May 16 2024, 6:56 AM
This revision was not accepted when it landed; it landed in state Needs Review.Sep 2 2024, 4:30 AM
This revision was automatically updated to reflect the committed changes.