mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-23 09:47:44 +02:00
ImageTool: Remove argument asserts
This commit is contained in:
parent
f374c858df
commit
78703654d8
@ -19,9 +19,6 @@ CreateEntry (
|
|||||||
EFI_IMAGE_RESOURCE_DIRECTORY *RDir;
|
EFI_IMAGE_RESOURCE_DIRECTORY *RDir;
|
||||||
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *Entry;
|
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *Entry;
|
||||||
|
|
||||||
assert (HiiSectionHeader != NULL);
|
|
||||||
assert (HiiSectionOffset != NULL);
|
|
||||||
|
|
||||||
RDir = (EFI_IMAGE_RESOURCE_DIRECTORY *)(HiiSectionHeader + *HiiSectionOffset);
|
RDir = (EFI_IMAGE_RESOURCE_DIRECTORY *)(HiiSectionHeader + *HiiSectionOffset);
|
||||||
*HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY);
|
*HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY);
|
||||||
RDir->NumberOfNamedEntries = 1;
|
RDir->NumberOfNamedEntries = 1;
|
||||||
@ -49,11 +46,6 @@ CreateStringEntry (
|
|||||||
{
|
{
|
||||||
EFI_IMAGE_RESOURCE_DIRECTORY_STRING *RDStr;
|
EFI_IMAGE_RESOURCE_DIRECTORY_STRING *RDStr;
|
||||||
|
|
||||||
assert (Entry != NULL);
|
|
||||||
assert (HiiSectionHeader != NULL);
|
|
||||||
assert (HiiSectionOffset != NULL);
|
|
||||||
assert (String != NULL);
|
|
||||||
|
|
||||||
Entry->u1.s.NameOffset = *HiiSectionOffset;
|
Entry->u1.s.NameOffset = *HiiSectionOffset;
|
||||||
RDStr = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *)(HiiSectionHeader + *HiiSectionOffset);
|
RDStr = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *)(HiiSectionHeader + *HiiSectionOffset);
|
||||||
RDStr->Length = (UINT16)StrLen (String);
|
RDStr->Length = (UINT16)StrLen (String);
|
||||||
@ -78,8 +70,6 @@ InitializeHiiResouceSectionHeader (
|
|||||||
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *LangRDirEntry;
|
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *LangRDirEntry;
|
||||||
EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
|
EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
|
||||||
|
|
||||||
assert (HiiSectionHeader != NULL);
|
|
||||||
|
|
||||||
HiiSectionOffset = 0;
|
HiiSectionOffset = 0;
|
||||||
//
|
//
|
||||||
// Create Type, Name, Language entries
|
// Create Type, Name, Language entries
|
||||||
@ -123,10 +113,6 @@ ConstructHii (
|
|||||||
UINT32 FileSize;
|
UINT32 FileSize;
|
||||||
UINT8 NumberOfFormPackages;
|
UINT8 NumberOfFormPackages;
|
||||||
|
|
||||||
assert (Hii != NULL);
|
|
||||||
assert (HiiGuid != NULL);
|
|
||||||
assert (FileNames != NULL);
|
|
||||||
|
|
||||||
NumberOfFormPackages = 0;
|
NumberOfFormPackages = 0;
|
||||||
|
|
||||||
EndPackage.Length = sizeof (EFI_HII_PACKAGE_HEADER);
|
EndPackage.Length = sizeof (EFI_HII_PACKAGE_HEADER);
|
||||||
|
@ -103,8 +103,6 @@ IsShdrLoadable (
|
|||||||
IN const Elf_Shdr *Shdr
|
IN const Elf_Shdr *Shdr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
assert (Shdr != NULL);
|
|
||||||
|
|
||||||
return (Shdr->sh_flags & SHF_ALLOC) != 0;
|
return (Shdr->sh_flags & SHF_ALLOC) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,7 +660,6 @@ ScanElf (
|
|||||||
const Elf_Ehdr *Ehdr;
|
const Elf_Ehdr *Ehdr;
|
||||||
Elf_Addr BaseAddress;
|
Elf_Addr BaseAddress;
|
||||||
|
|
||||||
assert (ImageInfo != NULL);
|
|
||||||
assert (File != NULL || FileSize == 0);
|
assert (File != NULL || FileSize == 0);
|
||||||
|
|
||||||
Status = ParseElfFile (&Context, File, FileSize);
|
Status = ParseElfFile (&Context, File, FileSize);
|
||||||
|
@ -16,9 +16,6 @@ CheckToolImageSegment (
|
|||||||
{
|
{
|
||||||
bool Overflow;
|
bool Overflow;
|
||||||
|
|
||||||
assert (Segment != NULL);
|
|
||||||
assert (PreviousEndAddress != NULL);
|
|
||||||
|
|
||||||
if (!IS_ALIGNED (Segment->ImageSize, SegmentInfo->SegmentAlignment)) {
|
if (!IS_ALIGNED (Segment->ImageSize, SegmentInfo->SegmentAlignment)) {
|
||||||
DEBUG_RAISE ();
|
DEBUG_RAISE ();
|
||||||
return false;
|
return false;
|
||||||
@ -58,9 +55,6 @@ CheckToolImageSegmentInfo (
|
|||||||
uint32_t Index;
|
uint32_t Index;
|
||||||
bool Result;
|
bool Result;
|
||||||
|
|
||||||
assert (SegmentInfo != NULL);
|
|
||||||
assert (ImageSize != NULL);
|
|
||||||
|
|
||||||
if (!IS_POW2 (SegmentInfo->SegmentAlignment)) {
|
if (!IS_POW2 (SegmentInfo->SegmentAlignment)) {
|
||||||
DEBUG_RAISE ();
|
DEBUG_RAISE ();
|
||||||
return false;
|
return false;
|
||||||
@ -123,9 +117,6 @@ ImageGetSegmentByAddress (
|
|||||||
{
|
{
|
||||||
uint32_t Index;
|
uint32_t Index;
|
||||||
|
|
||||||
assert (Address != NULL);
|
|
||||||
assert (SegmentInfo != NULL);
|
|
||||||
|
|
||||||
for (Index = 0; Index < SegmentInfo->NumSegments; ++Index) {
|
for (Index = 0; Index < SegmentInfo->NumSegments; ++Index) {
|
||||||
if ((SegmentInfo->Segments[Index].ImageAddress <= *Address)
|
if ((SegmentInfo->Segments[Index].ImageAddress <= *Address)
|
||||||
&& (*Address < SegmentInfo->Segments[Index].ImageAddress + SegmentInfo->Segments[Index].ImageSize)) {
|
&& (*Address < SegmentInfo->Segments[Index].ImageAddress + SegmentInfo->Segments[Index].ImageSize)) {
|
||||||
@ -181,9 +172,6 @@ CheckToolImageReloc (
|
|||||||
uint16_t MovHigh;
|
uint16_t MovHigh;
|
||||||
uint16_t MovLow;
|
uint16_t MovLow;
|
||||||
|
|
||||||
assert (Image != NULL);
|
|
||||||
assert (Reloc != NULL);
|
|
||||||
|
|
||||||
RelocOffset = Reloc->Target;
|
RelocOffset = Reloc->Target;
|
||||||
Segment = ImageGetSegmentByAddress (
|
Segment = ImageGetSegmentByAddress (
|
||||||
&RelocOffset,
|
&RelocOffset,
|
||||||
@ -245,8 +233,6 @@ CheckToolImageRelocInfo (
|
|||||||
uint32_t Index;
|
uint32_t Index;
|
||||||
bool Result;
|
bool Result;
|
||||||
|
|
||||||
assert (Image != NULL);
|
|
||||||
|
|
||||||
RelocInfo = &Image->RelocInfo;
|
RelocInfo = &Image->RelocInfo;
|
||||||
|
|
||||||
if (RelocInfo->NumRelocs == 0) {
|
if (RelocInfo->NumRelocs == 0) {
|
||||||
@ -289,8 +275,6 @@ CheckToolImageDebugInfo (
|
|||||||
const image_tool_debug_info_t *DebugInfo
|
const image_tool_debug_info_t *DebugInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
assert (DebugInfo != NULL);
|
|
||||||
|
|
||||||
if (DebugInfo->SymbolsPath != NULL) {
|
if (DebugInfo->SymbolsPath != NULL) {
|
||||||
// FIXME: UE-only?
|
// FIXME: UE-only?
|
||||||
if (DebugInfo->SymbolsPathLen > MAX_UINT8) {
|
if (DebugInfo->SymbolsPathLen > MAX_UINT8) {
|
||||||
@ -310,8 +294,6 @@ CheckToolImage (
|
|||||||
bool Result;
|
bool Result;
|
||||||
uint32_t ImageSize;
|
uint32_t ImageSize;
|
||||||
|
|
||||||
assert (Image != NULL);
|
|
||||||
|
|
||||||
Result = CheckToolImageSegmentInfo (&Image->SegmentInfo, &ImageSize);
|
Result = CheckToolImageSegmentInfo (&Image->SegmentInfo, &ImageSize);
|
||||||
if (!Result) {
|
if (!Result) {
|
||||||
DEBUG_RAISE ();
|
DEBUG_RAISE ();
|
||||||
@ -370,8 +352,6 @@ ToolImageDestruct (
|
|||||||
{
|
{
|
||||||
uint8_t Index;
|
uint8_t Index;
|
||||||
|
|
||||||
assert (Image != NULL);
|
|
||||||
|
|
||||||
if (Image->SegmentInfo.Segments != NULL) {
|
if (Image->SegmentInfo.Segments != NULL) {
|
||||||
for (Index = 0; Index < Image->SegmentInfo.NumSegments; ++Index) {
|
for (Index = 0; Index < Image->SegmentInfo.NumSegments; ++Index) {
|
||||||
free (Image->SegmentInfo.Segments[Index].Name);
|
free (Image->SegmentInfo.Segments[Index].Name);
|
||||||
|
@ -37,10 +37,6 @@ HiiSrc (
|
|||||||
FILE *FilePtr;
|
FILE *FilePtr;
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
|
|
||||||
assert (FileNames != NULL);
|
|
||||||
assert (HiiName != NULL);
|
|
||||||
assert (Guid != NULL);
|
|
||||||
|
|
||||||
Status = AsciiStrToGuid (Guid, &HiiGuid);
|
Status = AsciiStrToGuid (Guid, &HiiGuid);
|
||||||
if (RETURN_ERROR (Status)) {
|
if (RETURN_ERROR (Status)) {
|
||||||
fprintf (stderr, "ImageTool: Invalid GUID - %s\n", Guid);
|
fprintf (stderr, "ImageTool: Invalid GUID - %s\n", Guid);
|
||||||
@ -247,9 +243,6 @@ GetAcpi (
|
|||||||
UINT16 Index;
|
UINT16 Index;
|
||||||
UINT32 FileLength;
|
UINT32 FileLength;
|
||||||
|
|
||||||
assert (PeName != NULL);
|
|
||||||
assert (AcpiName != NULL);
|
|
||||||
|
|
||||||
Pe = UserReadFile (PeName, &PeSize);
|
Pe = UserReadFile (PeName, &PeSize);
|
||||||
if (Pe == NULL) {
|
if (Pe == NULL) {
|
||||||
fprintf (stderr, "ImageTool: Could not open %s: %s\n", PeName, strerror (errno));
|
fprintf (stderr, "ImageTool: Could not open %s: %s\n", PeName, strerror (errno));
|
||||||
|
@ -30,9 +30,6 @@ ScanPeGetRelocInfo (
|
|||||||
UINT16 RelocType;
|
UINT16 RelocType;
|
||||||
UINT16 RelocOffset;
|
UINT16 RelocOffset;
|
||||||
|
|
||||||
assert (RelocInfo != NULL);
|
|
||||||
assert (Context != NULL);
|
|
||||||
|
|
||||||
// FIXME: PE/COFF context access
|
// FIXME: PE/COFF context access
|
||||||
RelocBlockRva = Context->RelocDirRva;
|
RelocBlockRva = Context->RelocDirRva;
|
||||||
RelocDirSize = Context->RelocDirSize;
|
RelocDirSize = Context->RelocDirSize;
|
||||||
@ -158,9 +155,6 @@ ScanPeGetSegmentInfo (
|
|||||||
const char *ImageBuffer;
|
const char *ImageBuffer;
|
||||||
uint32_t Index;
|
uint32_t Index;
|
||||||
|
|
||||||
assert (SegmentInfo != NULL);
|
|
||||||
assert (Context != NULL);
|
|
||||||
|
|
||||||
NumSections = PeCoffGetSectionTable (Context, &Section);
|
NumSections = PeCoffGetSectionTable (Context, &Section);
|
||||||
|
|
||||||
SegmentInfo->Segments = calloc (NumSections, sizeof (*SegmentInfo->Segments));
|
SegmentInfo->Segments = calloc (NumSections, sizeof (*SegmentInfo->Segments));
|
||||||
@ -229,9 +223,6 @@ ScanPeGetDebugInfo (
|
|||||||
UINT32 PdbPathSize;
|
UINT32 PdbPathSize;
|
||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
|
|
||||||
assert (DebugInfo != NULL);
|
|
||||||
assert (Context != NULL);
|
|
||||||
|
|
||||||
Status = PeCoffGetPdbPath (Context, &PdbPath, &PdbPathSize);
|
Status = PeCoffGetPdbPath (Context, &PdbPath, &PdbPathSize);
|
||||||
if (Status == RETURN_NOT_FOUND) {
|
if (Status == RETURN_NOT_FOUND) {
|
||||||
return true;
|
return true;
|
||||||
@ -268,9 +259,6 @@ ScanPeGetHiiInfo (
|
|||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
const char *ImageBuffer;
|
const char *ImageBuffer;
|
||||||
|
|
||||||
assert (HiiInfo != NULL);
|
|
||||||
assert (Context != NULL);
|
|
||||||
|
|
||||||
Status = PeCoffGetHiiDataRva (Context, &HiiRva, &HiiSize);
|
Status = PeCoffGetHiiDataRva (Context, &HiiRva, &HiiSize);
|
||||||
if (Status == RETURN_NOT_FOUND) {
|
if (Status == RETURN_NOT_FOUND) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,9 +21,6 @@ ScanUefiImageGetHeaderInfo (
|
|||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
UINT64 Address;
|
UINT64 Address;
|
||||||
|
|
||||||
assert (HeaderInfo != NULL);
|
|
||||||
assert (Context != NULL);
|
|
||||||
|
|
||||||
HeaderInfo->BaseAddress = UefiImageGetPreferredAddress (Context);
|
HeaderInfo->BaseAddress = UefiImageGetPreferredAddress (Context);
|
||||||
HeaderInfo->EntryPointAddress = UefiImageGetEntryPointAddress (Context);
|
HeaderInfo->EntryPointAddress = UefiImageGetEntryPointAddress (Context);
|
||||||
HeaderInfo->Machine = UefiImageGetMachine (Context);
|
HeaderInfo->Machine = UefiImageGetMachine (Context);
|
||||||
@ -56,9 +53,6 @@ ScanUefiImageGetRelocInfo (
|
|||||||
{
|
{
|
||||||
UINT8 FormatIndex;
|
UINT8 FormatIndex;
|
||||||
|
|
||||||
assert (RelocInfo != NULL);
|
|
||||||
assert (Context != NULL);
|
|
||||||
|
|
||||||
FormatIndex = UefiImageGetFormat (Context);
|
FormatIndex = UefiImageGetFormat (Context);
|
||||||
|
|
||||||
RelocInfo->RelocsStripped = UefiImageGetRelocsStripped (Context);
|
RelocInfo->RelocsStripped = UefiImageGetRelocsStripped (Context);
|
||||||
@ -84,9 +78,6 @@ ScanUefiImageGetSegmentInfo (
|
|||||||
{
|
{
|
||||||
UINT8 FormatIndex;
|
UINT8 FormatIndex;
|
||||||
|
|
||||||
assert (SegmentInfo != NULL);
|
|
||||||
assert (Context != NULL);
|
|
||||||
|
|
||||||
FormatIndex = UefiImageGetFormat (Context);
|
FormatIndex = UefiImageGetFormat (Context);
|
||||||
|
|
||||||
SegmentInfo->SegmentAlignment = UefiImageGetSegmentAlignment (Context);
|
SegmentInfo->SegmentAlignment = UefiImageGetSegmentAlignment (Context);
|
||||||
@ -113,9 +104,6 @@ ScanUefiImageGetDebugInfo (
|
|||||||
const CHAR8 *SymbolsPath;
|
const CHAR8 *SymbolsPath;
|
||||||
UINT32 SymbolsPathSize;
|
UINT32 SymbolsPathSize;
|
||||||
|
|
||||||
assert (DebugInfo != NULL);
|
|
||||||
assert (Context != NULL);
|
|
||||||
|
|
||||||
Status = UefiImageGetSymbolsPath (Context, &SymbolsPath, &SymbolsPathSize);
|
Status = UefiImageGetSymbolsPath (Context, &SymbolsPath, &SymbolsPathSize);
|
||||||
if (Status == RETURN_NOT_FOUND || Status == RETURN_UNSUPPORTED) {
|
if (Status == RETURN_NOT_FOUND || Status == RETURN_UNSUPPORTED) {
|
||||||
return true;
|
return true;
|
||||||
@ -152,9 +140,6 @@ ScanUefiImageGetHiiInfo (
|
|||||||
UINT32 HiiSize;
|
UINT32 HiiSize;
|
||||||
const char *ImageBuffer;
|
const char *ImageBuffer;
|
||||||
|
|
||||||
assert (HiiInfo != NULL);
|
|
||||||
assert (Context != NULL);
|
|
||||||
|
|
||||||
Status = UefiImageGetHiiDataRva (Context, &HiiRva, &HiiSize);
|
Status = UefiImageGetHiiDataRva (Context, &HiiRva, &HiiSize);
|
||||||
if (Status == RETURN_NOT_FOUND) {
|
if (Status == RETURN_NOT_FOUND) {
|
||||||
return true;
|
return true;
|
||||||
@ -195,7 +180,6 @@ ToolContextConstructUefiImage (
|
|||||||
void *Destination;
|
void *Destination;
|
||||||
bool Success;
|
bool Success;
|
||||||
|
|
||||||
assert (Image != NULL);
|
|
||||||
assert (File != NULL || FileSize == 0);
|
assert (File != NULL || FileSize == 0);
|
||||||
|
|
||||||
if (FileSize > MAX_UINT32) {
|
if (FileSize > MAX_UINT32) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user