Hello Rémi, I was trying to do similar with rr-debugger [1] to load symbols iterating over mapped files, but it never got into a really got state.
But with a little modification (patch attached), your script does the same and is way less complicated.
I noted just one issue while testing a little with notepad.exe, with plain gdb and rr:
Sections other than .text of ELF libraries get mapped to address 0x0. (Could you see this too in 'info target'?) This combined with a kind of huge .data section of shell32.dll.so overlaps then with .text of notepad.exe, therefore gdb shows then in a backtrace not the right symbols. The other attached patch tries to also map the data section to resolve this. But I am not sure if other sections should also be mapped.
Thanks for sharing.
Kind regards, Bernhard