From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x242.google.com (mail-io0-x242.google.com [IPv6:2607:f8b0:4001:c06::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EB80D1A1E2A for ; Wed, 5 Oct 2016 16:25:38 -0700 (PDT) Received: by mail-io0-x242.google.com with SMTP id p26so151663ioo.2 for ; Wed, 05 Oct 2016 16:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Ucjdsk0lQbJpqvu9rf+ChE4A8gWq3+Hx+jIe9Im6gqA=; b=irVRD7blFTSPMMOQ8pCwEtZEAcfkS/6SUKZsuyiyVQ8Ncjcligxu/NudhjgXfLR+7r 4N83Jv/ooKC6ytDcxdtvcNgaXe7Zt410BDetntPWs9p/vNxhmccc8OMotyAKSpwxl/03 TjGqc/Lsk9kFh1khA9kKA4mpQ7owh2kd6gAfj7HQfqO+y94zbY7vaI/xnRmYyVTR4sqm w1dxvqmTrGJmmgDz1t6NVR1fql+ttjVFsq3XBa9g7NB1n7qVlbF3YtFnPIklVgWBEh3g OlH4jGMgwuheLYLZvqdfuvMSilYDHaeti6TJvmIv3GAPaMZbaBRAidt0T0wpURy2uzI0 pcxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Ucjdsk0lQbJpqvu9rf+ChE4A8gWq3+Hx+jIe9Im6gqA=; b=WUdmWoviNICDIFntwoF5mlsnwuID1YyQknl6uUIjIM8nTrGvYw2i1NBrB17m+rUSGI Ti3OFAfSz8qUYCTc19ZlinXp8C6D8Bo1wE0APt3V2DqJGGxPwYy31g/pGgzzxT5mIzXu hcDq2XXpNxxML5Wt2bQRYoWd/VzkeHvjP2vPQDQZR16FmlQc2fp8JCf4No+G5YDNEaTR yiNgCk2arfGYl40+SVAAGU8PxYSurep0KYoGsXu7ItnGbH+l3Qi2bktPl0p++lXV3RAA R8CRCDzHfsgMgtk3s3Ne48taXgJu0BC2QsfFkL8AB3cdvRnfhw73I1FxTxysD2vSJxu6 JoRQ== X-Gm-Message-State: AA6/9RmVr/JAxYd7lnTf8FTozaMyIahWRg2QUtUNYOCaot0BEcdzsjAG3XEZSK716s7p9vzpxPwQFlqSlS4JEQ== X-Received: by 10.107.157.15 with SMTP id g15mr7674018ioe.191.1475709938117; Wed, 05 Oct 2016 16:25:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.203.132 with HTTP; Wed, 5 Oct 2016 16:25:37 -0700 (PDT) In-Reply-To: References: <68CAE063-1A6B-493B-B728-B2991F018DC6@apple.com> <85365CC4-AEB9-41F3-9F71-A32A0AFF4588@apple.com> From: valerij zaporogeci Date: Thu, 6 Oct 2016 02:25:37 +0300 Message-ID: To: Andrew Fish Cc: edk2-devel Subject: Re: TE relocations X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2016 23:25:39 -0000 Content-Type: text/plain; charset=UTF-8 >> The ImageBase is the same for PE/COFF and TE. >> In the code ImageAddress points to the start of T or P (well P can have a DOS header >> prepended etc). I think a lot of the code operates on ImageAddress and thus needs the >> adjustment. Well, I don't want to abuse your attention. Just last try to explain the incosistency here I can not resolve. Suppose we have some imaginable ISA instruction somewhere in code: LOAD r1, [0x402f04bc] and 0x402f04bc is the address of some symbol, resolved by linker. let's parse this address. Let ImageBase be 0x402f0000, and data section offset be 0x400 and finally data item offset in the section be 0xbc. Data section is also at 0x400 from the file beginning, since sectionalignment==filealignment, which means the layout is the same. When it is loaded at 0x402f000, everything works. Data section is at 0x400 from there, and our variable is at 0xbc from the section start. Now, we make TE from it. Now, the data section in the TE file is NOT at 0x400 from the file beginning (it is closer). And when (and if) TE is loaded such that TE header is placed in memory at THE SAME ImageBase address as the original PE would have been, the referenced variable will not be at 402f04bc. And the code, referencing address 0x402f4bc, would get something else instead of this variable content. This is not the case in the reality. But why? The PI specification recipe, with only AddressOfEntryPoint adjustment and without adjustment of anything else referenced (in the code) should result in this incostistency.