I have apparently managed to use objcopy to weaken the list of symbols involved, according to a dump from objdump.
Used objcopy @cmdfile.txt libc.a libc-weakened.a
--weaken-symbol __retarget_lock_init
--weaken-symbol __retarget_lock_init_recursive
--weaken-symbol __retarget_lock_close
--weaken-symbol __retarget_lock_close_recursive
--weaken-symbol __retarget_lock_acquire
--weaken-symbol __retarget_lock_acquire_recursive
--weaken-symbol __retarget_lock_try_acquire
--weaken-symbol __retarget_lock_try_acquire_recursive
--weaken-symbol __retarget_lock_release
--weaken-symbol __retarget_lock_release_recursive
--weaken-symbol __lock___arc4random_mutex
--weaken-symbol __lock___dd_hash_mutex
--weaken-symbol __lock___tz_mutex
--weaken-symbol __lock___env_recursive_mutex
--weaken-symbol __lock___malloc_recursive_mutex
--weaken-symbol __lock___at_quick_exit_mutex
--weaken-symbol __lock___atexit_recursive_mutex
--weaken-symbol __lock___sfp_recursive_mutex
--weaken-symbol __lock___sinit_recursive_mutex
objdump shows
00000000 w F .text.__retarget_lock_init 00000004 __retarget_lock_init
00000000 w F .text.__retarget_lock_init_recursive 00000004 __retarget_lock_init_recursive
00000000 w F .text.__retarget_lock_close 00000004 __retarget_lock_close
00000000 w F .text.__retarget_lock_close_recursive 00000004 __retarget_lock_close_recursive
00000000 w F .text.__retarget_lock_acquire 00000004 __retarget_lock_acquire
00000000 w F .text.__retarget_lock_acquire_recursive 00000004 __retarget_lock_acquire_recursive
00000000 w F .text.__retarget_lock_try_acquire 00000008 __retarget_lock_try_acquire
00000000 w F .text.__retarget_lock_try_acquire_recursive 00000008 __retarget_lock_try_acquire_recursive
00000000 w F .text.__retarget_lock_release 00000004 __retarget_lock_release
00000000 w F .text.__retarget_lock_release_recursive 00000004 __retarget_lock_release_recursive
00000000 w O .bss.__lock___arc4random_mutex 00000001 __lock___arc4random_mutex
00000000 w O .bss.__lock___dd_hash_mutex 00000001 __lock___dd_hash_mutex
00000000 w O .bss.__lock___tz_mutex 00000001 __lock___tz_mutex
00000000 w O .bss.__lock___env_recursive_mutex 00000001 __lock___env_recursive_mutex
00000000 w O .bss.__lock___malloc_recursive_mutex 00000001 __lock___malloc_recursive_mutex
00000000 w O .bss.__lock___at_quick_exit_mutex 00000001 __lock___at_quick_exit_mutex
00000000 w O .bss.__lock___atexit_recursive_mutex 00000001 __lock___atexit_recursive_mutex
00000000 w O .bss.__lock___sfp_recursive_mutex 00000001 __lock___sfp_recursive_mutex
00000000 w O .bss.__lock___sinit_recursive_mutex 00000001 __lock___sinit_recursive_mutex
Now the Q is where to put the modified library. If I just replace the one in c:\ST\.... it will get overwritten next time Cube is installed. I have found a place:
project / properties / c/c++ build / settings / mcu g++ linker / libraries, and add the path to "libraries"
but, what a surprise, that doesn't work. The linker command line is correct
arm-none-eabi-g++ -o "xxxxxx.elf" @"objects.list" -l"C:/xxxxxx/Project1/LIBC/libc-weakened.a" -mcpu=cortex-m4 -T"C:\xxxxxx\Project1\LinkerScript.ld" --specs=nosys.specs -Wl,-Map="xxxxxx.map" -Wl,--gc-sections -static -u _printf_float -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group
but it doesn't like it
c:\st\stm32cubeide_1.10.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: cannot find
-lC:/KDE485/Project1/LIBC/libc-weakened.a
Unfortunately I have no other entries in the Libraries box which I could copy.