On 6/9/21 1:35 AM, Zimoch Dirk (PSI) via Core-talk wrote:
> On VxWorks, softIoc.munch and softioc.PVA.munch are statically linked. As normal with static linkage, only those symbols actually used in the program are copied into the program. While this is usually totally sufficient, it becomes a problem when the statically linked program dynamically loads plugins as possible with 'dlload' (or 'ld' on VxWorks).
> Those dynamically loaded plugins may use EPICS functions that are defined but not used in EPICS Base itself, resulting in load errors like this:
> Warning: module 0x76a130 holds reference to undefined symbol epicsMessageQueueReceiveWithTimeout.
>
> I have seen this on VxWorks only, as this is the only platform where I use static linkage with dynamic loading of modules. But I guess that other platforms may be affected as well. As I have never seen any complaints about this behavior, I may be the only one who uses softIoc this way.
I think the combination of static exe + dynamic loading would probably have the same
problem on any target using GCC. Dropping unused symbols is more of a compiler/linker behavior.
That said, I don't see this combination as useful on targets which support shared libraries.
Also, I suspect that the stricter rules of DLL linking would make this combination difficult
if not impossible on Windows. Not a big loss though since regular DLL builds should work
without issue.
> Anyway, the problem is easy to fix, and I would appreciate to have the fix included future EPICS releases:
> Add the linker flag -whole-archive when building softIoc/softIocPVA.
> I have added PROD_LDFLAGS_vxWorks = --whole-archive to modules/database/src/std/softIoc/Makefile and modules/pva2pva/pdbApp/Makefile.
> Maybe this or something similar (I don't know the corresponding Windows linker flag) should be done not only for VxWorks but for all statically built versions.
If available, '--gc-keep-exported' sounds like exactly what you want.
cf. https://sourceware.org/binutils/docs/ld/Options.html
> --gc-keep-exported
> When --gc-sections is enabled, this option prevents garbage collection of unused input sections that contain
> global symbols having default or protected visibility. This option is intended to be used for executables
> where unreferenced sections would otherwise be garbage collected regardless of the external visibility of
> contained symbols. Note that this option has no effect when linking shared objects since it is already the
> default behaviour. This option is only supported for ELF format targets.
Also, I'm not sure if this is relevant, but the entry for '--whole-archive' cautions:
> ... Second, don’t forget to use -Wl,-no-whole-archive after your list of archives,
> because gcc will add its own list of archives to your link and you may not want this
> flag to affect those as well.
- References:
- softiIoc and softIocPVA incomplete on VxWorks (and others?) Zimoch Dirk (PSI) via Core-talk
- Navigate by Date:
- Prev:
AW: softiIoc and softIocPVA incomplete on VxWorks (and others?) Zimoch Dirk (PSI) via Core-talk
- Next:
Re: softiIoc and softIocPVA incomplete on VxWorks (and others?) Johnson, Andrew N. via Core-talk
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
<2021>
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: softiIoc and softIocPVA incomplete on VxWorks (and others?) Johnson, Andrew N. via Core-talk
- Next:
Build completed: EPICS Base 7 base-7.0-335 AppVeyor via Core-talk
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
<2021>
2022
2023
2024
|