From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.8662.1681824026285544125 for ; Tue, 18 Apr 2023 06:20:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AUAvJiEg; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681824024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5zBSKThyf9lHI4H/+Xv//7JR8Q1/mUNRdJcdUeLSIzk=; b=AUAvJiEgsfy3+gaZkJ6S2LiTTHGcNlPXkGxfGPjxGvtb/k9whHiZEYMhMtZ7vCBWx6v9rE 76oEz/jZFw3CL2qJY2+4PVB333AWitnkc0NTagIlQjOi9ULNrps1xaPHQpcHN0UnpK24rU 2KzL2lYKLl0aqzj6OcJdShsx411enpA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-438-38EcjR23NDiF-pQeF1AM9w-1; Tue, 18 Apr 2023 09:20:19 -0400 X-MC-Unique: 38EcjR23NDiF-pQeF1AM9w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 096C885A588; Tue, 18 Apr 2023 13:20:18 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.149]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CF79D10DF8; Tue, 18 Apr 2023 13:20:16 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0BBF5180061C; Tue, 18 Apr 2023 15:20:15 +0200 (CEST) Date: Tue, 18 Apr 2023 15:20:15 +0200 From: "Gerd Hoffmann" To: Ard Biesheuvel Cc: devel@edk2.groups.io, Marvin =?utf-8?Q?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 Subject: Re: [edk2-devel] [PATCH v4 01/10] BaseTools: add BASETOOLS define Message-ID: References: <20230414080250.1357004-2-kraxel@redhat.com> <18EC1A6E-8B81-4564-83A5-DA8EC2BA54ED@posteo.de> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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? > 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