// create_def_file.js // // Copyright (c) 2009 Sun Microsystems, Inc. // Use is subject to license terms. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
// check that we got proper arguments if (args.length < 2)
{
echo("Usage: create_def_file <X86|X64> [static_library|objectfile|objectdirectory ...] ");
WScript.Quit(1);
}
var is64 = args.Item(0).toLowerCase() == "x64"; var shell = new ActiveXObject("WScript.Shell"); var fso = new ActiveXObject("Scripting.FileSystemObject");
Weuseaparameter/forLib,iftheresulting.deffileisused withlib.exe.
*/ var forLib = false;
OutputSymbols(CollectSymbols());
// takes the array that has been built up and writes out mysqld.def function OutputSymbols(symbols)
{ var out = WScript.StdOut;
out.WriteLine("EXPORTS"); for (var i= 0; i < symbols.length; i++)
out.WriteLine(symbols[i]);
}
function echo(message)
{
WScript.StdErr.WriteLine(message);
}
// Extract global symbol names and type from objects // Returns string array with symbol names function CollectSymbols()
{ var uniqueSymbols = new Object();
var rspfilename = "dumpsymbols.rsp";
CreateResponseFile(rspfilename); var commandline="dumpbin @"+rspfilename;
echo("Executing "+commandline); var oExec = shell.Exec(commandline);
while(!oExec.StdOut.AtEndOfStream)
{ var line = oExec.StdOut.ReadLine(); if (line.indexOf("External") == -1) continue; var columns = line.split(" "); var index = 0; if (columns.length < 3) continue;
/* IfthethirdcolumnofdumpbinoutputcontainsSECTx, thesymbolisdefinedinthatsectionoftheobjectfile. IfUNDEFappears,itisnotdefinedinthatobjectandmust beresolvedelsewhere.BSSsymbols(likeuninitializedarrays) appeartohavenon-zerosecondcolumn.
*/ if (columns[2].substring(0,4)!="SECT")
{ if (columns[2] == "UNDEF" && parseInt(columns[1])==0 ) continue;
}
/* Extractundecoratedsymbolnames between"|"andnextwhitespaceafterit.
*/ for (; index < columns.length; index++) if (columns[index] == "|") break;
var symbol = columns[index + 1]; var firstSpace = symbol.indexOf(" "); if (firstSpace != -1)
symbol = symbol.substring(0, firstSpace-1);
// Don't export compiler defined stuff if (IsCompilerDefinedSymbol(symbol)) continue;
// Correct symbol name for cdecl calling convention on x86
symbol = ScrubSymbol(symbol);
// Check if we have function or data if (line.indexOf("notype () ") == -1)
symbol = symbol + " DATA";
uniqueSymbols[symbol] = 1;
}
fso.DeleteFile(rspfilename); // Sort symbols names var keys=[]; var sorted = {}; for (key in uniqueSymbols)
{ if (uniqueSymbols.hasOwnProperty(key))
{
keys.push(key);
}
}
keys.sort();
return keys;
}
// performs necessary cleanup on the symbol name function ScrubSymbol(symbol)
{ if (is64) return symbol; if (symbol.charAt(0) != "_") return symbol;
if (forLib) return symbol.substring(1, symbol.length);
var atSign = symbol.indexOf("@"); if (atSign != -1)
{ var paramSize = symbol.substring(atSign+1, symbol.Length); if (paramSize.match("[0-9]+$")) return symbol;
} return symbol.substring(1, symbol.length);
}
// returns true if the symbol is compiler defined function IsCompilerDefinedSymbol(symbol)
{ return ((symbol.indexOf("__real@") != -1) ||
(symbol.indexOf("_xmm@") != -1) ||
(symbol.indexOf("_RTC_") != -1) ||
(symbol.indexOf("??_C@_") != -1) ||
(symbol.indexOf("??_R") != -1) ||
(symbol.indexOf("??_7") != -1) ||
(symbol.indexOf("_xmm@7F") != -1) || // VS2012 Win64 special symbol
(symbol.indexOf("?_G") != -1) || // scalar deleting destructor
(symbol.indexOf("_VInfreq_?") != -1) || // special label (exception handler?) for Intel compiler
(symbol.indexOf("?_E") != -1)); // vector deleting destructor
}
// Creates response file for dumpbin function CreateResponseFile(filename)
{ var responseFile = fso.CreateTextFile(filename,true);
responseFile.WriteLine("/SYMBOLS");
var index = 1; for (; index < args.length; index++)
{ var param = args.Item(index); if (param == "/forLib")
forLib = true; else
addToResponseFile(args.Item(index),responseFile);
}
responseFile.Close();
}
// Add object file/library to the dumpbin response file. // If filename parameter is directory, all objects and libs under // this directory or subdirectories are added. function addToResponseFile(filename, responseFile)
{ if (fso.FolderExists(filename))
{ var folder = fso.getFolder(filename); var enumerator = new Enumerator(folder.files); for (; !enumerator.atEnd(); enumerator.moveNext())
{
addToResponseFile(enumerator.item().Path, responseFile);
}
enumerator = new Enumerator(folder.subFolders); for (; !enumerator.atEnd(); enumerator.moveNext())
{
addToResponseFile(enumerator.item().Path, responseFile);
}
} elseif (fso.FileExists(filename))
{ var extension = filename.substr(filename.length -3).toLowerCase(); if(extension == "lib" || extension == "obj")
{
responseFile.WriteLine("\""+fso.GetFile(filename).Path+"\"");
}
} else
{
echo("file " + filename + " not found. Can't generate symbols file");
WScript.Quit (1);
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.