Page MenuHomeFreeBSD

remove CONSTRUCTORS from kernel linker scripts
ClosedPublic

Authored by emaste on Jul 28 2016, 12:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 15 2024, 11:17 PM
Unknown Object (File)
Feb 15 2024, 11:17 PM
Unknown Object (File)
Feb 15 2024, 11:05 PM
Unknown Object (File)
Feb 15 2024, 10:48 PM
Unknown Object (File)
Dec 22 2023, 9:41 PM
Unknown Object (File)
Sep 6 2023, 7:49 AM
Unknown Object (File)
Aug 3 2023, 11:18 PM
Unknown Object (File)
Aug 3 2023, 11:15 PM
Subscribers
None

Details

Summary

The linker script CONSTRUCTORS keyword is only meaningful "when linking object file formats which do not support arbitrary sections, such as ECOFF and XCOFF"[1] and is ignored for other object file formats.

LLVM's lld does not yet accept (and ignore) CONSTRUCTORS, so just remove it from the linker scripts since it has no effect. (Patch in progress upstream so lld will probably accept and ignore CONSTRUCTORS soon, but it seems sensible to me to clean it up.)

[1] https://sourceware.org/binutils/docs/ld/Output-Section-Keywords.html

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste retitled this revision from to remove CONSTRUCTORS from kernel linker scripts.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added reviewers: andrew, imp, kib.
emaste updated this object.
kib edited edge metadata.

Should it be replaced by *(SORT_BY_NAME(.ctors))'and*(SORT_BY_NAME(.dtors))' constructs, as mentioned in the ld manual ? H, it actually is.

This revision is now accepted and ready to land.Jul 28 2016, 9:44 AM

Do we use or support .ctors or .dtors in the kernel? If not I don't see why we would need to add them.

Do we use or support .ctors or .dtors in the kernel? If not I don't see why we would need to add them.

In principle the answer is yes, we might some day allow the attribute ((constructor)) to work in kernel. E.g. it might occur before the MI sysinit pass. For this reason, I do not see why would it be useful to strip linker script from many features which seems to be unused now.

This revision was automatically updated to reflect the committed changes.
In D7343#152829, @kib wrote:

Do we use or support .ctors or .dtors in the kernel? If not I don't see why we would need to add them.

In principle the answer is yes, we might some day allow the attribute ((constructor)) to work in kernel. E.g. it might occur before the MI sysinit pass. For this reason, I do not see why would it be useful to strip linker script from many features which seems to be unused now.

AFAIK (based on GNU ld's documentation) CONSTRUCTORS has (had) no effect for ELF output, this change would only have an effect on us if we built e.g. ECOFF-format kernels.