-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some symbols not making it into final core executable file #96
Comments
Imported from trac issue 65. Created by jphickey on 2015-06-08T16:08:14, last modified: 2019-03-05T14:57:55 |
Trac comment by jphickey on 2015-06-08 16:10:48: Implementing option 2 above for now. This is easy to do and it should not break any currently supported target as they all use GNU gcc/ld as the compiler and linker. |
Trac comment by jphickey on 2015-06-08 16:25:59: Pushed commit [changeset:f444663] for review Branch is "trac-65-cfecore-whole-archive-link". This adds the {{{--whole-archive}}} and {{{--no-whole-archive}}} linker options around CFE core, PSP, and OSAL which solves the problem for now. |
Trac comment by glimes on 2015-06-08 17:12:25: Wow, yes, I've hit this on other platforms in other contexts. The traversal from bunch-of-sources to bunch-of-objects Option 1 does sound like the right thing. Is there a way that I prefer Option 2 over Option 3. As a side note, only dragging The downside of #34 is not only the fragile collection of calls I'll watch my Bamboo logs to see if any of our agents are |
Trac comment by glimes on 2015-06-08 17:19:03: At least one Bamboo Agent will trip over this. {{{ |
Trac comment by jphickey on 2015-06-08 17:19:57: Also pushed commit [changeset:c71f372] which represents Option 3 above, as I had an idea on how this could be done relatively cleanly and not be overly "fragile" in terms of future maintenance. This is slightly more complicated than Option 2 but it does not hack the link line therefore should be compatible with linkers other than GNU. This generates a table of function pointers to the undefined symbols so the overhead is minimized, but it will end up still using sizeof(void (*)(void)) of memory for each entry in the table. On the flip side, this object could potentially even be stripped from the final exe to recover that memory. But in the current form this is only one entry so this is only 4 (or 8) bytes and probably not worth the effort yet. |
Trac comment by glimes on 2015-06-08 17:32:37: Just got a "CMake" failure from one of the RHEL agents |
Trac comment by glimes on 2015-06-08 17:33:59: Whoa, wait a sec, this is CFE, and my issue is |
Trac comment by jphickey on 2015-06-09 09:42:30: The following is a complete list of symbols that had been missing from the cfe core executable, but are included when building using the commits listed here. This is generated by running "diff" on the symbol table of {{{core-cpu1}}} before and after merging this fix. {{{ Option 2 performs a "catch-all" while option 3 gives more fine grained control over which symbols to include. In the current form option 3 will include the TBL functions but leave out the PSP ones. |
Trac comment by jphickey on 2015-07-21 11:19:52: Another possible downside to {{{--whole-archive}}} (option 2) is that it precludes one from supplying overrides to common code. Example: If using the {{{--whole-archive}}} for the PSP code then this results in duplicate symbols for these objects. But normally, without this option, only the first implementation of these functions in the link line is used and this can override the common functions later in the link line to get target-specific behavior. Might be worth considering only using {{{--whole-archive}}} for the CFE core and possibly OSAL. |
Trac comment by sstrege on 2015-07-24 16:20:31: The gsfc_build tool setvars script and makefiles are setup to allow a user to build the CFE without including Table Services. How do these options support this? |
Trac comment by glimes on 2015-07-27 12:34:20: As an aside, It might be a good idea to aim at |
Trac comment by sduran on 2015-07-27 17:28:26: It sounds like this is only a cmake issue. I have never seen it with the default Makefiles. I'd vote for option 1, maybe 2, not 3. |
Trac comment by jphickey on 2015-07-27 17:46:51: Replying to [comment:12 sduran]:
That is mostly a true statement - as Greg pointed out there was also a case in the classic build where But yes, this is mainly a CMake issue.... Some background: These larger CMake is very similar except it does not do the partial links, but builds static libraries instead for the intermediate OSAL, CFE, and PSP builds. Hence the slightly different linking semantics and why unreferenced code was getting pruned out. With this linker-pruning behavior caveat aside, the intermediate static library approach is arguably preferable since it does not rely on any toolchain-specific behavior i.e. the way static libraries behave are relatively consistent even on non-GNU toolchains. The partial link behavior ( |
Trac comment by jphickey on 2015-07-28 17:07:29: CCB review updates: [changeset:242c3ab] updates the [changeset:27a667b] updates the export symbol solution (option 3) to be a general purpose tool that a mission could use to ensure that any arbitrary symbol gets linked into the final exe. The symbol list is made into a cpu-specific file that is sourced from the mission definition directory, so it is entirely controlled by the mission configuration. An empty/nonexistant file (default) will have no effect on the build or link. The file is called |
Trac comment by glimes on 2015-07-30 15:15:51: [changeset:242c3ab trac-65-cfecore-whole-archive-link] is included in [changeset:6ea42ba ic-2015-07-28] [changeset:655d94e trac-65-export-symbol-table] is included in [changeset:6ea42ba ic-2015-07-28] |
Trac comment by glimes on 2015-09-08 12:58:14: ... somehow was not closed after the 07-28 integration was complete. |
Trac comment by glimes on 2016-02-16 13:16:45: Susie confirmed these tickets have been approved for CFE 6.5 |
Trac comment by jhageman on 2019-03-05 14:57:55: Milestone renamed |
In the current "cmake"-based build scripts, the final cfe core executable file is missing symbols that are not directly referenced in other parts of CFE. A notable example of this is {{{CFE_TBL_Register}}}.
Because these are defined in a shared library, the linker is simply not including them as they do not serve to define any unresolved symbols from the linker's point of view.
The {{{-rdynamic}}} option is already being used, but it does not apply since the CFE core code is in a static library.
There are several approaches to this problem:
Use the {{{MODULE}}} library type instead of making a static library for the CFE core. This way the {{{-rdynamic}}} export option will be applied to all the cfe code as it should be and therefore all functions included in the final link. This is the correct, officially supported solution but it requires cmake v2.8.8+ (released 2012). However RHEL still includes a very old version of cmake from 2009 with their distribution so going this route forces users of RHEL to go to other sources for a newer cmake.
Use the {{{--whole-archive}}} linker option to force the linker to include all objects from the CFE core, PSP, and OSAL libraries during the link. This works, but the {{{--whole-archive}}} is specific to the GNU ld linker and is unlikely to be supported on any other linkers. However, it appears that all targets supported by CFE use the GNU ld linker so this may not be a problem.
Create a "fake" function that calls all external functions, which causes them to be undefined and therefore included in the link. This does not change linker options or build scripts so should work with ANY linker and the old version of cmake, but it wastes some memory as this function is still loaded into memory, and it will require maintenance to keep it up to date.
The text was updated successfully, but these errors were encountered: