Sync EDKII BaseTools to BaseTools project r2006.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10764 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2010-08-03 03:29:17 +00:00
parent 934309d58e
commit 756ad8f8e9
24 changed files with 199 additions and 71 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -413,7 +413,7 @@
<Command.MSFT, Command.INTEL>
cd $(OUTPUT_DIR)(+)${s_dir}
"$(ASM16)" /nologo /c /omf /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj ${src}
"$(ASM16)" /nologo /c /omf $(INC) /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj ${src}
"$(ASMLINK)" $(ASMLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj,${dst},,,,
<Command.GCC>

View File

@ -632,6 +632,7 @@ WriteSections32 (
switch (ELF32_R_TYPE(Rel->r_info)) {
case R_ARM_RBASE:
// No relocation - no action required
// break skipped
case R_ARM_PC24:
case R_ARM_XPC25:
@ -639,6 +640,35 @@ WriteSections32 (
case R_ARM_THM_JUMP19:
case R_ARM_CALL:
case R_ARM_JMP24:
case R_ARM_THM_JUMP24:
case R_ARM_PREL31:
case R_ARM_MOVW_PREL_NC:
case R_ARM_MOVT_PREL:
case R_ARM_THM_MOVW_PREL_NC:
case R_ARM_THM_MOVT_PREL:
case R_ARM_THM_JMP6:
case R_ARM_THM_ALU_PREL_11_0:
case R_ARM_THM_PC12:
case R_ARM_REL32_NOI:
case R_ARM_ALU_PC_G0_NC:
case R_ARM_ALU_PC_G0:
case R_ARM_ALU_PC_G1_NC:
case R_ARM_ALU_PC_G1:
case R_ARM_ALU_PC_G2:
case R_ARM_LDR_PC_G1:
case R_ARM_LDR_PC_G2:
case R_ARM_LDRS_PC_G0:
case R_ARM_LDRS_PC_G1:
case R_ARM_LDRS_PC_G2:
case R_ARM_LDC_PC_G0:
case R_ARM_LDC_PC_G1:
case R_ARM_LDC_PC_G2:
case R_ARM_GOT_PREL:
case R_ARM_THM_JUMP11:
case R_ARM_THM_JUMP8:
case R_ARM_TLS_GD32:
case R_ARM_TLS_LDM32:
case R_ARM_TLS_IE32:
// Thease are all PC-relative relocations and don't require modification
// GCC does not seem to have the concept of a application that just needs to get relocated.
break;
@ -736,14 +766,45 @@ WriteRelocations32 (
}
} else if (mEhdr->e_machine == EM_ARM) {
switch (ELF32_R_TYPE(Rel->r_info)) {
case R_ARM_RBASE:
case R_ARM_RBASE:
// No relocation - no action required
// break skipped
case R_ARM_PC24:
case R_ARM_XPC25:
case R_ARM_THM_PC22:
case R_ARM_THM_JUMP19:
case R_ARM_CALL:
case R_ARM_JMP24:
case R_ARM_THM_JUMP24:
case R_ARM_PREL31:
case R_ARM_MOVW_PREL_NC:
case R_ARM_MOVT_PREL:
case R_ARM_THM_MOVW_PREL_NC:
case R_ARM_THM_MOVT_PREL:
case R_ARM_THM_JMP6:
case R_ARM_THM_ALU_PREL_11_0:
case R_ARM_THM_PC12:
case R_ARM_REL32_NOI:
case R_ARM_ALU_PC_G0_NC:
case R_ARM_ALU_PC_G0:
case R_ARM_ALU_PC_G1_NC:
case R_ARM_ALU_PC_G1:
case R_ARM_ALU_PC_G2:
case R_ARM_LDR_PC_G1:
case R_ARM_LDR_PC_G2:
case R_ARM_LDRS_PC_G0:
case R_ARM_LDRS_PC_G1:
case R_ARM_LDRS_PC_G2:
case R_ARM_LDC_PC_G0:
case R_ARM_LDC_PC_G1:
case R_ARM_LDC_PC_G2:
case R_ARM_GOT_PREL:
case R_ARM_THM_JUMP11:
case R_ARM_THM_JUMP8:
case R_ARM_TLS_GD32:
case R_ARM_TLS_LDM32:
case R_ARM_TLS_IE32:
// Thease are all PC-relative relocations and don't require modification
break;

View File

@ -602,6 +602,38 @@ typedef struct {
#define R_ARM_THM_MOVW_ABS_NC 47
#define R_ARM_THM_MOVT_ABS 48
// Block of PC-relative relocations added to work around gcc putting
// object relocations in static executables.
#define R_ARM_THM_JUMP24 30
#define R_ARM_PREL31 42
#define R_ARM_MOVW_PREL_NC 45
#define R_ARM_MOVT_PREL 46
#define R_ARM_THM_MOVW_PREL_NC 49
#define R_ARM_THM_MOVT_PREL 50
#define R_ARM_THM_JMP6 52
#define R_ARM_THM_ALU_PREL_11_0 53
#define R_ARM_THM_PC12 54
#define R_ARM_REL32_NOI 56
#define R_ARM_ALU_PC_G0_NC 57
#define R_ARM_ALU_PC_G0 58
#define R_ARM_ALU_PC_G1_NC 59
#define R_ARM_ALU_PC_G1 60
#define R_ARM_ALU_PC_G2 61
#define R_ARM_LDR_PC_G1 62
#define R_ARM_LDR_PC_G2 63
#define R_ARM_LDRS_PC_G0 64
#define R_ARM_LDRS_PC_G1 65
#define R_ARM_LDRS_PC_G2 66
#define R_ARM_LDC_PC_G0 67
#define R_ARM_LDC_PC_G1 68
#define R_ARM_LDC_PC_G2 69
#define R_ARM_GOT_PREL 96
#define R_ARM_THM_JUMP11 102
#define R_ARM_THM_JUMP8 103
#define R_ARM_TLS_GD32 104
#define R_ARM_TLS_LDM32 105
#define R_ARM_TLS_IE32 107
#define R_ARM_THM_JUMP19 51
#define R_ARM_GNU_VTENTRY 100
#define R_ARM_GNU_VTINHERIT 101
@ -612,6 +644,8 @@ typedef struct {
#define R_ARM_RPC24 254
#define R_ARM_RBASE 255
/* Name Value Field Calculation */
#define R_IA_64_NONE 0 /* None */
#define R_IA_64_IMM14 0x21 /* immediate14 S + A */

View File

@ -1888,7 +1888,7 @@ def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH, UniGenCFlag, UniGenBinBuff
else:
ShellMode = False
Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode, UniGenCFlag, UniGenBinBuffer)
Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, Info.IncludePathList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode, UniGenCFlag, UniGenBinBuffer)
if CompatibleMode or UniGenCFlag:
AutoGenC.Append("\n//\n//Unicode String Pack Definition\n//\n")
AutoGenC.Append(Code)

View File

@ -26,7 +26,7 @@ from BuildEngine import *
import Common.GlobalData as GlobalData
## Regular expression for finding header file inclusions
gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:[\"<]?[ \t]*)([\w.\\/]+)(?:[ \t]*[\">]?)", re.MULTILINE|re.UNICODE)
gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:[\"<]?[ \t]*)([\w.\\/() \t]+)(?:[ \t]*[\">]?)", re.MULTILINE|re.UNICODE|re.IGNORECASE)
## Regular expression for matching macro used in header file inclusion
gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)
@ -754,6 +754,7 @@ cleanlib:
CurrentFilePath = F.Dir
for Inc in IncludedFileList:
Inc = Inc.strip()
# if there's macro used to reference header file, expand it
HeaderList = gMacroPattern.findall(Inc)
if len(HeaderList) == 1 and len(HeaderList[0]) == 2:

View File

@ -1,4 +1,4 @@
# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2010, 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,6 +168,8 @@ def CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag):
Str = WriteLine(Str, Line)
Line = COMMENT_DEFINE_STR + ' ' + PRINTABLE_LANGUAGE_NAME_STRING_NAME + ' ' * (ValueStartPtr - len(DEFINE_STR + PRINTABLE_LANGUAGE_NAME_STRING_NAME)) + DecToHexStr(1, 4) + COMMENT_NOT_REFERENCED
Str = WriteLine(Str, Line)
#Group the referred STRING token together.
for Index in range(2, len(UniObjectClass.OrderedStringList[UniObjectClass.LanguageDef[0][0]])):
StringItem = UniObjectClass.OrderedStringList[UniObjectClass.LanguageDef[0][0]][Index]
Name = StringItem.StringName
@ -180,12 +182,22 @@ def CreateHFileContent(BaseName, UniObjectClass, IsCompatibleMode, UniGenCFlag):
Line = DEFINE_STR + ' ' + Name + ' ' + DecToHexStr(Token, 4)
else:
Line = DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4)
else:
Str = WriteLine(Str, Line)
#Group the unused STRING token together.
for Index in range(2, len(UniObjectClass.OrderedStringList[UniObjectClass.LanguageDef[0][0]])):
StringItem = UniObjectClass.OrderedStringList[UniObjectClass.LanguageDef[0][0]][Index]
Name = StringItem.StringName
Token = StringItem.Token
Referenced = StringItem.Referenced
if Name != None:
Line = ''
if Referenced == False:
if (ValueStartPtr - len(DEFINE_STR + Name)) <= 0:
Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED
else:
Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED
Str = WriteLine(Str, Line)
Str = WriteLine(Str, Line)
Str = WriteLine(Str, '')
if IsCompatibleMode or UniGenCFlag:
@ -506,7 +518,7 @@ def SearchString(UniObjectClass, FileList, IsCompatibleMode):
# This function is used for UEFI2.1 spec
#
#
def GetStringFiles(UniFilList, SourceFileList, IncludeList, SkipList, BaseName, IsCompatibleMode = False, ShellMode = False, UniGenCFlag = True, UniGenBinBuffer = None):
def GetStringFiles(UniFilList, SourceFileList, IncludeList, IncludePathList, SkipList, BaseName, IsCompatibleMode = False, ShellMode = False, UniGenCFlag = True, UniGenBinBuffer = None):
Status = True
ErrorMessage = ''
@ -515,15 +527,15 @@ def GetStringFiles(UniFilList, SourceFileList, IncludeList, SkipList, BaseName,
#
# support ISO 639-2 codes in .UNI files of EDK Shell
#
Uni = UniFileClassObject(UniFilList, True)
Uni = UniFileClassObject(sorted (UniFilList), True, IncludePathList)
else:
Uni = UniFileClassObject(UniFilList, IsCompatibleMode)
Uni = UniFileClassObject(sorted (UniFilList), IsCompatibleMode, IncludePathList)
else:
EdkLogger.error("UnicodeStringGather", AUTOGEN_ERROR, 'No unicode files given')
FileList = GetFileList(SourceFileList, IncludeList, SkipList)
Uni = SearchString(Uni, FileList, IsCompatibleMode)
Uni = SearchString(Uni, sorted (FileList), IsCompatibleMode)
HFile = CreateHFile(BaseName, Uni, IsCompatibleMode, UniGenCFlag)
CFile = None

View File

@ -177,18 +177,24 @@ class StringDefClassObject(object):
repr(self.StringValue) + ' ' + \
repr(self.UseOtherLangDef)
def UpdateValue(self, Value = None):
if Value != None:
self.StringValue = Value + u'\x00' # Add a NULL at string tail
self.StringValueByteList = UniToHexList(self.StringValue)
self.Length = len(self.StringValueByteList)
## UniFileClassObject
#
# A structure for .uni file definition
#
class UniFileClassObject(object):
def __init__(self, FileList = [], IsCompatibleMode = False):
def __init__(self, FileList = [], IsCompatibleMode = False, IncludePathList = []):
self.FileList = FileList
self.Token = 2
self.LanguageDef = [] #[ [u'LanguageIdentifier', u'PrintableName'], ... ]
self.OrderedStringList = {} #{ u'LanguageIdentifier' : [StringDefClassObject] }
self.IsCompatibleMode = IsCompatibleMode
self.IncludePathList = IncludePathList
if len(self.FileList) > 0:
self.LoadUniFiles(FileList)
@ -226,6 +232,21 @@ class UniFileClassObject(object):
self.AddStringToList(u'$LANGUAGE_NAME', LangName, LangName, 0, True, Index=0)
self.AddStringToList(u'$PRINTABLE_LANGUAGE_NAME', LangName, LangPrintName, 1, True, Index=1)
if not IsLangInDef:
#
# The found STRING tokens will be added into new language string list
# so that the unique STRING identifier is reserved for all languages in the package list.
#
FirstLangName = self.LanguageDef[0][0]
if LangName != FirstLangName:
for Index in range (2, len (self.OrderedStringList[FirstLangName])):
Item = self.OrderedStringList[FirstLangName][Index]
if Item.UseOtherLangDef != '':
OtherLang = Item.UseOtherLangDef
else:
OtherLang = FirstLangName
self.OrderedStringList[LangName].append (StringDefClassObject(Item.StringName, '', Item.Referenced, Item.Token, OtherLang))
return True
#
@ -266,7 +287,6 @@ class UniFileClassObject(object):
if not os.path.exists(File.Path) or not os.path.isfile(File.Path):
EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND, ExtraData=File.Path)
Dir = File.Dir
try:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf-16').readlines()
except UnicodeError, X:
@ -309,7 +329,13 @@ class UniFileClassObject(object):
IncList = gIncludePattern.findall(Line)
if len(IncList) == 1:
Lines.extend(self.PreProcess(PathClass(str(IncList[0]), Dir)))
for Dir in [File.Dir] + self.IncludePathList:
IncFile = PathClass(str(IncList[0]), Dir)
if os.path.isfile(IncFile.Path):
Lines.extend(self.PreProcess(IncFile))
break
else:
EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND, Message="Cannot find include file", ExtraData=str(IncList[0]))
continue
Lines.append(Line)
@ -421,15 +447,30 @@ class UniFileClassObject(object):
if Language not in self.OrderedStringList:
self.OrderedStringList[Language] = []
IsAdded = False
IsAdded = True
for Item in self.OrderedStringList[Language]:
if Name == Item.StringName:
IsAdded = True
IsAdded = False
if Value != None:
Item.UpdateValue(Value)
Item.UseOtherLangDef = ''
break
if not IsAdded:
if IsAdded:
Token = len(self.OrderedStringList[Language])
if Index == -1:
self.OrderedStringList[Language].append(StringDefClassObject(Name, Value, Referenced, Token, UseOtherLangDef))
for LangName in self.LanguageDef:
#
# New STRING token will be added into all language string lists.
# so that the unique STRING identifier is reserved for all languages in the package list.
#
if LangName[0] != Language:
if UseOtherLangDef != '':
OtherLangDef = UseOtherLangDef
else:
OtherLangDef = Language
self.OrderedStringList[LangName[0]].append(StringDefClassObject(Name, '', Referenced, Token, OtherLangDef))
else:
self.OrderedStringList[Language].insert(Index, StringDefClassObject(Name, Value, Referenced, Token, UseOtherLangDef))
@ -437,11 +478,15 @@ class UniFileClassObject(object):
# Set the string as referenced
#
def SetStringReferenced(self, Name):
for Lang in self.OrderedStringList:
for Item in self.OrderedStringList[Lang]:
if Name == Item.StringName:
Item.Referenced = True
break
#
# String stoken are added in the same order in all language string lists.
# So, only update the status of string stoken in first language string list.
#
Lang = self.LanguageDef[0][0]
for Item in self.OrderedStringList[Lang]:
if Name == Item.StringName:
Item.Referenced = True
break
#
# Search the string in language definition by Name
#
@ -467,61 +512,36 @@ class UniFileClassObject(object):
#
def ReToken(self):
#
# Search each string to find if it is defined for each language
# Use secondary language value to replace if missing in any one language
# Retoken all language strings according to the status of string stoken in the first language string.
#
for IndexI in range(0, len(self.LanguageDef)):
LangKey = self.LanguageDef[IndexI][0]
for Item in self.OrderedStringList[LangKey]:
Name = Item.StringName
Value = Item.StringValue[0:-1]
Referenced = Item.Referenced
Index = self.OrderedStringList[LangKey].index(Item)
for IndexJ in range(0, len(self.LanguageDef)):
LangFind = self.LanguageDef[IndexJ][0]
if self.FindStringValue(Name, LangFind) == None:
EdkLogger.debug(EdkLogger.DEBUG_5, Name)
Token = len(self.OrderedStringList[LangFind])
self.AddStringToList(Name, LangFind, Value, Token, Referenced, LangKey, Index)
#
# Retoken
#
# First re-token the first language
LangName = self.LanguageDef[0][0]
ReferencedStringList = []
NotReferencedStringList = []
Token = 0
FirstLangName = self.LanguageDef[0][0]
#
# Order UNI token by their String Name
# Use small token for all referred string stoken.
#
StringNameList = []
for Item in self.OrderedStringList[LangName]:
StringNameList.append (Item.StringName)
StringNameList.sort()
for Name in StringNameList:
Item = self.FindStringValue (Name, LangName)
if Item.Referenced == True:
Item.Token = Token
ReferencedStringList.append(Item)
Token = Token + 1
else:
NotReferencedStringList.append(Item)
self.OrderedStringList[LangName] = ReferencedStringList
for Index in range(len(NotReferencedStringList)):
NotReferencedStringList[Index].Token = Token + Index
self.OrderedStringList[LangName].append(NotReferencedStringList[Index])
RefToken = 0
for Index in range (0, len (self.OrderedStringList[FirstLangName])):
FirstLangItem = self.OrderedStringList[FirstLangName][Index]
if FirstLangItem.Referenced == True:
for LangNameItem in self.LanguageDef:
LangName = LangNameItem[0]
OtherLangItem = self.OrderedStringList[LangName][Index]
OtherLangItem.Referenced = True
OtherLangItem.Token = RefToken
RefToken = RefToken + 1
#
# Adjust the orders of other languages
# Use big token for all unreferred string stoken.
#
for IndexOfLanguage in range(1, len(self.LanguageDef)):
for OrderedString in self.OrderedStringList[LangName]:
for UnOrderedString in self.OrderedStringList[self.LanguageDef[IndexOfLanguage][0]]:
if OrderedString.StringName == UnOrderedString.StringName:
UnOrderedString.Token = OrderedString.Token
break
UnRefToken = 0
for Index in range (0, len (self.OrderedStringList[FirstLangName])):
FirstLangItem = self.OrderedStringList[FirstLangName][Index]
if FirstLangItem.Referenced == False:
for LangNameItem in self.LanguageDef:
LangName = LangNameItem[0]
OtherLangItem = self.OrderedStringList[LangName][Index]
OtherLangItem.Token = RefToken + UnRefToken
UnRefToken = UnRefToken + 1
#
# Show the instance itself