The JIT code registration protocol makes it possible to register while gdb is not attached to an inferior, and then when gdb attaches, it will crawl through the backlog of registration requests. However, there is no notification to the inferior that something has been successfully registered. As a result, those registration entries cannot be freed, nor can the ELF objects they point to. The registration entries are small enough to not worry about, but it bothers me to have to hang onto thousands of ELF objects after the relevant information has already been copied over and is in gdb's data structures. Perhaps it's verboten to write into the inferior's memory, but if gdb set a flag on an entry to say that it had been registered (or something like that), then I could free the memory. (As far as I can tell, gdb only uses the address where the object was to identify it for unregistration. It never needs to access it after registration.)
The first GDB can detach (either intentionally, or due to a crash), and another GDB can reattach. IIUC, your suggestion would make the second GDB not be able to find the JIT elf files.
Doh! You're right. I suppose there could be an option to point to a file rather than an in-memory blob, but I don't know if I would want to use that or not.