mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-22 01:07:44 +02:00
ImageTool: Support stripping relocs
This commit is contained in:
parent
07d0ca418e
commit
ae08542f89
@ -639,3 +639,15 @@ ToolImageCompare (
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ToolImageStripRelocs (
|
||||
image_tool_image_info_t *Image
|
||||
)
|
||||
{
|
||||
Image->RelocInfo.NumRelocs = 0;
|
||||
free (Image->RelocInfo.Relocs);
|
||||
Image->RelocInfo.Relocs = NULL;
|
||||
|
||||
Image->RelocInfo.RelocsStripped = TRUE;
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <IndustryStandard/Acpi30.h>
|
||||
#include <IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h>
|
||||
|
||||
#include <Library/UefiImageLib.h>
|
||||
|
||||
#include "ImageToolEmit.h"
|
||||
|
||||
#define EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION 0x0
|
||||
@ -289,7 +291,8 @@ GenExecutable (
|
||||
IN const char *FormatName,
|
||||
IN const char *TypeName,
|
||||
IN const char *HiiFileName,
|
||||
IN const char *BaseAddress
|
||||
IN const char *BaseAddress,
|
||||
IN bool Strip
|
||||
)
|
||||
{
|
||||
UINT32 InputFileSize;
|
||||
@ -356,7 +359,8 @@ GenExecutable (
|
||||
HiiFileSize,
|
||||
BaseAddress != NULL,
|
||||
NewBaseAddress,
|
||||
InputFileName
|
||||
InputFileName,
|
||||
Strip
|
||||
);
|
||||
|
||||
if (OutputFile == NULL) {
|
||||
@ -390,7 +394,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);
|
||||
Status = GenExecutable (argv[3], argv[2], "PE", argv[4], argc >= 6 ? argv[5] : NULL, NULL, FALSE);
|
||||
if (RETURN_ERROR (Status)) {
|
||||
raise ();
|
||||
return -1;
|
||||
@ -418,7 +422,7 @@ int main (int argc, const char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
Status = GenExecutable (argv[4], argv[3], "PE", NULL, NULL, argv[2]);
|
||||
Status = GenExecutable (argv[4], argv[3], "PE", NULL, NULL, argv[2], FALSE);
|
||||
if (RETURN_ERROR (Status)) {
|
||||
raise ();
|
||||
return -1;
|
||||
|
@ -130,6 +130,11 @@ ToolImageCompare (
|
||||
const image_tool_image_info_t *Image2
|
||||
);
|
||||
|
||||
void
|
||||
ToolImageStripRelocs (
|
||||
image_tool_image_info_t *Image
|
||||
);
|
||||
|
||||
RETURN_STATUS
|
||||
ToolContextConstructPe (
|
||||
OUT image_tool_image_info_t *Image,
|
||||
@ -145,7 +150,8 @@ CheckToolImage (
|
||||
void *
|
||||
ToolImageEmitPe (
|
||||
image_tool_image_info_t *Image,
|
||||
uint32_t *FileSize
|
||||
uint32_t *FileSize,
|
||||
bool Strip
|
||||
);
|
||||
|
||||
RETURN_STATUS
|
||||
|
@ -96,7 +96,8 @@ ToolImageEmit (
|
||||
IN uint32_t HiiFileSize,
|
||||
IN bool Relocate,
|
||||
IN uint64_t BaseAddress,
|
||||
IN const char *SymbolsPath OPTIONAL
|
||||
IN const char *SymbolsPath OPTIONAL,
|
||||
IN bool Strip
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
@ -161,7 +162,7 @@ ToolImageEmit (
|
||||
|
||||
OutputFile = NULL;
|
||||
if (Format == UefiImageFormatPe) {
|
||||
OutputFile = ToolImageEmitPe (&ImageInfo, OutputFileSize);
|
||||
OutputFile = ToolImageEmitPe (&ImageInfo, OutputFileSize, Strip);
|
||||
} else {
|
||||
assert (false);
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ ToolImageEmit (
|
||||
IN uint32_t HiiFileSize,
|
||||
IN bool Relocate,
|
||||
IN uint64_t BaseAddress,
|
||||
IN const char *SymbolsPath OPTIONAL
|
||||
IN const char *SymbolsPath OPTIONAL,
|
||||
IN bool Strip
|
||||
);
|
||||
|
||||
#endif // IMAGE_TOOL_EMIT_H
|
||||
|
@ -8,9 +8,14 @@
|
||||
void *
|
||||
ToolImageEmitPe (
|
||||
image_tool_image_info_t *Image,
|
||||
uint32_t *FileSize
|
||||
uint32_t *FileSize,
|
||||
bool Strip
|
||||
)
|
||||
{
|
||||
if (Strip) {
|
||||
ToolImageStripRelocs (Image);
|
||||
}
|
||||
|
||||
switch (Image->HeaderInfo.Machine) {
|
||||
case IMAGE_FILE_MACHINE_I386:
|
||||
case IMAGE_FILE_MACHINE_ARMTHUMB_MIXED:
|
||||
|
Loading…
x
Reference in New Issue
Block a user