Page MenuHomeFreeBSD

lib/csu: Ensure that ELF notes are retained with -Wl,--gc-sections
Needs RevisionPublic

Authored by arichardson on Jun 20 2022, 9:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 23, 4:38 PM
Unknown Object (File)
Feb 28 2025, 7:14 PM
Unknown Object (File)
Feb 26 2025, 8:37 AM
Unknown Object (File)
Jan 17 2025, 11:06 PM
Unknown Object (File)
Jan 17 2025, 5:43 PM
Unknown Object (File)
Dec 24 2024, 11:14 PM
Unknown Object (File)
Oct 24 2024, 10:35 AM
Unknown Object (File)
Oct 24 2024, 5:09 AM
Subscribers

Details

Reviewers
jrtc27
jhb
Summary

This requires a rather recent clang (https://reviews.llvm.org/D95730),
so I'm not sure if we can commit this as-is now.

Test Plan

previously building a binary with -static and -Wl,--gc-sections on
would not have the FreeBSD ABI note, and on some architectures (e.g. aarch64)
this would result in the kernel ELF loader rejecting the file with:
ELF binary type "0" not known.
This patch is based on CheriBSD (first patch submitted from my Morello board), but I will update to drop the non-upstream parts if this is considered the correct approach to work around this problem.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46043
Build 42932: arc lint + arc unit

Event Timeline

jrtc27 requested changes to this revision.Jun 20 2022, 9:38 PM

This was considered but not done as it requires the linker to support SHF_RETAIN. The best option is to move the note to just crti and have a dummy crti for CHERI downstream rather than omit it

This revision now requires changes to proceed.Jun 20 2022, 9:38 PM

This was considered but not done as it requires the linker to support SHF_RETAIN. The best option is to move the note to just crti and have a dummy crti for CHERI downstream rather than omit it

Makes sense, it is I was concerned about. How about downstream though, we don't have the old linker constraint there.

I think binutils allows (or allowed) SHF_GNU_RETAIN only with ELFOSABI_GNU or ELFOSABI_FREEBSD, and if we have that then this change is less important.