improve the mergedlib script

by copying the improvements from the normal find-can-be-private
script.

Change-Id: I3cb23022ca33d3008af962fa99b5b0907fe753b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166783
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2024-04-27 20:36:24 +02:00
parent 826e7e79f3
commit 32d7935b3d
5 changed files with 17020 additions and 331 deletions

View file

@ -23,18 +23,8 @@ exported_symbols1 = set()
imported_symbols1 = set() imported_symbols1 = set()
exported_symbols2 = set() # decoded exported_symbols2 = set() # decoded
imported_symbols2 = set() # decoded imported_symbols2 = set() # decoded
# all names that exist in the source code
#all_source_names = set()
#subprocess_find_all_source_names = subprocess.Popen("git grep -oh -P '\\b\\w\\w\\w+\\b' -- '*.h*' | sort -u",
# stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
#with subprocess_find_all_source_names.stdout as txt:
# for line in txt:
# line = line.strip()
# all_source_names.add(line)
#subprocess_find_all_source_names.terminate()
# find all our shared libs # find all our shared libs
subprocess_find = subprocess.Popen("find ./instdir -name *.so && find ./workdir/LinkTarget/CppunitTest -name *.so", subprocess_find = subprocess.Popen("find ./instdir -name *.so && find ./workdir/LinkTarget/CppunitTest -name *.so",
stdout=subprocess.PIPE, shell=True) stdout=subprocess.PIPE, shell=True)
@ -88,15 +78,6 @@ with subprocess_find.stdout as txt:
imported_symbols1.add(sym) imported_symbols1.add(sym)
subprocess_find.terminate() subprocess_find.terminate()
#progress = 0;
#for sym in sorted(imported_symbols - exported_symbols):
# progress += 1
# if (progress % 128 == 0): print( str(int(progress * 100 / len(diff))) + "%")
# filtered_sym = subprocess.check_output(["c++filt", sym]).strip().decode("utf-8")
# if filtered_sym.startswith("non-virtual thunk to "): filtered_sym = filtered_sym[21:]
# elif filtered_sym.startswith("virtual thunk to "): filtered_sym = filtered_sym[17:]
# print("Symbol imported but not exported? " + filtered_sym)
# Now we have to symbolize before comparing because sometimes (due to thunks) two # Now we have to symbolize before comparing because sometimes (due to thunks) two
# different encoded names symbolize to the same method/func name # different encoded names symbolize to the same method/func name
# #
@ -123,11 +104,6 @@ print("exported = " + str(len(exported_symbols2)))
print("imported = " + str(len(imported_symbols2))) print("imported = " + str(len(imported_symbols2)))
print("unused_exports = " + str(len(unused_exports))) print("unused_exports = " + str(len(unused_exports)))
#def extractFunctionNameFromSignature(sym):
# i = sym.find("(")
# if i == -1: return sym
# return sym[:i]
# for each class, count how many symbols will become hidden if we mark the class as hidden # for each class, count how many symbols will become hidden if we mark the class as hidden
can_be_hidden_count = dict() can_be_hidden_count = dict()
for sym in exported_symbols2: for sym in exported_symbols2:

View file

@ -0,0 +1,250 @@
118 SkCanvas
108 GraphicsRenderTests
97 SdrTextObj
90 SkPath
71 ScDocument
70 lucene::index::IndexWriter
67 StyleSettings
67 SkMatrix
66 QtFrame
64 sdr::table::SdrTableObj
61 vcl::Window
61 SvtSearchOptions
57 SvxRuler
49 lucene::queryParser::QueryParser
49 SdrObjCustomShape
46 E3dScene
44 GrDirectContext
43 SmDocShell
43 SdrPathObj
41 SfxObjectShell
38 ToolBox
38 SvxEditEngineForwarder
38 SfxMedium
37 VCLXMenu
36 StatusBar
36 SkTypeface
35 SkBitmap
35 ListBox
34 SvxShape
34 SkNWayCanvas
34 SdrObject
34 SdrObjGroup
34 Menu
33 XMLTextImportHelper
33 ThumbnailView
33 SkPathBuilder
33 SdrPaintView
32 lucene::queryParser::QueryParserTokenManager
32 framework::Desktop
32 SkString
31 lucene::util::Misc
31 SplitWindow
31 SkRegion
31 SdrObjEditView
31 ComboBox
30 SvXMLImport
30 SdrRectObj
30 SdrOle2Obj
29 lucene::util::StringBuffer
29 SdrModel
27 lucene::index::MultiReader
27 libepubgen::EPUBTextGenerator
27 SvxRTFParser
27 E3dObject
27 BrowseBox
26 svx::FrameSelector
26 lucene::index::IndexReader
26 lucene::document::Field
26 lucene::analysis::Token
26 connectivity::file::OPreparedStatement
26 SkiaSalBitmap
25 lucene::store::FSDirectory
25 StarBASIC
25 SkFont
24 sfx2::sidebar::SidebarController
24 comphelper::BackupFileHelper
24 SkPaintFilterCanvas
23 oox::drawingml::Color
23 SkTDStorage
23 SkPaint
23 SkMemoryStream
23 SkColorSpace
23 Application
22 SwXTextTableCursor
22 Hunspell
21 lucene::index::IndexModifier
21 formula::FormulaCompiler
21 SvxRectCtl
21 SvxMSDffManager
21 SvNumberformat
21 SkImage
21 SdrPageView
20 sdr::contact::ObjectContact
20 SkiaSalGraphicsImpl
20 SkPathRef
19 vcl::PDFExtOutDevData
19 lucene::analysis::PorterStemmer
19 SkSurface
19 SkOverdrawCanvas
19 LocaleDataWrapper
19 EditEngine
18 svx::frame::Array
18 ooo::vba::UserFormGeometryHelper
18 lucene::search::BooleanQuery
18 SvxUnoTextRangeBase
18 SvxPixelCtl
18 SkM44
18 SkGraphics
18 SkData
18 SfxViewFrame
18 SfxTemplateManagerDlg
18 SfxApplication
18 SbxVariable
18 SbxValue
18 OutputDevice
18 Dialog
17 tools::Polygon
17 connectivity::ODatabaseMetaDataResultSet
17 SkRRect
17 SkPicture
17 SfxUndoManager
16 sdr::properties::DefaultProperties
16 connectivity::file::OStatement_Base
16 SkImages
16 Formatter
15 utl::TempFileFastService
15 sdr::SelectionController
15 oox::drawingml::Shape
15 lucene::util::ScorerDocQueue
15 lucene::search::Explanation
15 dbtools::DatabaseMetaData
15 connectivity::sdbcx::OKey
15 basegfx::B3DPolygon
15 TextView
15 SvtPathOptions
15 SkFILEStream
15 SbxObject
15 GrBackendFormat
15 Control
14 sfx2::sidebar::Panel
14 lucene::store::RAMDirectory
14 lucene::queryParser::legacy::QueryParserBase
14 drawinglayer::geometry::ViewInformation2D
14 SkPixmap
14 SkImageInfo
14 SkDynamicMemoryWStream
14 SfxInterface
14 SdrSnapView
14 Ruler
14 LanguageTag
14 GrBackendRenderTarget
14 FmSearchEngine
14 FmFormShell
14 BasicManager
13 svx::DialControl
13 lucene::index::MultipleTermPositions
13 lucene::index::LogMergePolicy
13 lucene::index::FieldInfos
13 connectivity::sdbcx::OGroup
13 basegfx::B3DPolyPolygon
13 avmedia::MediaWindow
13 Wallpaper
13 TextEngine
13 TabBar
13 SvxBmpMask
13 SkTextBlobBuilder
13 SkCodec
13 SfxViewShell
13 SfxClassificationHelper
13 SdrPage
13 QtInstance
13 MyThes
13 ImplJobSetup
13 CodeCompleteOptions
12 vcl::PDFWriter
12 sdr::properties::BaseProperties
12 lucene::store::RAMOutputStream
12 lucene::store::RAMInputStream
12 lucene::store::IndexInput
12 lucene::search::spans::SpanNearQuery
12 connectivity::OSQLParseTreeIterator
12 SwMailMergeConfigItem
12 SvxZoomSliderControl
12 SvxShapeText
12 SvxSearchCharSet
12 SvxAutoCorrectLanguageLists
12 SkPixelRef
12 SkOrderedFontMgr
12 SkFontMgr
12 SkColorInfo
12 SkColorFilters
12 SfxRequest
12 SfxListUndoAction
12 SdrVirtObj
12 SbxArray
12 PaletteManager
12 HeaderBar
12 GrBackendTexture
12 GalleryTheme
12 GDIMetaFile
11 vcl::PrinterController
11 sfx2::sidebar::Theme
11 sdr::table::SvxTableController
11 oox::shape::ShapeContextHandler
11 lucene::store::BufferedIndexInput
11 lucene::search::SortField
11 lucene::search::PhraseQuery
11 lucene::index::Payload
11 drawinglayer::attribute::Sdr3DObjectAttribute
11 drawinglayer::attribute::FontAttribute
11 VirtualDevice
11 SwXDocumentSettings
11 SvxUnoTextField
11 SvXMLNumFormatContext
11 SvXMLExport
11 SkParse
11 SkAndroidCodec
11 Sk3DView
11 SfxFrame
11 SfxDispatcher
11 SdrUnoObj
11 SdrText
11 SdrPageObj
11 ScRangePairList
11 GrContext_Base
11 CompressGraphicsDialog
11 CalendarWrapper
10 sdr::overlay::OverlayManager
10 oox::shape::ShapeFilterBase
10 lucene::util::AStringReader
10 lucene::store::RAMFile
10 lucene::search::spans::SpanOrQuery
10 lucene::search::Sort
10 lucene::search::RangeQuery
10 lucene::search::FuzzyTermEnum
10 lucene::index::DirectoryIndexReader
10 XMLTextParagraphExport
10 Writer
10 VCLXWindow
10 SystemWindow
10 SwUserField
10 SvxNumberFormatShell
10 SvXMLNamespaceMap
10 SkWStream
10 SkUTF
10 SkTextBlob
10 SkRuntimeEffect
10 SkDrawable
10 SfxItemPool
10 ScViewUtil
10 ScRangeList
10 SbxDimArray
10 SbxBase
10 Help
10 FormatterBase
10 E3dView
10 E3dCompoundObject
10 DffPropertyReader
10 DdeService
10 ColorWindow

File diff suppressed because it is too large Load diff

View file

@ -1,251 +0,0 @@
BitmapColorQuantizationFilter
BitmapConvolutionMatrixFilter
BitmapEmbossGreyFilter
BitmapMedianFilter
BitmapMosaicFilter
BitmapPopArtFilter
BitmapSepiaFilter
BitmapSharpenFilter
BitmapSmoothenFilter
BitmapSobelGreyFilter
BitmapSolarizeFilter
CalendarField
CodeCompleteOptions
DdeGetPutItem
DdeHotLink
DdeItem
DdeLink
DdeService
DdeTopic
DialogGalleryPreview
DockingManager
DropdownDockingWindow
E3dCompoundObject
E3dExtrudeObj
E3dPolygonObj
EditUndo
EnhancedCustomShape
FileExportedDialog
FixedBitmap
FixedImage
FmSearchEngine
FocusListenerMultiplexer
FontStyleBox
FontSubsetInfo
FormatterBase
GalleryProgress
HelpIndexer
HelpLinker
HelpSearch
Hunspell
Hunzip
ImplJobSetup
IndexerPreProcessor
InputDialog
KeyListenerMultiplexer
MetaAction
MetaArcAction
MetaBmpExScalePartAction
MetaBmpScalePartAction
MetaChordAction
MetaPieAction
MetaPolyLineAction
MetaPolyPolygonAction
MetaPolygonAction
MetaTextArrayAction
MetaWallpaperAction
MetricFormatter
MouseListenerMultiplexer
MouseMotionListenerMultiplexer
MyThes
NotifyBrokenPackage
NotifyEvent
OpenCLConfig
OpenGLZone
PaintListenerMultiplexer
RequestPackageReparation
SEInitializerGpg
SalData
SalInfoPrinter
SalPrinter
SalSystem
SbMethod
SbxObject
SdrCaptionEscIsRelItem
SdrCaptionEscRelItem
SdrCaptionFitLineLenItem
SdrCaptionLineLenItem
SdrGrafContrastItem
SdrGrafGamma100Item
SdrGrafLuminanceItem
SdrGrafModeItem
SdrMeasureBelowRefEdgeItem
SdrMeasureDecimalPlacesItem
SdrMeasureTextHPosItem
SdrMeasureTextRota90Item
SdrMeasureTextVPosItem
SdrMeasureUnitItem
SdrPercentItem
SelectionListenerMultiplexer
SfxCharmapContainer
SfxCommonPrintOptionsTabPage
SfxHyphenRegionItem
SfxMacroInfoItem
SfxStatusForwarder
SfxTabDialogItem
SkiaZone
SpinListenerMultiplexer
SvFileInformationManager
SvtDefaultOptions
SvtDynamicMenuOptions
SvtGraphicFill
SvtGraphicFill::Transform
SvtGraphicStroke
SvxAttrNameTable
SvxAutoCorrectLanguageLists
SvxAutocorrWordList
SvxBmpNumValueSet
SvxDicListChgClamp
SvxGraphicItem
SvxLineEndLB
SvxLineLB
SvxNumValueSet
SvxNumberFormatShell
SvxPixelCtl
SvxPresetListBox
SvxRectCtl
SvxShapeGroupAnyD
SvxShowText
SvxTPage
SvxTextForwarder
SvxXConnectionPreview
SvxXLinePreview
SvxXMeasurePreview
SvxXRectPreview
SvxXShadowPreview
SyntaxHighlighter::Tokenizer
SystemWindow::ImplData
TBCExtraInfo
TBCGeneralInfo
TabPaneValue
TextListenerMultiplexer
VclBuilder::MenuAndId
VclBuilder::ParserState
VclBuilder::sortIntoBestTabTraversalOrder
VclDrawingArea
VclGrid
VclTestResult
WindowListenerMultiplexer
XBitmapEntry
XColorEntry
XFillAttrSetItem
XFillUseSlideBackgroundItem
XLineAttrSetItem
XMLDocumentWrapper_XmlSecImpl
XMLSignature_GpgImpl
basegfx::BColorModifier
basegfx::SystemDependentData
basegfx::SystemDependentDataHolder
basegfx::SystemDependentDataManager
basic::vba
canvas
canvas::CachedPrimitiveBase
canvas::CanvasCustomSpriteHelper
canvas::ParametricPolyPolygon
canvas::PropertySetHelper
canvas::SpriteRedrawManager
chart
comphelper::MemoryInputStream
comphelper::OMultiTypeInterfaceContainerHelper2
comphelper::OSLOutputStreamWrapper
comphelper::RefCountedMutex
comphelper::SimplePasswordRequest
comphelper::UnoInterfaceToUniqueIdentifierMapper
comphelper::date
comphelper::xmlsec
connectivity::OKeyValue
connectivity::OSkipDeletedSet
connectivity::OSortIndex
connectivity::QuotedTokenizedString
connectivity::file::OBoolOperator
connectivity::file::OOp_ISNOTNULL
connectivity::file::OOp_ISNULL
connectivity::file::OOp_LIKE
connectivity::odbc::ODBCDriver
connectivity::odbc::OStatement_BASE2
connectivity::odbc::OTools
connectivity::sdbcx::IObjectCollection
connectivity::sdbcx::ODescriptor
connectivity::sdbcx::OGroup
connectivity::sdbcx::OKey
connectivity::sdbcx::OUser
dbtools::param::ParameterWrapper
drawinglayer::animation::AnimationEntry
drawinglayer::primitive2d::AnimatedSwitchPrimitive2D
drawinglayer::primitive2d::FillGraphicPrimitive2D
drawinglayer::primitive2d::ObjectAndViewTransformationDependentPrimitive2D
drawinglayer::primitive2d::SdrFrameBorderData::SdrConnectStyleData
drawinglayer::primitive2d::ViewTransformationDependentPrimitive2D
drawinglayer::primitive3d
drawinglayer::primitive3d::BasePrimitive3D
drawinglayer::primitive3d::BufferedDecompositionPrimitive3D
drawinglayer::primitive3d::GroupPrimitive3D
drawinglayer::primitive3d::PolyPolygonMaterialPrimitive3D
drawinglayer::primitive3d::PolygonHairlinePrimitive3D
drawinglayer::primitive3d::SdrPrimitive3D
drawinglayer::processor2d::TextExtractor2D
formula::FormulaTokenIterator::Item
framework::DocumentUndoGuard
legacy::CntInt32
legacy::SfxBool
ooo::vba::ConcreteXShapeGeometryAttributes
ooo::vba::UserFormGeometryHelper
oox::GrabBagStack
oox::IProgressBar
oox::ModelObjectHelper
oox::ObjectContainer
oox::core::FastTokenHandler
oox::core::FilterDetect
oox::drawingml::ShapePropertyInfo
oox::drawingml::ShapePropertyMap
oox::drawingml::Theme
oox::drawingml::ThemeFilterBase
oox::formulaimport::XmlStreamBuilder
oox::ole
oox::ole::AxControlModelBase
oox::shape::ShapeContextHandler
oox::shape::ShapeFilterBase
oox::vml::FillModel
oox::vml::ShadowModel
openclwrapper::GPUEnv
sdr::SelectionController
sfx2::sidebar::Context
sfx2::sidebar::ResourceManager
svt
svt::BindableControlHelper
svtools::EditableExtendedColorConfig
svx::FrameSelector
svxform
svxform::FmSearchConfigItem
svxform::FmSearchParams
toolkitform
ucbhelper::AuthenticationFallbackRequest
ucbhelper::InteractionApprove
ucbhelper::InteractionAuthFallback
ucbhelper::InteractionDisapprove
ucbhelper::InteractionSupplyAuthentication
ucbhelper::InterceptedInteraction
ucbhelper::ResultSetMetaData
ucbhelper::SimpleCertificateValidationRequest
utl::DefaultFontConfiguration
utl::TempFileFastService
utl::ZipPackageHelper
utl::detail::Options
vcl::ExtOutDevData
vcl::ILibreOfficeKitNotifier
vcl::PDFOutputStream
vcl::PDFWriter
vcl::PrinterController
weld::HexColorControl
writerperfect::DirectoryStream::Impl
xmloff::AnimationsExporter

View file

@ -9,82 +9,207 @@ import subprocess
import re import re
import multiprocessing import multiprocessing
exported_symbols = set() exported_symbols1 = set()
imported_symbols = set() imported_symbols1 = set()
exported_symbols2 = set() # decoded
imported_symbols2 = set() # decoded
# look for symbols exported by libmerged # find all our shared libs, note that all the libs that have been merged into the mergedlib library will
subprocess_nm = subprocess.Popen("nm -D instdir/program/libmergedlo.so", stdout=subprocess.PIPE, shell=True) # not contain anything, those files are just empty
with subprocess_nm.stdout as txt: subprocess_find = subprocess.Popen("find ./instdir -name *.so && find ./workdir/LinkTarget/CppunitTest -name *.so",
# We are looking for lines something like: stdout=subprocess.PIPE, shell=True)
# 0000000000036ed0 T flash_component_getFactory
line_regex = re.compile(r'^[0-9a-fA-F]+ T ')
for line in txt:
line = line.strip().decode("utf-8")
if line_regex.match(line):
exported_symbols.add(line.split(" ")[2])
subprocess_nm.terminate()
# look for symbols imported from libmerged
subprocess_find = subprocess.Popen("(find instdir/program/ -type f; ls ./workdir/LinkTarget/CppunitTest/*.so) | xargs grep -l mergedlo",
stdout=subprocess.PIPE, shell=True)
with subprocess_find.stdout as txt: with subprocess_find.stdout as txt:
for line in txt: for line in txt:
sharedlib = line.strip().decode("utf-8") sharedlib = line.strip()
s = sharedlib[sharedlib.find("/lib") + 4 : len(sharedlib) - 3] # look for exported symbols
subprocess_nm = subprocess.Popen(b"nm -D " + sharedlib, stdout=subprocess.PIPE, shell=True)
with subprocess_nm.stdout as txt2:
# We are looking for lines something like:
# 0000000000036ed0 T flash_component_getFactory
line_regex = re.compile(r'^[0-9a-fA-F]+ T ')
for line2_bytes in txt2:
line2 = line2_bytes.strip().decode("utf-8")
if line_regex.match(line2):
sym = line2.split(" ")[2].strip()
exported_symbols1.add(sym)
subprocess_nm.terminate()
# look for imported symbols # look for imported symbols
subprocess_objdump = subprocess.Popen("objdump -T " + sharedlib, stdout=subprocess.PIPE, shell=True) subprocess_objdump = subprocess.Popen(b"objdump -T " + sharedlib, stdout=subprocess.PIPE, shell=True)
with subprocess_objdump.stdout as txt2: with subprocess_objdump.stdout as txt2:
# ignore some header bumpf # ignore some header bumpf
txt2.readline() txt2.readline()
txt2.readline() txt2.readline()
txt2.readline() txt2.readline()
txt2.readline() txt2.readline()
# We are looking for lines something like (noting that one of them uses spaces, and the other tabs) # We are looking for lines something like:
# 0000000000000000 DF *UND* 0000000000000000 _ZN16FilterConfigItem10WriteInt32ERKN3rtl8OUStringEi # 0000000000000000 DF *UND* 0000000000000000 _ZN16FilterConfigItem10WriteInt32ERKN3rtl8OUStringEi
for line2 in txt2: for line2_bytes in txt2:
line2 = line2.strip().decode("utf-8") line2 = line2_bytes.strip().decode("utf-8")
if line2.find("*UND*") == -1: continue if "*UND*" not in line2: continue
tokens = line2.split(" ") tokens = line2.split(" ")
sym = tokens[len(tokens)-1].strip() sym = tokens[len(tokens)-1].strip()
imported_symbols.add(sym) imported_symbols1.add(sym)
subprocess_objdump.terminate() subprocess_objdump.terminate()
subprocess_find.terminate() subprocess_find.terminate()
intersec_symbols = exported_symbols.intersection(imported_symbols) # look for imported symbols in executables
print("no symbols exported from libmerged = " + str(len(exported_symbols))) subprocess_find = subprocess.Popen("find ./instdir -name *.bin", stdout=subprocess.PIPE, shell=True)
print("no symbols that can be made internal = " + str(len(intersec_symbols))) with subprocess_find.stdout as txt:
for line in txt:
executable = line.strip()
# look for exported symbols
subprocess_nm = subprocess.Popen(b"nm -D " + executable + b" | grep -w U", stdout=subprocess.PIPE, shell=True)
with subprocess_nm.stdout as txt2:
# We are looking for lines something like:
# U sal_detail_deinitialize
for line2_bytes in txt2:
line2 = line2_bytes.strip().decode("utf-8")
sym = line2.split(" ")[1]
imported_symbols1.add(sym)
subprocess_find.terminate()
# Now look for classes where none of the class symbols are imported, # Now we have to symbolize before comparing because sometimes (due to thunks) two
# i.e. we can mark the whole class as hidden # different encoded names symbolize to the same method/func name
#
def extract_class(sym): progress = 0
progress_max_len = len(imported_symbols1) + len(exported_symbols1)
for sym in imported_symbols1:
progress += 1
if (progress % 128 == 0): print( str(int(progress * 100 / progress_max_len)) + "%")
filtered_sym = subprocess.check_output(["c++filt", sym]).strip().decode("utf-8") filtered_sym = subprocess.check_output(["c++filt", sym]).strip().decode("utf-8")
if filtered_sym.startswith("vtable for "): if filtered_sym.startswith("non-virtual thunk to "): filtered_sym = filtered_sym[21:]
classname = filtered_sym[11:] elif filtered_sym.startswith("virtual thunk to "): filtered_sym = filtered_sym[17:]
return classname imported_symbols2.add(filtered_sym)
if filtered_sym.startswith("non-virtual thunk to "): progress = 0
filtered_sym = filtered_sym[21:] for sym in exported_symbols1:
elif filtered_sym.startswith("virtual thunk to "): progress += 1
filtered_sym = filtered_sym[17:] if (progress % 128 == 0): print( str(int(progress * 100 / progress_max_len)) + "%")
i = filtered_sym.find("(") filtered_sym = subprocess.check_output(["c++filt", sym]).strip().decode("utf-8")
if i != -1: if filtered_sym.startswith("non-virtual thunk to "): filtered_sym = filtered_sym[21:]
i = filtered_sym.rfind("::", 0, i) elif filtered_sym.startswith("virtual thunk to "): filtered_sym = filtered_sym[17:]
if i != -1: exported_symbols2.add(filtered_sym)
classname = filtered_sym[:i]
return classname
return ""
pool = multiprocessing.Pool(multiprocessing.cpu_count())
classes_with_exported_symbols = set(pool.map(extract_class, list(exported_symbols)))
classes_with_imported_symbols = set(pool.map(extract_class, list(imported_symbols)))
# Some stuff is particular to Windows, so won't be found by a Linux analysis, so remove unused_exports = exported_symbols2 - imported_symbols2
# those classes. print("exported = " + str(len(exported_symbols2)))
can_be_private_classes = classes_with_exported_symbols - classes_with_imported_symbols; print("imported = " + str(len(imported_symbols2)))
can_be_private_classes.discard("SpinField") print("unused_exports = " + str(len(unused_exports)))
with open("bin/find-mergedlib-can-be-private.classes.results", "wt") as f: # for each class, count how many symbols will become hidden if we mark the class as hidden
for sym in sorted(can_be_private_classes): can_be_hidden_count = dict()
if sym.startswith("std::") or sym.startswith("void std::"): continue for sym in exported_symbols2:
i = sym.rfind("::")
if i == -1: continue
clz = sym[:i]
if clz in can_be_hidden_count:
can_be_hidden_count[clz] = can_be_hidden_count[clz] + 1
else:
can_be_hidden_count[clz] = 1
for sym in imported_symbols2:
i = sym.rfind("::")
if i == -1: continue
clz = sym[:i]
if clz in can_be_hidden_count:
can_be_hidden_count[clz] = can_be_hidden_count[clz] - 1
else:
can_be_hidden_count[clz] = -1
# convert to list, and sort the results in descending order
can_be_hidden_list = list()
for clz in can_be_hidden_count:
cnt = can_be_hidden_count[clz]
if cnt > 0:
can_be_hidden_list.append((cnt, clz))
can_be_hidden_list.sort(reverse=True)
with open("bin/find-mergedlib-can-be-private-symbols.classes.results", "wt") as f:
for i in can_be_hidden_list:
if i[0] < 10: break
f.write(str(i[0]) + " " + i[1] + "\n")
with open("bin/find-mergedlib-can-be-private-symbols.functions.results", "wt") as f:
for sym in sorted(unused_exports):
# Filter out most of the noise.
# No idea where these are coming from, but not our code.
if sym.startswith("CERT_"): continue
elif sym.startswith("DER_"): continue
elif sym.startswith("FORM_"): continue
elif sym.startswith("FPDF"): continue
elif sym.startswith("HASH_"): continue
elif sym.startswith("Hunspell_"): continue
elif sym.startswith("LL_"): continue
elif sym.startswith("LP_"): continue
elif sym.startswith("LU"): continue
elif sym.startswith("MIP"): continue
elif sym.startswith("MPS"): continue
elif sym.startswith("NSS"): continue
elif sym.startswith("NSC_"): continue
elif sym.startswith("PK11"): continue
elif sym.startswith("PL_"): continue
elif sym.startswith("PQ"): continue
elif sym.startswith("PBE_"): continue
elif sym.startswith("PORT_"): continue
elif sym.startswith("PRP_"): continue
elif sym.startswith("PR_"): continue
elif sym.startswith("PT_"): continue
elif sym.startswith("QS_"): continue
elif sym.startswith("REPORT_"): continue
elif sym.startswith("RSA_"): continue
elif sym.startswith("SEC"): continue
elif sym.startswith("SGN"): continue
elif sym.startswith("SOS"): continue
elif sym.startswith("SSL_"): continue
elif sym.startswith("VFY_"): continue
elif sym.startswith("_PR_"): continue
elif sym.startswith("ber_"): continue
elif sym.startswith("bfp_"): continue
elif sym.startswith("ldap_"): continue
elif sym.startswith("ne_"): continue
elif sym.startswith("opj_"): continue
elif sym.startswith("pg_"): continue
elif sym.startswith("pq"): continue
elif sym.startswith("presolve_"): continue
elif sym.startswith("sqlite3_"): continue
elif sym.startswith("libepubgen::"): continue
elif sym.startswith("lucene::"): continue
elif sym.startswith("Hunspell::"): continue
elif sym.startswith("sk_"): continue
elif sym.startswith("_Z"): continue
# dynamically loaded
elif sym.endswith("get_implementation"): continue
elif sym.endswith("component_getFactory"): continue
elif sym == "CreateUnoWrapper": continue
elif sym == "ExportDOC": continue
elif sym == "ExportRTF": continue
elif sym == "GetSaveWarningOfMSVBAStorage_ww8": continue
elif sym == "GetSpecialCharsForEdit": continue
elif sym.startswith("Import"): continue
elif sym.startswith("Java_com_sun_star_"): continue
elif sym.startswith("TestImport"): continue
elif sym.startswith("getAllCalendars_"): continue
elif sym.startswith("getAllCurrencies_"): continue
elif sym.startswith("getAllFormats"): continue
elif sym.startswith("getBreakIteratorRules_"): continue
elif sym.startswith("getCollationOptions_"): continue
elif sym.startswith("getCollatorImplementation_"): continue
elif sym.startswith("getContinuousNumberingLevels_"): continue
elif sym.startswith("getDateAcceptancePatterns_"): continue
elif sym.startswith("getForbiddenCharacters_"): continue
elif sym.startswith("getIndexAlgorithm_"): continue
elif sym.startswith("getLCInfo_"): continue
elif sym.startswith("getLocaleItem_"): continue
elif sym.startswith("getOutlineNumberingLevels_"): continue
elif sym.startswith("getReservedWords_"): continue
elif sym.startswith("getSTC_"): continue
elif sym.startswith("getSearchOptions_"): continue
elif sym.startswith("getTransliterations_"): continue
elif sym.startswith("getUnicodeScripts_"): continue
elif sym.startswith("lok_"): continue
# UDK API
elif sym.startswith("osl_"): continue
elif sym.startswith("rtl_"): continue
elif sym.startswith("typelib_"): continue
elif sym.startswith("typereg_"): continue
elif sym.startswith("uno_"): continue
f.write(sym + "\n") f.write(sym + "\n")