diff options
Diffstat (limited to 'BaseTools/Scripts')
-rw-r--r-- | BaseTools/Scripts/BinToPcd.py | 4 | ||||
-rw-r--r-- | BaseTools/Scripts/ClangBase.lds | 88 | ||||
-rw-r--r-- | BaseTools/Scripts/ConvertFceToStructurePcd.py | 2 | ||||
-rw-r--r-- | BaseTools/Scripts/GccBase.lds | 20 | ||||
-rw-r--r-- | BaseTools/Scripts/GetMaintainer.py | 11 | ||||
-rwxr-xr-x | BaseTools/Scripts/PatchCheck.py | 54 | ||||
-rw-r--r-- | BaseTools/Scripts/SetupGit.py | 2 | ||||
-rwxr-xr-x | BaseTools/Scripts/efi_debugging.py | 36 |
8 files changed, 94 insertions, 123 deletions
diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py index be726cc..43fc458 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -37,13 +37,13 @@ if __name__ == '__main__': return Value
def ValidatePcdName (Argument):
- if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']:
+ if re.split (r'[a-zA-Z\_][a-zA-Z0-9\_]*\.[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']:
Message = '{Argument} is not in the form <PcdTokenSpaceGuidCName>.<PcdCName>'.format (Argument = Argument)
raise argparse.ArgumentTypeError (Message)
return Argument
def ValidateGuidName (Argument):
- if re.split ('[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']:
+ if re.split (r'[a-zA-Z\_][a-zA-Z0-9\_]*', Argument) != ['', '']:
Message = '{Argument} is not a valid GUID C name'.format (Argument = Argument)
raise argparse.ArgumentTypeError (Message)
return Argument
diff --git a/BaseTools/Scripts/ClangBase.lds b/BaseTools/Scripts/ClangBase.lds deleted file mode 100644 index c7dcd20..0000000 --- a/BaseTools/Scripts/ClangBase.lds +++ /dev/null @@ -1,88 +0,0 @@ -/** @file
-
- Unified linker script for CLANG based builds
-
- Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved.<BR>
- Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
- (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-SECTIONS {
-
- /*
- * The PE/COFF binary consists of DOS and PE/COFF headers, and a sequence of
- * section headers adding up to PECOFF_HEADER_SIZE bytes (which differs
- * between 32-bit and 64-bit builds). The actual start of the .text section
- * will be rounded up based on its actual alignment.
- */
- . = PECOFF_HEADER_SIZE;
-
- .text : ALIGN(CONSTANT(MAXPAGESIZE)) {
- *(.text .text.* .stub .gnu.linkonce.t.*)
- *(.rodata .rodata.* .gnu.linkonce.r.*)
- *(.got .got.*)
-
- /*
- * The contents of AutoGen.c files are mostly constant from the POV of the
- * program, but most of it ends up in .data or .bss by default since few of
- * the variable definitions that get emitted are declared as CONST.
- * Unfortunately, we cannot pull it into the .text section entirely, since
- * patchable PCDs are also emitted here, but we can at least move all of the
- * emitted GUIDs here.
- */
- *:AutoGen.obj(.data.g*Guid)
- }
-
- /*
- * The alignment of the .data section should be less than or equal to the
- * alignment of the .text section. This ensures that the relative offset
- * between these sections is the same in the ELF and the PE/COFF versions of
- * this binary.
- */
- .data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(MAXPAGESIZE)) {
- *(.data .data.* .gnu.linkonce.d.*)
- *(.bss .bss.*)
- }
-
- .eh_frame ALIGN(CONSTANT(MAXPAGESIZE)) : {
- KEEP (*(.eh_frame))
- }
-
- .rela (INFO) : {
- *(.rela .rela.*)
- }
-
- .hii : ALIGN(CONSTANT(MAXPAGESIZE)) {
- KEEP (*(.hii))
- }
-
- .got : {
- *(.got)
- }
- ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
-
- .got.plt (INFO) : {
- *(.got.plt)
- }
- ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!")
-
- /*
- * Retain the GNU build id but in a non-allocatable section so GenFw
- * does not copy it into the PE/COFF image.
- */
- .build-id (INFO) : { *(.note.gnu.build-id) }
-
- /DISCARD/ : {
- *(.note.GNU-stack)
- *(.gnu_debuglink)
- *(.interp)
- *(.dynsym)
- *(.dynstr)
- *(.hash .gnu.hash)
- *(.comment)
- *(COMMON)
- }
-}
diff --git a/BaseTools/Scripts/ConvertFceToStructurePcd.py b/BaseTools/Scripts/ConvertFceToStructurePcd.py index 9e7fe58..a73604f 100644 --- a/BaseTools/Scripts/ConvertFceToStructurePcd.py +++ b/BaseTools/Scripts/ConvertFceToStructurePcd.py @@ -223,7 +223,7 @@ class Config(object): if 'DEFAULT_ID:' in read:
all_txt = read.split('FCEKEY DEFAULT')
for i in all_txt[1:]:
- part = [] #save all infomation for DEFAULT_ID
+ part = [] #save all information for DEFAULT_ID
str_id=''
ids = ids_re.findall(i.replace(' ',''))
for m in ids:
diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds index 9f27e83..8d6c29d 100644 --- a/BaseTools/Scripts/GccBase.lds +++ b/BaseTools/Scripts/GccBase.lds @@ -1,8 +1,8 @@ /** @file
- Unified linker script for GCC based builds
+ Unified linker script for GCC and CLANG based builds
- Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2021, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
@@ -10,6 +10,12 @@ **/
+PHDRS {
+ text PT_LOAD FLAGS(5); /* R_X */
+ data PT_LOAD FLAGS(6); /* RW_ */
+ dynamic PT_DYNAMIC FLAGS(4); /* R__ */
+}
+
SECTIONS {
/*
@@ -21,6 +27,7 @@ SECTIONS { . = PECOFF_HEADER_SIZE;
.text : ALIGN(CONSTANT(COMMONPAGESIZE)) {
+ KEEP(*(.entry))
*(.text .text.* .stub .gnu.linkonce.t.*)
*(.rodata .rodata.* .gnu.linkonce.r.*)
*(.got .got.*)
@@ -34,7 +41,7 @@ SECTIONS { * emitted GUIDs here.
*/
*:AutoGen.obj(.data.g*Guid)
- }
+ } :text
/*
* The alignment of the .data section should be less than or equal to the
@@ -45,19 +52,21 @@ SECTIONS { .data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(COMMONPAGESIZE)) {
*(.data .data.* .gnu.linkonce.d.*)
*(.bss .bss.*)
- }
+ } :data
.eh_frame ALIGN(CONSTANT(COMMONPAGESIZE)) : {
KEEP (*(.eh_frame))
}
+ .dynamic : { *(.dynamic) } :data :dynamic
+
.rela (INFO) : {
*(.rela .rela.*)
}
.hii : ALIGN(CONSTANT(COMMONPAGESIZE)) {
KEEP (*(.hii))
- }
+ } :data
.got : {
*(.got)
@@ -81,7 +90,6 @@ SECTIONS { *(.interp)
*(.dynsym)
*(.dynstr)
- *(.dynamic)
*(.hash .gnu.hash)
*(.comment)
}
diff --git a/BaseTools/Scripts/GetMaintainer.py b/BaseTools/Scripts/GetMaintainer.py index 8097ba4..986550c 100644 --- a/BaseTools/Scripts/GetMaintainer.py +++ b/BaseTools/Scripts/GetMaintainer.py @@ -179,6 +179,10 @@ if __name__ == '__main__': PARSER.add_argument('-l', '--lookup',
help='Find section matches for path LOOKUP',
required=False)
+ PARSER.add_argument('-g', '--github',
+ action='store_true',
+ help='Include GitHub usernames in output',
+ required=False)
ARGS = PARSER.parse_args()
REPO = SetupGit.locate_repo()
@@ -203,5 +207,8 @@ if __name__ == '__main__': for address in ADDRESSES:
if '<' in address and '>' in address:
- address = address.split('>', 1)[0] + '>'
- print(' %s' % address)
+ address, github_id = address.split('>', 1)
+ address = address + '>'
+ github_id = github_id.strip() if ARGS.github else ''
+
+ print(' %s %s' % (address, github_id))
diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck.py index d797ac8..5c14840 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -97,7 +97,7 @@ class EmailAddressCheck: class CommitMessageCheck:
"""Checks the contents of a git commit message."""
- def __init__(self, subject, message, author_email):
+ def __init__(self, subject, message, author_email, updated_packages):
self.ok = True
self.ignore_multi_package = False
@@ -117,6 +117,7 @@ class CommitMessageCheck: self.check_contributed_under()
if not MergifyMerge:
+ self.check_subject(updated_packages)
self.check_signed_off_by()
self.check_misc_signatures()
self.check_overall_format()
@@ -209,6 +210,14 @@ class CommitMessageCheck: return sigs
+ def check_subject(self, updated_packages):
+ if updated_packages:
+ for package in updated_packages:
+ current_package_re = r"(Revert \"|^|, ?)" + re.escape(package) + r"([ ,:\/])"
+ if not re.search(current_package_re, self.subject):
+ self.error("Subject line not in \"package/component: description\" format!")
+ return
+
def check_signed_off_by(self):
sob='Signed-off-by'
if self.msg.find(sob) < 0:
@@ -254,26 +263,29 @@ class CommitMessageCheck: self.error('Empty commit message!')
return
- if count >= 1 and re.search(self.cve_re, lines[0]):
+ if re.search(self.cve_re, lines[0]):
#
# If CVE-xxxx-xxxxx is present in subject line, then limit length of
# subject line to 92 characters
#
- if len(lines[0].rstrip()) >= 93:
- self.error(
- 'First line of commit message (subject line) is too long (%d >= 93).' %
- (len(lines[0].rstrip()))
- )
+ maxlength = 92
+ elif lines[0].find(':') > 55:
+ #
+ # If we need to enumerate lots of packages, ensure to leave room for
+ # a very short description at the end (after the ':').
+ #
+ maxlength = lines[0].find(':') + 20
else:
#
- # If CVE-xxxx-xxxxx is not present in subject line, then limit
- # length of subject line to 75 characters
+ # Otherwise, limit the length of subject line to 75 characters
#
- if len(lines[0].rstrip()) >= 76:
- self.error(
- 'First line of commit message (subject line) is too long (%d >= 76).' %
- (len(lines[0].rstrip()))
- )
+ maxlength = 75
+
+ if len(lines[0].rstrip()) > maxlength:
+ self.error(
+ 'First line of commit message (subject line) is too long (%d > %d).' %
+ (len(lines[0].rstrip()), maxlength)
+ )
if count >= 1 and len(lines[0].strip()) == 0:
self.error('First line of commit message (subject line) ' +
@@ -395,7 +407,6 @@ class GitDiffCheck: self.force_notabs = False
if self.filename.endswith('.sh') or \
self.filename.startswith('BaseTools/BinWrappers/PosixLike/') or \
- self.filename.startswith('BaseTools/BinPipWrappers/PosixLike/') or \
self.filename == 'BaseTools/BuildEnv':
#
# Do not enforce CR/LF line endings for linux shell scripts.
@@ -486,7 +497,7 @@ class GitDiffCheck: lines = [ msg ]
if self.filename is not None:
lines.append('File: ' + self.filename)
- lines.append('Line: ' + line)
+ lines.append('Line ' + str(self.line_num) + ': ' + line)
self.error(*lines)
@@ -540,7 +551,7 @@ class GitDiffCheck: def format_error(self, err):
self.format_ok = False
err = 'Patch format error: ' + err
- err2 = 'Line: ' + self.lines[self.line_num].rstrip()
+ err2 = 'Line ' + str(self.line_num) + ': ' + self.lines[self.line_num].rstrip()
self.error(err, err2)
def error(self, *err):
@@ -562,14 +573,14 @@ class CheckOnePatch: patch content.
"""
- def __init__(self, name, patch):
+ def __init__(self, name, patch, updated_packages=None):
self.patch = patch
self.find_patch_pieces()
email_check = EmailAddressCheck(self.author_email, 'Author')
email_ok = email_check.ok
- msg_check = CommitMessageCheck(self.commit_subject, self.commit_msg, self.author_email)
+ msg_check = CommitMessageCheck(self.commit_subject, self.commit_msg, self.author_email, updated_packages)
msg_ok = msg_check.ok
self.ignore_multi_package = msg_check.ignore_multi_package
@@ -696,7 +707,8 @@ class CheckGitCommits: email = self.read_committer_email_address_from_git(commit)
self.ok &= EmailAddressCheck(email, 'Committer').ok
patch = self.read_patch_from_git(commit)
- check_patch = CheckOnePatch(commit, patch)
+ updated_packages = self.get_parent_packages (dec_files, commit, 'ADM')
+ check_patch = CheckOnePatch(commit, patch, updated_packages)
self.ok &= check_patch.ok
ignore_multi_package = check_patch.ignore_multi_package
if PatchCheckConf.ignore_multi_package:
@@ -731,7 +743,7 @@ class CheckGitCommits: for dec_file in dec_files:
if os.path.commonpath([dec_file, file]):
dec_found = True
- parents.add(dec_file)
+ parents.add(dec_file.split('/')[0])
if not dec_found and os.path.dirname (file):
# No DEC file found and file is in a subdir
# Covers BaseTools, .github, .azurepipelines, .pytool
diff --git a/BaseTools/Scripts/SetupGit.py b/BaseTools/Scripts/SetupGit.py index 5f93124..9014eb5 100644 --- a/BaseTools/Scripts/SetupGit.py +++ b/BaseTools/Scripts/SetupGit.py @@ -150,7 +150,7 @@ if __name__ == '__main__': action='store_true',
required=False)
PARSER.add_argument('-n', '--name', type=str, metavar='repo',
- choices=['edk2', 'edk2-platforms', 'edk2-non-osi'],
+ choices=['edk2', 'edk2-platforms', 'edk2-non-osi', 'edk2-test'],
help='set the repo name to configure for, if not '
'detected automatically',
required=False)
diff --git a/BaseTools/Scripts/efi_debugging.py b/BaseTools/Scripts/efi_debugging.py index 9848cd5..1c1446a 100755 --- a/BaseTools/Scripts/efi_debugging.py +++ b/BaseTools/Scripts/efi_debugging.py @@ -33,6 +33,7 @@ import os import uuid
import struct
import re
+import zlib
from ctypes import c_char, c_uint8, c_uint16, c_uint32, c_uint64, c_void_p
from ctypes import ARRAY, sizeof
from ctypes import Structure, LittleEndianStructure
@@ -1770,8 +1771,10 @@ class EfiConfigurationTable: def __init__(self, file, gST_addr=None):
self._file = file
if gST_addr is None:
- # ToDo add code to search for gST via EFI_SYSTEM_TABLE_POINTER
- return
+ # search for gST via EFI_SYSTEM_TABLE_POINTER
+ system_table_pointer = self._get_system_table_pointer()
+ if not system_table_pointer is None:
+ gST_addr = system_table_pointer.EfiSystemTableBase
gST = self._ctype_read(EFI_SYSTEM_TABLE, gST_addr)
self.read_efi_config_table(gST.NumberOfTableEntries,
@@ -1796,6 +1799,35 @@ class EfiConfigurationTable: data = self._file.read(sizeof(ctype_struct))
return ctype_struct.from_buffer(bytearray(data))
+ def _get_system_table_pointer(self):
+ start_addr = 0x0
+ end_addr = 0xf0000000
+ alignment = 0x00400000
+ # The translation of "IBI SYST" for the signature of EFI_SYSTEM_TABLE
+ efi_system_table_signature = 0x5453595320494249
+
+ system_table_pointer = None
+
+ current_addr = start_addr
+ while current_addr < end_addr:
+ try:
+ self._file.seek(current_addr)
+ data = self._file.read(sizeof(EFI_SYSTEM_TABLE_POINTER))
+ except:
+ current_addr = current_addr + alignment
+ continue
+
+ system_table_pointer = EFI_SYSTEM_TABLE_POINTER.from_buffer(bytearray(data))
+ if system_table_pointer.Signature == efi_system_table_signature:
+ buf1 = bytearray(system_table_pointer)[:16]
+ crc32_value = zlib.crc32(buf1)
+ crc32_value = zlib.crc32(b'\0' * (sizeof(EFI_SYSTEM_TABLE_POINTER) - len(buf1)), crc32_value)
+ if crc32_value == system_table_pointer.Crc32:
+ break
+ system_table_pointer = None
+ current_addr = current_addr + alignment
+ return system_table_pointer
+
@ classmethod
def read_efi_config_table(cls, table_cnt, table_ptr, ctype_read):
'''Create a dictionary of EFI Configuration table entries'''
|