I use the executable file demo.axf of the project in STM32F4xx_DFP.2.15.0, execute readelf -S demo.axf on the command line and find that demo.axf has .debug.str, but when I compile this project, I find .debug. str disappeared.
My development environment is: keil5.36 MDK, my goal is to extract variable names from .debug.str.
You may check if you have enabled the option "Options for Target - Output - Debug Information":
https://www.keil.com/support/man/docs/uv4/uv4_dg_adsout.htm
Moreover, check which compiler toolchain version you are using.
On my side, a Blinky example project from the STM32F4xx_DFP.2.15 is built with Armclang v6.16 in MDK v5.36 and I got the .debug_str section in the axf image