mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-21 16:57:44 +02:00
ImageTool: Support XIP configuration
This commit is contained in:
parent
8957da50bb
commit
4166d3ffd3
@ -352,7 +352,7 @@
|
||||
$(OUTPUT_DIR)(+)$(MODULE_NAME).map
|
||||
|
||||
<Command.MSFT, Command.INTEL, Command.CLANGPDB>
|
||||
ImageTool GenImage -c PE -t $(MODULE_TYPE) -o ${dst} ${src}
|
||||
ImageTool GenImage -c PE -x -t $(MODULE_TYPE) -o ${dst} ${src}
|
||||
$(CP) ${dst} $(DEBUG_DIR)
|
||||
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||
@ -362,7 +362,7 @@
|
||||
$(CP) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||
$(OBJCOPY) $(OBJCOPY_STRIPFLAG) $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||
|
||||
ImageTool GenImage -c PE -t $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||
ImageTool GenImage -c PE -x -t $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).strip
|
||||
|
||||
$(CP) ${dst} $(DEBUG_DIR)
|
||||
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||
@ -373,7 +373,7 @@
|
||||
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
||||
# create symbol file for GDB debug
|
||||
-$(DSYMUTIL) ${src}
|
||||
ImageTool GenImage -c PE -t $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
||||
ImageTool GenImage -c PE -x -t $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
||||
$(CP) ${dst} $(DEBUG_DIR)
|
||||
$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||
-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||
|
@ -356,6 +356,7 @@ GenExecutable (
|
||||
IN const char *FormatName,
|
||||
IN const char *TypeName,
|
||||
IN const char *BaseAddress,
|
||||
IN bool Xip,
|
||||
IN bool Strip,
|
||||
IN bool FixedAddress
|
||||
)
|
||||
@ -411,6 +412,7 @@ GenExecutable (
|
||||
BaseAddress != NULL,
|
||||
NewBaseAddress,
|
||||
InputFileName,
|
||||
Xip,
|
||||
Strip,
|
||||
FixedAddress
|
||||
);
|
||||
@ -435,6 +437,7 @@ int main (int argc, const char *argv[])
|
||||
const char *FormatName;
|
||||
const char *TypeName;
|
||||
const char *BaseAddress;
|
||||
bool Xip;
|
||||
bool Strip;
|
||||
bool FixedAddress;
|
||||
int ArgIndex;
|
||||
@ -452,7 +455,7 @@ int main (int argc, const char *argv[])
|
||||
if (strcmp (argv[1], "GenImage") == 0) {
|
||||
if (argc < 5) {
|
||||
fprintf (stderr, "ImageTool: Command arguments are missing\n");
|
||||
fprintf (stderr, " Usage: ImageTool GenImage [-c Format] [-t ModuleType] [-b BaseAddress] [-s] [-f] -o OutputFile InputFile\n");
|
||||
fprintf (stderr, " Usage: ImageTool GenImage [-c Format] [-t ModuleType] [-b BaseAddress] [-x] [-s] [-f] -o OutputFile InputFile\n");
|
||||
raise ();
|
||||
return -1;
|
||||
}
|
||||
@ -462,6 +465,7 @@ int main (int argc, const char *argv[])
|
||||
FormatName = NULL;
|
||||
TypeName = NULL;
|
||||
BaseAddress = NULL;
|
||||
Xip = false;
|
||||
Strip = false;
|
||||
FixedAddress = false;
|
||||
for (ArgIndex = 2; ArgIndex < argc; ++ArgIndex) {
|
||||
@ -497,6 +501,8 @@ int main (int argc, const char *argv[])
|
||||
}
|
||||
|
||||
BaseAddress = argv[ArgIndex];
|
||||
} else if (strcmp (argv[ArgIndex], "-x") == 0) {
|
||||
Xip = true;
|
||||
} else if (strcmp (argv[ArgIndex], "-s") == 0) {
|
||||
Strip = true;
|
||||
} else if (strcmp (argv[ArgIndex], "-f") == 0) {
|
||||
@ -527,6 +533,7 @@ int main (int argc, const char *argv[])
|
||||
FormatName,
|
||||
TypeName,
|
||||
BaseAddress,
|
||||
Xip,
|
||||
Strip,
|
||||
FixedAddress
|
||||
);
|
||||
|
@ -152,6 +152,7 @@ void *
|
||||
ToolImageEmitPe (
|
||||
image_tool_image_info_t *Image,
|
||||
uint32_t *FileSize,
|
||||
bool Xip,
|
||||
bool Strip
|
||||
);
|
||||
|
||||
|
@ -94,6 +94,7 @@ ToolImageEmit (
|
||||
IN bool Relocate,
|
||||
IN uint64_t BaseAddress,
|
||||
IN const char *SymbolsPath OPTIONAL,
|
||||
IN bool Xip,
|
||||
IN bool Strip,
|
||||
IN bool FixedAddress
|
||||
)
|
||||
@ -158,7 +159,7 @@ ToolImageEmit (
|
||||
|
||||
OutputFile = NULL;
|
||||
if (Format == UefiImageFormatPe) {
|
||||
OutputFile = ToolImageEmitPe (&ImageInfo, OutputFileSize, Strip);
|
||||
OutputFile = ToolImageEmitPe (&ImageInfo, OutputFileSize, Xip, Strip);
|
||||
} else {
|
||||
assert (false);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ ToolImageEmit (
|
||||
IN bool Relocate,
|
||||
IN uint64_t BaseAddress,
|
||||
IN const char *SymbolsPath OPTIONAL,
|
||||
IN bool Xip,
|
||||
IN bool Strip,
|
||||
IN bool FixedAddress
|
||||
);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "ImageTool.h"
|
||||
|
||||
#include "DynamicBuffer.h"
|
||||
#include "PeEmitCommon.h"
|
||||
|
||||
#if PE_ARCH == 32
|
||||
|
||||
@ -644,8 +645,9 @@ ToolImageEmitPeFile (
|
||||
#define ToolImageEmitPe PE_SUFFIX (ToolImageEmitPe)
|
||||
void *
|
||||
ToolImageEmitPe (
|
||||
image_tool_image_info_t *Image,
|
||||
uint32_t *FileSize
|
||||
const image_tool_image_info_t *Image,
|
||||
uint32_t *FileSize,
|
||||
bool Xip
|
||||
)
|
||||
{
|
||||
bool Success;
|
||||
@ -659,8 +661,7 @@ ToolImageEmitPe (
|
||||
|
||||
ImageToolBufferInit (&Buffer);
|
||||
|
||||
// FIXME: Non-XIP is not well-supported right now.
|
||||
Success = ToolImageEmitPeFile (&Buffer, Image, true);
|
||||
Success = ToolImageEmitPeFile (&Buffer, Image, Xip);
|
||||
if (!Success) {
|
||||
raise ();
|
||||
ImageToolBufferFree (&Buffer);
|
||||
|
@ -9,6 +9,7 @@ void *
|
||||
ToolImageEmitPe (
|
||||
image_tool_image_info_t *Image,
|
||||
uint32_t *FileSize,
|
||||
bool Xip,
|
||||
bool Strip
|
||||
)
|
||||
{
|
||||
@ -20,13 +21,13 @@ ToolImageEmitPe (
|
||||
case IMAGE_FILE_MACHINE_I386:
|
||||
case IMAGE_FILE_MACHINE_ARMTHUMB_MIXED:
|
||||
{
|
||||
return ToolImageEmitPe32 (Image, FileSize);
|
||||
return ToolImageEmitPe32 (Image, FileSize, Xip);
|
||||
}
|
||||
|
||||
case IMAGE_FILE_MACHINE_X64:
|
||||
case IMAGE_FILE_MACHINE_ARM64:
|
||||
{
|
||||
return ToolImageEmitPe64 (Image, FileSize);
|
||||
return ToolImageEmitPe64 (Image, FileSize, Xip);
|
||||
}
|
||||
|
||||
default:
|
||||
|
@ -13,13 +13,15 @@
|
||||
void *
|
||||
ToolImageEmitPe32 (
|
||||
const image_tool_image_info_t *Image,
|
||||
uint32_t *FileSize
|
||||
uint32_t *FileSize,
|
||||
bool Xip
|
||||
);
|
||||
|
||||
void *
|
||||
ToolImageEmitPe64 (
|
||||
const image_tool_image_info_t *Image,
|
||||
uint32_t *FileSize
|
||||
uint32_t *FileSize,
|
||||
bool Xip
|
||||
);
|
||||
|
||||
#endif // PE_EMIT_COMMON_H
|
||||
|
@ -3855,6 +3855,7 @@ Returns:
|
||||
true,
|
||||
NewBaseAddress,
|
||||
NULL,
|
||||
TRUE,
|
||||
Strip,
|
||||
FALSE
|
||||
);
|
||||
|
@ -1456,6 +1456,7 @@ Returns:
|
||||
true,
|
||||
NewBaseAddress,
|
||||
NULL,
|
||||
TRUE,
|
||||
FALSE,
|
||||
TRUE
|
||||
);
|
||||
|
@ -95,6 +95,7 @@ class DataSection (DataSectionClassObject):
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict),
|
||||
Xip=True,
|
||||
Strip=True,
|
||||
IsMakefile = IsMakefile
|
||||
)
|
||||
|
@ -290,6 +290,7 @@ class EfiSection (EfiSectionClassObject):
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
File,
|
||||
Xip=True,
|
||||
Strip=True,
|
||||
IsMakefile = IsMakefile
|
||||
)
|
||||
|
@ -787,6 +787,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
File,
|
||||
Xip=True,
|
||||
Strip=True,
|
||||
IsMakefile=IsMakefile
|
||||
)
|
||||
@ -821,6 +822,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
GenSecInputFile,
|
||||
Xip=True,
|
||||
Strip=True,
|
||||
IsMakefile=IsMakefile
|
||||
)
|
||||
|
@ -607,7 +607,7 @@ class GenFdsGlobalVariable:
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FV")
|
||||
|
||||
@staticmethod
|
||||
def GenerateFirmwareImage(Output, Input, Format="Auto", Strip=False, IsMakefile=False):
|
||||
def GenerateFirmwareImage(Output, Input, Format="Auto", Xip=False, Strip=False, IsMakefile=False):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsMakefile:
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
@ -615,6 +615,8 @@ class GenFdsGlobalVariable:
|
||||
Cmd = ["ImageTool GenImage"]
|
||||
if Format != "Auto":
|
||||
Cmd += ("-c", Format)
|
||||
if Xip:
|
||||
Cmd.append("-x")
|
||||
if Strip:
|
||||
Cmd.append("-s")
|
||||
Cmd += ("-o", Output, Input)
|
||||
|
@ -642,7 +642,7 @@ class ModuleReport(object):
|
||||
if os.path.isfile(DefaultEFIfile):
|
||||
Tempfile = os.path.join(OutputDir, self.ModuleName + "_hash.tmp")
|
||||
# rebase the efi image since its base address may not zero
|
||||
cmd = ["ImageTool GenImage -b 0 -o", Tempfile, DefaultEFIfile]
|
||||
cmd = ["ImageTool GenImage -x -b 0 -o", Tempfile, DefaultEFIfile]
|
||||
try:
|
||||
PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
except Exception as X:
|
||||
|
@ -1524,16 +1524,16 @@ class Build():
|
||||
#
|
||||
# Update Image to new BaseAddress by ImageTool tool
|
||||
#
|
||||
LaunchCommand(["ImageTool", "GenImage", "-b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.OutputDir)
|
||||
LaunchCommand(["ImageTool", "GenImage", "-b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.DebugDir)
|
||||
LaunchCommand(["ImageTool", "GenImage", "-x", "-b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.OutputDir)
|
||||
LaunchCommand(["ImageTool", "GenImage", "-x", "-b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.DebugDir)
|
||||
## for SMM module in SMRAM, the SMRAM will be allocated from base to top.
|
||||
else:
|
||||
BaseAddress = AlignUp(BaseAddress, ModuleInfo.Image.SectionAlignment)
|
||||
#
|
||||
# Set new address to the section header only for SMM driver.
|
||||
#
|
||||
LaunchCommand(["ImageTool", "GenImage", "-f -b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.OutputDir)
|
||||
LaunchCommand(["ImageTool", "GenImage", "-f -b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.DebugDir)
|
||||
LaunchCommand(["ImageTool", "GenImage", "-x", "-f -b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.OutputDir)
|
||||
LaunchCommand(["ImageTool", "GenImage", "-x", "-f -b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.DebugDir)
|
||||
#
|
||||
# Collect function address from Map file
|
||||
#
|
||||
|
Loading…
x
Reference in New Issue
Block a user