mirror of https://github.com/acidanthera/audk.git
BaseTools: Update GenFw to support 4K alignment.
Get maximum section alignment from each ELF section, and this alignment is used to create PE header. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17727 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
bbb6369486
commit
54b1b57a59
|
@ -96,7 +96,7 @@ STATIC Elf_Phdr *mPhdrBase;
|
||||||
//
|
//
|
||||||
// Coff information
|
// Coff information
|
||||||
//
|
//
|
||||||
STATIC const UINT32 mCoffAlignment = 0x20;
|
STATIC UINT32 mCoffAlignment = 0x20;
|
||||||
|
|
||||||
//
|
//
|
||||||
// PE section alignment.
|
// PE section alignment.
|
||||||
|
@ -291,6 +291,20 @@ ScanSections32 (
|
||||||
mTableOffset = mCoffOffset;
|
mTableOffset = mCoffOffset;
|
||||||
mCoffOffset += mCoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER);
|
mCoffOffset += mCoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set mCoffAlignment to the maximum alignment of the input sections
|
||||||
|
// we care about
|
||||||
|
//
|
||||||
|
for (i = 0; i < mEhdr->e_shnum; i++) {
|
||||||
|
Elf_Shdr *shdr = GetShdrByIndex(i);
|
||||||
|
if (shdr->sh_addralign <= mCoffAlignment) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr)) {
|
||||||
|
mCoffAlignment = (UINT32)shdr->sh_addralign;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// First text sections.
|
// First text sections.
|
||||||
//
|
//
|
||||||
|
|
|
@ -97,7 +97,7 @@ STATIC Elf_Phdr *mPhdrBase;
|
||||||
//
|
//
|
||||||
// Coff information
|
// Coff information
|
||||||
//
|
//
|
||||||
STATIC const UINT32 mCoffAlignment = 0x20;
|
STATIC UINT32 mCoffAlignment = 0x20;
|
||||||
|
|
||||||
//
|
//
|
||||||
// PE section alignment.
|
// PE section alignment.
|
||||||
|
@ -285,6 +285,20 @@ ScanSections64 (
|
||||||
mTableOffset = mCoffOffset;
|
mTableOffset = mCoffOffset;
|
||||||
mCoffOffset += mCoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER);
|
mCoffOffset += mCoffNbrSections * sizeof(EFI_IMAGE_SECTION_HEADER);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set mCoffAlignment to the maximum alignment of the input sections
|
||||||
|
// we care about
|
||||||
|
//
|
||||||
|
for (i = 0; i < mEhdr->e_shnum; i++) {
|
||||||
|
Elf_Shdr *shdr = GetShdrByIndex(i);
|
||||||
|
if (shdr->sh_addralign <= mCoffAlignment) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (IsTextShdr(shdr) || IsDataShdr(shdr) || IsHiiRsrcShdr(shdr)) {
|
||||||
|
mCoffAlignment = (UINT32)shdr->sh_addralign;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// First text sections.
|
// First text sections.
|
||||||
//
|
//
|
||||||
|
|
|
@ -96,11 +96,11 @@ CoffAddFixup(
|
||||||
|
|
||||||
mCoffFile = realloc (
|
mCoffFile = realloc (
|
||||||
mCoffFile,
|
mCoffFile,
|
||||||
mCoffOffset + sizeof(EFI_IMAGE_BASE_RELOCATION) + 2*0x1000
|
mCoffOffset + sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT
|
||||||
);
|
);
|
||||||
memset (
|
memset (
|
||||||
mCoffFile + mCoffOffset, 0,
|
mCoffFile + mCoffOffset, 0,
|
||||||
sizeof(EFI_IMAGE_BASE_RELOCATION) + 2*0x1000
|
sizeof(EFI_IMAGE_BASE_RELOCATION) + 2 * MAX_COFF_ALIGNMENT
|
||||||
);
|
);
|
||||||
|
|
||||||
mCoffBaseRel = (EFI_IMAGE_BASE_RELOCATION*)(mCoffFile + mCoffOffset);
|
mCoffBaseRel = (EFI_IMAGE_BASE_RELOCATION*)(mCoffFile + mCoffOffset);
|
||||||
|
|
|
@ -34,6 +34,7 @@ extern UINT32 mOutImageType;
|
||||||
// Common EFI specific data.
|
// Common EFI specific data.
|
||||||
//
|
//
|
||||||
#define ELF_HII_SECTION_NAME ".hii"
|
#define ELF_HII_SECTION_NAME ".hii"
|
||||||
|
#define MAX_COFF_ALIGNMENT 0x10000
|
||||||
|
|
||||||
//
|
//
|
||||||
// Filter Types
|
// Filter Types
|
||||||
|
|
Loading…
Reference in New Issue