Page MenuHomeFreeBSD

sys/linker_set.h: Add SET_DECLARE_WEAK()
AbandonedPublic

Authored by arichardson on Mar 30 2021, 1:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 13, 9:33 PM
Unknown Object (File)
Sat, Apr 13, 9:17 PM
Unknown Object (File)
Sat, Apr 13, 9:05 PM
Unknown Object (File)
Sat, Apr 13, 8:05 PM
Unknown Object (File)
Thu, Apr 11, 11:17 PM
Unknown Object (File)
Thu, Apr 11, 10:33 PM
Unknown Object (File)
Feb 18 2024, 6:28 AM
Unknown Object (File)
Feb 9 2024, 4:29 PM
Subscribers

Details

Summary

Clang 12 does not allow re-defining weak symbols as non-weak. Therefore, if
we have both SET_DECLARE and DATA_SET/etc. in the same file this triggers
compiler errors. This commit changes the default behaviour of SET_DECLARE()
to declare a non-weak symbol (i.e. we will get linker errors if the set is
empty) and adds a new SET_DECLARE_WEAK() that can be used for optional
linker sets.

This also drops the __GLOBL() that was added back in commit
566af50bd26d7739d1e62d23438b32aef21383eb (r215137)
since both ld.bfd and ld.lld automatically add the __start/__stop
symbols for all orphan sections with the name being a valid C identifier.

Test Plan

fixes compilation errors

Diff Detail

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

Event Timeline

sys/sys/linker_set.h
96

Maybe makes more sense to flip these around so SET_DECLARE comes first and is the primary one?

sys/sys/linker_set.h
96

Yes sounds good, will switch them.

sys/sys/linker_set.h
96

The alternative is to abuse ptype and just make the callers who want a weak symbol use SET_DECLARE(foo, struct bar __weak_symbol)... :)

This revision is now accepted and ready to land.Apr 1 2021, 1:33 PM
This revision now requires review to proceed.Apr 7 2021, 1:19 PM
arichardson edited the summary of this revision. (Show Details)
  • tinderbox fixes
arichardson added a reviewer: kib.

Have to handle the kernel module case, so we do actually need the __GLOBL().