nasa / cFE

The Core Flight System (cFS) Core Flight Executive (cFE)
Apache License 2.0
410 stars 201 forks source link

Replace "--whole-archive" link switch #722

Open jphickey opened 4 years ago

jphickey commented 4 years ago

Is your feature request related to a problem? Please describe. The CFE core executable link process uses --whole-archive to ensure that all functions provided in libraries are actually linked into the executable.

Normally during a link procedure, if a compilation unit within a static library does not resolve any unresolved symbol (i.e. doesn't implement anything that is actually called by the application) it is dropped. However because CFE dynamically loads applications/libraries at runtime, this can be a problem if a particular API is only invoked by apps and not by CFE itself.

The --whole-archive linker flag does accomplish the goal of making sure all the APIs are linked in and available for application use, but it has problems:

Describe the solution you'd like A possible alternative would be to use the OSAL "static symbol" feature to pull in every API that should be available for application use.

Describe alternatives you've considered Leave as-is.

Additional context Downside of this approach is that it requires maintaining a separate list of every public API that CFE core + OSAL is supposed to contain. However, this is already (somewhat) done for unit test stubs.

The upside is that it can help catch errors of missing functions. This may become relevant if/when users are allowed to override parts of CFE with their own implementation (e.g. issue #554). If a required API is missing, this can detect it early and generate a linker error, whereas the current approach will get a runtime error only if/when an application is loaded that tries to use the missing API.

Requester Info Joseph Hickey, Vantage Systems, Inc.

skliper commented 4 years ago

Basic functional tests should also help identify missing API implementations. Once we get black box functional tests implemented... (hopefully soon).