Detect AR archives and set the type.

Re-use a less common type code for AR.
Use Dispack generically for all executables and AR archives.
This commit is contained in:
Moinak Ghosh 2013-12-18 23:00:39 +05:30
parent a741f34f78
commit 5521955a94
5 changed files with 11 additions and 6 deletions

View file

@ -1467,6 +1467,8 @@ detect_type_by_data(uchar_t *buf, size_t len)
// At least a few bytes. // At least a few bytes.
if (len < 16) return (TYPE_UNKNOWN); if (len < 16) return (TYPE_UNKNOWN);
if (memcmp(buf, "!<arch>\n", 8) == 0)
return (TYPE_BINARY|TYPE_ARCHIVE_AR);
if (U32_P(buf) == ELFINT) { // Regular ELF, check for 32/64-bit, core dump if (U32_P(buf) == ELFINT) { // Regular ELF, check for 32/64-bit, core dump
if (*(buf + 16) != 4) { if (*(buf + 16) != 4) {
if (*(buf + 4) == 2) { if (*(buf + 4) == 2) {

View file

@ -226,8 +226,11 @@ preproc_compress(pc_ctx_t *pctx, compress_func_ptr cmp_func, void *src, uint64_t
/* /*
* If Dispack is enabled it has to be done first since Dispack analyses the * If Dispack is enabled it has to be done first since Dispack analyses the
* x86 instruction stream in the raw data. * x86 instruction stream in the raw data.
* AR archives are typically static libraries. So we Dispack them unconditionally.
* TODO: Is this too much to assume in the generic case? Can we look inside ar archives?
*/ */
if (pctx->dispack_preprocess && stype == TYPE_EXE32) { if (pctx->dispack_preprocess && (stype == TYPE_EXE32 || stype == TYPE_EXE64 ||
stype == TYPE_ARCHIVE_AR)) {
_dstlen = fromlen; _dstlen = fromlen;
result = dispack_encode((uchar_t *)from, fromlen, to, &_dstlen); result = dispack_encode((uchar_t *)from, fromlen, to, &_dstlen);
if (result != -1) { if (result != -1) {

View file

@ -121,8 +121,8 @@ struct ext_entry {
{"arc" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_ARC, 3}, {"arc" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_ARC, 3},
{"jar" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_GZ, 3}, {"jar" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_GZ, 3},
{"lz" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZ, 2}, {"lz" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZ, 2},
{"lzh" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LH, 3}, {"lzh" , TYPE_BINARY|TYPE_COMPRESSED, 3},
{"lha" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LH, 3}, {"lha" , TYPE_BINARY|TYPE_COMPRESSED, 3},
{"lzma" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZMA, 4}, {"lzma" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZMA, 4},
{"lzo" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZO, 3}, {"lzo" , TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZO, 3},
{"dmg" , TYPE_BINARY, 3}, {"dmg" , TYPE_BINARY, 3},

View file

@ -111,8 +111,8 @@ arj,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_ARJ
arc,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_ARC arc,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_ARC
jar,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_GZ jar,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_GZ
lz,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZ lz,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZ
lzh,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LH lzh,TYPE_BINARY|TYPE_COMPRESSED
lha,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LH lha,TYPE_BINARY|TYPE_COMPRESSED
lzma,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZMA lzma,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZMA
lzo,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZO lzo,TYPE_BINARY|TYPE_COMPRESSED|TYPE_COMPRESSED_LZO
dmg,TYPE_BINARY dmg,TYPE_BINARY

View file

@ -256,7 +256,7 @@ typedef enum {
TYPE_COMPRESSED_ZIP = 56, TYPE_COMPRESSED_ZIP = 56,
TYPE_COMPRESSED_ARJ = 64, TYPE_COMPRESSED_ARJ = 64,
TYPE_COMPRESSED_ARC = 72, TYPE_COMPRESSED_ARC = 72,
TYPE_COMPRESSED_LH = 80, TYPE_ARCHIVE_AR = 80,
TYPE_COMPRESSED_LZMA = 88, TYPE_COMPRESSED_LZMA = 88,
TYPE_COMPRESSED_LZO = 96, TYPE_COMPRESSED_LZO = 96,
TYPE_AVI = 104, TYPE_AVI = 104,