summaryrefslogtreecommitdiff
path: root/BaseTools/Source/C
diff options
context:
space:
mode:
authorJeff Fan <jeff.fan@intel.com>2015-11-16 05:29:49 +0000
committervanjeff <vanjeff@Edk2>2015-11-16 05:29:49 +0000
commitaf7fca3649779f0e55220a7acda9bd11bc660fc3 (patch)
tree02585c606e356ce06fefa9ff80bc4529fcde256e /BaseTools/Source/C
parent59fd15c5a2174a6a6fc4133964e6d5b520b58663 (diff)
downloadedk2-platforms-af7fca3649779f0e55220a7acda9bd11bc660fc3.tar.xz
Update BaseTools from main trunk r18767.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@18784 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/C')
-rw-r--r--BaseTools/Source/C/Common/PeCoffLoaderEx.c2
-rw-r--r--BaseTools/Source/C/GenFw/Elf32Convert.c42
-rw-r--r--BaseTools/Source/C/GenFw/Elf64Convert.c42
-rw-r--r--BaseTools/Source/C/GenFw/GenFw.c82
-rw-r--r--BaseTools/Source/C/Split/Split.c25
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrSyntax.g12
6 files changed, 106 insertions, 99 deletions
diff --git a/BaseTools/Source/C/Common/PeCoffLoaderEx.c b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
index 382138a893..d04fa7d5ba 100644
--- a/BaseTools/Source/C/Common/PeCoffLoaderEx.c
+++ b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
@@ -402,8 +402,8 @@ PeCoffLoaderRelocateArmImage (
if (*FixupData != NULL) {
*FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
- *(UINT64 *)(*FixupData) = *Fixup16;
CopyMem (*FixupData, Fixup16, sizeof (UINT64));
+ *FixupData = *FixupData + sizeof(UINT64);
}
break;
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c
index e1b92ebd71..a7b077873b 100644
--- a/BaseTools/Source/C/GenFw/Elf32Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf32Convert.c
@@ -218,6 +218,15 @@ CoffAlign (
return (Offset + mCoffAlignment - 1) & ~(mCoffAlignment - 1);
}
+STATIC
+UINT32
+DebugRvaAlign (
+ UINT32 Offset
+ )
+{
+ return (Offset + 3) & ~3;
+}
+
//
// filter functions
//
@@ -331,12 +340,8 @@ ScanSections32 (
if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
// if the section address is aligned we must align PE/COFF
mCoffOffset = (mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);
- } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
- // ARM RVCT tools have behavior outside of the ELF specification to try
- // and make images smaller. If sh_addr is not aligned to sh_addralign
- // then the section needs to preserve sh_addr MOD sh_addralign.
- // Normally doing nothing here works great.
- Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+ } else {
+ Error (NULL, 0, 3000, "Invalid", "Section address not aligned to its own alignment.");
}
}
@@ -365,11 +370,8 @@ ScanSections32 (
assert (FALSE);
}
- mDebugOffset = mCoffOffset;
-
- if (mEhdr->e_machine != EM_ARM) {
- mCoffOffset = CoffAlign(mCoffOffset);
- }
+ mDebugOffset = DebugRvaAlign(mCoffOffset);
+ mCoffOffset = CoffAlign(mCoffOffset);
if (SectionCount > 1 && mOutImageType == FW_EFI_IMAGE) {
Warning (NULL, 0, 0, NULL, "Mulitple sections in %s are merged into 1 text section. Source level debug might not work correctly.", mInImageName);
@@ -389,12 +391,8 @@ ScanSections32 (
if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
// if the section address is aligned we must align PE/COFF
mCoffOffset = (mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);
- } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
- // ARM RVCT tools have behavior outside of the ELF specification to try
- // and make images smaller. If sh_addr is not aligned to sh_addralign
- // then the section needs to preserve sh_addr MOD sh_addralign.
- // Normally doing nothing here works great.
- Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+ } else {
+ Error (NULL, 0, 3000, "Invalid", "Section address not aligned to its own alignment.");
}
}
@@ -423,7 +421,7 @@ ScanSections32 (
// section alignment.
//
if (SectionCount > 0) {
- mDebugOffset = mCoffOffset;
+ mDebugOffset = DebugRvaAlign(mCoffOffset);
}
mCoffOffset = mDebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY) +
sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) +
@@ -446,12 +444,8 @@ ScanSections32 (
if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
// if the section address is aligned we must align PE/COFF
mCoffOffset = (mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);
- } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
- // ARM RVCT tools have behavior outside of the ELF specification to try
- // and make images smaller. If sh_addr is not aligned to sh_addralign
- // then the section needs to preserve sh_addr MOD sh_addralign.
- // Normally doing nothing here works great.
- Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+ } else {
+ Error (NULL, 0, 3000, "Invalid", "Section address not aligned to its own alignment.");
}
}
if (shdr->sh_size != 0) {
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c
index c758ed9d64..90d80a22da 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -211,6 +211,15 @@ CoffAlign (
return (Offset + mCoffAlignment - 1) & ~(mCoffAlignment - 1);
}
+STATIC
+UINT32
+DebugRvaAlign (
+ UINT32 Offset
+ )
+{
+ return (Offset + 3) & ~3;
+}
+
//
// filter functions
//
@@ -325,12 +334,8 @@ ScanSections64 (
if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
// if the section address is aligned we must align PE/COFF
mCoffOffset = (UINT32) ((mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1));
- } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
- // ARM RVCT tools have behavior outside of the ELF specification to try
- // and make images smaller. If sh_addr is not aligned to sh_addralign
- // then the section needs to preserve sh_addr MOD sh_addralign.
- // Normally doing nothing here works great.
- Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+ } else {
+ Error (NULL, 0, 3000, "Invalid", "Section address not aligned to its own alignment.");
}
}
@@ -359,11 +364,8 @@ ScanSections64 (
assert (FALSE);
}
- mDebugOffset = mCoffOffset;
-
- if (mEhdr->e_machine != EM_ARM) {
- mCoffOffset = CoffAlign(mCoffOffset);
- }
+ mDebugOffset = DebugRvaAlign(mCoffOffset);
+ mCoffOffset = CoffAlign(mCoffOffset);
if (SectionCount > 1 && mOutImageType == FW_EFI_IMAGE) {
Warning (NULL, 0, 0, NULL, "Mulitple sections in %s are merged into 1 text section. Source level debug might not work correctly.", mInImageName);
@@ -383,12 +385,8 @@ ScanSections64 (
if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
// if the section address is aligned we must align PE/COFF
mCoffOffset = (UINT32) ((mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1));
- } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
- // ARM RVCT tools have behavior outside of the ELF specification to try
- // and make images smaller. If sh_addr is not aligned to sh_addralign
- // then the section needs to preserve sh_addr MOD sh_addralign.
- // Normally doing nothing here works great.
- Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+ } else {
+ Error (NULL, 0, 3000, "Invalid", "Section address not aligned to its own alignment.");
}
}
@@ -412,7 +410,7 @@ ScanSections64 (
// section alignment.
//
if (SectionCount > 0) {
- mDebugOffset = mCoffOffset;
+ mDebugOffset = DebugRvaAlign(mCoffOffset);
}
mCoffOffset = mDebugOffset + sizeof(EFI_IMAGE_DEBUG_DIRECTORY_ENTRY) +
sizeof(EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY) +
@@ -439,12 +437,8 @@ ScanSections64 (
if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
// if the section address is aligned we must align PE/COFF
mCoffOffset = (UINT32) ((mCoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1));
- } else if ((shdr->sh_addr % shdr->sh_addralign) != (mCoffOffset % shdr->sh_addralign)) {
- // ARM RVCT tools have behavior outside of the ELF specification to try
- // and make images smaller. If sh_addr is not aligned to sh_addralign
- // then the section needs to preserve sh_addr MOD sh_addralign.
- // Normally doing nothing here works great.
- Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+ } else {
+ Error (NULL, 0, 3000, "Invalid", "Section address not aligned to its own alignment.");
}
}
if (shdr->sh_size != 0) {
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index 4756c52762..9ddd18e294 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -1,7 +1,7 @@
/** @file
Converts a pe32+ image to an FW, Te image type, or other specific image.
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2015, 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
@@ -168,7 +168,7 @@ Returns:
//
// Copyright declaration
//
- fprintf (stdout, "Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.\n\n");
+ fprintf (stdout, "Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.\n\n");
//
// Details Option
@@ -184,9 +184,9 @@ Returns:
PIC_PEIM, RELOCATABLE_PEIM, BS_DRIVER, RT_DRIVER,\n\
APPLICATION, SAL_RT_DRIVER to support all module types\n\
It can only be used together with --keepexceptiontable,\n\
- --keepzeropending, -r, -o option.It is a action option.\n\
- If it is combined with other action options, the later\n\
- input action option will override the previous one.\n");
+ --keepzeropending, --keepoptionalheader, -r, -o option.\n\
+ It is a action option. If it is combined with other action options,\n\
+ the later input action option will override the previous one.\n");
fprintf (stdout, " -c, --acpi Create Acpi table.\n\
It can't be combined with other action options\n\
except for -o, -r option. It is a action option.\n\
@@ -194,9 +194,9 @@ Returns:
input action option will override the previous one.\n");
fprintf (stdout, " -t, --terse Create Te Image.\n\
It can only be used together with --keepexceptiontable,\n\
- --keepzeropending, -r, -o option.It is a action option.\n\
- If it is combined with other action options, the later\n\
- input action option will override the previous one.\n");
+ --keepzeropending, --keepoptionalheader, -r, -o option.\n\
+ It is a action option. If it is combined with other action options,\n\
+ the later input action option will override the previous one.\n");
fprintf (stdout, " -u, --dump Dump TeImage Header.\n\
It can't be combined with other action options\n\
except for -o, -r option. It is a action option.\n\
@@ -246,6 +246,9 @@ Returns:
fprintf (stdout, " --keepexceptiontable Don't clear exception table.\n\
This option can be used together with -e or -t.\n\
It doesn't work for other options.\n");
+ fprintf (stdout, " --keepoptionalheader Don't zero PE/COFF optional header fields.\n\
+ This option can be used together with -e or -t.\n\
+ It doesn't work for other options.\n");
fprintf (stdout, " --keepzeropending Don't strip zero pending of .reloc.\n\
This option can be used together with -e or -t.\n\
It doesn't work for other options.\n");
@@ -1079,6 +1082,7 @@ Returns:
STATUS Status;
BOOLEAN ReplaceFlag;
BOOLEAN KeepExceptionTableFlag;
+ BOOLEAN KeepOptionalHeaderFlag;
BOOLEAN KeepZeroPendingFlag;
UINT64 LogLevel;
EFI_TE_IMAGE_HEADER TEImageHeader;
@@ -1141,6 +1145,7 @@ Returns:
Optional32 = NULL;
Optional64 = NULL;
KeepExceptionTableFlag = FALSE;
+ KeepOptionalHeaderFlag = FALSE;
KeepZeroPendingFlag = FALSE;
NumberOfFormPacakge = 0;
HiiPackageListBuffer = NULL;
@@ -1269,6 +1274,13 @@ Returns:
continue;
}
+ if (stricmp(argv[0], "--keepoptionalheader") == 0) {
+ KeepOptionalHeaderFlag = TRUE;
+ argc--;
+ argv++;
+ continue;
+ }
+
if (stricmp (argv[0], "--keepzeropending") == 0) {
KeepZeroPendingFlag = TRUE;
argc --;
@@ -2303,19 +2315,20 @@ Returns:
if (PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
Optional32 = (EFI_IMAGE_OPTIONAL_HEADER32 *)&PeHdr->Pe32.OptionalHeader;
- Optional32->MajorOperatingSystemVersion = 0;
- Optional32->MinorOperatingSystemVersion = 0;
- Optional32->MajorImageVersion = 0;
- Optional32->MinorImageVersion = 0;
- Optional32->MajorSubsystemVersion = 0;
- Optional32->MinorSubsystemVersion = 0;
- Optional32->Win32VersionValue = 0;
- Optional32->CheckSum = 0;
- Optional32->SizeOfStackReserve = 0;
- Optional32->SizeOfStackCommit = 0;
- Optional32->SizeOfHeapReserve = 0;
- Optional32->SizeOfHeapCommit = 0;
-
+ if (!KeepOptionalHeaderFlag) {
+ Optional32->MajorOperatingSystemVersion = 0;
+ Optional32->MinorOperatingSystemVersion = 0;
+ Optional32->MajorImageVersion = 0;
+ Optional32->MinorImageVersion = 0;
+ Optional32->MajorSubsystemVersion = 0;
+ Optional32->MinorSubsystemVersion = 0;
+ Optional32->Win32VersionValue = 0;
+ Optional32->CheckSum = 0;
+ Optional32->SizeOfStackReserve = 0;
+ Optional32->SizeOfStackCommit = 0;
+ Optional32->SizeOfHeapReserve = 0;
+ Optional32->SizeOfHeapCommit = 0;
+ }
TEImageHeader.AddressOfEntryPoint = Optional32->AddressOfEntryPoint;
TEImageHeader.BaseOfCode = Optional32->BaseOfCode;
TEImageHeader.ImageBase = (UINT64) (Optional32->ImageBase);
@@ -2395,19 +2408,20 @@ Returns:
}
} else if (PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
Optional64 = (EFI_IMAGE_OPTIONAL_HEADER64 *)&PeHdr->Pe32.OptionalHeader;
- Optional64->MajorOperatingSystemVersion = 0;
- Optional64->MinorOperatingSystemVersion = 0;
- Optional64->MajorImageVersion = 0;
- Optional64->MinorImageVersion = 0;
- Optional64->MajorSubsystemVersion = 0;
- Optional64->MinorSubsystemVersion = 0;
- Optional64->Win32VersionValue = 0;
- Optional64->CheckSum = 0;
- Optional64->SizeOfStackReserve = 0;
- Optional64->SizeOfStackCommit = 0;
- Optional64->SizeOfHeapReserve = 0;
- Optional64->SizeOfHeapCommit = 0;
-
+ if (!KeepOptionalHeaderFlag) {
+ Optional64->MajorOperatingSystemVersion = 0;
+ Optional64->MinorOperatingSystemVersion = 0;
+ Optional64->MajorImageVersion = 0;
+ Optional64->MinorImageVersion = 0;
+ Optional64->MajorSubsystemVersion = 0;
+ Optional64->MinorSubsystemVersion = 0;
+ Optional64->Win32VersionValue = 0;
+ Optional64->CheckSum = 0;
+ Optional64->SizeOfStackReserve = 0;
+ Optional64->SizeOfStackCommit = 0;
+ Optional64->SizeOfHeapReserve = 0;
+ Optional64->SizeOfHeapCommit = 0;
+ }
TEImageHeader.AddressOfEntryPoint = Optional64->AddressOfEntryPoint;
TEImageHeader.BaseOfCode = Optional64->BaseOfCode;
TEImageHeader.ImageBase = (UINT64) (Optional64->ImageBase);
diff --git a/BaseTools/Source/C/Split/Split.c b/BaseTools/Source/C/Split/Split.c
index b63aef78f9..44a09681d3 100644
--- a/BaseTools/Source/C/Split/Split.c
+++ b/BaseTools/Source/C/Split/Split.c
@@ -2,7 +2,7 @@
Split a file into two pieces at the request offset.
-Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 1999 - 2015, 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
@@ -58,7 +58,7 @@ Returns:
--*/
{
printf ("%s Version %d.%d %s\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
- printf ("Copyright (c) 1999-2014 Intel Corporation. All rights reserved.\n");
+ printf ("Copyright (c) 1999-2015 Intel Corporation. All rights reserved.\n");
printf ("\n SplitFile creates two Binary files either in the same directory as the current working\n");
printf (" directory or in the specified directory.\n");
}
@@ -176,20 +176,25 @@ CreateDir (
{
CHAR8* temp = *FullFileName;
CHAR8* start = temp;
+ CHAR8 tempchar;
UINT64 index = 0;
for (;index < strlen(temp); ++index) {
if (temp[index] == '\\' || temp[index] == '/') {
- temp[index] = 0;
- if (chdir(start)) {
- if (mkdir(start, S_IRWXU | S_IRWXG | S_IRWXO) != 0) {
- return EFI_ABORTED;
+ if (temp[index + 1] != '\0') {
+ tempchar = temp[index + 1];
+ temp[index + 1] = 0;
+ if (chdir(start)) {
+ if (mkdir(start, S_IRWXU | S_IRWXG | S_IRWXO) != 0) {
+ return EFI_ABORTED;
+ }
+ chdir(start);
}
- chdir(start);
+ start = temp + index + 1;
+ temp[index] = '/';
+ temp[index + 1] = tempchar;
+ }
}
- start = temp + index + 1;
- temp[index] = '/';
- }
}
return EFI_SUCCESS;
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index ad839b2ab6..d74fec8815 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -3258,7 +3258,7 @@ vfrStatementInconsistentIf :
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << IIObj.SetError (_STOSID(S->getText(), S->getLine())); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
vfrStatementExpression[0]
- E:EndIf << CRT_END_OP (E); >>
+ E:EndIf {";"} << CRT_END_OP (E); >>
;
vfrStatementNoSubmitIf :
@@ -3267,7 +3267,7 @@ vfrStatementNoSubmitIf :
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << NSIObj.SetError (_STOSID(S->getText(), S->getLine())); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
vfrStatementExpression[0]
- E:EndIf << CRT_END_OP (E); >>
+ E:EndIf {";"} << CRT_END_OP (E); >>
;
vfrStatementWarningIf :
@@ -3276,7 +3276,7 @@ vfrStatementWarningIf :
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << WIObj.SetWarning (_STOSID(S->getText(), S->getLine())); >>
{Timeout "=" T:Number "," << WIObj.SetTimeOut (_STOU8(T->getText(), T->getLine())); >>}
vfrStatementExpression[0]
- E:EndIf << CRT_END_OP (E); >>
+ E:EndIf {";"} << CRT_END_OP (E); >>
;
vfrStatementDisableIfQuest :
@@ -3286,7 +3286,7 @@ vfrStatementDisableIfQuest :
L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
vfrStatementExpression[0] ";"
vfrStatementQuestionOptionList
- E:EndIf << CRT_END_OP (E); >>
+ E:EndIf {";"} << CRT_END_OP (E); >>
;
vfrStatementRefresh :
@@ -3316,7 +3316,7 @@ vfrStatementSuppressIfQuest :
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
vfrStatementExpression[0] ";"
vfrStatementQuestionOptionList
- E:EndIf << CRT_END_OP (E); >>
+ E:EndIf {";"} << CRT_END_OP (E); >>
;
vfrStatementGrayOutIfQuest :
@@ -3325,7 +3325,7 @@ vfrStatementGrayOutIfQuest :
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
vfrStatementExpression[0] ";"
vfrStatementQuestionOptionList
- E:EndIf << CRT_END_OP (E); >>
+ E:EndIf {";"} << CRT_END_OP (E); >>
;
vfrStatementOptions :