Improvements to CL parser

dev/git-series/gccdum
Matt Godbolt 7 years ago
parent 31ab052d85
commit 610d646866

@ -0,0 +1,237 @@
// Copyright (c) 2012-2016, Matt Godbolt
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
var _ = require('underscore-node');
var sourceTag = /^;\s*([0-9]+)\s*:/;
var ignoreAll = /^\s*include listing\.inc$/;
var fileFind = /^; File\s+(.*)$/;
var gccExplorerDir = /\\gcc-explorer-compiler/; // has to match part of the path in compile.js (ugly)
// Parse into:
// * optional leading whitespace
// * middle part
// * comment part
var parseRe = /^(\s*)([^;]*)(;.*)*$/;
var isProc = /.*PROC$/;
var isEndp = /.*ENDP$/;
var constDef = /^([a-zA-Z_$@][a-zA-Z_$@0-9.]*)\s*=.*$/;
var labelFind = /[.a-zA-Z_@$][a-zA-Z_$@0-9.]*/g;
var labelDef = /^(.*):$/;
// Anything identifier-looking with a "@@" in the middle, and a comment at the end
// is treated as a mangled name. The comment will be used to replace the identifier.
var mangledIdentifier = /\?[^ ]+@@[^ ]+/;
var commentedLine = /([^;]+);\s*(.*)/;
var numberRe = /^\s+(([0-9a-f]+\b\s*)([0-9a-f][0-9a-f]\b\s*)*)(.*)/;
function debug() {
// console.log.apply(console, arguments);
}
var tabsRe = /\t/g;
function expandTabs(line) { // TODO dedupe
var extraChars = 0;
return line.replace(tabsRe, function (match, offset) {
var total = offset + extraChars;
var spacesNeeded = (total + 8) & 7;
extraChars += spacesNeeded - 1;
return " ".substr(spacesNeeded);
});
}
function demangle(line) {
var match, comment;
if (!(match = line.match(mangledIdentifier))) return line;
if (!(comment = line.match(commentedLine))) return line;
return comment[1].trimRight().replace(match[0], comment[2]);
}
function AddrOpcoder() {
var self = this;
this.opcodes = [];
this.offset = null;
var prevOffset = -1;
var prevOpcodes = [];
this.hasOpcodes = function () {
return self.offset !== null;
};
this.onLine = function (line) {
var match = line.match(numberRe);
self.opcodes = [];
self.offset = null;
if (!match) {
prevOffset = -1;
return line;
}
var restOfLine = match[4];
var numbers = match[1].split(/\s+/).filter(function (x) {
return x;
}).map(function (x) {
return parseInt(x, 16);
});
// If restOfLine is empty, we should accumulate offset opcodes...
if (restOfLine === "") {
if (prevOffset < 0) {
// First in a batch of opcodes, so first is the offset
prevOffset = numbers[0];
prevOpcodes = numbers.splice(1);
} else {
prevOpcodes = prevOpcodes.concat(numbers);
}
} else {
if (prevOffset >= 0) {
// we had something from a prior line
self.offset = prevOffset;
self.opcodes = prevOpcodes.concat(numbers);
prevOffset = -1;
} else {
self.offset = numbers[0];
self.opcodes = numbers.splice(1);
}
}
return " " + restOfLine;
};
}
function ClParser(filters) {
this.filters = filters;
this.opcoder = new AddrOpcoder();
this.result = [];
this.inMain = false;
this.source = null;
this.labels = {};
this.currentLabel = null;
debug("############################");
}
ClParser.prototype._add = function (obj) {
var lastWasEmpty = this.result.length === 0 || this.result[this.result.length - 1].text === "";
if (obj.text === "" && lastWasEmpty) return;
if (this.currentLabel) obj.label = this.currentLabel;
obj.text = expandTabs(obj.text); // TODO where best?
if (this.filters.binary && this.opcoder.hasOpcodes()) {
obj.opcodes = this.opcoder.opcodes;
obj.address = this.opcoder.offset;
}
this.result.push(obj);
debug(obj);
};
ClParser.prototype.addLine = function (line) {
if (!!line.match(ignoreAll)) return;
line = this.opcoder.onLine(line);
if (line.trim() === "") {
this._add({keep: true, text: "", source: null});
return;
}
var match;
if (!!(match = line.match(fileFind))) {
this.inMain = !!match[1].match(gccExplorerDir);
return;
}
if (!!(match = line.match(sourceTag))) {
if (this.inMain)
this.source = parseInt(match[1]);
return;
}
line = demangle(line);
match = line.match(parseRe);
if (!match) {
throw new Error("Unable to parse '" + line + "'");
}
var isIndented = match[1] !== "";
var command = match[2];
var comment = match[3] || "";
if (isIndented && this.opcoder.hasOpcodes()) {
this._add({keep: true, text: " " + command + comment, source: this.source});
match = command.match(labelFind);
_.each(match, function (label) {
this.labels[label] = true;
}, this);
} else {
var keep = !this.filters.directives;
if (command.match(isProc))
keep = true;
if (command.match(isEndp)) {
keep = true;
this.source = null;
this.currentLabel = null;
}
var tempDef = false;
if (!!(match = command.match(labelDef))) {
keep = !this.filters.labels;
this.currentLabel = match[1];
debug(match, this.currentLabel);
}
if (!!(match = command.match(constDef))) {
keep = !this.filters.labels;
this.currentLabel = match[1];
debug(match, this.currentLabel);
tempDef = true;
}
this._add({keep: keep, text: command + comment, source: null});
if (tempDef) this.currentLabel = null;
}
};
ClParser.prototype.findUsed = function () {
// TODO: quadratic!
debug("Ooce");
for (var i = 0; i < 100; ++i) {
var changed = false;
_.each(this.labels, function (key, label) {
_.each(this.result, function (obj) {
if (!obj.keep && obj.label == label) {
debug("RESURRECTED", obj);
obj.keep = true;
changed = true;
}
}, this);
}, this);
if (!changed) return;
}
};
ClParser.prototype.get = function () {
this.findUsed();
var lastWasEmpty = true;
return _.chain(this.result)
.filter(function (elem) {
if (!elem.keep) return false;
var thisIsEmpty = elem.text === "";
if (thisIsEmpty && lastWasEmpty) return false;
lastWasEmpty = thisIsEmpty;
return true;
})
.map(function (elem) {
return _.pick(elem, ['opcodes', 'address', 'source', 'text']);
})
.value();
};
module.exports = {
ClParser: ClParser
};

@ -24,6 +24,7 @@
(function () {
var _ = require('underscore-node');
var asmCl = require('./asm-cl');
var tabsRe = /\t/g;
function expandTabs(line) {
@ -111,7 +112,7 @@
}
function processAsm(asm, filters) {
if (asm.match(/^; Listing generated by Microsoft/)) return processClAsm(asm, filters);
if (asm.match(/^; Listing generated by Microsoft/)) return processClAsm(asm, filters);
if (filters.binary) return processBinaryAsm(asm, filters);
var result = [];
@ -252,9 +253,30 @@
return result;
}
// parser changes?
// Assume opcode stripping, assume preserves initial whitespace.
// Opcode is either:
// * beginning of line shouty directive: INCLUDELIB or PUBLIC
// (maybe group DD in here?)
// * beginning of line label/definition
// name <whitespace> [directives]
// name <comma> <whitespace?> [directives]
// name <colon>
// name = value
// * whitespace and then assembly instructions
// -- padding 'npad' is maybe a directive?
function processClAsm(asm, filters) {
var parser = new asmCl.ClParser(filters);
_.each(asm.split(/\r?\n/), function (line) {
parser.addLine(line);
});
return parser.get();
}
// TODO: dedupe with the above code
// TODO: support weak refs etc
function processClAsm(asm, filters) {
function processClAsm2(asm, filters) {
var asmLines = asm.split(/\r?\n/);
var labelsUsed = {};
var prevLabel = "";
@ -272,9 +294,18 @@
}
});
var directive = /^\s*(\.|([_A-Z]+\b))/;
var labelDefinition = /^([a-zA-Z0-9$_.]+):/; // NB not same as outer labelDef TODO dedupe
// var directive = /^(([_a-zA-Z]+[^;]+[A-Z]+)|(\s+([A-Z]+.*)|(\..*)))$/;
// var directive = /^\s*(\.|([_A-Z]+\b))/;
// covers "dot" directives, and anything whose first word is SHOUTY
var shoutyDirective = /^\s*(\.|([_A-Z]+\b))/;
// covers any line which starts on the margin and ends with SHOUTING
// e.g. 'xdata ENDS'
var endDirective = /^[_a-zA-Z]+.*[A-Z]+$/;
// Directives we want to keep
var keepDirectives = /\b(ENDP|PROC)\b/;
var commentOnly = /^\s*([#@;]|\/\/).*/;
var proc = /.*\bPROC$/;
var endBlock = /^[^ ]+\s+ENDP/;
var fileFind = /^; File\s+(.*)$/;
var inMain = false;
@ -391,18 +422,25 @@
prevLabel = match;
}
}
var hasOpcodes = addrOpcoder.hasOpcodes();
if (hasOpcodes) line = " " + line; // Reintroduce some indentation
if (!match && filters.directives) {
// Check for directives only if it wasn't a label; the regexp would
// otherwise misinterpret labels as directives.
if (line.match(dataDefn) && prevLabel) {
// We're defining data that's being used somewhere.
} else if (line.match(proc)) {
// this is a directive indicating the beginning of a function.
} else {
if (line.match(directive)) return;
match = line.match(shoutyDirective) || line.match(endDirective);
if (match && !line.match(keepDirectives)) {
console.log("DROPPING " + match);
return;
}
}
}
var hasOpcodes = addrOpcoder.hasOpcodes();
if (hasOpcodes) line = " " + line; // Reintroduce some indentation
line = expandTabs(line);
add({text: line, source: hasOpcodes ? source : null});
});

@ -1,44 +1,34 @@
[
{
"text": "x$ = 8",
"source": null
"source": null,
"text": "maxArray PROC"
},
{
"text": "y$ = 16",
"source": null
"source": null,
"text": ""
},
{
"text": "maxArray PROC",
"source": null
},
{
"text": "",
"source": null
},
{
"text": " lea rax, QWORD PTR [rcx+8]",
"source": 2,
"opcodes": [
72,
141,
65,
8
],
"address": 0
"address": 0,
"source": 2,
"text": " lea rax, QWORD PTR [rcx+8]"
},
{
"text": " sub rdx, rcx",
"source": 2,
"opcodes": [
72,
43,
209
],
"address": 4
"address": 4,
"source": 2,
"text": " sub rdx, rcx"
},
{
"text": " mov ecx, 16384 ; 00004000H",
"source": 2,
"opcodes": [
185,
0,
@ -46,30 +36,30 @@
0,
0
],
"address": 7
"address": 7,
"source": 2,
"text": " mov ecx, 16384 ; 00004000H"
},
{
"text": " npad 4",
"source": 2,
"opcodes": [
15,
31,
64,
0
],
"address": 12
"address": 12,
"source": 2,
"text": " npad 4"
},
{
"text": "$LL9@maxArray:",
"source": null
"source": null,
"text": "$LL9@maxArray:"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " movsd xmm0, QWORD PTR [rdx+rax-8]",
"source": 3,
"opcodes": [
242,
15,
@ -78,11 +68,11 @@
2,
248
],
"address": 16
"address": 16,
"source": 3,
"text": " movsd xmm0, QWORD PTR [rdx+rax-8]"
},
{
"text": " comisd xmm0, QWORD PTR [rax-8]",
"source": 3,
"opcodes": [
102,
15,
@ -90,20 +80,20 @@
64,
248
],
"address": 22
"address": 22,
"source": 3,
"text": " comisd xmm0, QWORD PTR [rax-8]"
},
{
"text": " jbe SHORT $LN10@maxArray",
"source": 3,
"opcodes": [
118,
5
],
"address": 27
"address": 27,
"source": 3,
"text": " jbe SHORT $LN10@maxArray"
},
{
"text": " movsd QWORD PTR [rax-8], xmm0",
"source": 3,
"opcodes": [
242,
15,
@ -111,15 +101,15 @@
64,
248
],
"address": 29
"address": 29,
"source": 3,
"text": " movsd QWORD PTR [rax-8], xmm0"
},
{
"text": "$LN10@maxArray:",
"source": null
"source": null,
"text": "$LN10@maxArray:"
},
{
"text": " movsd xmm0, QWORD PTR [rdx+rax]",
"source": 3,
"opcodes": [
242,
15,
@ -127,50 +117,50 @@
4,
2
],
"address": 34
"address": 34,
"source": 3,
"text": " movsd xmm0, QWORD PTR [rdx+rax]"
},
{
"text": " comisd xmm0, QWORD PTR [rax]",
"source": 3,
"opcodes": [
102,
15,
47,
0
],
"address": 39
"address": 39,
"source": 3,
"text": " comisd xmm0, QWORD PTR [rax]"
},
{
"text": " jbe SHORT $LN14@maxArray",
"source": 3,
"opcodes": [
118,
4
],
"address": 43
"address": 43,
"source": 3,
"text": " jbe SHORT $LN14@maxArray"
},
{
"text": " movsd QWORD PTR [rax], xmm0",
"source": 3,
"opcodes": [
242,
15,
17,
0
],
"address": 45
"address": 45,
"source": 3,
"text": " movsd QWORD PTR [rax], xmm0"
},
{
"text": "$LN14@maxArray:",
"source": null
"source": null,
"text": "$LN14@maxArray:"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " movsd xmm0, QWORD PTR [rdx+rax+8]",
"source": 3,
"opcodes": [
242,
15,
@ -179,11 +169,11 @@
2,
8
],
"address": 49
"address": 49,
"source": 3,
"text": " movsd xmm0, QWORD PTR [rdx+rax+8]"
},
{
"text": " comisd xmm0, QWORD PTR [rax+8]",
"source": 3,
"opcodes": [
102,
15,
@ -191,20 +181,20 @@
64,
8
],
"address": 55
"address": 55,
"source": 3,
"text": " comisd xmm0, QWORD PTR [rax+8]"
},
{
"text": " jbe SHORT $LN15@maxArray",
"source": 3,
"opcodes": [
118,
5
],
"address": 60
"address": 60,
"source": 3,
"text": " jbe SHORT $LN15@maxArray"
},
{
"text": " movsd QWORD PTR [rax+8], xmm0",
"source": 3,
"opcodes": [
242,
15,
@ -212,19 +202,19 @@
64,
8
],
"address": 62
"address": 62,
"source": 3,
"text": " movsd QWORD PTR [rax+8], xmm0"
},
{
"text": "$LN15@maxArray:",
"source": null
"source": null,
"text": "$LN15@maxArray:"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " movsd xmm0, QWORD PTR [rdx+rax+16]",
"source": 3,
"opcodes": [
242,
15,
@ -233,11 +223,11 @@
2,
16
],
"address": 67
"address": 67,
"source": 3,
"text": " movsd xmm0, QWORD PTR [rdx+rax+16]"
},
{
"text": " comisd xmm0, QWORD PTR [rax+16]",
"source": 3,
"opcodes": [
102,
15,
@ -245,20 +235,20 @@
64,
16
],
"address": 73
"address": 73,
"source": 3,
"text": " comisd xmm0, QWORD PTR [rax+16]"
},
{
"text": " jbe SHORT $LN16@maxArray",
"source": 3,
"opcodes": [
118,
5
],
"address": 78
"address": 78,
"source": 3,
"text": " jbe SHORT $LN16@maxArray"
},
{
"text": " movsd QWORD PTR [rax+16], xmm0",
"source": 3,
"opcodes": [
242,
15,
@ -266,65 +256,67 @@
64,
16
],
"address": 80
"address": 80,
"source": 3,
"text": " movsd QWORD PTR [rax+16], xmm0"
},
{
"text": "$LN16@maxArray:",
"source": null
"source": null,
"text": "$LN16@maxArray:"
},
{
"text": " add rax, 32 ; 00000020H",
"source": 3,
"opcodes": [
72,
131,
192,
32
],
"address": 85
"address": 85,
"source": 3,
"text": " add rax, 32 ; 00000020H"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " sub rcx, 1",
"source": 2,
"opcodes": [
72,
131,
233,
1
],
"address": 89
"address": 89,
"source": 2,
"text": " sub rcx, 1"
},
{
"text": " jne SHORT $LL9@maxArray",
"source": 2,
"opcodes": [
117,
177
],
"address": 93
"address": 93,
"source": 2,
"text": " jne SHORT $LL9@maxArray"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " ret 0",
"source": 4,
"opcodes": [
195
],
"address": 95
"address": 95,
"source": 4,
"text": " ret 0"
},
{
"text": "maxArray ENDP",
"source": null
"source": null,
"text": "maxArray ENDP"
},
{
"text": "",
"source": null
"source": null,
"text": ""
}
]

@ -1,138 +1,142 @@
[
{
"text": "self_regex$ = 32",
"source": null
"source": null,
"text": "self_regex$ = 32"
},
{
"text": "s$ = 72",
"source": null
"source": null,
"text": "s$ = 72"
},
{
"text": "regexTest PROC",
"source": null
"source": null,
"text": "__$ArrayPad$ = 104"
},
{
"text": "",
"source": null
"source": null,
"text": "regexTest PROC"
},
{
"text": " sub rsp, 120 ; 00000078H",
"source": 5
"source": null,
"text": ""
},
{
"text": "",
"source": null
"source": 5,
"text": " sub rsp, 120 ; 00000078H"
},
{
"text": " mov rax, QWORD PTR __security_cookie",
"source": 5
"source": null,
"text": ""
},
{
"text": " xor rax, rsp",
"source": 5
"source": 5,
"text": " mov rax, QWORD PTR __security_cookie"
},
{
"text": " mov QWORD PTR __$ArrayPad$[rsp], rax",
"source": 5
"source": 5,
"text": " xor rax, rsp"
},
{
"text": "",
"source": null
"source": 5,
"text": " mov QWORD PTR __$ArrayPad$[rsp], rax"
},
{
"text": " lea rdx, OFFSET FLAT:$SG44257",
"source": 6
"source": null,
"text": ""
},
{
"text": " lea rcx, QWORD PTR s$[rsp]",
"source": 6
"source": 6,
"text": " lea rdx, OFFSET FLAT:$SG44257"
},
{
"text": " call std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >",
"source": 6
"source": 6,
"text": " lea rcx, QWORD PTR s$[rsp]"
},
{
"text": "",
"source": null
"source": 6,
"text": " call std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >"
},
{
"text": " mov edx, 256 ; 00000100H",
"source": 9
"source": null,
"text": ""
},
{
"text": " mov ecx, 1",
"source": 9
"source": 9,
"text": " mov edx, 256 ; 00000100H"
},
{
"text": " call std::regex_constants::operator|",
"source": 9
"source": 9,
"text": " mov ecx, 1"
},
{
"text": " mov r8d, eax",
"source": 9
"source": 9,
"text": " call std::regex_constants::operator|"
},
{
"text": "",
"source": null
"source": 9,
"text": " mov r8d, eax"
},
{
"text": " lea rdx, OFFSET FLAT:$SG44258",
"source": 9
"source": null,
"text": ""
},
{
"text": " lea rcx, QWORD PTR self_regex$[rsp]",
"source": 9
"source": 9,
"text": " lea rdx, OFFSET FLAT:$SG44258"
},
{
"text": " call std::basic_regex<char,std::regex_traits<char> >::basic_regex<char,std::regex_traits<char> >",
"source": 9
"source": 9,
"text": " lea rcx, QWORD PTR self_regex$[rsp]"
},
{
"text": "",
"source": null
"source": 9,
"text": " call std::basic_regex<char,std::regex_traits<char> >::basic_regex<char,std::regex_traits<char> >"
},
{
"text": " lea rcx, QWORD PTR self_regex$[rsp]",
"source": 11
"source": null,
"text": ""
},
{
"text": " call std::basic_regex<char,std::regex_traits<char> >::~basic_regex<char,std::regex_traits<char> >",
"source": 11
"source": 11,
"text": " lea rcx, QWORD PTR self_regex$[rsp]"
},
{
"text": " lea rcx, QWORD PTR s$[rsp]",
"source": 11
"source": 11,
"text": " call std::basic_regex<char,std::regex_traits<char> >::~basic_regex<char,std::regex_traits<char> >"
},
{
"text": " call std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >",
"source": 11
"source": 11,
"text": " lea rcx, QWORD PTR s$[rsp]"
},
{
"text": " mov rcx, QWORD PTR __$ArrayPad$[rsp]",
"source": 11
"source": 11,
"text": " call std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >"
},
{
"text": " xor rcx, rsp",
"source": 11
"source": 11,
"text": " mov rcx, QWORD PTR __$ArrayPad$[rsp]"
},
{
"text": " call __security_check_cookie",
"source": 11
"source": 11,
"text": " xor rcx, rsp"
},
{
"text": " add rsp, 120 ; 00000078H",
"source": 11
"source": 11,
"text": " call __security_check_cookie"
},
{
"text": " ret 0",
"source": 11
"source": 11,
"text": " add rsp, 120 ; 00000078H"
},
{
"text": "regexTest ENDP",
"source": null
"source": 11,
"text": " ret 0"
},
{
"text": "",
"source": null
"source": null,
"text": "regexTest ENDP"
},
{
"source": null,
"text": ""
}
]
]

@ -1,38 +1,40 @@
[
{
"text": "self_regex$ = 32",
"source": null
"source": null,
"text": "self_regex$ = 32"
},
{
"text": "s$ = 72",
"source": null
"source": null,
"text": "s$ = 72"
},
{
"text": "regexTest PROC",
"source": null
"source": null,
"text": "__$ArrayPad$ = 104"
},
{
"text": "",
"source": null
"source": null,
"text": "regexTest PROC"
},
{
"source": null,
"text": ""
},
{
"text": " sub rsp, 120 ; 00000078H",
"source": 5,
"opcodes": [
72,
131,
236,
120
],
"address": 0
"address": 0,
"source": 5,
"text": " sub rsp, 120 ; 00000078H"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " mov rax, QWORD PTR __security_cookie",
"source": 5,
"opcodes": [
72,
139,
@ -42,21 +44,21 @@
0,
0
],
"address": 4
"address": 4,
"source": 5,
"text": " mov rax, QWORD PTR __security_cookie"
},
{
"text": " xor rax, rsp",
"source": 5,
"opcodes": [
72,
51,
196
],
"address": 11
"address": 11,
"source": 5,
"text": " xor rax, rsp"
},
{
"text": " mov QWORD PTR __$ArrayPad$[rsp], rax",
"source": 5,
"opcodes": [
72,
137,
@ -64,15 +66,15 @@
36,
104
],
"address": 14
"address": 14,
"source": 5,
"text": " mov QWORD PTR __$ArrayPad$[rsp], rax"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " lea rdx, OFFSET FLAT:$SG44257",
"source": 6,
"opcodes": [
72,
141,
@ -82,11 +84,11 @@
0,
0
],
"address": 19
"address": 19,
"source": 6,
"text": " lea rdx, OFFSET FLAT:$SG44257"
},
{
"text": " lea rcx, QWORD PTR s$[rsp]",
"source": 6,
"opcodes": [
72,
141,
@ -94,11 +96,11 @@
36,
72
],
"address": 26
"address": 26,
"source": 6,
"text": " lea rcx, QWORD PTR s$[rsp]"
},
{
"text": " call std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >",
"source": 6,
"opcodes": [
232,
0,
@ -106,15 +108,15 @@
0,
0
],
"address": 31
"address": 31,
"source": 6,
"text": " call std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " mov edx, 256 ; 00000100H",
"source": 9,
"opcodes": [
186,
0,
@ -122,11 +124,11 @@
0,
0
],
"address": 36
"address": 36,
"source": 9,
"text": " mov edx, 256 ; 00000100H"
},
{
"text": " mov ecx, 1",
"source": 9,
"opcodes": [
185,
1,
@ -134,11 +136,11 @@
0,
0
],
"address": 41
"address": 41,
"source": 9,
"text": " mov ecx, 1"
},
{
"text": " call std::regex_constants::operator|",
"source": 9,
"opcodes": [
232,
0,
@ -146,25 +148,25 @@
0,
0
],
"address": 46
"address": 46,
"source": 9,
"text": " call std::regex_constants::operator|"
},
{
"text": " mov r8d, eax",
"source": 9,
"opcodes": [
68,
139,
192
],
"address": 51
"address": 51,
"source": 9,
"text": " mov r8d, eax"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " lea rdx, OFFSET FLAT:$SG44258",
"source": 9,
"opcodes": [
72,
141,
@ -174,11 +176,11 @@
0,
0
],
"address": 54
"address": 54,
"source": 9,
"text": " lea rdx, OFFSET FLAT:$SG44258"
},
{
"text": " lea rcx, QWORD PTR self_regex$[rsp]",
"source": 9,
"opcodes": [
72,
141,
@ -186,11 +188,11 @@
36,
32
],
"address": 61
"address": 61,
"source": 9,
"text": " lea rcx, QWORD PTR self_regex$[rsp]"
},
{
"text": " call std::basic_regex<char,std::regex_traits<char> >::basic_regex<char,std::regex_traits<char> >",
"source": 9,
"opcodes": [
232,
0,
@ -198,15 +200,15 @@
0,
0
],
"address": 66
"address": 66,
"source": 9,
"text": " call std::basic_regex<char,std::regex_traits<char> >::basic_regex<char,std::regex_traits<char> >"
},
{
"text": "",
"source": null
"source": null,
"text": ""
},
{
"text": " lea rcx, QWORD PTR self_regex$[rsp]",
"source": 11,
"opcodes": [
72,
141,
@ -214,11 +216,11 @@
36,
32
],
"address": 71
"address": 71,
"source": 11,
"text": " lea rcx, QWORD PTR self_regex$[rsp]"
},
{
"text": " call std::basic_regex<char,std::regex_traits<char> >::~basic_regex<char,std::regex_traits<char> >",
"source": 11,
"opcodes": [
232,
0,
@ -226,11 +228,11 @@
0,
0
],
"address": 76
"address": 76,
"source": 11,
"text": " call std::basic_regex<char,std::regex_traits<char> >::~basic_regex<char,std::regex_traits<char> >"
},
{
"text": " lea rcx, QWORD PTR s$[rsp]",
"source": 11,
"opcodes": [
72,
141,
@ -238,11 +240,11 @@
36,
72
],
"address": 81
"address": 81,
"source": 11,
"text": " lea rcx, QWORD PTR s$[rsp]"
},
{
"text": " call std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >",
"source": 11,
"opcodes": [
232,
0,
@ -250,11 +252,11 @@
0,
0
],
"address": 86
"address": 86,
"source": 11,
"text": " call std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >"
},
{
"text": " mov rcx, QWORD PTR __$ArrayPad$[rsp]",
"source": 11,
"opcodes": [
72,
139,
@ -262,21 +264,21 @@
36,
104
],
"address": 91
"address": 91,
"source": 11,
"text": " mov rcx, QWORD PTR __$ArrayPad$[rsp]"
},
{
"text": " xor rcx, rsp",
"source": 11,
"opcodes": [
72,
51,
204
],
"address": 96
"address": 96,
"source": 11,
"text": " xor rcx, rsp"
},
{
"text": " call __security_check_cookie",
"source": 11,
"opcodes": [
232,
0,
@ -284,33 +286,35 @@
0,
0
],
"address": 99
"address": 99,
"source": 11,
"text": " call __security_check_cookie"
},
{
"text": " add rsp, 120 ; 00000078H",
"source": 11,
"opcodes": [
72,
131,
196,
120
],
"address": 104
"address": 104,
"source": 11,
"text": " add rsp, 120 ; 00000078H"
},
{
"text": " ret 0",
"source": 11,
"opcodes": [
195
],
"address": 108
"address": 108,
"source": 11,
"text": " ret 0"
},
{
"text": "regexTest ENDP",
"source": null
"source": null,
"text": "regexTest ENDP"
},
{
"text": "",
"source": null
"source": null,
"text": ""
}
]
]

@ -23,91 +23,91 @@ length$ = 16
testFunction, COMDAT PROC
$LN22:
mov QWORD PTR [rsp+8], rbx
0000 00 01 mov QWORD PTR [rsp+8], rbx
xor r8d, r8d
movsxd rbx, edx
mov r9, rcx
mov r11d, r8d
0000 00 01 xor r8d, r8d
0000 00 01 movsxd rbx, edx
0000 00 01 mov r9, rcx
0000 00 01 mov r11d, r8d
mov r10d, r8d
test edx, edx
jle SHORT $LN9@testFuncti
cmp ebx, 8
jb SHORT $LN9@testFuncti
mov eax, ebx
and eax, -2147483641 ; ffffffff80000007H
jge SHORT $LN19@testFuncti
dec eax
or eax, -8
inc eax
0000 00 01 mov r10d, r8d
0000 00 01 test edx, edx
0000 00 01 jle SHORT $LN9@testFuncti
0000 00 01 cmp ebx, 8
0000 00 01 jb SHORT $LN9@testFuncti
0000 00 01 mov eax, ebx
0000 00 01 and eax, -2147483641 ; ffffffff80000007H
0000 00 01 jge SHORT $LN19@testFuncti
0000 00 01 dec eax
0000 00 01 or eax, -8
0000 00 01 inc eax
$LN19@testFuncti:
mov edx, ebx
xorps xmm2, xmm2
sub edx, eax
movdqa xmm1, xmm2
0000 00 01 mov edx, ebx
0000 00 01 xorps xmm2, xmm2
0000 00 01 sub edx, eax
0000 00 01 movdqa xmm1, xmm2
npad 8
0000 00 01 npad 8
$LL4@testFuncti:
movsxd rax, r10d
0000 00 01 movsxd rax, r10d
movdqu xmm0, XMMWORD PTR [r9+rax*4]
lea eax, DWORD PTR [r10+4]
add r10d, 8
movsxd rcx, eax
paddd xmm0, xmm2
movdqa xmm2, xmm0
0000 00 01 movdqu xmm0, XMMWORD PTR [r9+rax*4]
0000 00 01 lea eax, DWORD PTR [r10+4]
0000 00 01 add r10d, 8
0000 00 01 movsxd rcx, eax
0000 00 01 paddd xmm0, xmm2
0000 00 01 movdqa xmm2, xmm0
movdqu xmm0, XMMWORD PTR [r9+rcx*4]
paddd xmm0, xmm1
movdqa xmm1, xmm0
cmp r10d, edx
jl SHORT $LL4@testFuncti
paddd xmm1, xmm2
movdqa xmm0, xmm1
psrldq xmm0, 8
paddd xmm1, xmm0
movdqa xmm0, xmm1
psrldq xmm0, 4
paddd xmm1, xmm0
movd r11d, xmm1
0000 00 01 movdqu xmm0, XMMWORD PTR [r9+rcx*4]
0000 00 01 paddd xmm0, xmm1
0000 00 01 movdqa xmm1, xmm0
0000 00 01 cmp r10d, edx
0000 00 01 jl SHORT $LL4@testFuncti
0000 00 01 paddd xmm1, xmm2
0000 00 01 movdqa xmm0, xmm1
0000 00 01 psrldq xmm0, 8
0000 00 01 paddd xmm1, xmm0
0000 00 01 movdqa xmm0, xmm1
0000 00 01 psrldq xmm0, 4
0000 00 01 paddd xmm1, xmm0
0000 00 01 movd r11d, xmm1
$LN9@testFuncti:
movsxd rcx, r10d
0000 00