Page MenuHomeFreeBSD

sys/linker_set.h: Add SET_DECLARE_WEAK()

Authored by arichardson on Mar 30 2021, 1:57 PM.



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

rS FreeBSD src repository - subversion
Lint OK
No Unit Test Coverage
Build Status
Buildable 38401
Build 35290: arc lint + arc unit

Event Timeline


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


Yes sounds good, will switch them.


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().