From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in4.apple.com (mail-out4.apple.com [17.151.62.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CF7321A1E31 for ; Wed, 5 Oct 2016 17:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1475712480; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AhnVt9h3+g2Kfs4TzftBMHs0is4JYx7vugQamYPi4Vw=; b=EE2ky8iU90IYTkS+D0ApfcroxXjkXP7j0/q6/5072zyj7vqiJIF/WMk/3dTcTK6u UqvuJDBBZJBy6xiVciLzTtd2FRMZdefb3tEvnIy8ae3C/X+erxYbP4LX8CPmp3L6 QsvhvWf9qXuG5oqLPJy9MZkMygF5bXAsVzxqBni49poBazPwlj83ch7gJEvuKe5m TslMJ77DhdU52mJLNZIqIggdcIUgTAj5mJ5qHkdyXGjAGGQx9NZtiLp+WFZjiy2D aOIPccr5hda/6Vdx/Hb0cPkAaGGOYFvWo2t7UaBAyAlb/1prBPVnJnTZfpVX6gTP xR5phJzyq+u0qRw2eaA/Kg==; Received: from relay6.apple.com (relay6.apple.com [17.128.113.90]) by mail-in4.apple.com (Apple Secure Mail Relay) with SMTP id F6.64.07001.0E595F75; Wed, 5 Oct 2016 17:08:00 -0700 (PDT) X-AuditID: 11973e12-23e0e9a000001b59-57-57f595e08fd5 Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by relay6.apple.com (Apple SCV relay) with SMTP id 59.68.23613.0E595F75; Wed, 5 Oct 2016 17:08:00 -0700 (PDT) MIME-version: 1.0 Received: from [17.153.37.250] by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.1.1.0 64bit (built Jun 15 2016)) with ESMTPSA id <0OEL002WEN1B7R30@nwk-mmpp-sz13.apple.com>; Wed, 05 Oct 2016 17:08:00 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Wed, 05 Oct 2016 17:07:59 -0700 Cc: edk2-devel Message-id: <065FA275-0EA3-4516-87EE-233AFF226C58@apple.com> References: <68CAE063-1A6B-493B-B728-B2991F018DC6@apple.com> <85365CC4-AEB9-41F3-9F71-A32A0AFF4588@apple.com> To: valerij zaporogeci X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJLMWRmVeSWpSXmKPExsUi2FAYpftg6tdwg3vHlCz2HDrKbPH4Xzuz A5PHzll32T26Z/9jCWCK4rJJSc3JLEst0rdL4Mq4em42W8Fu4Yqjr3sYGxjP8ncxcnJICJhI 9M7czQJiCwnsZZRY814KJj599h+mLkYuoPghRon7Z2aygiR4BQQlfky+B9TAwcEsIC9x8Lws SJhZQEvi+6NWFoj6d4wSLZcegA0VFhCXeHdmEzOErSSxtHEeO4jNJqAssWL+BzCbUyBY4uCc DlaQmSwCqhJT32tAzNSQ+Lp6OzvEWhuJizt/sUPMP8As8X7JXrCZIgI6EgfvX2QG6ZUQkJWY /csLpEZCYAubxIR5f9kmMArPQnL2LISzZyE5ewEj8ypGodzEzBzdzDwTvcSCgpxUveT83E2M oLCebie0g/HUKqtDjAIcjEo8vDdUv4YLsSaWFVfmHmKU5mBREudl/fA5XEggPbEkNTs1tSC1 KL6oNCe1+BAjEwenVAOjf+qVOb9FfGyrtQ5sP7+48O32h/I8BZrft4bWM+4xupC67X3IVx25 FX9C0r8G+n85vOa5nVXatMWc9lLqOy9dCk05Xx2z95i/ldGykueaB3Yc3v228qTArhv6345l XNV7XbxqUo/M3Q0GrhN6XQo/MW9bzmvw8KtY4dnI2pkPJI984m4+k9FspMRSnJFoqMVcVJwI AMO1EoRMAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeLIzCtJLcpLzFFi42IRbCi+oftg6tdwg/nbZC32HDrKbPH4Xzuz A5PHzll32T26Z/9jCWCK4rJJSc3JLEst0rdL4Mq4em42W8Fu4Yqjr3sYGxjP8ncxcnJICJhI TJ/9hwnCFpO4cG89WxcjF4eQwCFGiftnZrKCJHgFBCV+TL7H0sXIwcEsIC9x8LwsSJhZQEvi +6NWFoj6d4wSLZcesIAkhAXEJd6d2cQMYStJLG2cxw5iswkoS6yY/wHM5hQIljg4p4MVZCaL gKrE1PcaEDM1JL6u3s4OsdZG4uLOX+wQ8w8wS7xfshdspoiAjsTB+xeZQXolBGQlZv/ymsAo OAvJpbMQLp2F5NIFjMyrGAWKUnMSK830EgsKclL1kvNzNzGCA7Qwagdjw3KrQ4wCHIxKPLw3 VL+GC7EmlhVX5gKDgoNZSYT35xSgEG9KYmVValF+fFFpTmrxIcZkoPMnMkuJJucDoyevJN7Q xMTAxNjYzNjY3MScNGElcd7dlz+FCwmkJ5akZqemFqQWwWxh4uCUamBMyQ7pdQ/xYbM7YeZU Jn/t0fL5pqVu+00v6C1sfHpx20blmEfGfeaPqnZvaPzJuZnBd4tCyemSk0pfGDSXpTsv3mb6 IVihlHeewxefSbOOvFjRl3wuanVXyoOnli8+r61LWi1sFPV05+/MyQyKa1fN3bZ6u9WuA7rl DJbKufKPP5i6fG52vWSrxFKckWioxVxUnAgAdOM/9ZQCAAA= 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: Thu, 06 Oct 2016 00:08:01 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Oct 5, 2016, at 4:25 PM, valerij zaporogeci wrote: > >>> 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. Well I'm doing it off the top of my head so I'm not doing a lot of research. If I get a chance at some point I'll re-read the PI spec and see if is a bug in the specification since I can file an ECR to get it fixed. > 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. Quick answer is sectionalignment==filealignment for XIP is from the PE/COFF image point of view. From a TE point of view the FileAlignment has to get adjusted. But please remember TE is really just a shortened version of the PE/COFF header, so other than references to those header values it is still the PE/COFF image. So I have to ask why are you so interested in TE? Thanks, Andrew Fish > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel