> On Oct 5, 2016, at 4:25 PM, valerij zaporogeci <[email protected]> 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 > [email protected] > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

