diff --git a/Makefile b/Makefile index 672bd0031..dd52cc63a 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,14 @@ $(NODE_MODULES): package.json node_modules: $(NODE_MODULES) +test: + (cd test; node test.js) + @echo Tests pass + clean: rm -rf node_modules -.PHONY: clean run + +.PHONY: clean run test run-amazon run: node_modules ./node_modules/.bin/supervisor ./app.js diff --git a/app.js b/app.js index adbe110cd..bfdeb35d4 100755 --- a/app.js +++ b/app.js @@ -127,19 +127,21 @@ function compile(req, res) { child.stderr.on('data', function (data) { stderr += data; }); child.on('exit', function (code) { clearTimeout(timeout); - child_process.exec('cat "' + outputFilename + '" | c++filt', function(err, filt_stdout, filt_stderr) { - var data = filt_stdout; - if (err) { - data = ''; - } + child_process.exec('cat "' + outputFilename + '" | c++filt', + { maxBuffer: props.get("gcc-explorer", "max-asm-size", 8 * 1024 * 1024) }, + function(err, filt_stdout, filt_stderr) { + var data = filt_stdout; + if (err) { + data = ''; + } - res.end(JSON.stringify({ - stdout: stdout, - stderr: stderr, - asm: data, - code: code })); - fs.unlink(outputFilename, function() { fs.rmdir(dirPath); }); - }); + res.end(JSON.stringify({ + stdout: stdout, + stderr: stderr, + asm: data, + code: code })); + fs.unlink(outputFilename, function() { fs.rmdir(dirPath); }); + }); }); child.stdin.write(source); child.stdin.end(); diff --git a/etc/config/gcc-explorer.amazon.properties b/etc/config/gcc-explorer.amazon.properties index 80b92ac62..4a4f3a4ff 100644 --- a/etc/config/gcc-explorer.amazon.properties +++ b/etc/config/gcc-explorer.amazon.properties @@ -2,3 +2,4 @@ compileTimeoutMs=300 compilers=/usr/bin/g++-4.4:/usr/bin/g++-4.5:/usr/bin/g++-4.6:/usr/bin/g++-4.7:/usr/bin/arm-linux-gnueabi-g++-4.5:/usr/bin/clang++:/usr/bin/avr-g++:/usr/bin/msp430-g++:/usr/bin/arm-linux-gnueabi-g++-4.6 compiler-wrapper=./c-preload/compiler-wrapper +max-asm-size=262144 diff --git a/static/asm-mode.js b/static/asm-mode.js new file mode 100644 index 000000000..c777f8450 --- /dev/null +++ b/static/asm-mode.js @@ -0,0 +1,49 @@ + +CodeMirror.defineMode("asm", function() { + function tokenString(quote) { + return function(stream) { + var escaped = false, next, end = false; + while ((next = stream.next()) != null) { + if (next == quote && !escaped) {end = true; break;} + escaped = !escaped && next == "\\"; + } + return "string"; + }; + } + + return { + token: function(stream) { + if (stream.match(/^.+:$/)) { + return "variable-2"; + } + if (stream.sol() && stream.match(/^\s*\.\w+/)) { + return "header"; + } + if (stream.sol() && stream.match(/^\s\w+/)) { + return "keyword"; + } + if (stream.eatSpace()) return null; + var ch = stream.next(); + if (ch == '"' || ch == "'") { + return tokenString(ch)(stream); + } + if (/[\[\]{}\(\),;\:]/.test(ch)) return null; + if (/[\d$]/.test(ch) || (ch == '-' && stream.peek().match(/[0-9]/))) { + stream.eatWhile(/[\w\.]/); + return "number"; + } + if (ch == '%') { + stream.eatWhile(/\w+/); + return "variable-3"; + } + if (ch == '#') { + stream.eatWhile(/.*/); + return "comment"; + } + stream.eatWhile(/[\w\$_]/); + return "word"; + } + }; +}); + +CodeMirror.defineMIME("text/x-asm", "asm"); diff --git a/static/asm.js b/static/asm.js index 45b3ceba6..09e33e72a 100644 --- a/static/asm.js +++ b/static/asm.js @@ -1,70 +1,19 @@ - -CodeMirror.defineMode("asm", function() { - function tokenString(quote) { - return function(stream) { - var escaped = false, next, end = false; - while ((next = stream.next()) != null) { - if (next == quote && !escaped) {end = true; break;} - escaped = !escaped && next == "\\"; - } - return "string"; - }; - } - - return { - token: function(stream) { - if (stream.match(/^.+:$/)) { - return "variable-2"; - } - if (stream.sol() && stream.match(/^\s*\.\w+/)) { - return "header"; - } - if (stream.sol() && stream.match(/^\s\w+/)) { - return "keyword"; - } - if (stream.eatSpace()) return null; - var ch = stream.next(); - if (ch == '"' || ch == "'") { - return tokenString(ch)(stream); - } - if (/[\[\]{}\(\),;\:]/.test(ch)) return null; - if (/[\d$]/.test(ch) || (ch == '-' && stream.peek().match(/[0-9]/))) { - stream.eatWhile(/[\w\.]/); - return "number"; - } - if (ch == '%') { - stream.eatWhile(/\w+/); - return "variable-3"; - } - if (ch == '#') { - stream.eatWhile(/.*/); - return "comment"; - } - stream.eatWhile(/[\w\$_]/); - return "word"; - } - }; -}); - -CodeMirror.defineMIME("text/x-asm", "asm"); - function processAsm(asm, filters) { var result = []; var asmLines = asm.split("\n"); var labelsUsed = {}; - var labelFind = /\.[a-zA-Z0-9$_.]+/g; + var labelFind = /[.a-zA-Z0-9_][a-zA-Z0-9$_.]*/g; var files = {}; var prevLabel = ""; - var literalConstant = /^\.LC\d+/; - var lcString = /\.string/; + var dataDefn = /\.(string|asciz|ascii|[1248]?byte|short|word|long|quad|value|zero)/; var fileFind = /^\s*\.file\s+(\d+)\s+"([^"]+)"$/; var hasOpcode = /^\s*([a-zA-Z0-9$_][a-zA-Z0-9$_.]*:\s*)?[a-zA-Z].*/; - $.each(asmLines, function(_, line) { + asmLines.forEach(function(line) { if (line == "" || line[0] == ".") return; var match = line.match(labelFind); if (match && (!filters.directives || line.match(hasOpcode))) { // Only count a label as used if it's used by an opcode, or else we're not filtering directives. - $.each(match, function(_, label) { labelsUsed[label] = true; }); + match.forEach(function(label) { labelsUsed[label] = true; }); } match = line.match(fileFind); if (match) { @@ -73,14 +22,18 @@ function processAsm(asm, filters) { }); var directive = /^\s*\..*$/; - var labelDefinition = /^(\.[a-zA-Z0-9$_.]+):/; + var labelDefinition = /^([a-zA-Z0-9$_.]+):/; var commentOnly = /^\s*(#|@|\/\/).*/; var sourceTag = /^\s*\.loc\s+(\d+)\s+(\d+).*/; var stdInLooking = /.*|-/; + var endBlock = /\.(cfi_endproc|data|text|section)/; var source = null; - $.each(asmLines, function(_, line) { + asmLines.forEach(function(line) { var match; - if (line.trim() == "") return; + if (line.trim() == "") { + result.push({text:"", source:null}); + return; + } if (match = line.match(sourceTag)) { source = null; var file = files[parseInt(match[1])]; @@ -88,25 +41,32 @@ function processAsm(asm, filters) { source = parseInt(match[2]); } } + if (line.match(endBlock)) { + source = null; + prevLabel = null; + } if (filters.commentOnly && line.match(commentOnly)) return; + match = line.match(labelDefinition); - if (!match && line.match(lcString) && prevLabel) { - result.push({text: line, source: null}); - prevLabel = ""; - return; - } - if (match && labelsUsed[match[1]] == undefined) { - if (filters.labels) return; - } - if (match && line.match(literalConstant)) { - prevLabel = line; + if (match) { + // It's a label definition. + if (labelsUsed[match[1]] == undefined) { + // It's an unused label. + if (filters.labels) return; + } else { + // A used label. + prevLabel = match; + } } if (!match && filters.directives) { // Check for directives only if it wasn't a label; the regexp would // otherwise misinterpret labels as directives. - match = line.match(directive); - if (match) return; + if (line.match(dataDefn) && prevLabel) { + // We're defining data that's being used somewhere. + } else { + if (line.match(directive)) return; + } } var hasOpcodeMatch = line.match(hasOpcode); @@ -115,3 +75,8 @@ function processAsm(asm, filters) { return result; } +if (typeof module !== 'undefined' && module.exports) { + module.exports = { + processAsm: processAsm + }; +} diff --git a/static/index.html b/static/index.html index 3e99b6039..593c1dd55 100644 --- a/static/index.html +++ b/static/index.html @@ -8,6 +8,7 @@ + @@ -116,7 +117,10 @@ - Fork me on GitHub + Fork me on GitHub + + + diff --git a/test/cases/arm-hellow.asm b/test/cases/arm-hellow.asm new file mode 100644 index 000000000..2286295d4 --- /dev/null +++ b/test/cases/arm-hellow.asm @@ -0,0 +1,976 @@ + .syntax unified + .arch armv7-a + .eabi_attribute 27, 3 + .fpu vfpv3-d16 + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 2 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .thumb + .file "" + .text +.Ltext0: + .cfi_sections .debug_frame + .section .text.startup,"ax",%progbits + .align 2 + .global main + .thumb + .thumb_func + .type main, %function +main: + .fnstart +.LFB31: + .file 1 "" + .loc 1 2 0 + .cfi_startproc + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 +.LVL0: + push {r3, lr} + .save {r3, lr} +.LCFI0: + .cfi_def_cfa_offset 8 + .cfi_offset 14, -4 + .cfi_offset 3, -8 +.LBB6: +.LBB7: + .file 2 "/usr/arm-linux-gnueabi/include/bits/stdio2.h" + .loc 2 105 0 + movs r0, #1 + movw r1, #:lower16:.LC0 + movt r1, #:upper16:.LC0 + bl __printf_chk +.LVL1: +.LBE7: +.LBE6: +.LBB8: +.LBB9: + movs r0, #1 + movw r1, #:lower16:.LC1 + movt r1, #:upper16:.LC1 + bl __printf_chk +.LBE9: +.LBE8: + .loc 1 5 0 + movs r0, #0 + pop {r3, pc} + .cfi_endproc +.LFE31: + .fnend + .size main, .-main + .section .rodata.str1.4,"aMS",%progbits,1 + .align 2 +.LC0: + .ascii "Hello world\000" +.LC1: + .ascii "moo\012\000" + .text +.Letext0: + .file 3 "/usr/lib/gcc/arm-linux-gnueabi/4.6/include/stddef.h" + .file 4 "/usr/arm-linux-gnueabi/include/bits/types.h" + .file 5 "/usr/arm-linux-gnueabi/include/libio.h" + .file 6 "/usr/arm-linux-gnueabi/include/stdio.h" + .section .debug_info,"",%progbits +.Ldebug_info0: + .4byte 0x37d + .2byte 0x2 + .4byte .Ldebug_abbrev0 + .byte 0x4 + .uleb128 0x1 + .4byte .LASF50 + .byte 0x4 + .4byte .LASF51 + .4byte 0 + .4byte 0 + .4byte .Ldebug_ranges0+0 + .4byte .Ldebug_line0 + .uleb128 0x2 + .4byte .LASF8 + .byte 0x3 + .byte 0xd4 + .4byte 0x30 + .uleb128 0x3 + .byte 0x4 + .byte 0x7 + .4byte .LASF0 + .uleb128 0x3 + .byte 0x1 + .byte 0x8 + .4byte .LASF1 + .uleb128 0x3 + .byte 0x2 + .byte 0x7 + .4byte .LASF2 + .uleb128 0x3 + .byte 0x4 + .byte 0x7 + .4byte .LASF3 + .uleb128 0x3 + .byte 0x1 + .byte 0x6 + .4byte .LASF4 + .uleb128 0x3 + .byte 0x2 + .byte 0x5 + .4byte .LASF5 + .uleb128 0x4 + .byte 0x4 + .byte 0x5 + .ascii "int\000" + .uleb128 0x3 + .byte 0x8 + .byte 0x5 + .4byte .LASF6 + .uleb128 0x3 + .byte 0x8 + .byte 0x7 + .4byte .LASF7 + .uleb128 0x2 + .4byte .LASF9 + .byte 0x4 + .byte 0x38 + .4byte 0x61 + .uleb128 0x2 + .4byte .LASF10 + .byte 0x4 + .byte 0x8d + .4byte 0x85 + .uleb128 0x3 + .byte 0x4 + .byte 0x5 + .4byte .LASF11 + .uleb128 0x2 + .4byte .LASF12 + .byte 0x4 + .byte 0x8e + .4byte 0x6f + .uleb128 0x5 + .byte 0x4 + .uleb128 0x6 + .byte 0x4 + .4byte 0x9f + .uleb128 0x3 + .byte 0x1 + .byte 0x8 + .4byte .LASF13 + .uleb128 0x7 + .4byte .LASF43 + .byte 0x98 + .byte 0x5 + .2byte 0x111 + .4byte 0x267 + .uleb128 0x8 + .4byte .LASF14 + .byte 0x5 + .2byte 0x112 + .4byte 0x5a + .byte 0x2 + .byte 0x23 + .uleb128 0 + .uleb128 0x8 + .4byte .LASF15 + .byte 0x5 + .2byte 0x117 + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x4 + .uleb128 0x8 + .4byte .LASF16 + .byte 0x5 + .2byte 0x118 + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x8 + .uleb128 0x8 + .4byte .LASF17 + .byte 0x5 + .2byte 0x119 + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0xc + .uleb128 0x8 + .4byte .LASF18 + .byte 0x5 + .2byte 0x11a + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x10 + .uleb128 0x8 + .4byte .LASF19 + .byte 0x5 + .2byte 0x11b + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x14 + .uleb128 0x8 + .4byte .LASF20 + .byte 0x5 + .2byte 0x11c + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x18 + .uleb128 0x8 + .4byte .LASF21 + .byte 0x5 + .2byte 0x11d + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x1c + .uleb128 0x8 + .4byte .LASF22 + .byte 0x5 + .2byte 0x11e + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x20 + .uleb128 0x8 + .4byte .LASF23 + .byte 0x5 + .2byte 0x120 + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x24 + .uleb128 0x8 + .4byte .LASF24 + .byte 0x5 + .2byte 0x121 + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x28 + .uleb128 0x8 + .4byte .LASF25 + .byte 0x5 + .2byte 0x122 + .4byte 0x99 + .byte 0x2 + .byte 0x23 + .uleb128 0x2c + .uleb128 0x8 + .4byte .LASF26 + .byte 0x5 + .2byte 0x124 + .4byte 0x2b1 + .byte 0x2 + .byte 0x23 + .uleb128 0x30 + .uleb128 0x8 + .4byte .LASF27 + .byte 0x5 + .2byte 0x126 + .4byte 0x2b7 + .byte 0x2 + .byte 0x23 + .uleb128 0x34 + .uleb128 0x8 + .4byte .LASF28 + .byte 0x5 + .2byte 0x128 + .4byte 0x5a + .byte 0x2 + .byte 0x23 + .uleb128 0x38 + .uleb128 0x8 + .4byte .LASF29 + .byte 0x5 + .2byte 0x12c + .4byte 0x5a + .byte 0x2 + .byte 0x23 + .uleb128 0x3c + .uleb128 0x8 + .4byte .LASF30 + .byte 0x5 + .2byte 0x12e + .4byte 0x7a + .byte 0x2 + .byte 0x23 + .uleb128 0x40 + .uleb128 0x8 + .4byte .LASF31 + .byte 0x5 + .2byte 0x132 + .4byte 0x3e + .byte 0x2 + .byte 0x23 + .uleb128 0x44 + .uleb128 0x8 + .4byte .LASF32 + .byte 0x5 + .2byte 0x133 + .4byte 0x4c + .byte 0x2 + .byte 0x23 + .uleb128 0x46 + .uleb128 0x8 + .4byte .LASF33 + .byte 0x5 + .2byte 0x134 + .4byte 0x2bd + .byte 0x2 + .byte 0x23 + .uleb128 0x47 + .uleb128 0x8 + .4byte .LASF34 + .byte 0x5 + .2byte 0x138 + .4byte 0x2cd + .byte 0x2 + .byte 0x23 + .uleb128 0x48 + .uleb128 0x8 + .4byte .LASF35 + .byte 0x5 + .2byte 0x141 + .4byte 0x8c + .byte 0x2 + .byte 0x23 + .uleb128 0x50 + .uleb128 0x8 + .4byte .LASF36 + .byte 0x5 + .2byte 0x14a + .4byte 0x97 + .byte 0x2 + .byte 0x23 + .uleb128 0x58 + .uleb128 0x8 + .4byte .LASF37 + .byte 0x5 + .2byte 0x14b + .4byte 0x97 + .byte 0x2 + .byte 0x23 + .uleb128 0x5c + .uleb128 0x8 + .4byte .LASF38 + .byte 0x5 + .2byte 0x14c + .4byte 0x97 + .byte 0x2 + .byte 0x23 + .uleb128 0x60 + .uleb128 0x8 + .4byte .LASF39 + .byte 0x5 + .2byte 0x14d + .4byte 0x97 + .byte 0x2 + .byte 0x23 + .uleb128 0x64 + .uleb128 0x8 + .4byte .LASF40 + .byte 0x5 + .2byte 0x14e + .4byte 0x25 + .byte 0x2 + .byte 0x23 + .uleb128 0x68 + .uleb128 0x8 + .4byte .LASF41 + .byte 0x5 + .2byte 0x150 + .4byte 0x5a + .byte 0x2 + .byte 0x23 + .uleb128 0x6c + .uleb128 0x8 + .4byte .LASF42 + .byte 0x5 + .2byte 0x152 + .4byte 0x2d3 + .byte 0x2 + .byte 0x23 + .uleb128 0x70 + .byte 0 + .uleb128 0x9 + .4byte .LASF52 + .byte 0x5 + .byte 0xb6 + .uleb128 0xa + .4byte .LASF44 + .byte 0xc + .byte 0x5 + .byte 0xbc + .4byte 0x2a5 + .uleb128 0xb + .4byte .LASF45 + .byte 0x5 + .byte 0xbd + .4byte 0x2a5 + .byte 0x2 + .byte 0x23 + .uleb128 0 + .uleb128 0xb + .4byte .LASF46 + .byte 0x5 + .byte 0xbe + .4byte 0x2ab + .byte 0x2 + .byte 0x23 + .uleb128 0x4 + .uleb128 0xb + .4byte .LASF47 + .byte 0x5 + .byte 0xc2 + .4byte 0x5a + .byte 0x2 + .byte 0x23 + .uleb128 0x8 + .byte 0 + .uleb128 0x6 + .byte 0x4 + .4byte 0x26e + .uleb128 0x6 + .byte 0x4 + .4byte 0xa6 + .uleb128 0x6 + .byte 0x4 + .4byte 0x26e + .uleb128 0x6 + .byte 0x4 + .4byte 0xa6 + .uleb128 0xc + .4byte 0x9f + .4byte 0x2cd + .uleb128 0xd + .4byte 0x30 + .byte 0 + .byte 0 + .uleb128 0x6 + .byte 0x4 + .4byte 0x267 + .uleb128 0xc + .4byte 0x9f + .4byte 0x2e3 + .uleb128 0xd + .4byte 0x30 + .byte 0x27 + .byte 0 + .uleb128 0x6 + .byte 0x4 + .4byte 0x2e9 + .uleb128 0xe + .4byte 0x9f + .uleb128 0xf + .byte 0x1 + .4byte .LASF53 + .byte 0x2 + .byte 0x67 + .4byte 0x5a + .byte 0x3 + .byte 0x1 + .4byte 0x30d + .uleb128 0x10 + .4byte .LASF54 + .byte 0x2 + .byte 0x67 + .4byte 0x2e3 + .uleb128 0x11 + .byte 0 + .uleb128 0x12 + .byte 0x1 + .4byte .LASF55 + .byte 0x1 + .byte 0x2 + .4byte 0x5a + .4byte .LFB31 + .4byte .LFE31 + .4byte .LLST0 + .4byte 0x366 + .uleb128 0x13 + .4byte 0x2ee + .4byte .LBB6 + .4byte .LBE6 + .byte 0x1 + .byte 0x3 + .4byte 0x349 + .uleb128 0x14 + .4byte 0x300 + .byte 0x6 + .byte 0x3 + .4byte .LC0 + .byte 0x9f + .byte 0 + .uleb128 0x15 + .4byte 0x2ee + .4byte .LBB8 + .4byte .LBE8 + .byte 0x1 + .byte 0x4 + .uleb128 0x14 + .4byte 0x300 + .byte 0x6 + .byte 0x3 + .4byte .LC1 + .byte 0x9f + .byte 0 + .byte 0 + .uleb128 0x16 + .4byte .LASF48 + .byte 0x6 + .byte 0xa9 + .4byte 0x2ab + .byte 0x1 + .byte 0x1 + .uleb128 0x16 + .4byte .LASF49 + .byte 0x6 + .byte 0xaa + .4byte 0x2ab + .byte 0x1 + .byte 0x1 + .byte 0 + .section .debug_abbrev,"",%progbits +.Ldebug_abbrev0: + .uleb128 0x1 + .uleb128 0x11 + .byte 0x1 + .uleb128 0x25 + .uleb128 0xe + .uleb128 0x13 + .uleb128 0xb + .uleb128 0x1b + .uleb128 0xe + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x52 + .uleb128 0x1 + .uleb128 0x55 + .uleb128 0x6 + .uleb128 0x10 + .uleb128 0x6 + .byte 0 + .byte 0 + .uleb128 0x2 + .uleb128 0x16 + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x3 + .uleb128 0x24 + .byte 0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3e + .uleb128 0xb + .uleb128 0x3 + .uleb128 0xe + .byte 0 + .byte 0 + .uleb128 0x4 + .uleb128 0x24 + .byte 0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3e + .uleb128 0xb + .uleb128 0x3 + .uleb128 0x8 + .byte 0 + .byte 0 + .uleb128 0x5 + .uleb128 0xf + .byte 0 + .uleb128 0xb + .uleb128 0xb + .byte 0 + .byte 0 + .uleb128 0x6 + .uleb128 0xf + .byte 0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x7 + .uleb128 0x13 + .byte 0x1 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0x5 + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x8 + .uleb128 0xd + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0x5 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x38 + .uleb128 0xa + .byte 0 + .byte 0 + .uleb128 0x9 + .uleb128 0x16 + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .byte 0 + .byte 0 + .uleb128 0xa + .uleb128 0x13 + .byte 0x1 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0xb + .uleb128 0xd + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x38 + .uleb128 0xa + .byte 0 + .byte 0 + .uleb128 0xc + .uleb128 0x1 + .byte 0x1 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0xd + .uleb128 0x21 + .byte 0 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x2f + .uleb128 0xb + .byte 0 + .byte 0 + .uleb128 0xe + .uleb128 0x26 + .byte 0 + .uleb128 0x49 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0xf + .uleb128 0x2e + .byte 0x1 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x20 + .uleb128 0xb + .uleb128 0x34 + .uleb128 0xc + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x10 + .uleb128 0x5 + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x11 + .uleb128 0x18 + .byte 0 + .byte 0 + .byte 0 + .uleb128 0x12 + .uleb128 0x2e + .byte 0x1 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x40 + .uleb128 0x6 + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x13 + .uleb128 0x1d + .byte 0x1 + .uleb128 0x31 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x58 + .uleb128 0xb + .uleb128 0x59 + .uleb128 0xb + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x14 + .uleb128 0x5 + .byte 0 + .uleb128 0x31 + .uleb128 0x13 + .uleb128 0x2 + .uleb128 0xa + .byte 0 + .byte 0 + .uleb128 0x15 + .uleb128 0x1d + .byte 0x1 + .uleb128 0x31 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x58 + .uleb128 0xb + .uleb128 0x59 + .uleb128 0xb + .byte 0 + .byte 0 + .uleb128 0x16 + .uleb128 0x34 + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3c + .uleb128 0xc + .byte 0 + .byte 0 + .byte 0 + .section .debug_loc,"",%progbits +.Ldebug_loc0: +.LLST0: + .4byte .LFB31 + .4byte .LCFI0 + .2byte 0x2 + .byte 0x7d + .sleb128 0 + .4byte .LCFI0 + .4byte .LFE31 + .2byte 0x2 + .byte 0x7d + .sleb128 8 + .4byte 0 + .4byte 0 + .section .debug_aranges,"",%progbits + .4byte 0x1c + .2byte 0x2 + .4byte .Ldebug_info0 + .byte 0x4 + .byte 0 + .2byte 0 + .2byte 0 + .4byte .LFB31 + .4byte .LFE31-.LFB31 + .4byte 0 + .4byte 0 + .section .debug_ranges,"",%progbits +.Ldebug_ranges0: + .4byte .LFB31 + .4byte .LFE31 + .4byte 0 + .4byte 0 + .section .debug_line,"",%progbits +.Ldebug_line0: + .section .debug_str,"MS",%progbits,1 +.LASF22: + .ascii "_IO_buf_end\000" +.LASF9: + .ascii "__quad_t\000" +.LASF30: + .ascii "_old_offset\000" +.LASF25: + .ascii "_IO_save_end\000" +.LASF5: + .ascii "short int\000" +.LASF8: + .ascii "size_t\000" +.LASF50: + .ascii "GNU C++ 4.6.3\000" +.LASF35: + .ascii "_offset\000" +.LASF19: + .ascii "_IO_write_ptr\000" +.LASF14: + .ascii "_flags\000" +.LASF21: + .ascii "_IO_buf_base\000" +.LASF26: + .ascii "_markers\000" +.LASF16: + .ascii "_IO_read_end\000" +.LASF6: + .ascii "long long int\000" +.LASF34: + .ascii "_lock\000" +.LASF11: + .ascii "long int\000" +.LASF53: + .ascii "printf\000" +.LASF31: + .ascii "_cur_column\000" +.LASF47: + .ascii "_pos\000" +.LASF46: + .ascii "_sbuf\000" +.LASF43: + .ascii "_IO_FILE\000" +.LASF1: + .ascii "unsigned char\000" +.LASF4: + .ascii "signed char\000" +.LASF7: + .ascii "long long unsigned int\000" +.LASF0: + .ascii "unsigned int\000" +.LASF44: + .ascii "_IO_marker\000" +.LASF33: + .ascii "_shortbuf\000" +.LASF18: + .ascii "_IO_write_base\000" +.LASF42: + .ascii "_unused2\000" +.LASF15: + .ascii "_IO_read_ptr\000" +.LASF2: + .ascii "short unsigned int\000" +.LASF13: + .ascii "char\000" +.LASF55: + .ascii "main\000" +.LASF45: + .ascii "_next\000" +.LASF36: + .ascii "__pad1\000" +.LASF37: + .ascii "__pad2\000" +.LASF38: + .ascii "__pad3\000" +.LASF39: + .ascii "__pad4\000" +.LASF40: + .ascii "__pad5\000" +.LASF54: + .ascii "__fmt\000" +.LASF3: + .ascii "long unsigned int\000" +.LASF20: + .ascii "_IO_write_end\000" +.LASF12: + .ascii "__off64_t\000" +.LASF10: + .ascii "__off_t\000" +.LASF27: + .ascii "_chain\000" +.LASF24: + .ascii "_IO_backup_base\000" +.LASF48: + .ascii "stdin\000" +.LASF29: + .ascii "_flags2\000" +.LASF41: + .ascii "_mode\000" +.LASF17: + .ascii "_IO_read_base\000" +.LASF32: + .ascii "_vtable_offset\000" +.LASF51: + .ascii "/home/mgodbolt/dev/gcc-explorer\000" +.LASF23: + .ascii "_IO_save_base\000" +.LASF28: + .ascii "_fileno\000" +.LASF49: + .ascii "stdout\000" +.LASF52: + .ascii "_IO_lock_t\000" + .ident "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3" + .section .note.GNU-stack,"",%progbits diff --git a/test/cases/arm-hellow.asm.directives b/test/cases/arm-hellow.asm.directives new file mode 100644 index 000000000..281185871 --- /dev/null +++ b/test/cases/arm-hellow.asm.directives @@ -0,0 +1,95 @@ +.Ltext0: +main: +.LFB31: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 +.LVL0: + push {r3, lr} +.LCFI0: +.LBB6: +.LBB7: + movs r0, #1 + movw r1, #:lower16:.LC0 + movt r1, #:upper16:.LC0 + bl __printf_chk +.LVL1: +.LBE7: +.LBE6: +.LBB8: +.LBB9: + movs r0, #1 + movw r1, #:lower16:.LC1 + movt r1, #:upper16:.LC1 + bl __printf_chk +.LBE9: +.LBE8: + movs r0, #0 + pop {r3, pc} +.LFE31: +.LC0: + .ascii "Hello world\000" +.LC1: + .ascii "moo\012\000" +.Letext0: +.Ldebug_info0: +.Ldebug_abbrev0: +.Ldebug_loc0: +.LLST0: +.Ldebug_ranges0: +.Ldebug_line0: +.LASF22: +.LASF9: +.LASF30: +.LASF25: +.LASF5: +.LASF8: +.LASF50: +.LASF35: +.LASF19: +.LASF14: +.LASF21: +.LASF26: +.LASF16: +.LASF6: +.LASF34: +.LASF11: +.LASF53: +.LASF31: +.LASF47: +.LASF46: +.LASF43: +.LASF1: +.LASF4: +.LASF7: +.LASF0: +.LASF44: +.LASF33: +.LASF18: +.LASF42: +.LASF15: +.LASF2: +.LASF13: +.LASF55: +.LASF45: +.LASF36: +.LASF37: +.LASF38: +.LASF39: +.LASF40: +.LASF54: +.LASF3: +.LASF20: +.LASF12: +.LASF10: +.LASF27: +.LASF24: +.LASF48: +.LASF29: +.LASF41: +.LASF17: +.LASF32: +.LASF51: +.LASF23: +.LASF28: +.LASF49: +.LASF52: diff --git a/test/cases/arm-hellow.asm.directives.labels b/test/cases/arm-hellow.asm.directives.labels new file mode 100644 index 000000000..19c0c96af --- /dev/null +++ b/test/cases/arm-hellow.asm.directives.labels @@ -0,0 +1,18 @@ +main: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + push {r3, lr} + movs r0, #1 + movw r1, #:lower16:.LC0 + movt r1, #:upper16:.LC0 + bl __printf_chk + movs r0, #1 + movw r1, #:lower16:.LC1 + movt r1, #:upper16:.LC1 + bl __printf_chk + movs r0, #0 + pop {r3, pc} +.LC0: + .ascii "Hello world\000" +.LC1: + .ascii "moo\012\000" diff --git a/test/cases/arm-hellow.asm.directives.labels.comments b/test/cases/arm-hellow.asm.directives.labels.comments new file mode 100644 index 000000000..def5e3fec --- /dev/null +++ b/test/cases/arm-hellow.asm.directives.labels.comments @@ -0,0 +1,16 @@ +main: + push {r3, lr} + movs r0, #1 + movw r1, #:lower16:.LC0 + movt r1, #:upper16:.LC0 + bl __printf_chk + movs r0, #1 + movw r1, #:lower16:.LC1 + movt r1, #:upper16:.LC1 + bl __printf_chk + movs r0, #0 + pop {r3, pc} +.LC0: + .ascii "Hello world\000" +.LC1: + .ascii "moo\012\000" diff --git a/test/cases/arm-static.asm b/test/cases/arm-static.asm new file mode 100644 index 000000000..a62f6c2b4 --- /dev/null +++ b/test/cases/arm-static.asm @@ -0,0 +1,19 @@ +LongLong: + .word 123456 + .word 0 + .type Long, %object + .size Long, 4 +Long: + .word 2345 + .type Int, %object + .size Int, 4 +Int: + .word 123 + .type Short, %object + .size Short, 2 +Short: + .short 4660 + .type Char, %object + .size Char, 1 +Char: + .byte -128 diff --git a/test/cases/arm-static.asm.directives b/test/cases/arm-static.asm.directives new file mode 100644 index 000000000..693feadfe --- /dev/null +++ b/test/cases/arm-static.asm.directives @@ -0,0 +1,11 @@ +LongLong: + .word 123456 + .word 0 +Long: + .word 2345 +Int: + .word 123 +Short: + .short 4660 +Char: + .byte -128 diff --git a/test/cases/clang-hellow.asm b/test/cases/clang-hellow.asm new file mode 100644 index 000000000..a33d10f30 --- /dev/null +++ b/test/cases/clang-hellow.asm @@ -0,0 +1,195 @@ + .file "-" + .file 1 "/home/mgodbolt/dev/gcc-explorer/-" + .file 2 "/home/mgodbolt/dev/gcc-explorer/" + .section .debug_info,"",@progbits +.Lsection_info: + .section .debug_abbrev,"",@progbits +.Lsection_abbrev: + .section .debug_aranges,"",@progbits + .section .debug_macinfo,"",@progbits + .section .debug_line,"",@progbits +.Lsection_line: + .section .debug_loc,"",@progbits + .section .debug_pubnames,"",@progbits + .section .debug_pubtypes,"",@progbits + .section .debug_str,"",@progbits +.Lsection_str: + .section .debug_ranges,"",@progbits +.Ldebug_range: + .section .debug_loc,"",@progbits +.Lsection_debug_loc: + .text +.Ltext_begin: + .data + .text + .globl main + .align 16, 0x90 + .type main,@function +main: # @main +.Ltmp2: + .cfi_startproc +.Lfunc_begin0: + .loc 2 2 0 # :2:0 +# BB#0: + pushq %rbp +.Ltmp3: + .cfi_def_cfa_offset 16 +.Ltmp4: + .cfi_offset %rbp, -16 + movq %rsp, %rbp +.Ltmp5: + .cfi_def_cfa_register %rbp + .loc 2 3 1 prologue_end # :3:1 +.Ltmp6: + movl $.L.str, %edi + xorb %al, %al + callq printf + .loc 2 4 3 # :4:3 + movl $str, %edi + callq puts + xorl %eax, %eax + .loc 2 5 1 # :5:1 + popq %rbp + ret +.Ltmp7: +.Ltmp8: + .size main, .Ltmp8-main +.Lfunc_end0: +.Ltmp9: + .cfi_endproc +.Leh_func_end0: + .type .L.str,@object # @.str + .section .rodata.str1.1,"aMS",@progbits,1 +.L.str: + .asciz "Hello world" + .size .L.str, 12 + .type str,@object # @str + .section .rodata,"a",@progbits +str: + .asciz "moo" + .size str, 4 + .text +.Ltext_end: + .data +.Ldata_end: + .text +.Lsection_end1: + .section .debug_info,"",@progbits +.Linfo_begin1: + .long 175 # Length of Compilation Unit Info + .short 2 # DWARF version number + .long .Labbrev_begin # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0xa8 DW_TAG_compile_unit + .ascii "Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)" # DW_AT_producer + .byte 0 + .short 4 # DW_AT_language + .byte 45 # DW_AT_name + .byte 0 + .quad 0 # DW_AT_entry_pc + .long .Lsection_line # DW_AT_stmt_list + .ascii "/home/mgodbolt/dev/gcc-explorer" # DW_AT_comp_dir + .byte 0 + .byte 1 # DW_AT_APPLE_optimized + .byte 2 # Abbrev [2] 0x8b:0x20 DW_TAG_subprogram + .ascii "main" # DW_AT_name + .byte 0 + .byte 2 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .byte 1 # DW_AT_prototyped + .long 171 # DW_AT_type + .byte 1 # DW_AT_external + .quad .Lfunc_begin0 # DW_AT_low_pc + .quad .Lfunc_end0 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 3 # Abbrev [3] 0xab:0x7 DW_TAG_base_type + .ascii "int" # DW_AT_name + .byte 0 + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Linfo_end1: + .section .debug_abbrev,"",@progbits +.Labbrev_begin: + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 8 # DW_FORM_string + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 82 # DW_AT_entry_pc + .byte 1 # DW_FORM_addr + .byte 16 # DW_AT_stmt_list + .byte 6 # DW_FORM_data4 + .byte 27 # DW_AT_comp_dir + .byte 8 # DW_FORM_string + .ascii "\341\177" # DW_AT_APPLE_optimized + .byte 12 # DW_FORM_flag + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 39 # DW_AT_prototyped + .byte 12 # DW_FORM_flag + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 12 # DW_FORM_flag + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 1 # DW_FORM_addr + .byte 64 # DW_AT_frame_base + .byte 10 # DW_FORM_block1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) +.Labbrev_end: + .section .debug_pubnames,"",@progbits +.Lset0 = .Lpubnames_end1-.Lpubnames_begin1 # Length of Public Names Info + .long .Lset0 +.Lpubnames_begin1: + .short 2 # DWARF Version + .long .Linfo_begin1 # Offset of Compilation Unit Info +.Lset1 = .Linfo_end1-.Linfo_begin1 # Compilation Unit Length + .long .Lset1 + .long 139 # DIE offset + .asciz "main" # External Name + .long 0 # End Mark +.Lpubnames_end1: + .section .debug_pubtypes,"",@progbits +.Lset2 = .Lpubtypes_end1-.Lpubtypes_begin1 # Length of Public Types Info + .long .Lset2 +.Lpubtypes_begin1: + .short 2 # DWARF Version + .long .Linfo_begin1 # Offset of Compilation Unit Info +.Lset3 = .Linfo_end1-.Linfo_begin1 # Compilation Unit Length + .long .Lset3 + .long 0 # End Mark +.Lpubtypes_end1: + .section .debug_aranges,"",@progbits + .section .debug_ranges,"",@progbits + .section .debug_macinfo,"",@progbits + .section ".note.GNU-stack","",@progbits diff --git a/test/cases/clang-hellow.asm.directives b/test/cases/clang-hellow.asm.directives new file mode 100644 index 000000000..da4b9bc49 --- /dev/null +++ b/test/cases/clang-hellow.asm.directives @@ -0,0 +1,45 @@ +.Lsection_info: +.Lsection_abbrev: +.Lsection_line: +.Lsection_str: +.Ldebug_range: +.Lsection_debug_loc: +.Ltext_begin: +main: # @main +.Ltmp2: +.Lfunc_begin0: +# BB#0: + pushq %rbp +.Ltmp3: +.Ltmp4: + movq %rsp, %rbp +.Ltmp5: +.Ltmp6: + movl $.L.str, %edi + xorb %al, %al + callq printf + movl $str, %edi + callq puts + xorl %eax, %eax + popq %rbp + ret +.Ltmp7: +.Ltmp8: +.Lfunc_end0: +.Ltmp9: +.Leh_func_end0: +.L.str: + .asciz "Hello world" +str: + .asciz "moo" +.Ltext_end: +.Ldata_end: +.Lsection_end1: +.Linfo_begin1: +.Linfo_end1: +.Labbrev_begin: +.Labbrev_end: +.Lpubnames_begin1: +.Lpubnames_end1: +.Lpubtypes_begin1: +.Lpubtypes_end1: diff --git a/test/cases/clang-hellow.asm.directives.labels b/test/cases/clang-hellow.asm.directives.labels new file mode 100644 index 000000000..1ccff391f --- /dev/null +++ b/test/cases/clang-hellow.asm.directives.labels @@ -0,0 +1,16 @@ +main: # @main +# BB#0: + pushq %rbp + movq %rsp, %rbp + movl $.L.str, %edi + xorb %al, %al + callq printf + movl $str, %edi + callq puts + xorl %eax, %eax + popq %rbp + ret +.L.str: + .asciz "Hello world" +str: + .asciz "moo" diff --git a/test/cases/clang-hellow.asm.directives.labels.comments b/test/cases/clang-hellow.asm.directives.labels.comments new file mode 100644 index 000000000..7925c4450 --- /dev/null +++ b/test/cases/clang-hellow.asm.directives.labels.comments @@ -0,0 +1,15 @@ +main: # @main + pushq %rbp + movq %rsp, %rbp + movl $.L.str, %edi + xorb %al, %al + callq printf + movl $str, %edi + callq puts + xorl %eax, %eax + popq %rbp + ret +.L.str: + .asciz "Hello world" +str: + .asciz "moo" diff --git a/test/cases/clang-static.asm b/test/cases/clang-static.asm new file mode 100644 index 000000000..cae5c6b94 --- /dev/null +++ b/test/cases/clang-static.asm @@ -0,0 +1,24 @@ +Char: + .byte 128 # 0x80 + .size Char, 1 + .type Short,@object # @Short + .globl Short + .align 2 +Short: + .short 4660 # 0x1234 + .size Short, 2 + .type Int,@object # @Int + .globl Int + .align 4 +Int: + .long 123 # 0x7b + .size Int, 4 + .type Long,@object # @Long + .globl Long + .align 8 +Long: + .quad 2345 # 0x929 + .size Long, 8 + .type LongLong,@object # @LongLong + .globl LongLong + .align 8 diff --git a/test/cases/clang-static.asm.directives b/test/cases/clang-static.asm.directives new file mode 100644 index 000000000..e5f7baa67 --- /dev/null +++ b/test/cases/clang-static.asm.directives @@ -0,0 +1,8 @@ +Char: + .byte 128 # 0x80 +Short: + .short 4660 # 0x1234 +Int: + .long 123 # 0x7b +Long: + .quad 2345 # 0x929 diff --git a/test/cases/gcc4.6-hellow.asm b/test/cases/gcc4.6-hellow.asm new file mode 100644 index 000000000..571930e66 --- /dev/null +++ b/test/cases/gcc4.6-hellow.asm @@ -0,0 +1,940 @@ + .file "" + .text +.Ltext0: + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "Hello world" +.LC1: + .string "moo\n" + .section .text.startup,"ax",@progbits + .p2align 4,,15 + .globl main + .type main, @function +main: +.LFB31: + .file 1 "" + .loc 1 2 0 + .cfi_startproc +.LVL0: + subq $8, %rsp +.LCFI0: + .cfi_def_cfa_offset 16 +.LBB6: +.LBB7: + .file 2 "/usr/include/x86_64-linux-gnu/bits/stdio2.h" + .loc 2 105 0 + movl $.LC0, %esi + movl $1, %edi + xorl %eax, %eax + call __printf_chk +.LVL1: +.LBE7: +.LBE6: +.LBB8: +.LBB9: + movl $.LC1, %esi + movl $1, %edi + xorl %eax, %eax + call __printf_chk +.LBE9: +.LBE8: + .loc 1 5 0 + xorl %eax, %eax + addq $8, %rsp +.LCFI1: + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE31: + .size main, .-main + .text +.Letext0: + .file 3 "/usr/lib/gcc/x86_64-linux-gnu/4.6/include/stddef.h" + .file 4 "/usr/include/x86_64-linux-gnu/bits/types.h" + .file 5 "/usr/include/libio.h" + .file 6 "/usr/include/stdio.h" + .section .debug_info,"",@progbits +.Ldebug_info0: + .long 0x398 + .value 0x2 + .long .Ldebug_abbrev0 + .byte 0x8 + .uleb128 0x1 + .long .LASF47 + .byte 0x4 + .long .LASF48 + .quad 0 + .quad 0 + .long .Ldebug_ranges0+0 + .long .Ldebug_line0 + .uleb128 0x2 + .long .LASF7 + .byte 0x3 + .byte 0xd4 + .long 0x38 + .uleb128 0x3 + .byte 0x8 + .byte 0x7 + .long .LASF0 + .uleb128 0x3 + .byte 0x1 + .byte 0x8 + .long .LASF1 + .uleb128 0x3 + .byte 0x2 + .byte 0x7 + .long .LASF2 + .uleb128 0x3 + .byte 0x4 + .byte 0x7 + .long .LASF3 + .uleb128 0x3 + .byte 0x1 + .byte 0x6 + .long .LASF4 + .uleb128 0x3 + .byte 0x2 + .byte 0x5 + .long .LASF5 + .uleb128 0x4 + .byte 0x4 + .byte 0x5 + .string "int" + .uleb128 0x3 + .byte 0x8 + .byte 0x5 + .long .LASF6 + .uleb128 0x2 + .long .LASF8 + .byte 0x4 + .byte 0x8d + .long 0x69 + .uleb128 0x2 + .long .LASF9 + .byte 0x4 + .byte 0x8e + .long 0x69 + .uleb128 0x5 + .byte 0x8 + .uleb128 0x6 + .byte 0x8 + .long 0x8e + .uleb128 0x3 + .byte 0x1 + .byte 0x6 + .long .LASF10 + .uleb128 0x7 + .long .LASF40 + .byte 0xd8 + .byte 0x5 + .value 0x111 + .long 0x262 + .uleb128 0x8 + .long .LASF11 + .byte 0x5 + .value 0x112 + .long 0x62 + .byte 0x2 + .byte 0x23 + .uleb128 0 + .uleb128 0x8 + .long .LASF12 + .byte 0x5 + .value 0x117 + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x8 + .uleb128 0x8 + .long .LASF13 + .byte 0x5 + .value 0x118 + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x10 + .uleb128 0x8 + .long .LASF14 + .byte 0x5 + .value 0x119 + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x18 + .uleb128 0x8 + .long .LASF15 + .byte 0x5 + .value 0x11a + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x20 + .uleb128 0x8 + .long .LASF16 + .byte 0x5 + .value 0x11b + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x28 + .uleb128 0x8 + .long .LASF17 + .byte 0x5 + .value 0x11c + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x30 + .uleb128 0x8 + .long .LASF18 + .byte 0x5 + .value 0x11d + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x38 + .uleb128 0x8 + .long .LASF19 + .byte 0x5 + .value 0x11e + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x40 + .uleb128 0x8 + .long .LASF20 + .byte 0x5 + .value 0x120 + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x48 + .uleb128 0x8 + .long .LASF21 + .byte 0x5 + .value 0x121 + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x50 + .uleb128 0x8 + .long .LASF22 + .byte 0x5 + .value 0x122 + .long 0x88 + .byte 0x2 + .byte 0x23 + .uleb128 0x58 + .uleb128 0x8 + .long .LASF23 + .byte 0x5 + .value 0x124 + .long 0x2ac + .byte 0x2 + .byte 0x23 + .uleb128 0x60 + .uleb128 0x8 + .long .LASF24 + .byte 0x5 + .value 0x126 + .long 0x2b2 + .byte 0x2 + .byte 0x23 + .uleb128 0x68 + .uleb128 0x8 + .long .LASF25 + .byte 0x5 + .value 0x128 + .long 0x62 + .byte 0x2 + .byte 0x23 + .uleb128 0x70 + .uleb128 0x8 + .long .LASF26 + .byte 0x5 + .value 0x12c + .long 0x62 + .byte 0x2 + .byte 0x23 + .uleb128 0x74 + .uleb128 0x8 + .long .LASF27 + .byte 0x5 + .value 0x12e + .long 0x70 + .byte 0x2 + .byte 0x23 + .uleb128 0x78 + .uleb128 0x8 + .long .LASF28 + .byte 0x5 + .value 0x132 + .long 0x46 + .byte 0x3 + .byte 0x23 + .uleb128 0x80 + .uleb128 0x8 + .long .LASF29 + .byte 0x5 + .value 0x133 + .long 0x54 + .byte 0x3 + .byte 0x23 + .uleb128 0x82 + .uleb128 0x8 + .long .LASF30 + .byte 0x5 + .value 0x134 + .long 0x2b8 + .byte 0x3 + .byte 0x23 + .uleb128 0x83 + .uleb128 0x8 + .long .LASF31 + .byte 0x5 + .value 0x138 + .long 0x2c8 + .byte 0x3 + .byte 0x23 + .uleb128 0x88 + .uleb128 0x8 + .long .LASF32 + .byte 0x5 + .value 0x141 + .long 0x7b + .byte 0x3 + .byte 0x23 + .uleb128 0x90 + .uleb128 0x8 + .long .LASF33 + .byte 0x5 + .value 0x14a + .long 0x86 + .byte 0x3 + .byte 0x23 + .uleb128 0x98 + .uleb128 0x8 + .long .LASF34 + .byte 0x5 + .value 0x14b + .long 0x86 + .byte 0x3 + .byte 0x23 + .uleb128 0xa0 + .uleb128 0x8 + .long .LASF35 + .byte 0x5 + .value 0x14c + .long 0x86 + .byte 0x3 + .byte 0x23 + .uleb128 0xa8 + .uleb128 0x8 + .long .LASF36 + .byte 0x5 + .value 0x14d + .long 0x86 + .byte 0x3 + .byte 0x23 + .uleb128 0xb0 + .uleb128 0x8 + .long .LASF37 + .byte 0x5 + .value 0x14e + .long 0x2d + .byte 0x3 + .byte 0x23 + .uleb128 0xb8 + .uleb128 0x8 + .long .LASF38 + .byte 0x5 + .value 0x150 + .long 0x62 + .byte 0x3 + .byte 0x23 + .uleb128 0xc0 + .uleb128 0x8 + .long .LASF39 + .byte 0x5 + .value 0x152 + .long 0x2ce + .byte 0x3 + .byte 0x23 + .uleb128 0xc4 + .byte 0 + .uleb128 0x9 + .long .LASF49 + .byte 0x5 + .byte 0xb6 + .uleb128 0xa + .long .LASF41 + .byte 0x18 + .byte 0x5 + .byte 0xbc + .long 0x2a0 + .uleb128 0xb + .long .LASF42 + .byte 0x5 + .byte 0xbd + .long 0x2a0 + .byte 0x2 + .byte 0x23 + .uleb128 0 + .uleb128 0xb + .long .LASF43 + .byte 0x5 + .byte 0xbe + .long 0x2a6 + .byte 0x2 + .byte 0x23 + .uleb128 0x8 + .uleb128 0xb + .long .LASF44 + .byte 0x5 + .byte 0xc2 + .long 0x62 + .byte 0x2 + .byte 0x23 + .uleb128 0x10 + .byte 0 + .uleb128 0x6 + .byte 0x8 + .long 0x269 + .uleb128 0x6 + .byte 0x8 + .long 0x95 + .uleb128 0x6 + .byte 0x8 + .long 0x269 + .uleb128 0x6 + .byte 0x8 + .long 0x95 + .uleb128 0xc + .long 0x8e + .long 0x2c8 + .uleb128 0xd + .long 0x38 + .byte 0 + .byte 0 + .uleb128 0x6 + .byte 0x8 + .long 0x262 + .uleb128 0xc + .long 0x8e + .long 0x2de + .uleb128 0xd + .long 0x38 + .byte 0x13 + .byte 0 + .uleb128 0x6 + .byte 0x8 + .long 0x2e4 + .uleb128 0xe + .long 0x8e + .uleb128 0xf + .byte 0x1 + .long .LASF50 + .byte 0x2 + .byte 0x67 + .long 0x62 + .byte 0x3 + .byte 0x1 + .long 0x308 + .uleb128 0x10 + .long .LASF51 + .byte 0x2 + .byte 0x67 + .long 0x2de + .uleb128 0x11 + .byte 0 + .uleb128 0x12 + .byte 0x1 + .long .LASF52 + .byte 0x1 + .byte 0x2 + .long 0x62 + .quad .LFB31 + .quad .LFE31 + .long .LLST0 + .long 0x381 + .uleb128 0x13 + .long 0x2e9 + .quad .LBB6 + .quad .LBE6 + .byte 0x1 + .byte 0x3 + .long 0x358 + .uleb128 0x14 + .long 0x2fb + .byte 0xa + .byte 0x3 + .quad .LC0 + .byte 0x9f + .byte 0 + .uleb128 0x15 + .long 0x2e9 + .quad .LBB8 + .quad .LBE8 + .byte 0x1 + .byte 0x4 + .uleb128 0x14 + .long 0x2fb + .byte 0xa + .byte 0x3 + .quad .LC1 + .byte 0x9f + .byte 0 + .byte 0 + .uleb128 0x16 + .long .LASF45 + .byte 0x6 + .byte 0xa9 + .long 0x2a6 + .byte 0x1 + .byte 0x1 + .uleb128 0x16 + .long .LASF46 + .byte 0x6 + .byte 0xaa + .long 0x2a6 + .byte 0x1 + .byte 0x1 + .byte 0 + .section .debug_abbrev,"",@progbits +.Ldebug_abbrev0: + .uleb128 0x1 + .uleb128 0x11 + .byte 0x1 + .uleb128 0x25 + .uleb128 0xe + .uleb128 0x13 + .uleb128 0xb + .uleb128 0x1b + .uleb128 0xe + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x52 + .uleb128 0x1 + .uleb128 0x55 + .uleb128 0x6 + .uleb128 0x10 + .uleb128 0x6 + .byte 0 + .byte 0 + .uleb128 0x2 + .uleb128 0x16 + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x3 + .uleb128 0x24 + .byte 0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3e + .uleb128 0xb + .uleb128 0x3 + .uleb128 0xe + .byte 0 + .byte 0 + .uleb128 0x4 + .uleb128 0x24 + .byte 0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3e + .uleb128 0xb + .uleb128 0x3 + .uleb128 0x8 + .byte 0 + .byte 0 + .uleb128 0x5 + .uleb128 0xf + .byte 0 + .uleb128 0xb + .uleb128 0xb + .byte 0 + .byte 0 + .uleb128 0x6 + .uleb128 0xf + .byte 0 + .uleb128 0xb + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x7 + .uleb128 0x13 + .byte 0x1 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0x5 + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x8 + .uleb128 0xd + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0x5 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x38 + .uleb128 0xa + .byte 0 + .byte 0 + .uleb128 0x9 + .uleb128 0x16 + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .byte 0 + .byte 0 + .uleb128 0xa + .uleb128 0x13 + .byte 0x1 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0xb + .uleb128 0xb + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0xb + .uleb128 0xd + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x38 + .uleb128 0xa + .byte 0 + .byte 0 + .uleb128 0xc + .uleb128 0x1 + .byte 0x1 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0xd + .uleb128 0x21 + .byte 0 + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x2f + .uleb128 0xb + .byte 0 + .byte 0 + .uleb128 0xe + .uleb128 0x26 + .byte 0 + .uleb128 0x49 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0xf + .uleb128 0x2e + .byte 0x1 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x20 + .uleb128 0xb + .uleb128 0x34 + .uleb128 0xc + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x10 + .uleb128 0x5 + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x11 + .uleb128 0x18 + .byte 0 + .byte 0 + .byte 0 + .uleb128 0x12 + .uleb128 0x2e + .byte 0x1 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x40 + .uleb128 0x6 + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x13 + .uleb128 0x1d + .byte 0x1 + .uleb128 0x31 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x58 + .uleb128 0xb + .uleb128 0x59 + .uleb128 0xb + .uleb128 0x1 + .uleb128 0x13 + .byte 0 + .byte 0 + .uleb128 0x14 + .uleb128 0x5 + .byte 0 + .uleb128 0x31 + .uleb128 0x13 + .uleb128 0x2 + .uleb128 0xa + .byte 0 + .byte 0 + .uleb128 0x15 + .uleb128 0x1d + .byte 0x1 + .uleb128 0x31 + .uleb128 0x13 + .uleb128 0x11 + .uleb128 0x1 + .uleb128 0x12 + .uleb128 0x1 + .uleb128 0x58 + .uleb128 0xb + .uleb128 0x59 + .uleb128 0xb + .byte 0 + .byte 0 + .uleb128 0x16 + .uleb128 0x34 + .byte 0 + .uleb128 0x3 + .uleb128 0xe + .uleb128 0x3a + .uleb128 0xb + .uleb128 0x3b + .uleb128 0xb + .uleb128 0x49 + .uleb128 0x13 + .uleb128 0x3f + .uleb128 0xc + .uleb128 0x3c + .uleb128 0xc + .byte 0 + .byte 0 + .byte 0 + .section .debug_loc,"",@progbits +.Ldebug_loc0: +.LLST0: + .quad .LFB31 + .quad .LCFI0 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad .LCFI0 + .quad .LCFI1 + .value 0x2 + .byte 0x77 + .sleb128 16 + .quad .LCFI1 + .quad .LFE31 + .value 0x2 + .byte 0x77 + .sleb128 8 + .quad 0 + .quad 0 + .section .debug_aranges,"",@progbits + .long 0x2c + .value 0x2 + .long .Ldebug_info0 + .byte 0x8 + .byte 0 + .value 0 + .value 0 + .quad .LFB31 + .quad .LFE31-.LFB31 + .quad 0 + .quad 0 + .section .debug_ranges,"",@progbits +.Ldebug_ranges0: + .quad .LFB31 + .quad .LFE31 + .quad 0 + .quad 0 + .section .debug_line,"",@progbits +.Ldebug_line0: + .section .debug_str,"MS",@progbits,1 +.LASF19: + .string "_IO_buf_end" +.LASF27: + .string "_old_offset" +.LASF22: + .string "_IO_save_end" +.LASF5: + .string "short int" +.LASF7: + .string "size_t" +.LASF47: + .string "GNU C++ 4.6.3" +.LASF32: + .string "_offset" +.LASF16: + .string "_IO_write_ptr" +.LASF11: + .string "_flags" +.LASF18: + .string "_IO_buf_base" +.LASF23: + .string "_markers" +.LASF13: + .string "_IO_read_end" +.LASF31: + .string "_lock" +.LASF6: + .string "long int" +.LASF50: + .string "printf" +.LASF28: + .string "_cur_column" +.LASF44: + .string "_pos" +.LASF43: + .string "_sbuf" +.LASF40: + .string "_IO_FILE" +.LASF1: + .string "unsigned char" +.LASF4: + .string "signed char" +.LASF3: + .string "unsigned int" +.LASF41: + .string "_IO_marker" +.LASF30: + .string "_shortbuf" +.LASF15: + .string "_IO_write_base" +.LASF39: + .string "_unused2" +.LASF12: + .string "_IO_read_ptr" +.LASF2: + .string "short unsigned int" +.LASF10: + .string "char" +.LASF52: + .string "main" +.LASF42: + .string "_next" +.LASF33: + .string "__pad1" +.LASF34: + .string "__pad2" +.LASF35: + .string "__pad3" +.LASF36: + .string "__pad4" +.LASF37: + .string "__pad5" +.LASF51: + .string "__fmt" +.LASF0: + .string "long unsigned int" +.LASF17: + .string "_IO_write_end" +.LASF9: + .string "__off64_t" +.LASF8: + .string "__off_t" +.LASF24: + .string "_chain" +.LASF21: + .string "_IO_backup_base" +.LASF45: + .string "stdin" +.LASF26: + .string "_flags2" +.LASF38: + .string "_mode" +.LASF14: + .string "_IO_read_base" +.LASF29: + .string "_vtable_offset" +.LASF48: + .string "/home/mgodbolt/dev/gcc-explorer" +.LASF20: + .string "_IO_save_base" +.LASF25: + .string "_fileno" +.LASF46: + .string "stdout" +.LASF49: + .string "_IO_lock_t" + .ident "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3" + .section .note.GNU-stack,"",@progbits diff --git a/test/cases/gcc4.6-hellow.asm.directives b/test/cases/gcc4.6-hellow.asm.directives new file mode 100644 index 000000000..61eed2cb9 --- /dev/null +++ b/test/cases/gcc4.6-hellow.asm.directives @@ -0,0 +1,92 @@ +.Ltext0: +.LC0: + .string "Hello world" +.LC1: + .string "moo\n" +main: +.LFB31: +.LVL0: + subq $8, %rsp +.LCFI0: +.LBB6: +.LBB7: + movl $.LC0, %esi + movl $1, %edi + xorl %eax, %eax + call __printf_chk +.LVL1: +.LBE7: +.LBE6: +.LBB8: +.LBB9: + movl $.LC1, %esi + movl $1, %edi + xorl %eax, %eax + call __printf_chk +.LBE9: +.LBE8: + xorl %eax, %eax + addq $8, %rsp +.LCFI1: + ret +.LFE31: +.Letext0: +.Ldebug_info0: +.Ldebug_abbrev0: +.Ldebug_loc0: +.LLST0: +.Ldebug_ranges0: +.Ldebug_line0: +.LASF19: +.LASF27: +.LASF22: +.LASF5: +.LASF7: +.LASF47: +.LASF32: +.LASF16: +.LASF11: +.LASF18: +.LASF23: +.LASF13: +.LASF31: +.LASF6: +.LASF50: +.LASF28: +.LASF44: +.LASF43: +.LASF40: +.LASF1: +.LASF4: +.LASF3: +.LASF41: +.LASF30: +.LASF15: +.LASF39: +.LASF12: +.LASF2: +.LASF10: +.LASF52: +.LASF42: +.LASF33: +.LASF34: +.LASF35: +.LASF36: +.LASF37: +.LASF51: +.LASF0: +.LASF17: +.LASF9: +.LASF8: +.LASF24: +.LASF21: +.LASF45: +.LASF26: +.LASF38: +.LASF14: +.LASF29: +.LASF48: +.LASF20: +.LASF25: +.LASF46: +.LASF49: diff --git a/test/cases/gcc4.6-hellow.asm.directives.labels b/test/cases/gcc4.6-hellow.asm.directives.labels new file mode 100644 index 000000000..f855f5a2d --- /dev/null +++ b/test/cases/gcc4.6-hellow.asm.directives.labels @@ -0,0 +1,17 @@ +.LC0: + .string "Hello world" +.LC1: + .string "moo\n" +main: + subq $8, %rsp + movl $.LC0, %esi + movl $1, %edi + xorl %eax, %eax + call __printf_chk + movl $.LC1, %esi + movl $1, %edi + xorl %eax, %eax + call __printf_chk + xorl %eax, %eax + addq $8, %rsp + ret diff --git a/test/cases/gcc4.6-hellow.asm.directives.labels.comments b/test/cases/gcc4.6-hellow.asm.directives.labels.comments new file mode 100644 index 000000000..f855f5a2d --- /dev/null +++ b/test/cases/gcc4.6-hellow.asm.directives.labels.comments @@ -0,0 +1,17 @@ +.LC0: + .string "Hello world" +.LC1: + .string "moo\n" +main: + subq $8, %rsp + movl $.LC0, %esi + movl $1, %edi + xorl %eax, %eax + call __printf_chk + movl $.LC1, %esi + movl $1, %edi + xorl %eax, %eax + call __printf_chk + xorl %eax, %eax + addq $8, %rsp + ret diff --git a/test/cases/gcc4.6-static.asm b/test/cases/gcc4.6-static.asm new file mode 100644 index 000000000..ecb21cf31 --- /dev/null +++ b/test/cases/gcc4.6-static.asm @@ -0,0 +1,25 @@ +LongLong: + .quad 123456 + .globl Long + .align 8 + .type Long, @object + .size Long, 8 +Long: + .quad 2345 + .globl Int + .align 4 + .type Int, @object + .size Int, 4 +Int: + .long 123 + .globl Short + .align 2 + .type Short, @object + .size Short, 2 +Short: + .value 4660 + .globl Char + .type Char, @object + .size Char, 1 +Char: + .byte -128 diff --git a/test/cases/gcc4.6-static.asm.directives b/test/cases/gcc4.6-static.asm.directives new file mode 100644 index 000000000..28bbd8438 --- /dev/null +++ b/test/cases/gcc4.6-static.asm.directives @@ -0,0 +1,10 @@ +LongLong: + .quad 123456 +Long: + .quad 2345 +Int: + .long 123 +Short: + .value 4660 +Char: + .byte -128 diff --git a/test/cases/icc-static.asm b/test/cases/icc-static.asm new file mode 100644 index 000000000..475b0caa8 --- /dev/null +++ b/test/cases/icc-static.asm @@ -0,0 +1,23 @@ +LongLong: + .long 0x0001e240,0x00000000 + .type LongLong,@object + .size LongLong,8 + .align 4 + .globl Int +Int: + .long 123 + .type Int,@object + .size Int,4 + .align 2 + .globl Short +Short: + .word 4660 + .type Short,@object + .size Short,2 + .align 1 + .globl Char +Char: + .byte -128 + .type Char,@object + .size Char,1 + .data diff --git a/test/cases/icc-static.asm.directives b/test/cases/icc-static.asm.directives new file mode 100644 index 000000000..61ddec0f1 --- /dev/null +++ b/test/cases/icc-static.asm.directives @@ -0,0 +1,8 @@ +LongLong: + .long 0x0001e240,0x00000000 +Int: + .long 123 +Short: + .word 4660 +Char: + .byte -128 diff --git a/test/cases/icc.hellow.asm b/test/cases/icc.hellow.asm new file mode 100644 index 000000000..8a52bfe08 --- /dev/null +++ b/test/cases/icc.hellow.asm @@ -0,0 +1,322 @@ + .section .text +.LNDBG_TX: +# mark_description "Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1 Build 20120410"; + .file "iccKTGaIssTdIn_" + .text +..TXTST0: +# -- Begin main +# mark_begin; + .align 16,0x90 + .globl main +main: +..B1.1: # Preds ..B1.0 +..___tag_value_main.2: # +..LN0: + .file 1 "-" + .loc 1 2 is_stmt 1 + pushq %rbp #2.12 +..___tag_value_main.4: # +..LN1: + movq %rsp, %rbp #2.12 +..___tag_value_main.5: # +..LN2: + andq $-128, %rsp #2.12 +..LN3: + subq $128, %rsp #2.12 +..LN4: + movl $3, %edi #2.12 +..___tag_value_main.8: #2.12 +..LN5: + call __intel_new_proc_init #2.12 +..___tag_value_main.9: # +..LN6: + # LOE rbx r12 r13 r14 r15 +..B1.6: # Preds ..B1.1 +..LN7: + stmxcsr (%rsp) #2.12 +..LN8: + .loc 1 3 is_stmt 1 + movl $.L_2__STRING.0, %edi #3.1 +..LN9: + xorl %eax, %eax #3.1 +..LN10: + .loc 1 2 is_stmt 1 + orl $32832, (%rsp) #2.12 +..LN11: + ldmxcsr (%rsp) #2.12 +..___tag_value_main.10: #3.1 +..LN12: + .loc 1 3 is_stmt 1 + call printf #3.1 +..___tag_value_main.11: # +..LN13: + # LOE rbx r12 r13 r14 r15 +..B1.2: # Preds ..B1.6 +..LN14: + .loc 1 4 is_stmt 1 + movl $.L_2__STRING.1, %edi #4.3 +..LN15: + xorl %eax, %eax #4.3 +..___tag_value_main.12: #4.3 +..LN16: + call printf #4.3 +..___tag_value_main.13: # +..LN17: + # LOE rbx r12 r13 r14 r15 +..B1.3: # Preds ..B1.2 +..LN18: + .loc 1 5 is_stmt 1 + xorl %eax, %eax #5.1 +..LN19: + movq %rbp, %rsp #5.1 +..LN20: + popq %rbp #5.1 +..___tag_value_main.15: # +..LN21: + ret #5.1 + .align 16,0x90 +..___tag_value_main.19: # +..LN22: + # LOE +..LN23: +# mark_end; + .type main,@function + .size main,.-main +..LNmain.24: +.LNmain: + .data +# -- End main + .section .rodata.str1.4, "aMS",@progbits,1 + .align 4 + .align 4 +.L_2__STRING.0: + .byte 72 + .byte 101 + .byte 108 + .byte 108 + .byte 111 + .byte 32 + .byte 119 + .byte 111 + .byte 114 + .byte 108 + .byte 100 + .byte 0 + .type .L_2__STRING.0,@object + .size .L_2__STRING.0,12 + .align 4 +.L_2__STRING.1: + .byte 109 + .byte 111 + .byte 111 + .byte 10 + .byte 0 + .type .L_2__STRING.1,@object + .size .L_2__STRING.1,5 + .data + .section .note.GNU-stack, "" +// -- Begin DWARF2 SEGMENT .debug_info + .section .debug_info +.debug_info_seg: + .align 1 + .4byte 0x000000fe + .2byte 0x0002 + .4byte .debug_abbrev_seg + .byte 0x08 +// DW_TAG_compile_unit: + .byte 0x01 +// DW_AT_comp_dir: + .8byte 0x676d2f656d6f682f + .8byte 0x642f746c6f62646f + .8byte 0x652d6363672f7665 + .8byte 0x007265726f6c7078 +// DW_AT_language: + .byte 0x04 +// DW_AT_producer: + .8byte 0x2952286c65746e49 + .8byte 0x6c65746e49204320 + .8byte 0x4320343620295228 + .8byte 0x2072656c69706d6f + .8byte 0x6120726f66204558 + .8byte 0x69746163696c7070 + .8byte 0x6e6e757220736e6f + .8byte 0x49206e6f20676e69 + .8byte 0x202952286c65746e + .8byte 0x73726556202c3436 + .8byte 0x312e3231206e6f69 + .8byte 0x3220646c69754220 + .8byte 0x0a30313430323130 + .8byte 0x5320736578694620 + .8byte 0x616b6e694c656d61 + .8byte 0x4d20656d614e6567 + .8byte 0x696f507265626d65 + .4byte 0x7265746e + .2byte 0x0a73 + .byte 0x00 +// DW_AT_stmt_list: + .4byte .debug_line_seg +// DW_TAG_namespace: + .byte 0x02 +// DW_AT_name: + .4byte 0x00647473 +// DW_TAG_namespace: + .byte 0x02 +// DW_AT_name: + .8byte 0x6962617878635f5f + .2byte 0x3176 + .byte 0x00 +// DW_TAG_base_type: + .byte 0x03 +// DW_AT_byte_size: + .byte 0x04 +// DW_AT_encoding: + .byte 0x05 +// DW_AT_name: + .4byte 0x00746e69 +// DW_TAG_subprogram: + .byte 0x04 +// DW_AT_decl_line: + .byte 0x02 +// DW_AT_decl_column: + .byte 0x05 +// DW_AT_decl_file: + .byte 0x01 +// DW_AT_inline: + .byte 0x00 +// DW_AT_accessibility: + .byte 0x01 +// DW_AT_type: + .4byte 0x000000d1 +// DW_AT_prototyped: + .byte 0x01 +// DW_AT_name: + .4byte 0x6e69616d + .byte 0x00 + .4byte 0x6e69616d + .byte 0x00 +// DW_AT_low_pc: + .8byte main +// DW_AT_high_pc: + .8byte ..LNmain.24 +// DW_AT_external: + .byte 0x01 + .byte 0x00 + .byte 0x00 + .byte 0x00 + .byte 0x00 +// -- Begin DWARF2 SEGMENT .debug_line + .section .debug_line +.debug_line_seg: + .align 1 +// -- Begin DWARF2 SEGMENT .debug_abbrev + .section .debug_abbrev +.debug_abbrev_seg: + .align 1 + .byte 0x01 + .byte 0x11 + .byte 0x01 + .byte 0x1b + .byte 0x08 + .byte 0x13 + .byte 0x0b + .byte 0x25 + .byte 0x08 + .byte 0x10 + .byte 0x06 + .2byte 0x0000 + .byte 0x02 + .byte 0x39 + .byte 0x00 + .byte 0x03 + .byte 0x08 + .2byte 0x0000 + .byte 0x03 + .byte 0x24 + .byte 0x00 + .byte 0x0b + .byte 0x0b + .byte 0x3e + .byte 0x0b + .byte 0x03 + .byte 0x08 + .2byte 0x0000 + .byte 0x04 + .byte 0x2e + .byte 0x00 + .byte 0x3b + .byte 0x0b + .byte 0x39 + .byte 0x0b + .byte 0x3a + .byte 0x0b + .byte 0x20 + .byte 0x0b + .byte 0x32 + .byte 0x0b + .byte 0x49 + .byte 0x13 + .byte 0x27 + .byte 0x0c + .byte 0x03 + .byte 0x08 + .2byte 0x4087 + .byte 0x08 + .byte 0x11 + .byte 0x01 + .byte 0x12 + .byte 0x01 + .byte 0x3f + .byte 0x0c + .2byte 0x0000 + .byte 0x00 +// -- Begin DWARF2 SEGMENT .debug_frame + .section .debug_frame +.debug_frame_seg: + .align 1 + .4byte 0x00000014 + .8byte 0x78010001ffffffff + .8byte 0x0000019008070c10 + .4byte 0x00000000 + .4byte 0x00000034 + .4byte .debug_frame_seg + .8byte ..___tag_value_main.2 + .8byte ..___tag_value_main.19-..___tag_value_main.2 + .byte 0x04 + .4byte ..___tag_value_main.4-..___tag_value_main.2 + .2byte 0x100e + .byte 0x04 + .4byte ..___tag_value_main.5-..___tag_value_main.4 + .4byte 0x8610060c + .2byte 0x0402 + .4byte ..___tag_value_main.15-..___tag_value_main.5 + .8byte 0x00000000c608070c + .2byte 0x0000 +// -- Begin DWARF2 SEGMENT .eh_frame + .section .eh_frame,"a",@progbits +.eh_frame_seg: + .align 8 + .4byte 0x0000001c + .8byte 0x00507a0100000000 + .4byte 0x09107801 + .byte 0x00 + .8byte __gxx_personality_v0 + .4byte 0x9008070c + .2byte 0x0001 + .byte 0x00 + .4byte 0x00000034 + .4byte 0x00000024 + .8byte ..___tag_value_main.2 + .8byte ..___tag_value_main.19-..___tag_value_main.2 + .2byte 0x0400 + .4byte ..___tag_value_main.4-..___tag_value_main.2 + .2byte 0x100e + .byte 0x04 + .4byte ..___tag_value_main.5-..___tag_value_main.4 + .4byte 0x8610060c + .2byte 0x0402 + .4byte ..___tag_value_main.15-..___tag_value_main.5 + .8byte 0x00000000c608070c + .byte 0x00 + .section .text +.LNDBG_TXe: +# End diff --git a/test/cases/icc.hellow.asm.directives b/test/cases/icc.hellow.asm.directives new file mode 100644 index 000000000..7d557c1c6 --- /dev/null +++ b/test/cases/icc.hellow.asm.directives @@ -0,0 +1,128 @@ +.LNDBG_TX: +# mark_description "Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1 Build 20120410"; +..TXTST0: +# -- Begin main +# mark_begin; +main: +..B1.1: # Preds ..B1.0 +..___tag_value_main.2: # +..LN0: + pushq %rbp #2.12 +..___tag_value_main.4: # +..LN1: + movq %rsp, %rbp #2.12 +..___tag_value_main.5: # +..LN2: + andq $-128, %rsp #2.12 +..LN3: + subq $128, %rsp #2.12 +..LN4: + movl $3, %edi #2.12 +..___tag_value_main.8: #2.12 +..LN5: + call __intel_new_proc_init #2.12 +..___tag_value_main.9: # +..LN6: + # LOE rbx r12 r13 r14 r15 +..B1.6: # Preds ..B1.1 +..LN7: + stmxcsr (%rsp) #2.12 +..LN8: + movl $.L_2__STRING.0, %edi #3.1 +..LN9: + xorl %eax, %eax #3.1 +..LN10: + orl $32832, (%rsp) #2.12 +..LN11: + ldmxcsr (%rsp) #2.12 +..___tag_value_main.10: #3.1 +..LN12: + call printf #3.1 +..___tag_value_main.11: # +..LN13: + # LOE rbx r12 r13 r14 r15 +..B1.2: # Preds ..B1.6 +..LN14: + movl $.L_2__STRING.1, %edi #4.3 +..LN15: + xorl %eax, %eax #4.3 +..___tag_value_main.12: #4.3 +..LN16: + call printf #4.3 +..___tag_value_main.13: # +..LN17: + # LOE rbx r12 r13 r14 r15 +..B1.3: # Preds ..B1.2 +..LN18: + xorl %eax, %eax #5.1 +..LN19: + movq %rbp, %rsp #5.1 +..LN20: + popq %rbp #5.1 +..___tag_value_main.15: # +..LN21: + ret #5.1 +..___tag_value_main.19: # +..LN22: + # LOE +..LN23: +# mark_end; +..LNmain.24: +.LNmain: +# -- End main +.L_2__STRING.0: + .byte 72 + .byte 101 + .byte 108 + .byte 108 + .byte 111 + .byte 32 + .byte 119 + .byte 111 + .byte 114 + .byte 108 + .byte 100 + .byte 0 +.L_2__STRING.1: + .byte 109 + .byte 111 + .byte 111 + .byte 10 + .byte 0 +// -- Begin DWARF2 SEGMENT .debug_info +.debug_info_seg: +// DW_TAG_compile_unit: +// DW_AT_comp_dir: +// DW_AT_language: +// DW_AT_producer: +// DW_AT_stmt_list: +// DW_TAG_namespace: +// DW_AT_name: +// DW_TAG_namespace: +// DW_AT_name: +// DW_TAG_base_type: +// DW_AT_byte_size: +// DW_AT_encoding: +// DW_AT_name: +// DW_TAG_subprogram: +// DW_AT_decl_line: +// DW_AT_decl_column: +// DW_AT_decl_file: +// DW_AT_inline: +// DW_AT_accessibility: +// DW_AT_type: +// DW_AT_prototyped: +// DW_AT_name: +// DW_AT_low_pc: +// DW_AT_high_pc: +// DW_AT_external: +// -- Begin DWARF2 SEGMENT .debug_line +.debug_line_seg: +// -- Begin DWARF2 SEGMENT .debug_abbrev +.debug_abbrev_seg: +// -- Begin DWARF2 SEGMENT .debug_frame +.debug_frame_seg: +// -- Begin DWARF2 SEGMENT .eh_frame +.eh_frame_seg: +.LNDBG_TXe: +# End diff --git a/test/cases/icc.hellow.asm.directives.labels b/test/cases/icc.hellow.asm.directives.labels new file mode 100644 index 000000000..fb58fa47c --- /dev/null +++ b/test/cases/icc.hellow.asm.directives.labels @@ -0,0 +1,79 @@ +# mark_description "Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1 Build 20120410"; +# -- Begin main +# mark_begin; +main: + pushq %rbp #2.12 + movq %rsp, %rbp #2.12 + andq $-128, %rsp #2.12 + subq $128, %rsp #2.12 + movl $3, %edi #2.12 + call __intel_new_proc_init #2.12 + # LOE rbx r12 r13 r14 r15 + stmxcsr (%rsp) #2.12 + movl $.L_2__STRING.0, %edi #3.1 + xorl %eax, %eax #3.1 + orl $32832, (%rsp) #2.12 + ldmxcsr (%rsp) #2.12 + call printf #3.1 + # LOE rbx r12 r13 r14 r15 + movl $.L_2__STRING.1, %edi #4.3 + xorl %eax, %eax #4.3 + call printf #4.3 + # LOE rbx r12 r13 r14 r15 + xorl %eax, %eax #5.1 + movq %rbp, %rsp #5.1 + popq %rbp #5.1 + ret #5.1 + # LOE +# mark_end; +# -- End main +.L_2__STRING.0: + .byte 72 + .byte 101 + .byte 108 + .byte 108 + .byte 111 + .byte 32 + .byte 119 + .byte 111 + .byte 114 + .byte 108 + .byte 100 + .byte 0 +.L_2__STRING.1: + .byte 109 + .byte 111 + .byte 111 + .byte 10 + .byte 0 +// -- Begin DWARF2 SEGMENT .debug_info +// DW_TAG_compile_unit: +// DW_AT_comp_dir: +// DW_AT_language: +// DW_AT_producer: +// DW_AT_stmt_list: +// DW_TAG_namespace: +// DW_AT_name: +// DW_TAG_namespace: +// DW_AT_name: +// DW_TAG_base_type: +// DW_AT_byte_size: +// DW_AT_encoding: +// DW_AT_name: +// DW_TAG_subprogram: +// DW_AT_decl_line: +// DW_AT_decl_column: +// DW_AT_decl_file: +// DW_AT_inline: +// DW_AT_accessibility: +// DW_AT_type: +// DW_AT_prototyped: +// DW_AT_name: +// DW_AT_low_pc: +// DW_AT_high_pc: +// DW_AT_external: +// -- Begin DWARF2 SEGMENT .debug_line +// -- Begin DWARF2 SEGMENT .debug_abbrev +// -- Begin DWARF2 SEGMENT .debug_frame +// -- Begin DWARF2 SEGMENT .eh_frame +# End diff --git a/test/cases/icc.hellow.asm.directives.labels.comments b/test/cases/icc.hellow.asm.directives.labels.comments new file mode 100644 index 000000000..678cfb947 --- /dev/null +++ b/test/cases/icc.hellow.asm.directives.labels.comments @@ -0,0 +1,39 @@ +main: + pushq %rbp #2.12 + movq %rsp, %rbp #2.12 + andq $-128, %rsp #2.12 + subq $128, %rsp #2.12 + movl $3, %edi #2.12 + call __intel_new_proc_init #2.12 + stmxcsr (%rsp) #2.12 + movl $.L_2__STRING.0, %edi #3.1 + xorl %eax, %eax #3.1 + orl $32832, (%rsp) #2.12 + ldmxcsr (%rsp) #2.12 + call printf #3.1 + movl $.L_2__STRING.1, %edi #4.3 + xorl %eax, %eax #4.3 + call printf #4.3 + xorl %eax, %eax #5.1 + movq %rbp, %rsp #5.1 + popq %rbp #5.1 + ret #5.1 +.L_2__STRING.0: + .byte 72 + .byte 101 + .byte 108 + .byte 108 + .byte 111 + .byte 32 + .byte 119 + .byte 111 + .byte 114 + .byte 108 + .byte 100 + .byte 0 +.L_2__STRING.1: + .byte 109 + .byte 111 + .byte 111 + .byte 10 + .byte 0 diff --git a/test/test.js b/test/test.js new file mode 100755 index 000000000..1de17720d --- /dev/null +++ b/test/test.js @@ -0,0 +1,73 @@ +#!/usr/bin/env node + +// Copyright (c) 2012, 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 fs = require('fs'); +var asm = require('../static/asm.js'); + +function processAsm(filename, filters) { + var file = fs.readFileSync(filename, 'utf-8'); + return asm.processAsm(file, filters); +} + +var cases = fs.readdirSync('./cases') + .filter(function(x){return x.match(/\.asm$/)}) + .map(function(x){return './cases/' + x;}); + +var failures = 0; + +function assertEq(a, b, context) { + if (a != b) { + console.log("Fail: ", a, " != ", b, context); + failures++; + } +} + +function testFilter(filename, suffix, filters) { + var result = processAsm(filename, filters); + var expected = filename + suffix; + try { + var file = fs.readFileSync(expected, 'utf-8').split('\n'); + } catch (e) { + return; + } + assertEq(file.length, result.length, expected); + if (file.length != result.length) return; + for (var i = 0; i < file.length; ++i) { + assertEq(file[i], result[i].text, expected + ":" + (i+1)); + } +} + + +cases.forEach(function(x){ testFilter(x, "", {}) }); +cases.forEach(function(x){ testFilter(x, ".directives", { directives: true}) }); +cases.forEach(function(x){ testFilter(x, ".directives.labels", + { directives: true, labels: true}) }); +cases.forEach(function(x){ testFilter(x, ".directives.labels.comments", + { directives: true, labels: true, commentOnly: true }) }); + +if (failures) { + console.log(failures + " failures"); +}