/** @file
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "WinNtInclude.h"
#ifndef __GNUC__
#include <windows.h>
#include <io.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <Common/UefiBaseTypes.h>
#include <IndustryStandard/PeImage.h>
#include "EfiUtilityMsgs.h"
#include "GenFw.h"
#include "ElfConvert.h"
#include "Elf32Convert.h"
#include "Elf64Convert.h"
//
// Result Coff file in memory.
//
//
// COFF relocation data
//
//
// Current offset in coff file.
//
//
// Offset in Coff file of headers and sections.
//
//
//*****************************************************************************
// Common ELF Functions
//*****************************************************************************
//
)
{
*mCoffEntryRel = Val;
mCoffOffset += 2;
}
)
{
if (mCoffBaseRel == NULL
if (mCoffBaseRel != NULL) {
//
// Add a null entry (is it required ?)
//
CoffAddFixupEntry (0);
//
// Pad for alignment.
//
if (mCoffOffset % 4 != 0)
CoffAddFixupEntry (0);
}
);
memset (
mCoffFile + mCoffOffset, 0,
);
mCoffOffset += sizeof(EFI_IMAGE_BASE_RELOCATION);
}
//
// Fill the entry.
//
}
)
{
Hdr->PointerToRelocations = 0;
Hdr->PointerToLinenumbers = 0;
Hdr->NumberOfRelocations = 0;
Hdr->NumberOfLinenumbers = 0;
mTableOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
}
//
//*****************************************************************************
// Functions called from GenFw main code.
//*****************************************************************************
//
)
{
}
UINT8 **FileBuffer,
)
{
//
// Determine ELF type and set function table pointer correctly.
//
VerboseMsg ("Check Elf Image Header");
if (EiClass == ELFCLASS32) {
return FALSE;
}
} else if (EiClass == ELFCLASS64) {
return FALSE;
}
} else {
return FALSE;
}
//
// Compute sections new address.
//
VerboseMsg ("Compute sections new address.");
//
// Write and relocate sections.
//
VerboseMsg ("Write and relocate sections.");
//
// Translate and write relocations.
//
VerboseMsg ("Translate and write relocations.");
//
// Write debug info.
//
VerboseMsg ("Write debug info.");
//
// Make sure image size is correct before returning the new image.
//
VerboseMsg ("Set image size.");
//
// Replace.
//
free (*FileBuffer);
*FileBuffer = mCoffFile;
//
// Free resources used by ELF functions.
//
ElfFunctions.CleanUp ();
return TRUE;
}