Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ed623a322 | ||
|
|
ed130fe1b0 | ||
|
|
a2d18a1a72 | ||
|
|
f455e29deb | ||
|
|
03b13d0c87 | ||
|
|
cdbac56b21 | ||
|
|
a5153c7d22 | ||
|
|
7818a79009 | ||
|
|
656c2e01f4 | ||
|
|
0d2c02af46 | ||
|
|
086ee07659 | ||
|
|
efdde9271c | ||
|
|
f7c28ac340 | ||
|
|
17a70c6c9b | ||
|
|
8454abf95e | ||
|
|
d68e7a1f7f | ||
|
|
62f13d4bab | ||
|
|
c1adeddbea | ||
|
|
37131650e5 |
+12
-11
@@ -4,14 +4,15 @@
|
||||
*.ilk
|
||||
*.exp
|
||||
*.lib
|
||||
*.suo
|
||||
|
||||
/rabcasm
|
||||
/rabcdasm
|
||||
/abcexport
|
||||
/abcreplace
|
||||
/swfbinexport
|
||||
/swfbinreplace
|
||||
/swfdecompress
|
||||
/swf7zcompress
|
||||
/swflzmacompress
|
||||
*.suo
|
||||
|
||||
/build_rabcdasm
|
||||
/rabcasm
|
||||
/rabcdasm
|
||||
/abcexport
|
||||
/abcreplace
|
||||
/swfbinexport
|
||||
/swfbinreplace
|
||||
/swfdecompress
|
||||
/swf7zcompress
|
||||
/swflzmacompress
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
RABCDAsm Changelog
|
||||
==================
|
||||
|
||||
RABCDAsm v1.19 (????.??.??)
|
||||
---------------------------
|
||||
|
||||
* Ignore duplicate class names during dependency registration
|
||||
* Make over-estimation of uncompressed SWF size non-fatal
|
||||
* Improve robustness of zlib decompression
|
||||
* Disassemble type `0x00` as `Undefined` instead of `Void`
|
||||
- This matches the terminology used in the AVM specification.
|
||||
- `Void` continues to be recognized as a synonym for `Undefined`.
|
||||
|
||||
RABCDAsm v1.18 (2016.01.16)
|
||||
---------------------------
|
||||
|
||||
|
||||
@@ -141,8 +141,8 @@ use [this handy list][avm2i] as well). You will find it difficult to
|
||||
understand the disassembly without good understanding of concepts such as
|
||||
namespaces and multinames.
|
||||
|
||||
[avm2]: http://www.adobe.com/devnet-archive/actionscript/articles/avm2overview.pdf
|
||||
[avm2i]: http://www.anotherbigidea.com/javaswf/avm2/AVM2Instructions.html
|
||||
[avm2]: https://www.adobe.com/content/dam/acom/en/devnet/pdf/avm2overview.pdf
|
||||
[avm2i]: https://web.archive.org/web/20160215185222/www.anotherbigidea.com/javaswf/avm2/AVM2Instructions.html
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012, 2013, 2014 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* Copyright 2010, 2011, 2012, 2013, 2014, 2021 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* This file is part of RABCDAsm.
|
||||
*
|
||||
* RABCDAsm is free software: you can redistribute it and/or modify
|
||||
@@ -269,8 +269,8 @@ class ABCFile
|
||||
|
||||
enum ASType : ubyte
|
||||
{
|
||||
Void = 0x00, // not actually interned
|
||||
Undefined = Void,
|
||||
Undefined = 0x00,
|
||||
Void = Undefined, // not actually interned
|
||||
Utf8 = 0x01,
|
||||
Decimal = 0x02,
|
||||
Integer = 0x03,
|
||||
@@ -302,7 +302,7 @@ enum ASType : ubyte
|
||||
}
|
||||
|
||||
string[ASType.Max] ASTypeNames = [
|
||||
"Void",
|
||||
"Undefined",
|
||||
"Utf8",
|
||||
"Decimal",
|
||||
"Integer",
|
||||
@@ -340,6 +340,7 @@ static this()
|
||||
{
|
||||
foreach (t, n; ASTypeNames)
|
||||
ASTypeByName[n] = cast(ASType)t;
|
||||
ASTypeByName["Void"] = ASType.Void;
|
||||
ASTypeByName = ASTypeByName.rehash;
|
||||
}
|
||||
|
||||
@@ -544,7 +545,7 @@ enum Opcode : ubyte
|
||||
OP_getglobalscope = 0x64,
|
||||
OP_getscopeobject = 0x65,
|
||||
OP_getproperty = 0x66,
|
||||
OP_getpropertylate = 0x67,
|
||||
OP_getouterscope = 0x67,
|
||||
OP_initproperty = 0x68,
|
||||
OP_setpropertylate = 0x69,
|
||||
OP_deleteproperty = 0x6A,
|
||||
@@ -771,7 +772,7 @@ const OpcodeInfo[256] opcodeInfo = [
|
||||
/* 0x64 */ {"getglobalscope", []},
|
||||
/* 0x65 */ {"getscopeobject", [OpcodeArgumentType.UByteLiteral]},
|
||||
/* 0x66 */ {"getproperty", [OpcodeArgumentType.Multiname]},
|
||||
/* 0x67 */ {"getpropertylate", []},
|
||||
/* 0x67 */ {"getouterscope", [OpcodeArgumentType.UIntLiteral]},
|
||||
/* 0x68 */ {"initproperty", [OpcodeArgumentType.Multiname]},
|
||||
/* 0x69 */ {"setpropertylate", []},
|
||||
/* 0x6A */ {"deleteproperty", [OpcodeArgumentType.Multiname]},
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
</keywords>
|
||||
|
||||
<keywords ignorecase="no" region="ASType">
|
||||
<word name="Undefined"/>
|
||||
<word name="Void"/>
|
||||
<word name="Utf8"/>
|
||||
<word name="Decimal"/>
|
||||
@@ -240,7 +241,7 @@
|
||||
<word name="getglobalscope"/>
|
||||
<word name="getscopeobject"/>
|
||||
<word name="getproperty"/>
|
||||
<word name="getpropertylate"/>
|
||||
<word name="getouterscope"/>
|
||||
<word name="initproperty"/>
|
||||
<word name="setpropertylate"/>
|
||||
<word name="deleteproperty"/>
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012, 2013, 2014 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* Copyright 2010, 2011, 2012, 2013, 2014, 2016 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* This file is part of RABCDAsm.
|
||||
*
|
||||
* RABCDAsm is free software: you can redistribute it and/or modify
|
||||
@@ -981,7 +981,7 @@ private final class AStoABC : ASVisitor
|
||||
ASProgram.Class[] classObjects = classes.getPreliminaryValues();
|
||||
foreach (c; classObjects)
|
||||
{
|
||||
assert(!(c.instance.name in classByName), "Duplicate class name " ~ c.instance.name.toString());
|
||||
//assert(!(c.instance.name in classByName), "Duplicate class name " ~ c.instance.name.toString());
|
||||
classByName[c.instance.name] = c;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012, 2013, 2014, 2015 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* This file is part of RABCDAsm.
|
||||
*
|
||||
* RABCDAsm is free software: you can redistribute it and/or modify
|
||||
@@ -175,7 +175,7 @@ final class Assembler
|
||||
@property char front()
|
||||
{
|
||||
char c;
|
||||
return (c = *ptr) != 0 ? c : (loadNextChunk(), *ptr);
|
||||
return (c = *ptr) != 0 ? c : { loadNextChunk(); return *ptr; }();
|
||||
}
|
||||
|
||||
void popFront()
|
||||
|
||||
+15
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012, 2013 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* Copyright 2010, 2011, 2012, 2013, 2016 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* This file is part of RABCDAsm.
|
||||
*
|
||||
* RABCDAsm is free software: you can redistribute it and/or modify
|
||||
@@ -35,7 +35,7 @@ else
|
||||
const DEFAULT_COMPILER = "gdmd";
|
||||
|
||||
const DEFAULT_FLAGS = "-O -inline";
|
||||
const LZMA_FLAGS = "-version=HAVE_LZMA";
|
||||
const LZMA_FLAGS = ["-version=HAVE_LZMA"];
|
||||
|
||||
import std.exception;
|
||||
import std.file;
|
||||
@@ -43,26 +43,28 @@ import std.process;
|
||||
import std.stdio;
|
||||
import std.string;
|
||||
|
||||
string compiler, flags;
|
||||
string compiler;
|
||||
string[] flags;
|
||||
|
||||
void compile(string program)
|
||||
{
|
||||
stderr.writeln("* Building ", program);
|
||||
enforce(system(format("rdmd --build-only --compiler=%s %s %s", compiler, flags, program)) == 0, "Compilation of " ~ program ~ " failed");
|
||||
enforce(spawnProcess(["rdmd", "--build-only", "--compiler=" ~ compiler] ~ flags ~ program).wait() == 0, "Compilation of " ~ program ~ " failed");
|
||||
}
|
||||
|
||||
void test(string code, string extraFlags=null)
|
||||
void test(string code, in string[] extraFlags=null)
|
||||
{
|
||||
const BASE = "build_rabcdasm_buildtest";
|
||||
const FN = BASE ~ ".d";
|
||||
std.file.write(FN, code);
|
||||
scope(exit) foreach (de; dirEntries(".", BASE ~ "*", SpanMode.shallow)) remove(de.name);
|
||||
enforce(system(format("rdmd --force --compiler=%s -od. %s %s %s", compiler, flags, extraFlags, FN)) == 0, "Test failed");
|
||||
enforce(spawnProcess(["rdmd", "--force", "--compiler=" ~ compiler, "-od."] ~ flags ~ extraFlags ~ FN).wait() == 0, "Test failed");
|
||||
stderr.writeln(" >>> OK");
|
||||
}
|
||||
|
||||
void testBug(string description, int bugId, string code)
|
||||
{
|
||||
stderr.writefln("* Checking for compiler bug %d...", bugId);
|
||||
scope(failure)
|
||||
{
|
||||
stderr.writefln("Compiler bug detected: %s ( https://issues.dlang.org/show_bug.cgi?id=%d ).", description, bugId);
|
||||
@@ -77,20 +79,15 @@ int main(string[] args)
|
||||
{
|
||||
auto programs = ["rabcasm", "rabcdasm", "abcexport", "abcreplace", "swfbinexport", "swfbinreplace", "swfdecompress", "swf7zcompress"];
|
||||
|
||||
compiler = getenv("DC");
|
||||
if (compiler is null)
|
||||
compiler = DEFAULT_COMPILER;
|
||||
|
||||
flags = getenv("DCFLAGS");
|
||||
if (flags is null)
|
||||
flags = DEFAULT_FLAGS;
|
||||
compiler = environment.get("DC", DEFAULT_COMPILER);
|
||||
flags = environment.get("DCFLAGS", DEFAULT_FLAGS).split(" ");
|
||||
|
||||
string[] optionArgs, programArgs;
|
||||
foreach (arg; args[1..$])
|
||||
(arg.startsWith("-") ? optionArgs : programArgs) ~= arg;
|
||||
|
||||
if (optionArgs.length)
|
||||
flags = optionArgs.join(" ");
|
||||
flags = optionArgs;
|
||||
if (programArgs.length)
|
||||
programs = programArgs;
|
||||
|
||||
@@ -99,10 +96,12 @@ int main(string[] args)
|
||||
void main() {}
|
||||
`);
|
||||
|
||||
stderr.writeln("* Checking for known compiler bugs...");
|
||||
testBug("[REG 2.064] Wrong code with -O on x86_64 for char comparisons", 11508, `
|
||||
import assembler; int main() { foreach (c; "_") if (!Assembler.isWordChar(c)) return 1; return 0; }
|
||||
`);
|
||||
testBug("[REG 2.069] Wrong double-to-string conversion with -O", 15861, `
|
||||
import std.format; int main() { return format("%.18g", 4286853117.0) == "4286853117" ? 0 : 1; }
|
||||
`);
|
||||
|
||||
bool haveLZMA;
|
||||
|
||||
@@ -129,7 +128,7 @@ int main(string[] args)
|
||||
stderr.writeln(" >>> LZMA not found, building without LZMA support.");
|
||||
|
||||
if (haveLZMA)
|
||||
flags ~= " " ~ LZMA_FLAGS;
|
||||
flags ~= LZMA_FLAGS;
|
||||
|
||||
foreach (program; programs)
|
||||
compile(program);
|
||||
|
||||
@@ -89,6 +89,9 @@ final class StringBuilder
|
||||
buf[pos++] = c;
|
||||
}
|
||||
|
||||
void opOpAssign(string op : "~", V)(V s) {
|
||||
put(s);
|
||||
}
|
||||
alias put opCatAssign;
|
||||
|
||||
void write(T)(T v)
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010, 2011 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* Copyright 2010, 2011, 2016 Vladimir Panteleev <vladimir@thecybershadow.net>
|
||||
* This file is part of RABCDAsm.
|
||||
*
|
||||
* RABCDAsm is free software: you can redistribute it and/or modify
|
||||
@@ -71,7 +71,7 @@ void main(string[] args)
|
||||
if (header.fileLength != data.length + 8)
|
||||
throw new Exception("Incorrect file length in file header");
|
||||
write(arg ~ ".tempdata", data);
|
||||
if (system(`7z a -tgzip -mx=9 -mfb=258 "` ~ arg ~ `.tempdata.gz" "` ~ arg ~ `.tempdata"`) || !exists(arg ~ ".tempdata.gz"))
|
||||
if (spawnProcess(["7z", "a", "-tgzip", "-mx=9", "-mfb=258", arg ~ ".tempdata.gz", arg ~ ".tempdata"]).wait() || !exists(arg ~ ".tempdata.gz"))
|
||||
throw new Exception("7-Zip failed");
|
||||
remove(arg ~ ".tempdata");
|
||||
auto gzipdata = cast(ubyte[])read(arg ~ ".tempdata.gz");
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
module zlibx;
|
||||
|
||||
import core.memory;
|
||||
import std.string : format;
|
||||
import std.zlib, etc.c.zlib, std.conv;
|
||||
static import etc.c.zlib;
|
||||
alias std.zlib.Z_SYNC_FLUSH Z_SYNC_FLUSH;
|
||||
debug import std.stdio : stderr;
|
||||
|
||||
/// Avoid bug(?) in D zlib implementation with 7zip-generated zlib streams
|
||||
ubyte[] exactUncompress(ubyte[] srcbuf, size_t destlen)
|
||||
@@ -23,24 +26,59 @@ ubyte[] exactUncompress(ubyte[] srcbuf, size_t destlen)
|
||||
err = etc.c.zlib.inflateInit2(&zs, 15);
|
||||
if (err)
|
||||
{
|
||||
delete destbuf;
|
||||
GC.free(destbuf.ptr);
|
||||
throw new ZlibException(err);
|
||||
}
|
||||
|
||||
err = etc.c.zlib.inflate(&zs, Z_SYNC_FLUSH);
|
||||
if (err != Z_OK && err != Z_STREAM_END)
|
||||
while (true)
|
||||
{
|
||||
Lerr:
|
||||
delete destbuf;
|
||||
etc.c.zlib.inflateEnd(&zs);
|
||||
throw new ZlibException(err);
|
||||
err = etc.c.zlib.inflate(&zs, Z_SYNC_FLUSH);
|
||||
if (err != Z_OK && err != Z_STREAM_END)
|
||||
{
|
||||
Lerr:
|
||||
GC.free(destbuf.ptr);
|
||||
etc.c.zlib.inflateEnd(&zs);
|
||||
throw new ZlibException(err);
|
||||
}
|
||||
|
||||
if (err == Z_STREAM_END)
|
||||
break;
|
||||
else
|
||||
if (zs.avail_out == 0)
|
||||
{
|
||||
debug stderr.writefln("Wrong uncompressed file length (read %d/%d bytes and wrote %d/%d bytes)",
|
||||
srcbuf .length - zs.avail_in , srcbuf .length,
|
||||
destlen - zs.avail_out, destlen);
|
||||
auto out_pos = zs.next_out - destbuf.ptr;
|
||||
destbuf.length = 1024 + destbuf.length * 2;
|
||||
zs.next_out = destbuf.ptr + out_pos;
|
||||
zs.avail_out = to!uint(destbuf.length - out_pos);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if (zs.avail_in == 0)
|
||||
{
|
||||
debug stderr.writefln("Unterminated Zlib stream (read %d/%d bytes and wrote %d/%d bytes)",
|
||||
srcbuf .length - zs.avail_in , srcbuf .length,
|
||||
destlen - zs.avail_out, destlen);
|
||||
break;
|
||||
}
|
||||
else
|
||||
throw new Exception(format("Unexpected zlib state (err=%d, avail_in == %d, avail_out = %d)",
|
||||
err, zs.avail_in , zs.avail_out));
|
||||
}
|
||||
if (zs.avail_out != 0)
|
||||
throw new Exception("Too little data in stream");
|
||||
|
||||
if (zs.avail_in != 0 || zs.avail_out != 0)
|
||||
debug stderr.writefln("Zlib stream incongruity (read %d/%d bytes and wrote %d/%d bytes)",
|
||||
srcbuf .length - zs.avail_in , srcbuf .length,
|
||||
destlen - zs.avail_out, destlen);
|
||||
|
||||
err = etc.c.zlib.inflateEnd(&zs);
|
||||
if (err != Z_OK)
|
||||
goto Lerr;
|
||||
|
||||
return destbuf;
|
||||
if (zs.avail_out != 0)
|
||||
debug stderr.writefln("Too little data in zlib stream: expected %d, got %d", destlen, destlen - zs.avail_out);
|
||||
|
||||
return destbuf[0..$-zs.avail_out];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user