mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-25 18:48:42 +02:00
ImageTool: Support FixedAddress
This commit is contained in:
parent
692969b2b1
commit
9fe980971f
@ -292,7 +292,8 @@ GenExecutable (
|
||||
IN const char *TypeName,
|
||||
IN const char *HiiFileName,
|
||||
IN const char *BaseAddress,
|
||||
IN bool Strip
|
||||
IN bool Strip,
|
||||
IN bool FixedAddress
|
||||
)
|
||||
{
|
||||
UINT32 InputFileSize;
|
||||
@ -360,7 +361,8 @@ GenExecutable (
|
||||
BaseAddress != NULL,
|
||||
NewBaseAddress,
|
||||
InputFileName,
|
||||
Strip
|
||||
Strip,
|
||||
FixedAddress
|
||||
);
|
||||
|
||||
if (OutputFile == NULL) {
|
||||
@ -394,7 +396,7 @@ int main (int argc, const char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
Status = GenExecutable (argv[3], argv[2], "PE", argv[4], argc >= 6 ? argv[5] : NULL, NULL, FALSE);
|
||||
Status = GenExecutable (argv[3], argv[2], "PE", argv[4], argc >= 6 ? argv[5] : NULL, NULL, FALSE, FALSE);
|
||||
if (RETURN_ERROR (Status)) {
|
||||
raise ();
|
||||
return -1;
|
||||
@ -422,7 +424,7 @@ int main (int argc, const char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
Status = GenExecutable (argv[4], argv[3], "PE", NULL, NULL, argv[2], FALSE);
|
||||
Status = GenExecutable (argv[4], argv[3], "PE", NULL, NULL, argv[2], FALSE, FALSE);
|
||||
if (RETURN_ERROR (Status)) {
|
||||
raise ();
|
||||
return -1;
|
||||
|
@ -40,7 +40,8 @@ typedef struct {
|
||||
uint16_t Machine;
|
||||
uint16_t Subsystem;
|
||||
uint8_t IsXip;
|
||||
uint8_t Reserved[7];
|
||||
uint8_t FixedAddress;
|
||||
uint8_t Reserved[6];
|
||||
} image_tool_header_info_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -96,7 +96,8 @@ ToolImageEmit (
|
||||
IN bool Relocate,
|
||||
IN uint64_t BaseAddress,
|
||||
IN const char *SymbolsPath OPTIONAL,
|
||||
IN bool Strip
|
||||
IN bool Strip,
|
||||
IN bool FixedAddress
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
@ -159,6 +160,10 @@ ToolImageEmit (
|
||||
}
|
||||
}
|
||||
|
||||
if (FixedAddress) {
|
||||
ImageInfo.HeaderInfo.FixedAddress = true;
|
||||
}
|
||||
|
||||
OutputFile = NULL;
|
||||
if (Format == UefiImageFormatPe) {
|
||||
OutputFile = ToolImageEmitPe (&ImageInfo, OutputFileSize, Strip);
|
||||
|
@ -22,7 +22,8 @@ ToolImageEmit (
|
||||
IN bool Relocate,
|
||||
IN uint64_t BaseAddress,
|
||||
IN const char *SymbolsPath OPTIONAL,
|
||||
IN bool Strip
|
||||
IN bool Strip,
|
||||
IN bool FixedAddress
|
||||
);
|
||||
|
||||
#endif // IMAGE_TOOL_EMIT_H
|
||||
|
@ -337,6 +337,23 @@ ToolImageEmitPeSectionHeaders (
|
||||
SectionOffset += Sections[Index].SizeOfRawData;
|
||||
}
|
||||
|
||||
if (Image->HeaderInfo.FixedAddress) {
|
||||
for (Index = 0; Index < Image->SegmentInfo.NumSegments; ++Index) {
|
||||
if ((Sections[Index].Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) == 0) {
|
||||
WriteUnaligned64 (
|
||||
(VOID *)&Sections[Index].PointerToRelocations,
|
||||
Image->HeaderInfo.BaseAddress
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == Image->SegmentInfo.NumSegments) {
|
||||
raise ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*BufferSize -= SectionHeadersSize;
|
||||
*Buffer += SectionHeadersSize;
|
||||
|
||||
|
@ -18,16 +18,34 @@ ScanUefiImageGetHeaderInfo (
|
||||
IN UEFI_IMAGE_LOADER_IMAGE_CONTEXT *Context
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
UINT64 Address;
|
||||
|
||||
assert (HeaderInfo != NULL);
|
||||
assert (Context != NULL);
|
||||
|
||||
HeaderInfo->BaseAddress = (uint64_t)UefiImageGetPreferredAddress (Context);
|
||||
HeaderInfo->BaseAddress = UefiImageGetPreferredAddress (Context);
|
||||
HeaderInfo->EntryPointAddress = UefiImageGetEntryPointAddress (Context);
|
||||
HeaderInfo->Machine = UefiImageGetMachine (Context);
|
||||
HeaderInfo->Subsystem = UefiImageGetSubsystem (Context);
|
||||
// FIXME:
|
||||
HeaderInfo->IsXip = true;
|
||||
|
||||
Status = UefiImageGetFixedAddress (Context, &Address);
|
||||
if (!RETURN_ERROR (Status)) {
|
||||
if (Address != HeaderInfo->BaseAddress) {
|
||||
fprintf (
|
||||
stderr,
|
||||
"ImageTool: Images with a fixed address different from their base address are not supported.\n"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
HeaderInfo->FixedAddress = true;
|
||||
} else if (Status != RETURN_NOT_FOUND) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user