summaryrefslogtreecommitdiff
path: root/usr/src/tools/onbld/Checks/Mapfile.py
diff options
context:
space:
mode:
authorAli Bahrami <Ali.Bahrami@Oracle.COM>2010-06-24 18:16:42 -0600
committerAli Bahrami <Ali.Bahrami@Oracle.COM>2010-06-24 18:16:42 -0600
commitcd3e933325e68e23516a196a8fea7f49b1e497c3 (patch)
treeb3d6fcc31c1e7dc60bd48d34239721e8a8b68cfe /usr/src/tools/onbld/Checks/Mapfile.py
parentf6f041a26ccdc2172df744c7a891423cabe01265 (diff)
downloadillumos-gate-cd3e933325e68e23516a196a8fea7f49b1e497c3.tar.gz
6916796 OSnet mapfiles should use version 2 link-editor syntax
--HG-- rename : usr/src/cmd/sgs/libelf/common/mapfile-common => usr/src/cmd/sgs/libelf/common/mapfile-vers rename : usr/src/cmd/sgs/link_audit/i386/mapfile-vers-bindings => usr/src/cmd/sgs/link_audit/common/mapfile-vers-bindings rename : usr/src/cmd/sgs/link_audit/i386/mapfile-vers-perfcnt => usr/src/cmd/sgs/link_audit/common/mapfile-vers-perfcnt rename : usr/src/cmd/sgs/link_audit/i386/mapfile-vers-symbindrep => usr/src/cmd/sgs/link_audit/common/mapfile-vers-symbindrep rename : usr/src/cmd/sgs/link_audit/i386/mapfile-vers-truss => usr/src/cmd/sgs/link_audit/common/mapfile-vers-truss rename : usr/src/cmd/sgs/link_audit/i386/mapfile-vers-who => usr/src/cmd/sgs/link_audit/common/mapfile-vers-who rename : usr/src/common/mapfiles/i386/map.noexdata => usr/src/common/mapfiles/common/map.noexdata rename : usr/src/lib/libaio/sparc/mapfile-vers => usr/src/lib/libaio/common/mapfile-vers rename : usr/src/lib/libelfsign/common/mapfile.map => usr/src/lib/libelfsign/common/mapfile-vers rename : usr/src/lib/libpthread/sparc/mapfile-vers => usr/src/lib/libpthread/common/mapfile-vers rename : usr/src/lib/librt/amd64/mapfile-vers => usr/src/lib/librt/common/mapfile-vers rename : usr/src/lib/libsys/sparc/mapfile-vers => usr/src/lib/libsys/common/mapfile-vers rename : usr/src/lib/libthread/sparc/mapfile-vers => usr/src/lib/libthread/common/mapfile-vers
Diffstat (limited to 'usr/src/tools/onbld/Checks/Mapfile.py')
-rw-r--r--usr/src/tools/onbld/Checks/Mapfile.py55
1 files changed, 50 insertions, 5 deletions
diff --git a/usr/src/tools/onbld/Checks/Mapfile.py b/usr/src/tools/onbld/Checks/Mapfile.py
index a215e674bf..2a8cb74aed 100644
--- a/usr/src/tools/onbld/Checks/Mapfile.py
+++ b/usr/src/tools/onbld/Checks/Mapfile.py
@@ -21,8 +21,7 @@
#
#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
@@ -39,10 +38,56 @@ You should not be making modifications here until you've read the most current
copy of that file. If you need help, contact a gatekeeper for guidance.
'''
-import sys, CmtBlk
+import re, sys, CmtBlk
MAPFILE = MAPFILE.splitlines()[1:] # Don't include initial \n
def mapfilechk(fh, filename=None, verbose=False, output=sys.stderr):
- return CmtBlk.cmtblkchk(fh, 'MAPFILE', MAPFILE, filename=filename,
- verbose=verbose, output=output)
+ if filename:
+ name = filename
+ else:
+ name = fh.name
+
+ # Verify that the mapfile is using version 2 syntax. Read and discard
+ # comment and empty lines until the first non-empty line is seen.
+ # This line must be '$mapfile_version 2'.
+ CmtRE = re.compile(r'#.*$')
+ LeadingWSRE = re.compile(r'^\s+')
+ VersionRE = re.compile(r'^\$mapfile_version\s+2\s*$')
+ for line in fh:
+ line = CmtRE.sub(r'', line)
+ line = LeadingWSRE.sub(r'', line)
+ if line == '' :
+ continue
+
+ # First non=empty line must be version declaration
+ if not VersionRE.match(line):
+ output.write("Warning: mapfile version 2 syntax"
+ " expected in file %s\n" % name)
+ return 1
+
+ # We have verified version 2 syntax. Exit the loop
+ break
+
+
+ # If the mapfile contains a SYMBOL_VERSION directive, the file
+ # must include a copy of the MAPFILE warning comment above. The
+ # comment is specific to symbol versioning, so we don't harrass
+ # the authors of mapfiles used exclusively for other purposes.
+ SymVerRE = re.compile(r'^\s*symbol_version\s+', re.IGNORECASE)
+ for line in fh:
+ # If we find a SYMBOL_VERSION, then verify that the comment
+ # is present. The comment usually precedes the mapfile_version
+ # comment and any mapfile directives (including SYMBOL_VERSION),
+ # so we need to rewind the file. This is more efficient than it
+ # might seem: All of these items are near the top of the file,
+ # so not not many lines are read, and file contents are
+ # bufferred.
+ if SymVerRE.match(line):
+ fh.seek(0);
+ return CmtBlk.cmtblkchk(fh, 'MAPFILE', MAPFILE,
+ filename=filename, verbose=verbose,
+ output=output)
+
+ # Comment is not required.
+ return 0