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