From: valerij zaporogeci <vlrzprgts@gmail.com>
To: Andrew Fish <afish@apple.com>
Cc: edk2-devel <edk2-devel@lists.01.org>
Subject: Re: TE relocations
Date: Wed, 5 Oct 2016 22:24:51 +0300 [thread overview]
Message-ID: <CANPuzFyCvvux4cBW+CyfUp_CdunS9RN63tA5VUEd7SkuVpv0Og@mail.gmail.com> (raw)
In-Reply-To: <68CAE063-1A6B-493B-B728-B2991F018DC6@apple.com>
Thank you, Andrew, I guess I understood. PE/TE images get relocated at
FV creation time, they execute directly from FV and they are linked at
where they really will lie in XIP memory. And the alignment value
chosen is not that minimum of 512 byte, mentioned in the PE
specification. Now it's clear. The only thing I still don't get is
that:
Suppose you have your input PE image, which you need to translate in
TE. It's linked at 0. It has a code section and it is lying (in the
file) at the first available 20h aligned offset right after all the
headers. Now you make translation into TE following the specification
algorithm. It says you should strip away all not needed stuff from the
beginning of the PE file, then put TE header instead (28h byte) and
right after it you should place all the remaining PE content. But
constructed this way TE, will break absolute referencies in the code.
Suppose some code references some data, using its address: address =
<ImageBase>:0 + <DataSectionBase> + <SectionOffset>. Where
DataSectionBase is the offset of the beginning of the section from the
ImageBase, thus its RVA. ImageBase remains the same - 0, SectionOffset
too, but _actual_ DataSectionBase, would not be the same for the newly
created TE, because stripping got the data section closer to the file
beginning. Every reference to the data would be broken. Base
relocation at the FV creation won't help, since it changes ImageBase
(from 0 to "ROM address"), it doesn't fix DataSectionBase mismatch. If
after PE->TE translation, "somehow" DataSectionBase remains the same,
then what space saving it is? :)
next prev parent reply other threads:[~2016-10-05 19:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-05 15:08 TE relocations valerij zaporogeci
2016-10-05 16:51 ` Andrew Fish
2016-10-05 19:24 ` valerij zaporogeci [this message]
2016-10-05 20:58 ` Andrew Fish
2016-10-05 21:45 ` valerij zaporogeci
2016-10-05 22:11 ` Andrew Fish
2016-10-05 23:25 ` valerij zaporogeci
2016-10-06 0:07 ` Andrew Fish
2016-10-06 13:01 ` valerij zaporogeci
2016-10-08 8:54 ` Gao, Liming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CANPuzFyCvvux4cBW+CyfUp_CdunS9RN63tA5VUEd7SkuVpv0Og@mail.gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox