|
From: Vincent R. <vin...@fr...> - 2023-08-11 14:34:49
|
Dear FreeMiNT users, I've designed a new executable format named PRG/ELF (a.k.a elf32-atariprg). It is 100% PRG and 99% ELF. Basically, it is a standard ELF executable embedded into a PRG. It has a PRG header at the beginning, followed by ELF data, then a PRG relocation table as usual. As it is a valid PRG, it can be loaded as usual by TOS or FreeMiNT. Because of the PRG header, standard ELF tools can't recognize such binary as ELF. But after a tiny patch to skip the PRG header, they just work. So such executables provide the best of the 2 worlds: full PRG compatibility, and almost full ELF compatibility after minor patch of the ELF tools. Nowadays, ELF is the standard format for .o files and executables. It is used by Linux and many other systems. Key point is the ability to organize data in arbitrary "sections" stored in the files. Some sections are automatically loaded into memory by the operating system. Other sections can contain additional data, not loaded, such as debug information. The trick: in an ELF executable, loaded sections are always stored before non-load sections. So I just arranged things to fit loaded sections into the PRG TEXT/DATA segments, and non-loaded sections into the PRG symbols table. As the symbols table is never loaded by the OS, it just works: such extra data doesn't waste any RAM (except the small ELF headers at the beginning). I'll give more detailed technical information later. So I'm glad to announce a brand-new toolchain with GCC 13: m68k-atari-mintelf toolchain with PRG/ELF format It is available on that new page: http://vincent.riviere.free.fr/soft/m68k-atari-mintelf/ As usual, Cygwin and Ubuntu binaries are provided. You can safely install them side-by-side with the old m68k-atari-mint a.out toolchain, they won't interfere. This toolchain features: - binutils 2.41 gas is configured to produce ELF object files. And I have patched the linker to produce PRG/ELF executables. This is a brand-new patch for the ELF linker, I have completely reworked it. There is no more a.out stuff in that patch, so we don't have to fear obsolescence anyore. Fortunately, there are some similarities between the a.out and ELF targets, so I've been able to reuse some code from Guido's original patch. The tricky part was to convince ld to write a valid ELF header after the beginning of the file. But after some efforts, it finally worked. Note that I haven't enabled any a.out stuff. So you can't reuse old a.out libraries (but you can rebuild them). - MiNTBin I have patched the tools such as m68k-atari-mintelf-stack and m68k-atari-mintelf-flags to support the new PRG/ELF file format. This was a piece of cake. I also kept support for the old a.out files, so those tools can still be used on any PRG. - GCC 13.2.0 The GCC patch has always been rather thin (as most of the magic resides in the binutils). Thorsten has regularly tested new GCC versions, and added many features on his own fork. In the version I provide here, I have stripped the GCC patch to a maximum, just to enable support for the new m68k-atari-mintelf target. I thank Thorsten for his efforts, specially on the C++ library support. So I've been able to quickly use his GCC before stripping it down. Of course features could easily be reintroduced. - FDLIBM Oh, I have finally dropped PML. Many thanks to Thorsten for his hard work on this math library. It works out of the box. - There is also gemlib, cflib, gemma, as usual. So, how to try this new toolchain? Install it. Then use m68k-atari-mintelf-gcc (instead of the old m68k-atari-mint-gcc). Nothing more, it just works. I've been able to build a few programs, as well as EmuTOS and FreeMiNT (*). I only made limited testing. Specially, I haven't tested ColdFire binaries. Nor corner cases such as cpx, ldg, or slb. But we will see shortly. With the obsolescence of a.out in binutils and GCC, we had to find a solution. ELF was the obvious choice. I always thought it was possible to build hybrid PRG/ELF binaries. Now, this is done. We may find a few bugs, but I consider the binutils patch as mature. I expected it to become the new standard for next decades. (*) I encountered minor issues when building FreeMiNT with GCC 13. I will report them in a separate message. Another note: back to 2009, I already made experiments with a mintelf target. It used ELF object files, but a.out PRG files. This was possible as the GNU linker is able to mix different object file formats. But this was only half-ELF. Thorsten still builds that target. I kept the same m68k-atari-mintelf triplet to identify the new PRG/ELF target, because this is really the sequel of that old one, with full ELF support. Enjoy 😃 -- Vincent Rivière |