Skip to content

Commit

Permalink
Updates per PR Review
Browse files Browse the repository at this point in the history
  • Loading branch information
Javagedes committed Mar 18, 2024
1 parent 44a9d7b commit 5946b89
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
10 changes: 6 additions & 4 deletions src/pe/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,11 @@ impl ctx::TryIntoCtx<scroll::Endian> for Header {
}
}

/// The TE header is a reduced PE32/PE32+ header containing only fields required for
/// execution in the PI architecture. The TE header is described in by the PI spec:
/// https://uefi.org/specs/PI/1.8/V1_TE_Image.html#te-header
/// The TE header is a reduced PE32/PE32+ header containing only fields
/// required for execution in the Platform Initialization
/// ([PI](https://uefi.org/specs/PI/1.8/V1_Introduction.html)) architecture.
/// The TE header is described in this specification:
/// <https://uefi.org/specs/PI/1.8/V1_TE_Image.html#te-header>
#[cfg(feature = "te")]
#[repr(C)]
#[derive(Debug, Default, PartialEq, Copy, Clone, Pread, Pwrite)]
Expand All @@ -600,7 +602,7 @@ pub struct TeHeader {
pub machine: u16,
/// The number of sections
pub number_of_sections: u8,
/// The subystem
/// The subsystem
pub subsystem: u8,
/// the amount of bytes stripped from the header when converting from a
/// PE32/PE32+ header to a TE header. Used to resolve addresses
Expand Down
16 changes: 10 additions & 6 deletions src/pe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,19 +467,23 @@ impl<'a> ctx::TryIntoCtx<scroll::Endian> for PE<'a> {

/// An analyzed TE binary
///
/// A TE binary is a PE/PE32+ binary that has had it's header stripped
/// and re-formatted to the TE specification. This presents a challenge
/// for parsing, as all relative addresses (RVAs) are not updated to
/// take this into account, and are thus incorrect. The parsing of a TE
/// must take this into account by using the `stripped_size` field of the
/// TE header to adjust the RVAs during parsing.
/// A TE binary is a PE/PE32+ binary that has had it's header stripped and
/// re-formatted to the TE specification. This presents a challenge for
/// parsing, as all relative addresses (RVAs) are not updated to take this into
/// account, and are thus incorrect. The parsing of a TE must take this into
/// account by using the [header::TeHeader::stripped_size`] field of the TE
/// header to adjust the RVAs during parsing.
#[cfg(feature = "te")]
#[derive(Debug)]
pub struct TE<'a> {
/// The TE header
pub header: header::TeHeader,
/// A list of the sections in this TE binary
pub sections: Vec<section_table::SectionTable>,
/// Debug information, contained in the PE header
pub debug_data: debug::DebugData<'a>,
/// The offset to apply to addresses not parsed by the TE parser
/// itself: [header::TeHeader::stripped_size] - size_of::<[header::TeHeader]>()
pub rva_offset: usize,
}

Expand Down
16 changes: 11 additions & 5 deletions tests/bins/te/Readme.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# TE binaries

Binaries located in this directory are precompiled PE32/PE32+ binaries using a
terse executable (TE) header as defined in the PI specification:
[TE](https://uefi.org/specs/PI/1.8/V1_TE_Image.html#te-header). These binaries
were compiled using the [EDK2](https://github.com/tianocore/edk2) build system.
terse executable (TE) header as defined in the Platform Initialization (PI)
specification: [TE](https://uefi.org/specs/PI/1.8/V1_TE_Image.html#te-header).
These binaries were compiled using the
[EDK2](https://github.com/tianocore/edk2) build system.

## test_image.te

This binary is a simple Terse executable binary

## test_image_loaded.bin

This binary is the same as `test_image.te`, but it has been loaded by a loader, meaning the sections have been placed in the expected address. Please note that this particular binary has not been relocated, so no relocations have been applied
This binary is the same as `test_image.te`, but it has been loaded by a loader,
meaning the sections have been placed in the expected address. Please note that
this particular binary has not been relocated, so no relocations have been
applied

## test_image_relocated.bin

This binary is the same as `test_image.te`, but it has been loaded by a loader, meaning the sections have been placed in the expected address, and any any relocations have been applied.
This binary is the same as `test_image.te`, but it has been loaded by a loader,
meaning the sections have been placed in the expected address, and any any
relocations have been applied.

0 comments on commit 5946b89

Please sign in to comment.