On Tue, 18 Apr 2023 at 15:20, Gerd Hoffmann <kra...@redhat.com> wrote: > > On Tue, Apr 18, 2023 at 01:59:43PM +0200, Ard Biesheuvel wrote: > > On Tue, 18 Apr 2023 at 13:52, Gerd Hoffmann <kra...@redhat.com> wrote: > > > > > > Seems to work fine on fedora 37, even without adding --relax, maybe this > > > is enabled by default (there is a --no-relax switch after all). I'll go > > > try older distros / compilers / binutils too. > > > > > > What would be the failure mode? Errors on ELF -> PE conversion because > > > a GOT is present? Or will things break at runtime? > > > > > > > The problem here is that we rely on --emit-relocs to get at the > > relocations in the binary, in order to convert the absolute ones into > > PE/COFF relocations. > > > > However, --emit-relocs did not use to cover the GOT, as those are > > added at the end by the linker and not by the compiler. So if the GOT > > is non-empty, the resulting PE executable will be corrupt. > > So no build error. And at runtime probably random effects, depending on > whenever the execution path happens to hit a bad relocation or not. So > compile + boot testing doesn't cut it. Lovely. > > So, what can I do instead? Check **/DEBUG/*.debug and see whenever a > .got section is present? >
We should probably add an ASSERT() to the linker script, just like I did for Linux: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e544ea57ac0734bc https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=262b5cae67a67240 > > Of course, the answer here is to dump GenFw altogether for ELF to PE > > conversion, and implement something that consumes the dynamic > > relocations generated when linking in PIE mode. > > Marvin's ImageTool is exactly that I think ... > > take care, > Gerd > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#103167): https://edk2.groups.io/g/devel/message/103167 Mute This Topic: https://groups.io/mt/98257896/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-