From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.13168.1681833034225811971 for ; Tue, 18 Apr 2023 08:50:34 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TjAdV0FI; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C18316361E for ; Tue, 18 Apr 2023 15:50:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF3BCC4339C for ; Tue, 18 Apr 2023 15:50:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681833032; bh=XPXyGBXgASVgjR7dw4te8AUYT+vFJSQgIOdALZ4a600=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=TjAdV0FIIeYoeNMhA+Bk0M7vuI0Ok1rzRrhFDdzOWjiG2uKCOEeoappqX/K/UuMqW evx/AtKcfNimqv7cgoU09lq0pBUhiy154Pz75ME66Ney/13f1MTTRH1SeCeI+4OXSk 1DCWrKORW3HcoEXbf+R9yB1jlYPdi9fq7SHss/I3+436pjxSVEaO8sW+jdCMUnflkw tFmhW5jcVNF7ZvSrdUBvhUxb/SzphJNDlqxJQc31Mh2xrGRgStXFY2ftpvd9tkazzb Oz3oXZa2vqXIv9zO+ZwnQzflQtZB+83Jv3aaVRIx13GOVEDn7OwfxTONlwYX/daeHv QbeWLnoguUt+A== Received: by mail-lj1-f169.google.com with SMTP id h8so15004626ljf.3 for ; Tue, 18 Apr 2023 08:50:32 -0700 (PDT) X-Gm-Message-State: AAQBX9do5GiW5tcFT/Q4b0aZ0VleTzPexHaKMx3oUO2LLfP7lk/JJm3V mWMzuIJC+1IYFhS/xuGPftFKaYTxn+xd1ALxbGo= X-Google-Smtp-Source: AKy350ZU+sRpsfhoPCd9u9Y9p5qFXb9YueOWSfT23IVFJpGvkoqS9QdNvh7RV0su8ZHqDo+hkd7lddvJTNfExp1Mfds= X-Received: by 2002:a2e:99c2:0:b0:2a7:7647:8694 with SMTP id l2-20020a2e99c2000000b002a776478694mr904121ljj.36.1681833030688; Tue, 18 Apr 2023 08:50:30 -0700 (PDT) MIME-Version: 1.0 References: <20230414080250.1357004-2-kraxel@redhat.com> <18EC1A6E-8B81-4564-83A5-DA8EC2BA54ED@posteo.de> In-Reply-To: From: "Ard Biesheuvel" Date: Tue, 18 Apr 2023 17:50:19 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v4 01/10] BaseTools: add BASETOOLS define To: Gerd Hoffmann Cc: devel@edk2.groups.io, =?UTF-8?Q?Marvin_H=C3=A4user?= , Pawel Polawski , Dongyan Qian , Sunil V L , Baoqi Zhang , Chao Li , Rebecca Cran , Ard Biesheuvel , Zhiguang Liu , Liming Gao , Yuwei Chen , Leif Lindholm , Michael D Kinney , Daniel Schaefer , Bob Feng , Oliver Steffen Content-Type: text/plain; charset="UTF-8" On Tue, 18 Apr 2023 at 15:20, Gerd Hoffmann wrote: > > On Tue, Apr 18, 2023 at 01:59:43PM +0200, Ard Biesheuvel wrote: > > On Tue, 18 Apr 2023 at 13:52, Gerd Hoffmann 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 >