mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-31 16:57:10 +00:00
MFhead @ r275911 (also, sort out MK_* flags in BMAKE, etc on this branch)
This commit is contained in:
commit
afbe8aa46f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/building-blocks/; revision=275913
@ -113,6 +113,8 @@ _REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
|
||||
.for _DIR in ${LOCAL_LIB_DIRS}
|
||||
.if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)
|
||||
SUBDIR+= ${_DIR}
|
||||
.else
|
||||
.warning ${_DIR} not added to SUBDIR list. See UPDATING 20141121.
|
||||
.endif
|
||||
.endfor
|
||||
.endif
|
||||
@ -261,8 +263,9 @@ BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
|
||||
MK_HTML=no MK_INFO=no NO_LINT=yes MK_MAN=no \
|
||||
-DNO_PIC MK_PROFILE=no -DNO_SHARED \
|
||||
-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
|
||||
MK_CLANG_FULL=no MK_LLDB=no MK_TESTS=no \
|
||||
MK_DEBUG_FILES=no
|
||||
MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
|
||||
MK_DEBUG_FILES=no \
|
||||
MK_LLDB=no MK_TESTS=no
|
||||
|
||||
# build-tools stage
|
||||
TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
|
||||
@ -273,9 +276,12 @@ TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
|
||||
SSP_CFLAGS= \
|
||||
-DNO_LINT \
|
||||
-DNO_CPU_CFLAGS \
|
||||
MK_WARNS=no MK_CTF=no MK_CLANG_FULL=no MK_LLDB=no MK_MAN=no \
|
||||
MK_CTF=no \
|
||||
MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
|
||||
MK_DEBUG_FILES=no \
|
||||
MK_LLDB=no MK_MAN=no \
|
||||
MK_SHAREDOCS=no MK_TESTS=no \
|
||||
MK_WARNS=no
|
||||
|
||||
# cross-tools stage
|
||||
XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
|
||||
@ -528,8 +534,9 @@ _worldtmp:
|
||||
-p ${WORLDTMP}/usr/lib >/dev/null
|
||||
.endif
|
||||
.if ${MK_TESTS} != "no"
|
||||
mkdir -p ${WORLDTMP}${TESTSBASE}
|
||||
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
|
||||
-p ${WORLDTMP}/usr >/dev/null
|
||||
-p ${WORLDTMP}${TESTSBASE} >/dev/null
|
||||
.endif
|
||||
.for _mtree in ${LOCAL_MTREE}
|
||||
mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
|
||||
@ -792,7 +799,7 @@ _zoneinfo= zic tzsetup
|
||||
ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
|
||||
date echo egrep find grep id install ${_install-info} \
|
||||
ln lockf make mkdir mtree mv pwd_mkdb \
|
||||
rm sed services_mkdb sh sysctl test true uname wc ${_zoneinfo} \
|
||||
rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
|
||||
${LOCAL_ITOOLS}
|
||||
|
||||
# Needed for share/man
|
||||
@ -868,8 +875,9 @@ distributeworld installworld: _installcheck_world
|
||||
-p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
|
||||
.endif
|
||||
.if ${MK_TESTS} != "no" && ${dist} == "tests"
|
||||
-mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
|
||||
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
|
||||
-p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
|
||||
-p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
|
||||
.endif
|
||||
.if defined(NO_ROOT)
|
||||
${IMAKEENV} mtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
|
||||
@ -1479,7 +1487,8 @@ NXBMAKE= ${NXBENV} ${MAKE} \
|
||||
MK_HTML=no MK_INFO=no NO_LINT=yes MK_MAN=no \
|
||||
-DNO_PIC MK_PROFILE=no -DNO_SHARED \
|
||||
-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
|
||||
MK_CLANG_FULL=no MK_LLDB=no
|
||||
MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
|
||||
MK_LLDB=no
|
||||
|
||||
native-xtools: .MAKE
|
||||
mkdir -p ${OBJTREE}/nxb-bin/bin
|
||||
@ -2093,8 +2102,9 @@ _xi-mtree:
|
||||
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
|
||||
-p ${XDDESTDIR}/usr/include >/dev/null
|
||||
.if ${MK_TESTS} != "no"
|
||||
mkdir -p ${XDDESTDIR}${TESTSBASE}
|
||||
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
|
||||
-p ${XDDESTDIR}/usr >/dev/null
|
||||
-p ${XDDESTDIR}${TESTSBASE} >/dev/null
|
||||
.endif
|
||||
|
||||
.ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
|
||||
|
8
UPDATING
8
UPDATING
@ -31,6 +31,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
|
||||
disable the most expensive debugging functionality run
|
||||
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
|
||||
|
||||
20141121:
|
||||
The handling of LOCAL_LIB_DIRS has been altered to skip addition of
|
||||
directories to top level SUBDIR variable when their parent
|
||||
directory is included in LOCAL_DIRS. Users with build systems with
|
||||
such hierarchies and without SUBDIR entries in the parent
|
||||
directory Makefiles should add them or add the directories to
|
||||
LOCAL_DIRS.
|
||||
|
||||
20141109:
|
||||
faith(4) and faithd(8) has been removed from base system. It
|
||||
has been obsolete for a very long time.
|
||||
|
@ -29,7 +29,7 @@
|
||||
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd August 27, 2014
|
||||
.Dd December 9, 2014
|
||||
.Dt PS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -332,6 +332,7 @@ the include file
|
||||
.It Dv "P_SINGLE_BOUNDARY" Ta No "0x400000" Ta "Threads should suspend at user boundary"
|
||||
.It Dv "P_HWPMC" Ta No "0x800000" Ta "Process is using HWPMCs"
|
||||
.It Dv "P_JAILED" Ta No "0x1000000" Ta "Process is in jail"
|
||||
.It Dv "P_TOTAL_STOP" Ta No "0x2000000" Ta "Stopped for system suspend"
|
||||
.It Dv "P_INEXEC" Ta No "0x4000000" Ta "Process is in execve()"
|
||||
.It Dv "P_STATCHILD" Ta No "0x8000000" Ta "Child process stopped or exited"
|
||||
.It Dv "P_INMEM" Ta No "0x10000000" Ta "Loaded into memory"
|
||||
|
@ -54,6 +54,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include "shell.h"
|
||||
#include "syntax.h"
|
||||
@ -111,42 +113,86 @@ outstr(const char *p, struct output *file)
|
||||
outbin(p, strlen(p), file);
|
||||
}
|
||||
|
||||
static void
|
||||
byteseq(int ch, struct output *file)
|
||||
{
|
||||
char seq[4];
|
||||
|
||||
seq[0] = '\\';
|
||||
seq[1] = (ch >> 6 & 0x3) + '0';
|
||||
seq[2] = (ch >> 3 & 0x7) + '0';
|
||||
seq[3] = (ch & 0x7) + '0';
|
||||
outbin(seq, 4, file);
|
||||
}
|
||||
|
||||
static void
|
||||
outdqstr(const char *p, struct output *file)
|
||||
{
|
||||
const char *end;
|
||||
mbstate_t mbs;
|
||||
size_t clen;
|
||||
wchar_t wc;
|
||||
|
||||
memset(&mbs, '\0', sizeof(mbs));
|
||||
end = p + strlen(p);
|
||||
outstr("$'", file);
|
||||
while ((clen = mbrtowc(&wc, p, end - p + 1, &mbs)) != 0) {
|
||||
if (clen == (size_t)-2) {
|
||||
while (p < end)
|
||||
byteseq(*p++, file);
|
||||
break;
|
||||
}
|
||||
if (clen == (size_t)-1) {
|
||||
memset(&mbs, '\0', sizeof(mbs));
|
||||
byteseq(*p++, file);
|
||||
continue;
|
||||
}
|
||||
if (wc == L'\n')
|
||||
outcslow('\n', file), p++;
|
||||
else if (wc == L'\r')
|
||||
outstr("\\r", file), p++;
|
||||
else if (wc == L'\t')
|
||||
outstr("\\t", file), p++;
|
||||
else if (!iswprint(wc)) {
|
||||
for (; clen > 0; clen--)
|
||||
byteseq(*p++, file);
|
||||
} else {
|
||||
if (wc == L'\'' || wc == L'\\')
|
||||
outcslow('\\', file);
|
||||
outbin(p, clen, file);
|
||||
p += clen;
|
||||
}
|
||||
}
|
||||
outcslow('\'', file);
|
||||
}
|
||||
|
||||
/* Like outstr(), but quote for re-input into the shell. */
|
||||
void
|
||||
outqstr(const char *p, struct output *file)
|
||||
{
|
||||
char ch;
|
||||
int inquotes;
|
||||
int i;
|
||||
|
||||
if (p[0] == '\0') {
|
||||
outstr("''", file);
|
||||
return;
|
||||
}
|
||||
if (p[strcspn(p, "|&;<>()$`\\\"' \t\n*?[~#=")] == '\0' ||
|
||||
for (i = 0; p[i] != '\0'; i++) {
|
||||
if ((p[i] > '\0' && p[i] < ' ' && p[i] != '\n') ||
|
||||
(p[i] & 0x80) != 0 || p[i] == '\'') {
|
||||
outdqstr(p, file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (p[strcspn(p, "|&;<>()$`\\\" \n*?[~#=")] == '\0' ||
|
||||
strcmp(p, "[") == 0) {
|
||||
outstr(p, file);
|
||||
return;
|
||||
}
|
||||
|
||||
inquotes = 0;
|
||||
while ((ch = *p++) != '\0') {
|
||||
switch (ch) {
|
||||
case '\'':
|
||||
/* Can't quote single quotes inside single quotes. */
|
||||
if (inquotes)
|
||||
outcslow('\'', file);
|
||||
inquotes = 0;
|
||||
outstr("\\'", file);
|
||||
break;
|
||||
default:
|
||||
if (!inquotes)
|
||||
outcslow('\'', file);
|
||||
inquotes = 1;
|
||||
outc(ch, file);
|
||||
}
|
||||
}
|
||||
if (inquotes)
|
||||
outcslow('\'', file);
|
||||
outcslow('\'', file);
|
||||
outstr(p, file);
|
||||
outcslow('\'', file);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -44,6 +44,7 @@ FILES+= set-n4.0
|
||||
FILES+= set-x1.0
|
||||
FILES+= set-x2.0
|
||||
FILES+= set-x3.0
|
||||
FILES+= set-x4.0
|
||||
FILES+= shellproc1.0
|
||||
FILES+= subshell1.0 subshell1.0.stdout
|
||||
FILES+= subshell2.0
|
||||
|
7
bin/sh/tests/execution/set-x4.0
Normal file
7
bin/sh/tests/execution/set-x4.0
Normal file
@ -0,0 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
key=`printf '\r\t\001\200\300'`
|
||||
r=`{ set -x; : "$key"; } 2>&1 >/dev/null`
|
||||
case $r in
|
||||
*[![:print:]]*) echo fail; exit 3
|
||||
esac
|
@ -1184,7 +1184,7 @@ visit_indirect(spa_t *spa, const dnode_phys_t *dnp,
|
||||
print_indirect(bp, zb, dnp);
|
||||
|
||||
if (BP_GET_LEVEL(bp) > 0 && !BP_IS_HOLE(bp)) {
|
||||
uint32_t flags = ARC_WAIT;
|
||||
arc_flags_t flags = ARC_FLAG_WAIT;
|
||||
int i;
|
||||
blkptr_t *cbp;
|
||||
int epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT;
|
||||
@ -1884,8 +1884,8 @@ dump_dir(objset_t *os)
|
||||
if (dds.dds_type == DMU_OST_META) {
|
||||
dds.dds_creation_txg = TXG_INITIAL;
|
||||
usedobjs = BP_GET_FILL(os->os_rootbp);
|
||||
refdbytes = os->os_spa->spa_dsl_pool->
|
||||
dp_mos_dir->dd_phys->dd_used_bytes;
|
||||
refdbytes = dsl_dir_phys(os->os_spa->spa_dsl_pool->dp_mos_dir)->
|
||||
dd_used_bytes;
|
||||
} else {
|
||||
dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch);
|
||||
}
|
||||
|
@ -23,15 +23,15 @@
|
||||
.\" Copyright (c) 2012, Glen Barber <gjb@FreeBSD.org>
|
||||
.\" Copyright (c) 2012, Bryan Drewery <bdrewery@FreeBSD.org>
|
||||
.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
||||
.\" Copyright (c) 2013 Nexenta Systems, Inc. All Rights Reserved.
|
||||
.\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
|
||||
.\" Copyright (c) 2013, Steven Hartland <smh@FreeBSD.org>
|
||||
.\" Copyright (c) 2014 Nexenta Systems, Inc. All Rights Reserved.
|
||||
.\" Copyright (c) 2014, Xin LI <delphij@FreeBSD.org>
|
||||
.\" Copyright (c) 2014, The FreeBSD Foundation, All Rights Reserved.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd November 12, 2014
|
||||
.Dd December 12, 2014
|
||||
.Dt ZFS 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -3505,10 +3505,9 @@ are also displayed.
|
||||
.Bd -literal -offset 2n
|
||||
.Li # Ic zfs allow cindys create,destroy,mount,snapshot tank/cindys
|
||||
.Li # Ic zfs allow tank/cindys
|
||||
-------------------------------------------------------------
|
||||
Local+Descendent permissions on (tank/cindys)
|
||||
user cindys create,destroy,mount,snapshot
|
||||
-------------------------------------------------------------
|
||||
---- Permissions on tank/cindys --------------------------------------
|
||||
Local+Descendent permissions:
|
||||
user cindys create,destroy,mount,snapshot
|
||||
.Ed
|
||||
.It Sy Example 18 No Delegating Create Time Permissions on a Tn ZFS No Dataset
|
||||
.Pp
|
||||
@ -3524,12 +3523,11 @@ are also displayed.
|
||||
.Li # Ic zfs allow staff create,mount tank/users
|
||||
.Li # Ic zfs allow -c destroy tank/users
|
||||
.Li # Ic zfs allow tank/users
|
||||
-------------------------------------------------------------
|
||||
Create time permissions on (tank/users)
|
||||
create,destroy
|
||||
Local+Descendent permissions on (tank/users)
|
||||
group staff create,mount
|
||||
-------------------------------------------------------------
|
||||
---- Permissions on tank/users ---------------------------------------
|
||||
Permission sets:
|
||||
destroy
|
||||
Local+Descendent permissions:
|
||||
group staff create,mount
|
||||
.Ed
|
||||
.It Xo
|
||||
.Sy Example 19
|
||||
@ -3547,14 +3545,11 @@ are also displayed.
|
||||
.Li # Ic zfs allow -s @pset create,destroy,snapshot,mount tank/users
|
||||
.Li # Ic zfs allow staff @pset tank/users
|
||||
.Li # Ic zfs allow tank/users
|
||||
-------------------------------------------------------------
|
||||
Permission sets on (tank/users)
|
||||
---- Permissions on tank/users ---------------------------------------
|
||||
Permission sets:
|
||||
@pset create,destroy,mount,snapshot
|
||||
Create time permissions on (tank/users)
|
||||
create,destroy
|
||||
Local+Descendent permissions on (tank/users)
|
||||
group staff @pset,create,mount
|
||||
-------------------------------------------------------------
|
||||
Local+Descendent permissions:
|
||||
group staff @pset
|
||||
.Ed
|
||||
.It Sy Example 20 No Delegating Property Permissions on a Tn ZFS No Dataset
|
||||
.Pp
|
||||
@ -3566,16 +3561,15 @@ file system. The permissions on
|
||||
are also displayed.
|
||||
.Bd -literal -offset 2n
|
||||
.Li # Ic zfs allow cindys quota,reservation users/home
|
||||
.Li # Ic zfs allow cindys
|
||||
-------------------------------------------------------------
|
||||
Local+Descendent permissions on (users/home)
|
||||
.Li # Ic zfs allow users/home
|
||||
---- Permissions on users/home ---------------------------------------
|
||||
Local+Descendent permissions:
|
||||
user cindys quota,reservation
|
||||
-------------------------------------------------------------
|
||||
.Li # Ic su - cindys
|
||||
.Li cindys% Ic zfs set quota=10G users/home/marks
|
||||
.Li cindys% Ic zfs get quota users/home/marks
|
||||
NAME PROPERTY VALUE SOURCE
|
||||
users/home/marks quota 10G local
|
||||
NAME PROPERTY VALUE SOURCE
|
||||
users/home/marks quota 10G local
|
||||
.Ed
|
||||
.It Sy Example 21 No Removing ZFS Delegated Permissions on a Tn ZFS No Dataset
|
||||
.Pp
|
||||
@ -3589,14 +3583,11 @@ are also displayed.
|
||||
.Bd -literal -offset 2n
|
||||
.Li # Ic zfs unallow staff snapshot tank/users
|
||||
.Li # Ic zfs allow tank/users
|
||||
-------------------------------------------------------------
|
||||
Permission sets on (tank/users)
|
||||
---- Permissions on tank/users ---------------------------------------
|
||||
Permission sets:
|
||||
@pset create,destroy,mount,snapshot
|
||||
Create time permissions on (tank/users)
|
||||
create,destroy
|
||||
Local+Descendent permissions on (tank/users)
|
||||
group staff @pset,create,mount
|
||||
-------------------------------------------------------------
|
||||
Local+Descendent permissions:
|
||||
group staff @pset
|
||||
.Ed
|
||||
.It Sy Example 22 Showing the differences between a snapshot and a ZFS Dataset
|
||||
.Pp
|
||||
|
@ -110,7 +110,7 @@ dtrace_dof_init(void)
|
||||
Elf32_Ehdr *elf;
|
||||
#endif
|
||||
dof_helper_t dh;
|
||||
Link_map *lmp;
|
||||
Link_map *lmp = NULL;
|
||||
#if defined(sun)
|
||||
Lmid_t lmid;
|
||||
#else
|
||||
|
@ -24,7 +24,7 @@
|
||||
* Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
|
||||
* All rights reserved.
|
||||
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
|
||||
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -193,9 +193,6 @@ zfs_iter_bookmarks(zfs_handle_t *zhp, zfs_iter_f func, void *data)
|
||||
fnvlist_add_boolean(props, zfs_prop_to_name(ZFS_PROP_CREATETXG));
|
||||
fnvlist_add_boolean(props, zfs_prop_to_name(ZFS_PROP_CREATION));
|
||||
|
||||
/* Allocate an nvlist to hold the bookmarks. */
|
||||
bmarks = fnvlist_alloc();
|
||||
|
||||
if ((err = lzc_get_bookmarks(zhp->zfs_name, props, &bmarks)) != 0)
|
||||
goto out;
|
||||
|
||||
|
@ -1,3 +1,49 @@
|
||||
2009-02-15 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* elf64-ppc.c (struct _ppc64_elf_section_data): Delete t_symndx,
|
||||
add toc.symndx and toc.add.
|
||||
(ppc64_elf_check_relocs): Don't set htab->tls_get_addr here.
|
||||
Set up toc.add.
|
||||
(get_tls_mask): Add toc_addend param, set from toc.add. Adjust all
|
||||
callers.
|
||||
(ppc64_elf_tls_setup): Set htab->tls_get_addr and tls_get_addr_fd.
|
||||
(branch_reloc_hash_match): New function, extracted from..
|
||||
(ppc64_elf_tls_optimize): ..here.
|
||||
(ppc64_elf_relocate_section): Properly set addends when optimizing
|
||||
tls sequences. Avoid unnecessary reading and writing of insns.
|
||||
Only redo reloc when symbol changed. Bypass symbol checks when
|
||||
using tlsld_got.
|
||||
* elf32-ppc.c (ppc_elf_tls_setup): Correct comment.
|
||||
(branch_reloc_hash_match): New function, extracted from..
|
||||
(ppc_elf_tls_optimize): ..here.
|
||||
(ppc_elf_relocate_section): Avoid unnecessary reading of insns.
|
||||
Don't clear addend on zapped __tls_get_addr reloc.
|
||||
|
||||
2008-08-11 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* elf64-ppc.c (toc_adjusting_stub_needed): Any call via the plt
|
||||
needs r2 valid, not just those to external syms.
|
||||
|
||||
2007-11-06 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* elf32-ppc.c (ppc_elf_check_relocs): Don't refcount tlsld_got here..
|
||||
(ppc_elf_gc_sweep_hook): ..or here..
|
||||
(ppc_elf_tls_optimize): ..or here. Make two passes through the
|
||||
relocs, ensuring that tls_get_addr calls follow gd and ld relocs.
|
||||
(allocate_dynrelocs): Refcount tlsld_got here.
|
||||
(ppc_elf_size_dynamic_sections): Call allocate_dynrelocs before
|
||||
allocating tlsld_got.
|
||||
(ppc_elf_relocate_section): Remove check that a tls_get_addr
|
||||
call follows gd and ld relocs.
|
||||
|
||||
2007-08-13 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* elf64-ppc.c (ADDI_R12_R12, LD_R11_0R2, LD_R2_0R2): Define.
|
||||
Update stub comments.
|
||||
(build_plt_stub): Build two variants, one without "addis".
|
||||
(ppc_build_one_stub): Build stubs without "addis" if possible.
|
||||
(ppc_size_one_stub): Size new stubs.
|
||||
|
||||
2007-07-02 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
* elfxx-mips.c (mips_elf_calculate_relocation): Handle
|
||||
|
@ -1380,6 +1380,9 @@ typedef struct bfd_section
|
||||
/* Nonzero if this section has TLS related relocations. */
|
||||
unsigned int has_tls_reloc:1;
|
||||
|
||||
/* Nonzero if this section has a call to __tls_get_addr. */
|
||||
unsigned int has_tls_get_addr_call:1;
|
||||
|
||||
/* Nonzero if this section has a gp reloc. */
|
||||
unsigned int has_gp_reloc:1;
|
||||
|
||||
@ -1640,11 +1643,11 @@ extern asection bfd_ind_section;
|
||||
/* segment_mark, sec_info_type, use_rela_p, has_tls_reloc, */ \
|
||||
0, 0, 0, 0, \
|
||||
\
|
||||
/* has_gp_reloc, need_finalize_relax, reloc_done, */ \
|
||||
0, 0, 0, \
|
||||
/* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax, */ \
|
||||
0, 0, 0, \
|
||||
\
|
||||
/* vma, lma, size, rawsize */ \
|
||||
0, 0, 0, 0, \
|
||||
/* reloc_done, vma, lma, size, rawsize */ \
|
||||
0, 0, 0, 0, 0, \
|
||||
\
|
||||
/* output_offset, output_section, alignment_power, */ \
|
||||
0, (struct bfd_section *) &SEC, 0, \
|
||||
@ -2896,6 +2899,8 @@ in the instruction. */
|
||||
|
||||
/* PowerPC and PowerPC64 thread-local storage relocations. */
|
||||
BFD_RELOC_PPC_TLS,
|
||||
BFD_RELOC_PPC_TLSGD,
|
||||
BFD_RELOC_PPC_TLSLD,
|
||||
BFD_RELOC_PPC_DTPMOD,
|
||||
BFD_RELOC_PPC_TPREL16,
|
||||
BFD_RELOC_PPC_TPREL16_LO,
|
||||
|
@ -58,10 +58,10 @@ static asection bfd_debug_section =
|
||||
0, 0, 1, 0,
|
||||
/* segment_mark, sec_info_type, use_rela_p, has_tls_reloc, */
|
||||
0, 0, 0, 0,
|
||||
/* has_gp_reloc, need_finalize_relax, reloc_done, */
|
||||
0, 0, 0,
|
||||
/* vma, lma, size, rawsize, */
|
||||
0, 0, 0, 0,
|
||||
/* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax, */
|
||||
0, 0, 0,
|
||||
/* reloc_done, vma, lma, size, rawsize, */
|
||||
0, 0, 0, 0, 0,
|
||||
/* output_offset, output_section, alignment_power, */
|
||||
0, NULL, 0,
|
||||
/* relocation, orelocation, reloc_count, filepos, rel_filepos, */
|
||||
|
@ -746,7 +746,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = {
|
||||
0xffff, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
/* Marker reloc for TLS. */
|
||||
/* Marker relocs for TLS. */
|
||||
HOWTO (R_PPC_TLS,
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
@ -761,6 +761,34 @@ static reloc_howto_type ppc_elf_howto_raw[] = {
|
||||
0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPC_TLSGD,
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_PPC_TLSGD", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
HOWTO (R_PPC_TLSLD,
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
FALSE, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
"R_PPC_TLSLD", /* name */
|
||||
FALSE, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
0, /* dst_mask */
|
||||
FALSE), /* pcrel_offset */
|
||||
|
||||
/* Computes the load module index of the load module that contains the
|
||||
definition of its TLS sym. */
|
||||
HOWTO (R_PPC_DTPMOD32,
|
||||
@ -1524,6 +1552,8 @@ ppc_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
||||
case BFD_RELOC_CTOR: r = R_PPC_ADDR32; break;
|
||||
case BFD_RELOC_PPC_TOC16: r = R_PPC_TOC16; break;
|
||||
case BFD_RELOC_PPC_TLS: r = R_PPC_TLS; break;
|
||||
case BFD_RELOC_PPC_TLSGD: r = R_PPC_TLSGD; break;
|
||||
case BFD_RELOC_PPC_TLSLD: r = R_PPC_TLSLD; break;
|
||||
case BFD_RELOC_PPC_DTPMOD: r = R_PPC_DTPMOD32; break;
|
||||
case BFD_RELOC_PPC_TPREL16: r = R_PPC_TPREL16; break;
|
||||
case BFD_RELOC_PPC_TPREL16_LO: r = R_PPC_TPREL16_LO; break;
|
||||
@ -2345,16 +2375,34 @@ struct plt_entry
|
||||
bfd_vma glink_offset;
|
||||
};
|
||||
|
||||
/* Of those relocs that might be copied as dynamic relocs, this macro
|
||||
/* Of those relocs that might be copied as dynamic relocs, this function
|
||||
selects those that must be copied when linking a shared library,
|
||||
even when the symbol is local. */
|
||||
|
||||
#define MUST_BE_DYN_RELOC(RTYPE) \
|
||||
((RTYPE) != R_PPC_REL24 \
|
||||
&& (RTYPE) != R_PPC_REL14 \
|
||||
&& (RTYPE) != R_PPC_REL14_BRTAKEN \
|
||||
&& (RTYPE) != R_PPC_REL14_BRNTAKEN \
|
||||
&& (RTYPE) != R_PPC_REL32)
|
||||
static int
|
||||
must_be_dyn_reloc (struct bfd_link_info *info,
|
||||
enum elf_ppc_reloc_type r_type)
|
||||
{
|
||||
switch (r_type)
|
||||
{
|
||||
default:
|
||||
return 1;
|
||||
|
||||
case R_PPC_REL24:
|
||||
case R_PPC_REL14:
|
||||
case R_PPC_REL14_BRTAKEN:
|
||||
case R_PPC_REL14_BRNTAKEN:
|
||||
case R_PPC_REL32:
|
||||
return 0;
|
||||
|
||||
case R_PPC_TPREL32:
|
||||
case R_PPC_TPREL16:
|
||||
case R_PPC_TPREL16_LO:
|
||||
case R_PPC_TPREL16_HI:
|
||||
case R_PPC_TPREL16_HA:
|
||||
return !info->executable;
|
||||
}
|
||||
}
|
||||
|
||||
/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
|
||||
copying dynamic variables from a shared lib into an app's dynbss
|
||||
@ -2421,7 +2469,7 @@ struct ppc_elf_link_hash_table
|
||||
/* The .got.plt section (VxWorks only)*/
|
||||
asection *sgotplt;
|
||||
|
||||
/* Shortcut to .__tls_get_addr. */
|
||||
/* Shortcut to __tls_get_addr. */
|
||||
struct elf_link_hash_entry *tls_get_addr;
|
||||
|
||||
/* The bfd that forced an old-style PLT. */
|
||||
@ -3040,6 +3088,7 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
const Elf_Internal_Rela *rel;
|
||||
const Elf_Internal_Rela *rel_end;
|
||||
asection *got2, *sreloc;
|
||||
struct elf_link_hash_entry *tga;
|
||||
|
||||
if (info->relocatable)
|
||||
return TRUE;
|
||||
@ -3063,6 +3112,8 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
ppc_elf_howto_init ();
|
||||
|
||||
htab = ppc_elf_hash_table (info);
|
||||
tga = elf_link_hash_lookup (&htab->elf, "__tls_get_addr",
|
||||
FALSE, FALSE, TRUE);
|
||||
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
||||
sym_hashes = elf_sym_hashes (abfd);
|
||||
got2 = bfd_get_section_by_name (abfd, ".got2");
|
||||
@ -3074,7 +3125,7 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
unsigned long r_symndx;
|
||||
enum elf_ppc_reloc_type r_type;
|
||||
struct elf_link_hash_entry *h;
|
||||
int tls_type = 0;
|
||||
int tls_type;
|
||||
|
||||
r_symndx = ELF32_R_SYM (rel->r_info);
|
||||
if (r_symndx < symtab_hdr->sh_info)
|
||||
@ -3101,14 +3152,48 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
BFD_ASSERT (h == htab->elf.hgot);
|
||||
}
|
||||
|
||||
tls_type = 0;
|
||||
r_type = ELF32_R_TYPE (rel->r_info);
|
||||
if (h != NULL && h == tga)
|
||||
switch (r_type)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case R_PPC_PLTREL24:
|
||||
case R_PPC_LOCAL24PC:
|
||||
case R_PPC_REL24:
|
||||
case R_PPC_REL14:
|
||||
case R_PPC_REL14_BRTAKEN:
|
||||
case R_PPC_REL14_BRNTAKEN:
|
||||
case R_PPC_ADDR24:
|
||||
case R_PPC_ADDR14:
|
||||
case R_PPC_ADDR14_BRTAKEN:
|
||||
case R_PPC_ADDR14_BRNTAKEN:
|
||||
if (rel != relocs
|
||||
&& (ELF32_R_TYPE (rel[-1].r_info) == R_PPC_TLSGD
|
||||
|| ELF32_R_TYPE (rel[-1].r_info) == R_PPC_TLSLD))
|
||||
/* We have a new-style __tls_get_addr call with a marker
|
||||
reloc. */
|
||||
;
|
||||
else
|
||||
/* Mark this section as having an old-style call. */
|
||||
sec->has_tls_get_addr_call = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
case R_PPC_TLSGD:
|
||||
case R_PPC_TLSLD:
|
||||
/* These special tls relocs tie a call to __tls_get_addr with
|
||||
its parameter symbol. */
|
||||
break;
|
||||
|
||||
case R_PPC_GOT_TLSLD16:
|
||||
case R_PPC_GOT_TLSLD16_LO:
|
||||
case R_PPC_GOT_TLSLD16_HI:
|
||||
case R_PPC_GOT_TLSLD16_HA:
|
||||
htab->tlsld_got.refcount += 1;
|
||||
tls_type = TLS_TLS | TLS_LD;
|
||||
goto dogottls;
|
||||
|
||||
@ -3123,7 +3208,7 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
case R_PPC_GOT_TPREL16_LO:
|
||||
case R_PPC_GOT_TPREL16_HI:
|
||||
case R_PPC_GOT_TPREL16_HA:
|
||||
if (info->shared)
|
||||
if (!info->executable)
|
||||
info->flags |= DF_STATIC_TLS;
|
||||
tls_type = TLS_TLS | TLS_TPREL;
|
||||
goto dogottls;
|
||||
@ -3358,7 +3443,7 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
|
||||
/* This refers only to functions defined in the shared library. */
|
||||
case R_PPC_LOCAL24PC:
|
||||
if (h && h == htab->elf.hgot && htab->plt_type == PLT_UNSET)
|
||||
if (h != NULL && h == htab->elf.hgot && htab->plt_type == PLT_UNSET)
|
||||
{
|
||||
htab->plt_type = PLT_OLD;
|
||||
htab->old_bfd = abfd;
|
||||
@ -3381,7 +3466,11 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
|
||||
/* We shouldn't really be seeing these. */
|
||||
case R_PPC_TPREL32:
|
||||
if (info->shared)
|
||||
case R_PPC_TPREL16:
|
||||
case R_PPC_TPREL16_LO:
|
||||
case R_PPC_TPREL16_HI:
|
||||
case R_PPC_TPREL16_HA:
|
||||
if (!info->executable)
|
||||
info->flags |= DF_STATIC_TLS;
|
||||
goto dodyn;
|
||||
|
||||
@ -3390,14 +3479,6 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
case R_PPC_DTPREL32:
|
||||
goto dodyn;
|
||||
|
||||
case R_PPC_TPREL16:
|
||||
case R_PPC_TPREL16_LO:
|
||||
case R_PPC_TPREL16_HI:
|
||||
case R_PPC_TPREL16_HA:
|
||||
if (info->shared)
|
||||
info->flags |= DF_STATIC_TLS;
|
||||
goto dodyn;
|
||||
|
||||
case R_PPC_REL32:
|
||||
if (h == NULL
|
||||
&& got2 != NULL
|
||||
@ -3488,7 +3569,7 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
dynamic library if we manage to avoid copy relocs for the
|
||||
symbol. */
|
||||
if ((info->shared
|
||||
&& (MUST_BE_DYN_RELOC (r_type)
|
||||
&& (must_be_dyn_reloc (info, r_type)
|
||||
|| (h != NULL
|
||||
&& (! info->symbolic
|
||||
|| h->root.type == bfd_link_hash_defweak
|
||||
@ -3583,7 +3664,7 @@ ppc_elf_check_relocs (bfd *abfd,
|
||||
}
|
||||
|
||||
p->count += 1;
|
||||
if (!MUST_BE_DYN_RELOC (r_type))
|
||||
if (!must_be_dyn_reloc (info, r_type))
|
||||
p->pc_count += 1;
|
||||
}
|
||||
|
||||
@ -3903,9 +3984,6 @@ ppc_elf_gc_sweep_hook (bfd *abfd,
|
||||
case R_PPC_GOT_TLSLD16_LO:
|
||||
case R_PPC_GOT_TLSLD16_HI:
|
||||
case R_PPC_GOT_TLSLD16_HA:
|
||||
htab->tlsld_got.refcount -= 1;
|
||||
/* Fall thru */
|
||||
|
||||
case R_PPC_GOT_TLSGD16:
|
||||
case R_PPC_GOT_TLSGD16_LO:
|
||||
case R_PPC_GOT_TLSGD16_HI:
|
||||
@ -3979,7 +4057,8 @@ ppc_elf_gc_sweep_hook (bfd *abfd,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Set htab->tls_get_addr and call the generic ELF tls_setup function. */
|
||||
/* Set plt output section type, htab->tls_get_addr, and call the
|
||||
generic ELF tls_setup function. */
|
||||
|
||||
asection *
|
||||
ppc_elf_tls_setup (bfd *obfd, struct bfd_link_info *info)
|
||||
@ -4000,6 +4079,43 @@ ppc_elf_tls_setup (bfd *obfd, struct bfd_link_info *info)
|
||||
return _bfd_elf_tls_setup (obfd, info);
|
||||
}
|
||||
|
||||
/* Return TRUE iff REL is a branch reloc with a global symbol matching
|
||||
HASH. */
|
||||
|
||||
static bfd_boolean
|
||||
branch_reloc_hash_match (const bfd *ibfd,
|
||||
const Elf_Internal_Rela *rel,
|
||||
const struct elf_link_hash_entry *hash)
|
||||
{
|
||||
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
|
||||
enum elf_ppc_reloc_type r_type = ELF32_R_TYPE (rel->r_info);
|
||||
unsigned int r_symndx = ELF32_R_SYM (rel->r_info);
|
||||
|
||||
if (r_symndx >= symtab_hdr->sh_info
|
||||
&& (r_type == R_PPC_PLTREL24
|
||||
|| r_type == R_PPC_LOCAL24PC
|
||||
|| r_type == R_PPC_REL14
|
||||
|| r_type == R_PPC_REL14_BRTAKEN
|
||||
|| r_type == R_PPC_REL14_BRNTAKEN
|
||||
|| r_type == R_PPC_REL24
|
||||
|| r_type == R_PPC_ADDR24
|
||||
|| r_type == R_PPC_ADDR14
|
||||
|| r_type == R_PPC_ADDR14_BRTAKEN
|
||||
|| r_type == R_PPC_ADDR14_BRNTAKEN))
|
||||
{
|
||||
struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (ibfd);
|
||||
struct elf_link_hash_entry *h;
|
||||
|
||||
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
||||
while (h->root.type == bfd_link_hash_indirect
|
||||
|| h->root.type == bfd_link_hash_warning)
|
||||
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
||||
if (h == hash)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Run through all the TLS relocs looking for optimization
|
||||
opportunities. */
|
||||
|
||||
@ -4010,187 +4126,204 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED,
|
||||
bfd *ibfd;
|
||||
asection *sec;
|
||||
struct ppc_elf_link_hash_table *htab;
|
||||
int pass;
|
||||
|
||||
if (info->relocatable || info->shared)
|
||||
if (info->relocatable || !info->executable)
|
||||
return TRUE;
|
||||
|
||||
htab = ppc_elf_hash_table (info);
|
||||
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
|
||||
{
|
||||
Elf_Internal_Sym *locsyms = NULL;
|
||||
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
|
||||
/* Make two passes through the relocs. First time check that tls
|
||||
relocs involved in setting up a tls_get_addr call are indeed
|
||||
followed by such a call. If they are not, exclude them from
|
||||
the optimizations done on the second pass. */
|
||||
for (pass = 0; pass < 2; ++pass)
|
||||
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
|
||||
{
|
||||
Elf_Internal_Sym *locsyms = NULL;
|
||||
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
|
||||
|
||||
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
|
||||
if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section))
|
||||
{
|
||||
Elf_Internal_Rela *relstart, *rel, *relend;
|
||||
int expecting_tls_get_addr;
|
||||
for (sec = ibfd->sections; sec != NULL; sec = sec->next)
|
||||
if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section))
|
||||
{
|
||||
Elf_Internal_Rela *relstart, *rel, *relend;
|
||||
|
||||
/* Read the relocations. */
|
||||
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
|
||||
info->keep_memory);
|
||||
if (relstart == NULL)
|
||||
return FALSE;
|
||||
/* Read the relocations. */
|
||||
relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
|
||||
info->keep_memory);
|
||||
if (relstart == NULL)
|
||||
return FALSE;
|
||||
|
||||
expecting_tls_get_addr = 0;
|
||||
relend = relstart + sec->reloc_count;
|
||||
for (rel = relstart; rel < relend; rel++)
|
||||
{
|
||||
enum elf_ppc_reloc_type r_type;
|
||||
unsigned long r_symndx;
|
||||
struct elf_link_hash_entry *h = NULL;
|
||||
char *tls_mask;
|
||||
char tls_set, tls_clear;
|
||||
bfd_boolean is_local;
|
||||
relend = relstart + sec->reloc_count;
|
||||
for (rel = relstart; rel < relend; rel++)
|
||||
{
|
||||
enum elf_ppc_reloc_type r_type;
|
||||
unsigned long r_symndx;
|
||||
struct elf_link_hash_entry *h = NULL;
|
||||
char *tls_mask;
|
||||
char tls_set, tls_clear;
|
||||
bfd_boolean is_local;
|
||||
int expecting_tls_get_addr;
|
||||
bfd_signed_vma *got_count;
|
||||
|
||||
r_symndx = ELF32_R_SYM (rel->r_info);
|
||||
if (r_symndx >= symtab_hdr->sh_info)
|
||||
{
|
||||
struct elf_link_hash_entry **sym_hashes;
|
||||
r_symndx = ELF32_R_SYM (rel->r_info);
|
||||
if (r_symndx >= symtab_hdr->sh_info)
|
||||
{
|
||||
struct elf_link_hash_entry **sym_hashes;
|
||||
|
||||
sym_hashes = elf_sym_hashes (ibfd);
|
||||
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
||||
while (h->root.type == bfd_link_hash_indirect
|
||||
|| h->root.type == bfd_link_hash_warning)
|
||||
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
||||
}
|
||||
sym_hashes = elf_sym_hashes (ibfd);
|
||||
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
||||
while (h->root.type == bfd_link_hash_indirect
|
||||
|| h->root.type == bfd_link_hash_warning)
|
||||
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
||||
}
|
||||
|
||||
is_local = FALSE;
|
||||
if (h == NULL
|
||||
|| !h->def_dynamic)
|
||||
is_local = TRUE;
|
||||
expecting_tls_get_addr = 0;
|
||||
is_local = FALSE;
|
||||
if (h == NULL
|
||||
|| !h->def_dynamic)
|
||||
is_local = TRUE;
|
||||
|
||||
r_type = ELF32_R_TYPE (rel->r_info);
|
||||
switch (r_type)
|
||||
{
|
||||
case R_PPC_GOT_TLSLD16:
|
||||
case R_PPC_GOT_TLSLD16_LO:
|
||||
case R_PPC_GOT_TLSLD16_HI:
|
||||
case R_PPC_GOT_TLSLD16_HA:
|
||||
/* These relocs should never be against a symbol
|
||||
defined in a shared lib. Leave them alone if
|
||||
that turns out to be the case. */
|
||||
expecting_tls_get_addr = 0;
|
||||
htab->tlsld_got.refcount -= 1;
|
||||
if (!is_local)
|
||||
continue;
|
||||
r_type = ELF32_R_TYPE (rel->r_info);
|
||||
switch (r_type)
|
||||
{
|
||||
case R_PPC_GOT_TLSLD16:
|
||||
case R_PPC_GOT_TLSLD16_LO:
|
||||
expecting_tls_get_addr = 1;
|
||||
/* Fall thru */
|
||||
|
||||
/* LD -> LE */
|
||||
tls_set = 0;
|
||||
tls_clear = TLS_LD;
|
||||
expecting_tls_get_addr = 1;
|
||||
break;
|
||||
case R_PPC_GOT_TLSLD16_HI:
|
||||
case R_PPC_GOT_TLSLD16_HA:
|
||||
/* These relocs should never be against a symbol
|
||||
defined in a shared lib. Leave them alone if
|
||||
that turns out to be the case. */
|
||||
if (!is_local)
|
||||
continue;
|
||||
|
||||
case R_PPC_GOT_TLSGD16:
|
||||
case R_PPC_GOT_TLSGD16_LO:
|
||||
case R_PPC_GOT_TLSGD16_HI:
|
||||
case R_PPC_GOT_TLSGD16_HA:
|
||||
if (is_local)
|
||||
/* GD -> LE */
|
||||
/* LD -> LE */
|
||||
tls_set = 0;
|
||||
else
|
||||
/* GD -> IE */
|
||||
tls_set = TLS_TLS | TLS_TPRELGD;
|
||||
tls_clear = TLS_GD;
|
||||
expecting_tls_get_addr = 1;
|
||||
break;
|
||||
tls_clear = TLS_LD;
|
||||
break;
|
||||
|
||||
case R_PPC_GOT_TPREL16:
|
||||
case R_PPC_GOT_TPREL16_LO:
|
||||
case R_PPC_GOT_TPREL16_HI:
|
||||
case R_PPC_GOT_TPREL16_HA:
|
||||
expecting_tls_get_addr = 0;
|
||||
if (is_local)
|
||||
{
|
||||
/* IE -> LE */
|
||||
case R_PPC_GOT_TLSGD16:
|
||||
case R_PPC_GOT_TLSGD16_LO:
|
||||
expecting_tls_get_addr = 1;
|
||||
/* Fall thru */
|
||||
|
||||
case R_PPC_GOT_TLSGD16_HI:
|
||||
case R_PPC_GOT_TLSGD16_HA:
|
||||
if (is_local)
|
||||
/* GD -> LE */
|
||||
tls_set = 0;
|
||||
tls_clear = TLS_TPREL;
|
||||
break;
|
||||
}
|
||||
else
|
||||
else
|
||||
/* GD -> IE */
|
||||
tls_set = TLS_TLS | TLS_TPRELGD;
|
||||
tls_clear = TLS_GD;
|
||||
break;
|
||||
|
||||
case R_PPC_GOT_TPREL16:
|
||||
case R_PPC_GOT_TPREL16_LO:
|
||||
case R_PPC_GOT_TPREL16_HI:
|
||||
case R_PPC_GOT_TPREL16_HA:
|
||||
if (is_local)
|
||||
{
|
||||
/* IE -> LE */
|
||||
tls_set = 0;
|
||||
tls_clear = TLS_TPREL;
|
||||
break;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
case R_PPC_REL14:
|
||||
case R_PPC_REL14_BRTAKEN:
|
||||
case R_PPC_REL14_BRNTAKEN:
|
||||
case R_PPC_REL24:
|
||||
if (expecting_tls_get_addr
|
||||
&& h != NULL
|
||||
&& h == htab->tls_get_addr)
|
||||
{
|
||||
struct plt_entry *ent = find_plt_ent (h, NULL, 0);
|
||||
if (ent != NULL && ent->plt.refcount > 0)
|
||||
ent->plt.refcount -= 1;
|
||||
}
|
||||
expecting_tls_get_addr = 0;
|
||||
continue;
|
||||
if (pass == 0)
|
||||
{
|
||||
if (!expecting_tls_get_addr
|
||||
|| !sec->has_tls_get_addr_call)
|
||||
continue;
|
||||
|
||||
default:
|
||||
expecting_tls_get_addr = 0;
|
||||
continue;
|
||||
}
|
||||
if (rel + 1 < relend
|
||||
&& branch_reloc_hash_match (ibfd, rel + 1,
|
||||
htab->tls_get_addr))
|
||||
continue;
|
||||
|
||||
if (h != NULL)
|
||||
{
|
||||
if (tls_set == 0)
|
||||
{
|
||||
/* We managed to get rid of a got entry. */
|
||||
if (h->got.refcount > 0)
|
||||
h->got.refcount -= 1;
|
||||
}
|
||||
tls_mask = &ppc_elf_hash_entry (h)->tls_mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
Elf_Internal_Sym *sym;
|
||||
bfd_signed_vma *lgot_refs;
|
||||
char *lgot_masks;
|
||||
/* Uh oh, we didn't find the expected call. We
|
||||
could just mark this symbol to exclude it
|
||||
from tls optimization but it's safer to skip
|
||||
the entire section. */
|
||||
sec->has_tls_reloc = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (locsyms == NULL)
|
||||
{
|
||||
locsyms = (Elf_Internal_Sym *) symtab_hdr->contents;
|
||||
if (locsyms == NULL)
|
||||
locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
|
||||
symtab_hdr->sh_info,
|
||||
0, NULL, NULL, NULL);
|
||||
if (locsyms == NULL)
|
||||
{
|
||||
if (elf_section_data (sec)->relocs != relstart)
|
||||
free (relstart);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
sym = locsyms + r_symndx;
|
||||
lgot_refs = elf_local_got_refcounts (ibfd);
|
||||
if (lgot_refs == NULL)
|
||||
abort ();
|
||||
if (tls_set == 0)
|
||||
{
|
||||
/* We managed to get rid of a got entry. */
|
||||
if (lgot_refs[r_symndx] > 0)
|
||||
lgot_refs[r_symndx] -= 1;
|
||||
}
|
||||
lgot_masks = (char *) (lgot_refs + symtab_hdr->sh_info);
|
||||
tls_mask = &lgot_masks[r_symndx];
|
||||
}
|
||||
if (h != NULL)
|
||||
{
|
||||
tls_mask = &ppc_elf_hash_entry (h)->tls_mask;
|
||||
got_count = &h->got.refcount;
|
||||
}
|
||||
else
|
||||
{
|
||||
Elf_Internal_Sym *sym;
|
||||
bfd_signed_vma *lgot_refs;
|
||||
char *lgot_masks;
|
||||
|
||||
*tls_mask |= tls_set;
|
||||
*tls_mask &= ~tls_clear;
|
||||
}
|
||||
if (locsyms == NULL)
|
||||
{
|
||||
locsyms = (Elf_Internal_Sym *) symtab_hdr->contents;
|
||||
if (locsyms == NULL)
|
||||
locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
|
||||
symtab_hdr->sh_info,
|
||||
0, NULL, NULL, NULL);
|
||||
if (locsyms == NULL)
|
||||
{
|
||||
if (elf_section_data (sec)->relocs != relstart)
|
||||
free (relstart);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
sym = locsyms + r_symndx;
|
||||
lgot_refs = elf_local_got_refcounts (ibfd);
|
||||
if (lgot_refs == NULL)
|
||||
abort ();
|
||||
lgot_masks = (char *) (lgot_refs + symtab_hdr->sh_info);
|
||||
tls_mask = &lgot_masks[r_symndx];
|
||||
got_count = &lgot_refs[r_symndx];
|
||||
}
|
||||
|
||||
if (elf_section_data (sec)->relocs != relstart)
|
||||
free (relstart);
|
||||
if (tls_set == 0)
|
||||
{
|
||||
/* We managed to get rid of a got entry. */
|
||||
if (*got_count > 0)
|
||||
*got_count -= 1;
|
||||
}
|
||||
|
||||
if (expecting_tls_get_addr)
|
||||
{
|
||||
struct plt_entry *ent;
|
||||
|
||||
ent = find_plt_ent (htab->tls_get_addr, NULL, 0);
|
||||
if (ent != NULL && ent->plt.refcount > 0)
|
||||
ent->plt.refcount -= 1;
|
||||
}
|
||||
|
||||
*tls_mask |= tls_set;
|
||||
*tls_mask &= ~tls_clear;
|
||||
}
|
||||
|
||||
if (elf_section_data (sec)->relocs != relstart)
|
||||
free (relstart);
|
||||
}
|
||||
|
||||
if (locsyms != NULL
|
||||
&& (symtab_hdr->contents != (unsigned char *) locsyms))
|
||||
{
|
||||
if (!info->keep_memory)
|
||||
free (locsyms);
|
||||
else
|
||||
symtab_hdr->contents = (unsigned char *) locsyms;
|
||||
}
|
||||
|
||||
if (locsyms != NULL
|
||||
&& (symtab_hdr->contents != (unsigned char *) locsyms))
|
||||
{
|
||||
if (!info->keep_memory)
|
||||
free (locsyms);
|
||||
else
|
||||
symtab_hdr->contents = (unsigned char *) locsyms;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -4615,8 +4748,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
|
||||
|
||||
if (eh->tls_mask == (TLS_TLS | TLS_LD)
|
||||
&& !eh->elf.def_dynamic)
|
||||
/* If just an LD reloc, we'll just use htab->tlsld_got.offset. */
|
||||
eh->elf.got.offset = (bfd_vma) -1;
|
||||
{
|
||||
/* If just an LD reloc, we'll just use htab->tlsld_got.offset. */
|
||||
htab->tlsld_got.refcount += 1;
|
||||
eh->elf.got.offset = (bfd_vma) -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bfd_boolean dyn;
|
||||
@ -4664,7 +4800,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
|
||||
if (info->shared)
|
||||
{
|
||||
/* Relocs that use pc_count are those that appear on a call insn,
|
||||
or certain REL relocs (see MUST_BE_DYN_RELOC) that can be
|
||||
or certain REL relocs (see must_be_dyn_reloc) that can be
|
||||
generated via assembly. We want calls to protected symbols to
|
||||
resolve directly to the function rather than going via the plt.
|
||||
If people want function pointer comparisons to work as expected
|
||||
@ -4891,6 +5027,9 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
*local_got = (bfd_vma) -1;
|
||||
}
|
||||
|
||||
/* Allocate space for global sym dynamic relocs. */
|
||||
elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info);
|
||||
|
||||
if (htab->tlsld_got.refcount > 0)
|
||||
{
|
||||
htab->tlsld_got.offset = allocate_got (htab, 8);
|
||||
@ -4900,9 +5039,6 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
|
||||
else
|
||||
htab->tlsld_got.offset = (bfd_vma) -1;
|
||||
|
||||
/* Allocate space for global sym dynamic relocs. */
|
||||
elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info);
|
||||
|
||||
if (htab->got != NULL && htab->plt_type != PLT_VXWORKS)
|
||||
{
|
||||
unsigned int g_o_t = 32768;
|
||||
@ -5754,16 +5890,13 @@ ppc_elf_relocate_section (bfd *output_bfd,
|
||||
for the final instruction stream. */
|
||||
tls_mask = 0;
|
||||
tls_gd = 0;
|
||||
if (IS_PPC_TLS_RELOC (r_type))
|
||||
if (h != NULL)
|
||||
tls_mask = ((struct ppc_elf_link_hash_entry *) h)->tls_mask;
|
||||
else if (local_got_offsets != NULL)
|
||||
{
|
||||
if (h != NULL)
|
||||
tls_mask = ((struct ppc_elf_link_hash_entry *) h)->tls_mask;
|
||||
else if (local_got_offsets != NULL)
|
||||
{
|
||||
char *lgot_masks;
|
||||
lgot_masks = (char *) (local_got_offsets + symtab_hdr->sh_info);
|
||||
tls_mask = lgot_masks[r_symndx];
|
||||
}
|
||||
char *lgot_masks;
|
||||
lgot_masks = (char *) (local_got_offsets + symtab_hdr->sh_info);
|
||||
tls_mask = lgot_masks[r_symndx];
|
||||
}
|
||||
|
||||
/* Ensure reloc mapping code below stays sane. */
|
||||
@ -5870,85 +6003,147 @@ ppc_elf_relocate_section (bfd *output_bfd,
|
||||
case R_PPC_GOT_TLSGD16_LO:
|
||||
tls_gd = TLS_TPRELGD;
|
||||
if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
|
||||
goto tls_get_addr_check;
|
||||
goto tls_ldgd_opt;
|
||||
break;
|
||||
|
||||
case R_PPC_GOT_TLSLD16:
|
||||
case R_PPC_GOT_TLSLD16_LO:
|
||||
if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
|
||||
{
|
||||
tls_get_addr_check:
|
||||
if (rel + 1 < relend)
|
||||
unsigned int insn1, insn2;
|
||||
bfd_vma offset;
|
||||
|
||||
tls_ldgd_opt:
|
||||
offset = (bfd_vma) -1;
|
||||
/* If not using the newer R_PPC_TLSGD/LD to mark
|
||||
__tls_get_addr calls, we must trust that the call
|
||||
stays with its arg setup insns, ie. that the next
|
||||
reloc is the __tls_get_addr call associated with
|
||||
the current reloc. Edit both insns. */
|
||||
if (input_section->has_tls_get_addr_call
|
||||
&& rel + 1 < relend
|
||||
&& branch_reloc_hash_match (input_bfd, rel + 1,
|
||||
htab->tls_get_addr))
|
||||
offset = rel[1].r_offset;
|
||||
if ((tls_mask & tls_gd) != 0)
|
||||
{
|
||||
enum elf_ppc_reloc_type r_type2;
|
||||
unsigned long r_symndx2;
|
||||
struct elf_link_hash_entry *h2;
|
||||
bfd_vma insn1, insn2;
|
||||
bfd_vma offset;
|
||||
|
||||
/* The next instruction should be a call to
|
||||
__tls_get_addr. Peek at the reloc to be sure. */
|
||||
r_type2 = ELF32_R_TYPE (rel[1].r_info);
|
||||
r_symndx2 = ELF32_R_SYM (rel[1].r_info);
|
||||
if (r_symndx2 < symtab_hdr->sh_info
|
||||
|| (r_type2 != R_PPC_REL14
|
||||
&& r_type2 != R_PPC_REL14_BRTAKEN
|
||||
&& r_type2 != R_PPC_REL14_BRNTAKEN
|
||||
&& r_type2 != R_PPC_REL24
|
||||
&& r_type2 != R_PPC_PLTREL24))
|
||||
break;
|
||||
|
||||
h2 = sym_hashes[r_symndx2 - symtab_hdr->sh_info];
|
||||
while (h2->root.type == bfd_link_hash_indirect
|
||||
|| h2->root.type == bfd_link_hash_warning)
|
||||
h2 = (struct elf_link_hash_entry *) h2->root.u.i.link;
|
||||
if (h2 == NULL || h2 != htab->tls_get_addr)
|
||||
break;
|
||||
|
||||
/* OK, it checks out. Replace the call. */
|
||||
offset = rel[1].r_offset;
|
||||
/* IE */
|
||||
insn1 = bfd_get_32 (output_bfd,
|
||||
contents + rel->r_offset - d_offset);
|
||||
if ((tls_mask & tls_gd) != 0)
|
||||
insn1 &= (1 << 26) - 1;
|
||||
insn1 |= 32 << 26; /* lwz */
|
||||
if (offset != (bfd_vma) -1)
|
||||
{
|
||||
/* IE */
|
||||
insn1 &= (1 << 26) - 1;
|
||||
insn1 |= 32 << 26; /* lwz */
|
||||
rel[1].r_info
|
||||
= ELF32_R_INFO (ELF32_R_SYM (rel[1].r_info),
|
||||
R_PPC_NONE);
|
||||
insn2 = 0x7c631214; /* add 3,3,2 */
|
||||
rel[1].r_info = ELF32_R_INFO (r_symndx2, R_PPC_NONE);
|
||||
rel[1].r_addend = 0;
|
||||
r_type = (((r_type - (R_PPC_GOT_TLSGD16 & 3)) & 3)
|
||||
+ R_PPC_GOT_TPREL16);
|
||||
rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
||||
bfd_put_32 (output_bfd, insn2, contents + offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* LE */
|
||||
insn1 = 0x3c620000; /* addis 3,2,0 */
|
||||
insn2 = 0x38630000; /* addi 3,3,0 */
|
||||
if (tls_gd == 0)
|
||||
{
|
||||
/* Was an LD reloc. */
|
||||
r_symndx = 0;
|
||||
rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
|
||||
}
|
||||
r_type = R_PPC_TPREL16_HA;
|
||||
rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
||||
rel[1].r_info = ELF32_R_INFO (r_symndx,
|
||||
R_PPC_TPREL16_LO);
|
||||
rel[1].r_offset += d_offset;
|
||||
rel[1].r_addend = rel->r_addend;
|
||||
}
|
||||
bfd_put_32 (output_bfd, insn1, contents + rel->r_offset - d_offset);
|
||||
bfd_put_32 (output_bfd, insn2, contents + offset);
|
||||
r_type = (((r_type - (R_PPC_GOT_TLSGD16 & 3)) & 3)
|
||||
+ R_PPC_GOT_TPREL16);
|
||||
rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* LE */
|
||||
insn1 = 0x3c620000; /* addis 3,2,0 */
|
||||
if (tls_gd == 0)
|
||||
{
|
||||
/* We changed the symbol on an LD reloc. Start over
|
||||
in order to get h, sym, sec etc. right. */
|
||||
rel--;
|
||||
continue;
|
||||
/* Was an LD reloc. */
|
||||
for (r_symndx = 0;
|
||||
r_symndx < symtab_hdr->sh_info;
|
||||
r_symndx++)
|
||||
if (local_sections[r_symndx] == sec)
|
||||
break;
|
||||
if (r_symndx >= symtab_hdr->sh_info)
|
||||
r_symndx = 0;
|
||||
rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
|
||||
if (r_symndx != 0)
|
||||
rel->r_addend -= (local_syms[r_symndx].st_value
|
||||
+ sec->output_offset
|
||||
+ sec->output_section->vma);
|
||||
}
|
||||
r_type = R_PPC_TPREL16_HA;
|
||||
rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
||||
if (offset != (bfd_vma) -1)
|
||||
{
|
||||
rel[1].r_info = ELF32_R_INFO (r_symndx, R_PPC_TPREL16_LO);
|
||||
rel[1].r_offset = offset + d_offset;
|
||||
rel[1].r_addend = rel->r_addend;
|
||||
insn2 = 0x38630000; /* addi 3,3,0 */
|
||||
bfd_put_32 (output_bfd, insn2, contents + offset);
|
||||
}
|
||||
}
|
||||
bfd_put_32 (output_bfd, insn1,
|
||||
contents + rel->r_offset - d_offset);
|
||||
if (tls_gd == 0)
|
||||
{
|
||||
/* We changed the symbol on an LD reloc. Start over
|
||||
in order to get h, sym, sec etc. right. */
|
||||
rel--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case R_PPC_TLSGD:
|
||||
if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
|
||||
{
|
||||
unsigned int insn2;
|
||||
bfd_vma offset = rel->r_offset;
|
||||
|
||||
if ((tls_mask & TLS_TPRELGD) != 0)
|
||||
{
|
||||
/* IE */
|
||||
r_type = R_PPC_NONE;
|
||||
insn2 = 0x7c631214; /* add 3,3,2 */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* LE */
|
||||
r_type = R_PPC_TPREL16_LO;
|
||||
rel->r_offset += d_offset;
|
||||
insn2 = 0x38630000; /* addi 3,3,0 */
|
||||
}
|
||||
rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
||||
bfd_put_32 (output_bfd, insn2, contents + offset);
|
||||
/* Zap the reloc on the _tls_get_addr call too. */
|
||||
BFD_ASSERT (offset == rel[1].r_offset);
|
||||
rel[1].r_info = ELF32_R_INFO (ELF32_R_SYM (rel[1].r_info),
|
||||
R_PPC_NONE);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_PPC_TLSLD:
|
||||
if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
|
||||
{
|
||||
unsigned int insn2;
|
||||
|
||||
for (r_symndx = 0;
|
||||
r_symndx < symtab_hdr->sh_info;
|
||||
r_symndx++)
|
||||
if (local_sections[r_symndx] == sec)
|
||||
break;
|
||||
if (r_symndx >= symtab_hdr->sh_info)
|
||||
r_symndx = 0;
|
||||
rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
|
||||
if (r_symndx != 0)
|
||||
rel->r_addend -= (local_syms[r_symndx].st_value
|
||||
+ sec->output_offset
|
||||
+ sec->output_section->vma);
|
||||
|
||||
rel->r_info = ELF32_R_INFO (r_symndx, R_PPC_TPREL16_LO);
|
||||
rel->r_offset += d_offset;
|
||||
insn2 = 0x38630000; /* addi 3,3,0 */
|
||||
bfd_put_32 (output_bfd, insn2,
|
||||
contents + rel->r_offset - d_offset);
|
||||
/* Zap the reloc on the _tls_get_addr call too. */
|
||||
BFD_ASSERT (rel->r_offset - d_offset == rel[1].r_offset);
|
||||
rel[1].r_info = ELF32_R_INFO (ELF32_R_SYM (rel[1].r_info),
|
||||
R_PPC_NONE);
|
||||
rel--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -6003,6 +6198,8 @@ ppc_elf_relocate_section (bfd *output_bfd,
|
||||
|
||||
case R_PPC_NONE:
|
||||
case R_PPC_TLS:
|
||||
case R_PPC_TLSGD:
|
||||
case R_PPC_TLSLD:
|
||||
case R_PPC_EMB_MRKREF:
|
||||
case R_PPC_GNU_VTINHERIT:
|
||||
case R_PPC_GNU_VTENTRY:
|
||||
@ -6044,6 +6241,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
|
||||
case R_PPC_GOT16_LO:
|
||||
case R_PPC_GOT16_HI:
|
||||
case R_PPC_GOT16_HA:
|
||||
tls_mask = 0;
|
||||
dogot:
|
||||
{
|
||||
/* Relocation is to the entry for this symbol in the global
|
||||
@ -6342,7 +6540,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
|
||||
&& (h == NULL
|
||||
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
||||
|| h->root.type != bfd_link_hash_undefweak)
|
||||
&& (MUST_BE_DYN_RELOC (r_type)
|
||||
&& (must_be_dyn_reloc (info, r_type)
|
||||
|| !SYMBOL_CALLS_LOCAL (info, h)))
|
||||
|| (ELIMINATE_COPY_RELOCS
|
||||
&& !info->shared
|
||||
@ -6411,10 +6609,10 @@ ppc_elf_relocate_section (bfd *output_bfd,
|
||||
outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
|
||||
else
|
||||
{
|
||||
long indx;
|
||||
long indx = 0;
|
||||
|
||||
if (bfd_is_abs_section (sec))
|
||||
indx = 0;
|
||||
if (r_symndx == 0 || bfd_is_abs_section (sec))
|
||||
;
|
||||
else if (sec == NULL || sec->owner == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1169,6 +1169,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
|
||||
"BFD_RELOC_PPC64_PLTGOT16_DS",
|
||||
"BFD_RELOC_PPC64_PLTGOT16_LO_DS",
|
||||
"BFD_RELOC_PPC_TLS",
|
||||
"BFD_RELOC_PPC_TLSGD",
|
||||
"BFD_RELOC_PPC_TLSLD",
|
||||
"BFD_RELOC_PPC_DTPMOD",
|
||||
"BFD_RELOC_PPC_TPREL16",
|
||||
"BFD_RELOC_PPC_TPREL16_LO",
|
||||
|
@ -2626,6 +2626,10 @@ ENUMDOC
|
||||
|
||||
ENUM
|
||||
BFD_RELOC_PPC_TLS
|
||||
ENUMX
|
||||
BFD_RELOC_PPC_TLSGD
|
||||
ENUMX
|
||||
BFD_RELOC_PPC_TLSLD
|
||||
ENUMX
|
||||
BFD_RELOC_PPC_DTPMOD
|
||||
ENUMX
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* Object file "section" support for the BFD library.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
@ -382,6 +382,9 @@ CODE_FRAGMENT
|
||||
. {* Nonzero if this section has TLS related relocations. *}
|
||||
. unsigned int has_tls_reloc:1;
|
||||
.
|
||||
. {* Nonzero if this section has a call to __tls_get_addr. *}
|
||||
. unsigned int has_tls_get_addr_call:1;
|
||||
.
|
||||
. {* Nonzero if this section has a gp reloc. *}
|
||||
. unsigned int has_gp_reloc:1;
|
||||
.
|
||||
@ -642,11 +645,11 @@ CODE_FRAGMENT
|
||||
. {* segment_mark, sec_info_type, use_rela_p, has_tls_reloc, *} \
|
||||
. 0, 0, 0, 0, \
|
||||
. \
|
||||
. {* has_gp_reloc, need_finalize_relax, reloc_done, *} \
|
||||
. 0, 0, 0, \
|
||||
. {* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax, *} \
|
||||
. 0, 0, 0, \
|
||||
. \
|
||||
. {* vma, lma, size, rawsize *} \
|
||||
. 0, 0, 0, 0, \
|
||||
. {* reloc_done, vma, lma, size, rawsize *} \
|
||||
. 0, 0, 0, 0, 0, \
|
||||
. \
|
||||
. {* output_offset, output_section, alignment_power, *} \
|
||||
. 0, (struct bfd_section *) &SEC, 0, \
|
||||
|
@ -2509,108 +2509,156 @@ md_assemble (char *str)
|
||||
(char *) NULL, 0);
|
||||
}
|
||||
#ifdef OBJ_ELF
|
||||
else if ((reloc = ppc_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED)
|
||||
else
|
||||
{
|
||||
/* Some TLS tweaks. */
|
||||
switch (reloc)
|
||||
if (ex.X_op == O_symbol && str[0] == '(')
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case BFD_RELOC_PPC_TLS:
|
||||
insn = ppc_insert_operand (insn, operand, ppc_obj64 ? 13 : 2,
|
||||
(char *) NULL, 0);
|
||||
break;
|
||||
/* We'll only use the 32 (or 64) bit form of these relocations
|
||||
in constants. Instructions get the 16 bit form. */
|
||||
case BFD_RELOC_PPC_DTPREL:
|
||||
reloc = BFD_RELOC_PPC_DTPREL16;
|
||||
break;
|
||||
case BFD_RELOC_PPC_TPREL:
|
||||
reloc = BFD_RELOC_PPC_TPREL16;
|
||||
break;
|
||||
}
|
||||
const char *sym_name = S_GET_NAME (ex.X_add_symbol);
|
||||
if (sym_name[0] == '.')
|
||||
++sym_name;
|
||||
|
||||
/* For the absolute forms of branches, convert the PC
|
||||
relative form back into the absolute. */
|
||||
if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0)
|
||||
{
|
||||
switch (reloc)
|
||||
if (strcasecmp (sym_name, "__tls_get_addr") == 0)
|
||||
{
|
||||
case BFD_RELOC_PPC_B26:
|
||||
reloc = BFD_RELOC_PPC_BA26;
|
||||
break;
|
||||
case BFD_RELOC_PPC_B16:
|
||||
reloc = BFD_RELOC_PPC_BA16;
|
||||
break;
|
||||
case BFD_RELOC_PPC_B16_BRTAKEN:
|
||||
reloc = BFD_RELOC_PPC_BA16_BRTAKEN;
|
||||
break;
|
||||
case BFD_RELOC_PPC_B16_BRNTAKEN:
|
||||
reloc = BFD_RELOC_PPC_BA16_BRNTAKEN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
expressionS tls_exp;
|
||||
|
||||
hold = input_line_pointer;
|
||||
input_line_pointer = str + 1;
|
||||
expression (&tls_exp);
|
||||
if (tls_exp.X_op == O_symbol)
|
||||
{
|
||||
reloc = BFD_RELOC_UNUSED;
|
||||
if (strncasecmp (input_line_pointer, "@tlsgd)", 7) == 0)
|
||||
{
|
||||
reloc = BFD_RELOC_PPC_TLSGD;
|
||||
input_line_pointer += 7;
|
||||
}
|
||||
else if (strncasecmp (input_line_pointer, "@tlsld)", 7) == 0)
|
||||
{
|
||||
reloc = BFD_RELOC_PPC_TLSLD;
|
||||
input_line_pointer += 7;
|
||||
}
|
||||
if (reloc != BFD_RELOC_UNUSED)
|
||||
{
|
||||
SKIP_WHITESPACE ();
|
||||
str = input_line_pointer;
|
||||
|
||||
if (fc >= MAX_INSN_FIXUPS)
|
||||
as_fatal (_("too many fixups"));
|
||||
fixups[fc].exp = tls_exp;
|
||||
fixups[fc].opindex = *opindex_ptr;
|
||||
fixups[fc].reloc = reloc;
|
||||
++fc;
|
||||
}
|
||||
}
|
||||
input_line_pointer = hold;
|
||||
}
|
||||
}
|
||||
|
||||
if (ppc_obj64
|
||||
&& (operand->flags & (PPC_OPERAND_DS | PPC_OPERAND_DQ)) != 0)
|
||||
if ((reloc = ppc_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED)
|
||||
{
|
||||
/* Some TLS tweaks. */
|
||||
switch (reloc)
|
||||
{
|
||||
case BFD_RELOC_16:
|
||||
reloc = BFD_RELOC_PPC64_ADDR16_DS;
|
||||
break;
|
||||
case BFD_RELOC_LO16:
|
||||
reloc = BFD_RELOC_PPC64_ADDR16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_16_GOTOFF:
|
||||
reloc = BFD_RELOC_PPC64_GOT16_DS;
|
||||
break;
|
||||
case BFD_RELOC_LO16_GOTOFF:
|
||||
reloc = BFD_RELOC_PPC64_GOT16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_LO16_PLTOFF:
|
||||
reloc = BFD_RELOC_PPC64_PLT16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_16_BASEREL:
|
||||
reloc = BFD_RELOC_PPC64_SECTOFF_DS;
|
||||
break;
|
||||
case BFD_RELOC_LO16_BASEREL:
|
||||
reloc = BFD_RELOC_PPC64_SECTOFF_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_TOC16:
|
||||
reloc = BFD_RELOC_PPC64_TOC16_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC64_TOC16_LO:
|
||||
reloc = BFD_RELOC_PPC64_TOC16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC64_PLTGOT16:
|
||||
reloc = BFD_RELOC_PPC64_PLTGOT16_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC64_PLTGOT16_LO:
|
||||
reloc = BFD_RELOC_PPC64_PLTGOT16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_DTPREL16:
|
||||
reloc = BFD_RELOC_PPC64_DTPREL16_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_DTPREL16_LO:
|
||||
reloc = BFD_RELOC_PPC64_DTPREL16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_TPREL16:
|
||||
reloc = BFD_RELOC_PPC64_TPREL16_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_TPREL16_LO:
|
||||
reloc = BFD_RELOC_PPC64_TPREL16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_GOT_DTPREL16:
|
||||
case BFD_RELOC_PPC_GOT_DTPREL16_LO:
|
||||
case BFD_RELOC_PPC_GOT_TPREL16:
|
||||
case BFD_RELOC_PPC_GOT_TPREL16_LO:
|
||||
break;
|
||||
default:
|
||||
as_bad (_("unsupported relocation for DS offset field"));
|
||||
break;
|
||||
|
||||
case BFD_RELOC_PPC_TLS:
|
||||
insn = ppc_insert_operand (insn, operand, ppc_obj64 ? 13 : 2,
|
||||
(char *) NULL, 0);
|
||||
break;
|
||||
|
||||
/* We'll only use the 32 (or 64) bit form of these relocations
|
||||
in constants. Instructions get the 16 bit form. */
|
||||
case BFD_RELOC_PPC_DTPREL:
|
||||
reloc = BFD_RELOC_PPC_DTPREL16;
|
||||
break;
|
||||
case BFD_RELOC_PPC_TPREL:
|
||||
reloc = BFD_RELOC_PPC_TPREL16;
|
||||
break;
|
||||
}
|
||||
|
||||
/* For the absolute forms of branches, convert the PC
|
||||
relative form back into the absolute. */
|
||||
if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0)
|
||||
{
|
||||
switch (reloc)
|
||||
{
|
||||
case BFD_RELOC_PPC_B26:
|
||||
reloc = BFD_RELOC_PPC_BA26;
|
||||
break;
|
||||
case BFD_RELOC_PPC_B16:
|
||||
reloc = BFD_RELOC_PPC_BA16;
|
||||
break;
|
||||
case BFD_RELOC_PPC_B16_BRTAKEN:
|
||||
reloc = BFD_RELOC_PPC_BA16_BRTAKEN;
|
||||
break;
|
||||
case BFD_RELOC_PPC_B16_BRNTAKEN:
|
||||
reloc = BFD_RELOC_PPC_BA16_BRNTAKEN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ppc_obj64
|
||||
&& (operand->flags & (PPC_OPERAND_DS | PPC_OPERAND_DQ)) != 0)
|
||||
{
|
||||
switch (reloc)
|
||||
{
|
||||
case BFD_RELOC_16:
|
||||
reloc = BFD_RELOC_PPC64_ADDR16_DS;
|
||||
break;
|
||||
case BFD_RELOC_LO16:
|
||||
reloc = BFD_RELOC_PPC64_ADDR16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_16_GOTOFF:
|
||||
reloc = BFD_RELOC_PPC64_GOT16_DS;
|
||||
break;
|
||||
case BFD_RELOC_LO16_GOTOFF:
|
||||
reloc = BFD_RELOC_PPC64_GOT16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_LO16_PLTOFF:
|
||||
reloc = BFD_RELOC_PPC64_PLT16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_16_BASEREL:
|
||||
reloc = BFD_RELOC_PPC64_SECTOFF_DS;
|
||||
break;
|
||||
case BFD_RELOC_LO16_BASEREL:
|
||||
reloc = BFD_RELOC_PPC64_SECTOFF_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_TOC16:
|
||||
reloc = BFD_RELOC_PPC64_TOC16_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC64_TOC16_LO:
|
||||
reloc = BFD_RELOC_PPC64_TOC16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC64_PLTGOT16:
|
||||
reloc = BFD_RELOC_PPC64_PLTGOT16_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC64_PLTGOT16_LO:
|
||||
reloc = BFD_RELOC_PPC64_PLTGOT16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_DTPREL16:
|
||||
reloc = BFD_RELOC_PPC64_DTPREL16_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_DTPREL16_LO:
|
||||
reloc = BFD_RELOC_PPC64_DTPREL16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_TPREL16:
|
||||
reloc = BFD_RELOC_PPC64_TPREL16_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_TPREL16_LO:
|
||||
reloc = BFD_RELOC_PPC64_TPREL16_LO_DS;
|
||||
break;
|
||||
case BFD_RELOC_PPC_GOT_DTPREL16:
|
||||
case BFD_RELOC_PPC_GOT_DTPREL16_LO:
|
||||
case BFD_RELOC_PPC_GOT_TPREL16:
|
||||
case BFD_RELOC_PPC_GOT_TPREL16_LO:
|
||||
break;
|
||||
default:
|
||||
as_bad (_("unsupported relocation for DS offset field"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2618,12 +2666,11 @@ md_assemble (char *str)
|
||||
if (fc >= MAX_INSN_FIXUPS)
|
||||
as_fatal (_("too many fixups"));
|
||||
fixups[fc].exp = ex;
|
||||
fixups[fc].opindex = 0;
|
||||
fixups[fc].opindex = *opindex_ptr;
|
||||
fixups[fc].reloc = reloc;
|
||||
++fc;
|
||||
}
|
||||
#endif /* OBJ_ELF */
|
||||
|
||||
#else /* OBJ_ELF */
|
||||
else
|
||||
{
|
||||
/* We need to generate a fixup for this expression. */
|
||||
@ -2634,6 +2681,7 @@ md_assemble (char *str)
|
||||
fixups[fc].reloc = BFD_RELOC_UNUSED;
|
||||
++fc;
|
||||
}
|
||||
#endif /* OBJ_ELF */
|
||||
|
||||
if (need_paren)
|
||||
{
|
||||
@ -5908,6 +5956,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
|
||||
break;
|
||||
|
||||
case BFD_RELOC_PPC_TLS:
|
||||
case BFD_RELOC_PPC_TLSLD:
|
||||
case BFD_RELOC_PPC_TLSGD:
|
||||
break;
|
||||
|
||||
case BFD_RELOC_PPC_DTPMOD:
|
||||
|
@ -1,3 +1,8 @@
|
||||
2009-03-04 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* ppc.h (R_PPC_TLSGD, R_PPC_TLSLD): Add new relocs.
|
||||
* ppc64.h (R_PPC64_TLSGD, R_PPC64_TLSLD): Add new relocs.
|
||||
|
||||
2007-06-29 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
* ppc.h (Tag_GNU_Power_ABI_FP): Define.
|
||||
|
@ -100,6 +100,8 @@ START_RELOC_NUMBERS (elf_ppc_reloc_type)
|
||||
RELOC_NUMBER (R_PPC_GOT_DTPREL16_LO, 92)
|
||||
RELOC_NUMBER (R_PPC_GOT_DTPREL16_HI, 93)
|
||||
RELOC_NUMBER (R_PPC_GOT_DTPREL16_HA, 94)
|
||||
RELOC_NUMBER (R_PPC_TLSGD, 95)
|
||||
RELOC_NUMBER (R_PPC_TLSLD, 96)
|
||||
|
||||
/* The remaining relocs are from the Embedded ELF ABI, and are not
|
||||
in the SVR4 ELF ABI. */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* PPC64 ELF support for BFD.
|
||||
Copyright 2003 Free Software Foundation, Inc.
|
||||
Copyright 2003, 2005, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
@ -136,6 +136,8 @@ START_RELOC_NUMBERS (elf_ppc64_reloc_type)
|
||||
RELOC_NUMBER (R_PPC64_DTPREL16_HIGHERA, 104)
|
||||
RELOC_NUMBER (R_PPC64_DTPREL16_HIGHEST, 105)
|
||||
RELOC_NUMBER (R_PPC64_DTPREL16_HIGHESTA, 106)
|
||||
RELOC_NUMBER (R_PPC64_TLSGD, 107)
|
||||
RELOC_NUMBER (R_PPC64_TLSLD, 108)
|
||||
|
||||
/* These are GNU extensions to enable C++ vtable garbage collection. */
|
||||
RELOC_NUMBER (R_PPC64_GNU_VTINHERIT, 253)
|
||||
|
@ -1109,7 +1109,8 @@ strip_main(struct elfcopy *ecp, int argc, char **argv)
|
||||
|
||||
if (ecp->strip == 0 &&
|
||||
((ecp->flags & DISCARD_LOCAL) == 0) &&
|
||||
((ecp->flags & DISCARD_LLABEL) == 0))
|
||||
((ecp->flags & DISCARD_LLABEL) == 0) &&
|
||||
lookup_symop_list(ecp, NULL, SYMOP_STRIP) == NULL)
|
||||
ecp->strip = STRIP_ALL;
|
||||
if (optind == argc)
|
||||
strip_usage();
|
||||
|
@ -439,7 +439,7 @@ copy_phdr(struct elfcopy *ecp)
|
||||
seg->fsz = seg->msz = 0;
|
||||
for (i = 0; i < seg->nsec; i++) {
|
||||
s = seg->v_sec[i];
|
||||
seg->msz = s->off + s->sz - seg->off;
|
||||
seg->msz = s->vma + s->sz - seg->addr;
|
||||
if (s->type != SHT_NOBITS)
|
||||
seg->fsz = seg->msz;
|
||||
}
|
||||
|
15
contrib/elftoolchain/readelf/Makefile
Normal file
15
contrib/elftoolchain/readelf/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
# $Id: Makefile 2076 2011-10-27 03:50:33Z jkoshy $
|
||||
|
||||
TOP= ..
|
||||
|
||||
PROG= readelf
|
||||
SRCS= readelf.c
|
||||
|
||||
WARNS?= 6
|
||||
|
||||
DPADD= ${LIBDWARF} ${LIBELF}
|
||||
LDADD= -ldwarf -lelftc -lelf
|
||||
|
||||
MAN1= readelf.1
|
||||
|
||||
.include "${TOP}/mk/elftoolchain.prog.mk"
|
197
contrib/elftoolchain/readelf/readelf.1
Normal file
197
contrib/elftoolchain/readelf/readelf.1
Normal file
@ -0,0 +1,197 @@
|
||||
.\" Copyright (c) 2009,2011 Joseph Koshy <jkoshy@users.sourceforge.net>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer
|
||||
.\" in this position and unchanged.
|
||||
.\" 2. 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 AUTHORS ``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 AUTHOR 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.
|
||||
.\"
|
||||
.\" $Id: readelf.1 2577 2012-09-13 16:07:04Z jkoshy $
|
||||
.\"
|
||||
.Dd September 13, 2012
|
||||
.Os
|
||||
.Dt READELF 1
|
||||
.Sh NAME
|
||||
.Nm readelf
|
||||
.Nd display information about ELF objects
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl a | Fl -all
|
||||
.Op Fl c | Fl -archive-index
|
||||
.Op Fl d | Fl -dynamic
|
||||
.Op Fl e | Fl -headers
|
||||
.Op Fl g | Fl -section-groups
|
||||
.Op Fl h | Fl -file-header
|
||||
.Op Fl l | Fl -program-headers
|
||||
.Op Fl n | Fl -notes
|
||||
.Op Fl p Ar section | Fl -string-dump Ns = Ns Ar section
|
||||
.Op Fl r | Fl -relocs
|
||||
.Op Fl t | Fl -section-details
|
||||
.Op Fl x Ar section | Fl -hex-dump Ns = Ns Ar section
|
||||
.Op Fl v | Fl -version
|
||||
.Oo
|
||||
.Fl w Ns Oo Ns Ar afilmoprsFLR Ns Oc |
|
||||
.Fl -debug-dump Ns Op Ns = Ns Ar long-option-name , Ns ...
|
||||
.Oc
|
||||
.Op Fl A | Fl -arch-specific
|
||||
.Op Fl D | Fl -use-dynamic
|
||||
.Op Fl H | Fl -help
|
||||
.Op Fl I | Fl -histogram
|
||||
.Op Fl N | -full-section-name
|
||||
.Op Fl S | Fl -sections | Fl -section-headers
|
||||
.Op Fl V | Fl -version-info
|
||||
.Op Fl W | Fl -wide
|
||||
.Ar file...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility displays information about ELF objects and
|
||||
.Xr ar 1
|
||||
archives.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
utility recognizes the following options:
|
||||
.Bl -tag -width indent
|
||||
.It Fl a | Fl -all
|
||||
Turn on the following flags:
|
||||
.Fl d ,
|
||||
.Fl h ,
|
||||
.Fl I ,
|
||||
.Fl l ,
|
||||
.Fl r ,
|
||||
.Fl s ,
|
||||
.Fl A ,
|
||||
.Fl S
|
||||
and
|
||||
.Fl V .
|
||||
.It Fl c | Fl -archive-index
|
||||
Print the archive symbol table for archives.
|
||||
.It Fl d | Fl -dynamic
|
||||
Print the contents of the
|
||||
.Li SHT_DYNAMIC
|
||||
sections in the ELF object.
|
||||
.It Fl e | Fl -headers
|
||||
Print all program, file and section headers in the ELF object.
|
||||
.It Fl g | Fl -section-groups
|
||||
This option is recognized, but is ignored.
|
||||
.It Fl h | Fl -file-header
|
||||
Print the file header of the ELF object.
|
||||
.It Fl l | Fl -program-headers
|
||||
Print the content of the program header table for the object.
|
||||
.It Fl n | Fl -notes
|
||||
Print the contents of
|
||||
.Li PT_NOTE
|
||||
segments or
|
||||
.Li SHT_NOTE
|
||||
sections present in the ELF object.
|
||||
.It Fl p Ar section | Fl -string-dump Ns = Ns Ar section
|
||||
Print the contents of the specified section as printable strings.
|
||||
The argument
|
||||
.Ar section
|
||||
should be the name of a section or a numeric section index.
|
||||
.It Fl r | Fl -relocs
|
||||
Print relocation information.
|
||||
.It Fl s | Fl -syms | Fl -symbols
|
||||
Print symbol tables.
|
||||
.It Fl t | Fl -section-details
|
||||
Print additional information about sections, such as the flags
|
||||
fields in section headers.
|
||||
.It Fl v | Fl -version
|
||||
Prints a version identifier for
|
||||
.Nm
|
||||
and exits.
|
||||
.It Fl w Ns Oo afilmoprsFLR Oc | Xo
|
||||
.Fl -debug-dump Ns Op Ns = Ns Ar long-option-name , Ns ...
|
||||
.Xc
|
||||
Display DWARF information.
|
||||
The
|
||||
.Fl w
|
||||
option is used with the short options in the following
|
||||
table; the
|
||||
.Fl -debug-dump
|
||||
option is used with a comma-separated list of the corresponding long
|
||||
option names:
|
||||
.Bl -column ".Em Short Option" "aranges|ranges"
|
||||
.It Em Short Option Ta Em Long Option Ta Em Description
|
||||
.It a Ta abbrev Ta Show abbreviation information.
|
||||
.It f Ta frames Ta Show frame information, displaying frame instructions.
|
||||
.It i Ta info Ta Show debugging information entries.
|
||||
.It l Ta rawline Ta Show line information in raw form.
|
||||
.It m Ta macro Ta Show macro information.
|
||||
.It o Ta loc Ta Show location list information.
|
||||
.It p Ta pubnames Ta Show global names.
|
||||
.It r Ta aranges|ranges Ta Show address range information.
|
||||
.It s Ta str Ta Show the debug string table.
|
||||
.It F Ta Ta Show frame information, displaying register rules.
|
||||
.It L Ta decodedline Ta Show line information in decoded form.
|
||||
.It R Ta Ranges Ta Show range lists.
|
||||
.El
|
||||
.Pp
|
||||
If no sub-options are specified, the default is to show information
|
||||
corresponding to the
|
||||
.Ar a , f , i, l , o , p , r , s
|
||||
and
|
||||
.Ar R
|
||||
short options.
|
||||
.It Fl x Ar section | Fl -hex-dump Ns = Ns Ar section
|
||||
Display the contents of the specified section in hexadecimal.
|
||||
The argument
|
||||
.Ar section
|
||||
should be the name of a section or a numeric section index.
|
||||
.It Fl A | Fl -arch-specific
|
||||
This option is accepted but is currently unimplemented.
|
||||
.It Fl D | Fl -use-dynamic
|
||||
Print the symbol table specified by the
|
||||
.Li DT_SYMTAB
|
||||
entry in the
|
||||
.Dq Li .dynamic
|
||||
section.
|
||||
.It Fl H | Fl -help
|
||||
Print a help message.
|
||||
.It Fl I | Fl -histogram
|
||||
Print information on bucket list lengths for sections of type
|
||||
.Li SHT_HASH
|
||||
and
|
||||
.Li SHT_GNU_HASH .
|
||||
.It Fl N | Fl -full-section-name
|
||||
This option is accepted but is currently unimplemented.
|
||||
.It Fl S | Fl -sections | Fl -section-headers
|
||||
Print information in the section headers for each ELF object.
|
||||
.It Fl V | Fl -version-info
|
||||
Print symbol versioning information.
|
||||
.It Fl W | Fl -wide
|
||||
Print information about ELF structures using one long line per
|
||||
structure.
|
||||
If this option is not specified,
|
||||
.Nm
|
||||
will list information in the headers of 64 bit ELF objects on two
|
||||
separate lines.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std
|
||||
.Sh SEE ALSO
|
||||
.Xr nm 1 ,
|
||||
.Xr addr2line 1 ,
|
||||
.Xr elfcopy 1 ,
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
|
6845
contrib/elftoolchain/readelf/readelf.c
Normal file
6845
contrib/elftoolchain/readelf/readelf.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,69 @@
|
||||
2014-12-10 20:01 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* release 5.21
|
||||
|
||||
2014-11-27 18:40 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Allow setting more parameters from the command line.
|
||||
* Split name/use and indirect magic recursion limits.
|
||||
|
||||
2014-11-27 11:12 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Adjust ELF parameters and the default recursion
|
||||
level.
|
||||
* Allow setting the recursion level dynamically.
|
||||
|
||||
2014-11-24 8:55 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* The following fixes resulted from Thomas Jarosch's fuzzing
|
||||
tests that revealed severe performance issues on pathological
|
||||
input:
|
||||
- limit number of elf program and sections processing
|
||||
- abort elf note processing quickly
|
||||
- reduce the number of recursion levels from 20 to 10
|
||||
- preserve error messages in indirect magic handling
|
||||
|
||||
2014-11-12 10:30 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* fix bogus free in the user buffer case.
|
||||
|
||||
2014-11-11 12:35 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* fix out of bounds read for pascal strings
|
||||
* fix memory leak (not freeing the head of each mlist)
|
||||
|
||||
2014-11-07 10:25 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* When printing strings from a file, convert them to printable
|
||||
on a byte by byte basis, so that we don't get issues with
|
||||
locale's trying to interpret random byte streams as UTF-8 and
|
||||
having printf error out with EILSEQ.
|
||||
|
||||
2014-10-17 11:48 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* fix bounds in note reading (Francisco Alonso / Red Hat)
|
||||
|
||||
2014-10-11 15:02 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* fix autoconf glue for setlocale and locale_t; some OS's
|
||||
have locale_t in xlocale.h
|
||||
|
||||
2014-10-10 15:01 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* release 5.20
|
||||
|
||||
2014-08-17 10:01 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* recognize encrypted CDF documents
|
||||
|
||||
2014-08-04 9:18 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* add magic_load_buffers from Brooks Davis
|
||||
|
||||
2014-07-24 16:40 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* add thumbs.db support
|
||||
|
||||
2014-06-12 12:28 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* release 5.19
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Makefile.in generated by automake 1.14 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
@ -618,9 +618,10 @@ distcheck: dist
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build \
|
||||
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
|
||||
&& ../configure \
|
||||
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
--srcdir=.. --prefix="$$dc_install_base" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
|
@ -15,3 +15,5 @@ small amount of C is needed (because fast execution is typically only
|
||||
required for soft magic, not the more detailed information given by
|
||||
hard-wired routines). In this regard, note that hplip, which is
|
||||
BSD-licensed, has a magic reimplementation in Python.
|
||||
|
||||
Read the kerberos magic entry for more ideas.
|
||||
|
8
contrib/file/aclocal.m4
vendored
8
contrib/file/aclocal.m4
vendored
@ -1,4 +1,4 @@
|
||||
# generated automatically by aclocal 1.14 -*- Autoconf -*-
|
||||
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
|
||||
@ -21,7 +21,7 @@ If you have problems, you may need to regenerate the build system entirely.
|
||||
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
|
||||
|
||||
# visibility.m4 serial 5 (gettext-0.18.2)
|
||||
dnl Copyright (C) 2005, 2008, 2010-2013 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2005, 2008, 2010-2014 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
@ -113,7 +113,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||
[am__api_version='1.14'
|
||||
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||
dnl require some minimum version. Point them to the right macro.
|
||||
m4_if([$1], [1.14], [],
|
||||
m4_if([$1], [1.14.1], [],
|
||||
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||
])
|
||||
|
||||
@ -129,7 +129,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
|
||||
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
|
||||
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||
[AM_AUTOMAKE_VERSION([1.14])dnl
|
||||
[AM_AUTOMAKE_VERSION([1.14.1])dnl
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
||||
|
@ -44,6 +44,9 @@
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define to 1 if you have the `freelocale' function. */
|
||||
#undef HAVE_FREELOCALE
|
||||
|
||||
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||
#undef HAVE_FSEEKO
|
||||
|
||||
@ -95,9 +98,15 @@
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define to 1 if you have the `newlocale' function. */
|
||||
#undef HAVE_NEWLOCALE
|
||||
|
||||
/* Define to 1 if you have the `pread' function. */
|
||||
#undef HAVE_PREAD
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#undef HAVE_STDDEF_H
|
||||
|
||||
@ -182,6 +191,9 @@
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the `uselocale' function. */
|
||||
#undef HAVE_USELOCALE
|
||||
|
||||
/* Define to 1 if you have the `utime' function. */
|
||||
#undef HAVE_UTIME
|
||||
|
||||
@ -219,6 +231,9 @@
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#undef HAVE_WORKING_VFORK
|
||||
|
||||
/* Define to 1 if you have the <xlocale.h> header file. */
|
||||
#undef HAVE_XLOCALE_H
|
||||
|
||||
/* Define to 1 if you have the <zlib.h> header file. */
|
||||
#undef HAVE_ZLIB_H
|
||||
|
||||
|
24
contrib/file/configure
vendored
24
contrib/file/configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for file 5.19.
|
||||
# Generated by GNU Autoconf 2.69 for file 5.21.
|
||||
#
|
||||
# Report bugs to <christos@astron.com>.
|
||||
#
|
||||
@ -590,8 +590,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='file'
|
||||
PACKAGE_TARNAME='file'
|
||||
PACKAGE_VERSION='5.19'
|
||||
PACKAGE_STRING='file 5.19'
|
||||
PACKAGE_VERSION='5.21'
|
||||
PACKAGE_STRING='file 5.21'
|
||||
PACKAGE_BUGREPORT='christos@astron.com'
|
||||
PACKAGE_URL=''
|
||||
|
||||
@ -1327,7 +1327,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures file 5.19 to adapt to many kinds of systems.
|
||||
\`configure' configures file 5.21 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@ -1397,7 +1397,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of file 5.19:";;
|
||||
short | recursive ) echo "Configuration of file 5.21:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@ -1507,7 +1507,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
file configure 5.19
|
||||
file configure 5.21
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@ -2163,7 +2163,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by file $as_me 5.19, which was
|
||||
It was created by file $as_me 5.21, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@ -3029,7 +3029,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='file'
|
||||
VERSION='5.19'
|
||||
VERSION='5.21'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@ -12785,7 +12785,7 @@ fi
|
||||
|
||||
done
|
||||
|
||||
for ac_header in getopt.h err.h
|
||||
for ac_header in getopt.h err.h xlocale.h
|
||||
do :
|
||||
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
|
||||
@ -14191,7 +14191,7 @@ fi
|
||||
fi
|
||||
|
||||
|
||||
for ac_func in strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof
|
||||
for ac_func in strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale setlocale
|
||||
do :
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||
@ -14998,7 +14998,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by file $as_me 5.19, which was
|
||||
This file was extended by file $as_me 5.21, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@ -15064,7 +15064,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
file config.status 5.19
|
||||
file config.status 5.21
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT([file],[5.19],[christos@astron.com])
|
||||
AC_INIT([file],[5.21],[christos@astron.com])
|
||||
AM_INIT_AUTOMAKE([subdir-objects foreign])
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
@ -82,7 +82,7 @@ AC_HEADER_MAJOR
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
|
||||
AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h)
|
||||
AC_CHECK_HEADERS(getopt.h err.h)
|
||||
AC_CHECK_HEADERS(getopt.h err.h xlocale.h)
|
||||
AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
|
||||
AC_CHECK_HEADERS(zlib.h)
|
||||
|
||||
@ -138,7 +138,7 @@ else
|
||||
fi])
|
||||
|
||||
dnl Checks for functions
|
||||
AC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof)
|
||||
AC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale setlocale)
|
||||
|
||||
dnl Provide implementation of some required functions if necessary
|
||||
AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r pread strcasestr fmtcheck)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Makefile.in generated by automake 1.14 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" $File: file.man,v 1.106 2014/03/07 23:11:51 christos Exp $
|
||||
.Dd December 3, 2014
|
||||
.\" $File: file.man,v 1.110 2014/11/28 02:46:39 christos Exp $
|
||||
.Dd November 27, 2014
|
||||
.Dt FILE __CSECTION__
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -16,6 +16,7 @@
|
||||
.Op Fl F Ar separator
|
||||
.Op Fl f Ar namefile
|
||||
.Op Fl m Ar magicfiles
|
||||
.Op Fl P Ar name=value
|
||||
.Ar
|
||||
.Ek
|
||||
.Nm
|
||||
@ -303,6 +304,15 @@ or
|
||||
attempt to preserve the access time of files analyzed, to pretend that
|
||||
.Nm
|
||||
never read them.
|
||||
.It Fl P , Fl Fl parameter Ar name=value
|
||||
Set various parameter limits.
|
||||
.Bl -column "elf_phnum" "Default" "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -offset indent
|
||||
.It Sy "Name" Ta Sy "Default" Ta Sy "Explanation"
|
||||
.It Li indir Ta 15 Ta recursion limit for indirect magic
|
||||
.It Li name Ta 30 Ta use count limit for name/use magic
|
||||
.It Li elf_phnum Ta 128 Ta max ELF program sections processed
|
||||
.It Li elf_shnum Ta 32768 Ta max ELF sections processed
|
||||
.El
|
||||
.It Fl r , Fl Fl raw
|
||||
Don't translate unprintable characters to \eooo.
|
||||
Normally
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $File: libmagic.man,v 1.28 2014/03/02 14:47:16 christos Exp $
|
||||
.\" $File: libmagic.man,v 1.33 2014/11/28 02:46:39 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) Christos Zoulas 2003.
|
||||
.\" All Rights Reserved.
|
||||
@ -25,7 +25,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd January 6, 2012
|
||||
.Dd November 27, 2014
|
||||
.Dt LIBMAGIC 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -40,6 +40,9 @@
|
||||
.Nm magic_compile ,
|
||||
.Nm magic_list ,
|
||||
.Nm magic_load ,
|
||||
.Nm magic_load_buffers ,
|
||||
.Nm magic_setparam ,
|
||||
.Nm magic_getparam ,
|
||||
.Nm magic_version
|
||||
.Nd Magic number recognition library
|
||||
.Sh LIBRARY
|
||||
@ -71,6 +74,12 @@
|
||||
.Ft int
|
||||
.Fn magic_load "magic_t cookie" "const char *filename"
|
||||
.Ft int
|
||||
.Fn magic_load_buffers "magic_t cookie" "void **buffers" "size_t *sizes" "size_t nbuffers"
|
||||
.Ft int
|
||||
.Fn magic_getparam "magic_t cookie" "int param" "void *value"
|
||||
.Ft int
|
||||
.Fn magic_setparam "magic_t cookie" "int param" "const void *value"
|
||||
.Ft int
|
||||
.Fn magic_version "void"
|
||||
.Sh DESCRIPTION
|
||||
These functions
|
||||
@ -253,6 +262,55 @@ adds
|
||||
to the database filename as appropriate.
|
||||
.Pp
|
||||
The
|
||||
.Fn magic_load_buffers
|
||||
function takes an array of size
|
||||
.Fa nbuffers
|
||||
of
|
||||
.Fa buffers
|
||||
with a respective size for each in the array of
|
||||
.Fa sizes
|
||||
loaded with the contents of the magic databases from the filesystem.
|
||||
This function can be used in environment where the magic library does
|
||||
not have direct access to the filesystem, but can access the magic
|
||||
database via shared memory or other IPC means.
|
||||
.Pp
|
||||
The
|
||||
.Fn magic_getparam
|
||||
and
|
||||
.Fn magic_setparam
|
||||
allow getting and setting various limits related to the the magic
|
||||
library.
|
||||
.Bl -column "MAGIC_PARAM_ELF_PHNUM_MAX" "size_t" "Default" -offset indent
|
||||
.It Sy "Parameter" Ta Sy "Type" Ta Sy "Default"
|
||||
.It Li MAGIC_PARAM_INDIR_MAX Ta size_t Ta 15
|
||||
.It Li MAGIC_PARAM_NAME_MAX Ta size_t Ta 30
|
||||
.It Li MAGIC_PARAM_ELF_PHNUM_MAX Ta size_t Ta 128
|
||||
.It Li MAGIC_PARAM_ELF_SHNUM_MAX Ta size_t Ta 32768
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Dv MAGIC_PARAM_INDIR_RECURSION
|
||||
parameter controls how many levels of recursion will be followed for
|
||||
indirect magic entries.
|
||||
.Pp
|
||||
The
|
||||
.Dv MAGIC_PARAM_NAME_RECURSION
|
||||
parameter controls how many levels of recursion will be followed for
|
||||
for name/use calls.
|
||||
.Pp
|
||||
The
|
||||
.Dv MAGIC_PARAM_NAME_MAX
|
||||
parameter controls the maximum number of calls for name/use.
|
||||
.Pp
|
||||
The
|
||||
.Dv MAGIC_PARAM_PHNUM_MAX
|
||||
parameter controls how many elf program sections will be processed.
|
||||
.Pp
|
||||
The
|
||||
.Dv MAGIC_PARAM_SHNUM_MAX
|
||||
parameter controls how many elf sections will be processed.
|
||||
.Pp
|
||||
The
|
||||
.Fn magic_version
|
||||
command returns the version number of this library which is compiled into
|
||||
the shared library using the constant
|
||||
|
@ -2,6 +2,6 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Localstuff: file(1) magic for locally observed files
|
||||
#
|
||||
# $File: Localstuff,v 1.4 2003/03/23 04:17:27 christos Exp $
|
||||
# $File: Localstuff,v 1.5 2007/01/12 17:38:27 christos Exp $
|
||||
# Add any locally observed files here. Remember:
|
||||
# text if readable, executable if runnable binary, data if unreadable.
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------
|
||||
# $File: android,v 1.4 2014/06/03 19:01:34 christos Exp $
|
||||
# $File: android,v 1.7 2014/11/10 05:08:23 christos Exp $
|
||||
# Various android related magic entries
|
||||
#------------------------------------------------------------
|
||||
|
||||
@ -15,54 +15,11 @@
|
||||
>0 regex dey\n[0-9]{2}\0 Dalvik dex file (optimized for host)
|
||||
>4 string >000 version %s
|
||||
|
||||
# http://android.stackexchange.com/questions/23357/\
|
||||
# is-there-a-way-to-look-inside-and-modify-an-adb-backup-created-file/\
|
||||
# 23608#23608
|
||||
0 string ANDROID\040BACKUP\n Android Backup
|
||||
>15 string 1\n \b, version 1
|
||||
>17 string 0\n \b, uncompressed
|
||||
>17 string 1\n \b, compressed
|
||||
>19 string none\n \b, unencrypted
|
||||
>19 string AES-256\n \b, encrypted AES-256
|
||||
|
||||
# Android bootimg format
|
||||
# From https://android.googlesource.com/\
|
||||
# platform/system/core/+/master/mkbootimg/bootimg.h
|
||||
0 string ANDROID! Android bootimg
|
||||
>8 lelong >0 \b, kernel
|
||||
>>12 lelong >0 \b (0x%x)
|
||||
>16 lelong >0 \b, ramdisk
|
||||
>>20 lelong >0 \b (0x%x)
|
||||
>24 lelong >0 \b, second stage
|
||||
>>28 lelong >0 \b (0x%x)
|
||||
>36 lelong >0 \b, page size: %d
|
||||
>38 string >0 \b, name: %s
|
||||
>64 string >0 \b, cmdline (%s)
|
||||
# Dalvik .dex format. http://retrodev.com/android/dexformat.html
|
||||
# From <mkf@google.com> "Mike Fleming"
|
||||
# Fixed to avoid regexec 17 errors on some dex files
|
||||
# From <diff@lookout.com> "Tim Strazzere"
|
||||
0 string dex\n
|
||||
>0 regex dex\n[0-9]{2}\0 Dalvik dex file
|
||||
>4 string >000 version %s
|
||||
0 string dey\n
|
||||
>0 regex dey\n[0-9]{2}\0 Dalvik dex file (optimized for host)
|
||||
>4 string >000 version %s
|
||||
|
||||
# http://android.stackexchange.com/questions/23357/\
|
||||
# is-there-a-way-to-look-inside-and-modify-an-adb-backup-created-file/\
|
||||
# 23608#23608
|
||||
0 string ANDROID\040BACKUP\n Android Backup
|
||||
>15 string 1\n \b, version 1
|
||||
>17 string 0\n \b, uncompressed
|
||||
>17 string 1\n \b, compressed
|
||||
>19 string none\n \b, unencrypted
|
||||
>19 string AES-256\n \b, encrypted AES-256
|
||||
|
||||
# Android bootimg format
|
||||
# From https://android.googlesource.com/\
|
||||
# platform/system/core/+/master/mkbootimg/bootimg.h
|
||||
0 string ANDROID! Android bootimg
|
||||
>1024 string LOKI\01 \b, LOKI'd
|
||||
>8 lelong >0 \b, kernel
|
||||
>>12 lelong >0 \b (0x%x)
|
||||
>16 lelong >0 \b, ramdisk
|
||||
@ -98,3 +55,85 @@
|
||||
#>>>>>&1 regex/1l .* \b, PBKDF2 rounds: %s
|
||||
#>>>>>>&1 regex/1l .* \b, IV: %s
|
||||
#>>>>>>>&1 regex/1l .* \b, Key: %s
|
||||
|
||||
# *.pit files by Joerg Jenderek
|
||||
# http://forum.xda-developers.com/showthread.php?p=9122369
|
||||
# http://forum.xda-developers.com/showthread.php?t=816449
|
||||
# Partition Information Table for Samsung's smartphone with Android
|
||||
# used by flash software Odin
|
||||
0 ulelong 0x12349876
|
||||
# 1st pit entry marker
|
||||
>0x01C ulequad&0xFFFFFFFCFFFFFFFC =0x0000000000000000
|
||||
# minimal 13 and maximal 18 PIT entries found
|
||||
>>4 ulelong <128 Partition Information Table for Samsung smartphone
|
||||
>>>4 ulelong x \b, %d entries
|
||||
# 1. pit entry
|
||||
>>>4 ulelong >0 \b; #1
|
||||
>>>0x01C use PIT-entry
|
||||
>>>4 ulelong >1 \b; #2
|
||||
>>>0x0A0 use PIT-entry
|
||||
>>>4 ulelong >2 \b; #3
|
||||
>>>0x124 use PIT-entry
|
||||
>>>4 ulelong >3 \b; #4
|
||||
>>>0x1A8 use PIT-entry
|
||||
>>>4 ulelong >4 \b; #5
|
||||
>>>0x22C use PIT-entry
|
||||
>>>4 ulelong >5 \b; #6
|
||||
>>>0x2B0 use PIT-entry
|
||||
>>>4 ulelong >6 \b; #7
|
||||
>>>0x334 use PIT-entry
|
||||
>>>4 ulelong >7 \b; #8
|
||||
>>>0x3B8 use PIT-entry
|
||||
>>>4 ulelong >8 \b; #9
|
||||
>>>0x43C use PIT-entry
|
||||
>>>4 ulelong >9 \b; #10
|
||||
>>>0x4C0 use PIT-entry
|
||||
>>>4 ulelong >10 \b; #11
|
||||
>>>0x544 use PIT-entry
|
||||
>>>4 ulelong >11 \b; #12
|
||||
>>>0x5C8 use PIT-entry
|
||||
>>>4 ulelong >12 \b; #13
|
||||
>>>>0x64C use PIT-entry
|
||||
# 14. pit entry
|
||||
>>>4 ulelong >13 \b; #14
|
||||
>>>>0x6D0 use PIT-entry
|
||||
>>>4 ulelong >14 \b; #15
|
||||
>>>0x754 use PIT-entry
|
||||
>>>4 ulelong >15 \b; #16
|
||||
>>>0x7D8 use PIT-entry
|
||||
>>>4 ulelong >16 \b; #17
|
||||
>>>0x85C use PIT-entry
|
||||
# 18. pit entry
|
||||
>>>4 ulelong >17 \b; #18
|
||||
>>>0x8E0 use PIT-entry
|
||||
|
||||
0 name PIT-entry
|
||||
# garbage value implies end of pit entries
|
||||
>0x00 ulequad&0xFFFFFFFCFFFFFFFC =0x0000000000000000
|
||||
# skip empty partition name
|
||||
>>0x24 ubyte !0
|
||||
# partition name
|
||||
>>>0x24 string >\0 %-.32s
|
||||
# flags
|
||||
>>>0x0C ulelong&0x00000002 2 \b+RW
|
||||
# partition ID:
|
||||
# 0~IPL,MOVINAND,GANG;1~PIT,GPT;2~HIDDEN;3~SBL,HIDDEN;4~SBL2,HIDDEN;5~BOOT;6~KENREl,RECOVER,misc;7~RECOVER
|
||||
# ;11~MODEM;20~efs;21~PARAM;22~FACTORY,SYSTEM;23~DBDATAFS,USERDATA;24~CACHE;80~BOOTLOADER;81~TZSW
|
||||
>>>0x08 ulelong x (0x%x)
|
||||
# filename
|
||||
>>>0x44 string >\0 "%-.64s"
|
||||
#>>>0x18 ulelong >0
|
||||
# blocksize in 512 byte units ?
|
||||
#>>>>0x18 ulelong x \b, %db
|
||||
# partition size in blocks ?
|
||||
#>>>>0x22 ulelong x \b*%d
|
||||
|
||||
# Android bootimg format
|
||||
# From https://android.googlesource.com/\
|
||||
# platform/system/core/+/master/libsparse/sparse_format.h
|
||||
0 lelong 0xed26ff3a Android sparse image
|
||||
>4 leshort x \b, version: %d
|
||||
>6 leshort x \b.%d
|
||||
>16 lelong x \b, Total of %d
|
||||
>12 lelong x \b %d-byte output blocks in
|
||||
>20 lelong x \b %d input chunks.
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: animation,v 1.53 2014/04/30 21:41:02 christos Exp $
|
||||
# $File: animation,v 1.56 2014/10/23 23:12:51 christos Exp $
|
||||
# animation: file(1) magic for animation/movie formats
|
||||
#
|
||||
# animation formats
|
||||
@ -32,43 +32,155 @@
|
||||
!:mime application/x-quicktime-player
|
||||
4 string/W jP JPEG 2000 image
|
||||
!:mime image/jp2
|
||||
# http://www.ftyps.com/ with local additions
|
||||
4 string ftyp ISO Media
|
||||
>8 string isom \b, MPEG v4 system, version 1
|
||||
!:mime video/mp4
|
||||
>8 string iso2 \b, MPEG v4 system, part 12 revision
|
||||
>8 string mp41 \b, MPEG v4 system, version 1
|
||||
!:mime video/mp4
|
||||
>8 string mp42 \b, MPEG v4 system, version 2
|
||||
!:mime video/mp4
|
||||
>8 string mp7t \b, MPEG v4 system, MPEG v7 XML
|
||||
>8 string mp7b \b, MPEG v4 system, MPEG v7 binary XML
|
||||
>8 string/W jp2 \b, JPEG 2000
|
||||
!:mime image/jp2
|
||||
>8 string 3ge \b, MPEG v4 system, 3GPP
|
||||
!:mime video/3gpp
|
||||
>8 string 3gg \b, MPEG v4 system, 3GPP
|
||||
!:mime video/3gpp
|
||||
>8 string 3gp \b, MPEG v4 system, 3GPP
|
||||
!:mime video/3gpp
|
||||
>8 string 3gs \b, MPEG v4 system, 3GPP
|
||||
!:mime video/3gpp
|
||||
>8 string 3g2 \b, MPEG v4 system, 3GPP2
|
||||
!:mime video/3gpp2
|
||||
>>11 byte 4 \b v4 (H.263/AMR GSM 6.10)
|
||||
>>11 byte 5 \b v5 (H.263/AMR GSM 6.10)
|
||||
>>11 byte 6 \b v6 (ITU H.264/AMR GSM 6.10)
|
||||
>8 string mmp4 \b, MPEG v4 system, 3GPP Mobile
|
||||
!:mime video/mp4
|
||||
>8 string avc1 \b, MPEG v4 system, 3GPP JVT AVC
|
||||
>>11 byte a \b C.S0050-0 V1.0
|
||||
>>11 byte b \b C.S0050-0-A V1.0.0
|
||||
>>11 byte c \b C.S0050-0-B V1.0
|
||||
>8 string 3ge \b, MPEG v4 system, 3GPP
|
||||
!:mime video/3gpp
|
||||
>8 string/W M4A \b, MPEG v4 system, iTunes AAC-LC
|
||||
!:mime audio/mp4
|
||||
>8 string/W M4V \b, MPEG v4 system, iTunes AVC-LC
|
||||
>>11 byte 6 \b, Release 6 MBMS Extended Presentations
|
||||
>>11 byte 7 \b, Release 7 MBMS Extended Presentations
|
||||
>8 string 3gg \b, MPEG v4 system, 3GPP
|
||||
>11 byte 6 \b, Release 6 General Profile
|
||||
!:mime video/3gpp
|
||||
>8 string 3gp \b, MPEG v4 system, 3GPP
|
||||
>11 byte 1 \b, Release %d (non existent)
|
||||
>11 byte 2 \b, Release %d (non existent)
|
||||
>11 byte 3 \b, Release %d (non existent)
|
||||
>11 byte 4 \b, Release %d
|
||||
>11 byte 5 \b, Release %d
|
||||
>11 byte 6 \b, Release %d
|
||||
>11 byte 7 \b, Release %d Streaming Servers
|
||||
!:mime video/3gpp
|
||||
>8 string 3gs \b, MPEG v4 system, 3GPP
|
||||
>11 byte 7 \b, Release %d Streaming Servers
|
||||
!:mime video/3gpp
|
||||
>8 string avc1 \b, MPEG v4 system, 3GPP JVT AVC [ISO 14496-12:2005]
|
||||
!:mime video/mp4
|
||||
>8 string/W M4P \b, MPEG v4 system, iTunes AES encrypted
|
||||
>8 string/W M4B \b, MPEG v4 system, iTunes bookmarked
|
||||
>8 string/W qt \b, Apple QuickTime movie
|
||||
!:mime video/quicktime
|
||||
>8 string CAEP \b, Canon Digital Camera
|
||||
>8 string caqv \b, Casio Digital Camera
|
||||
>8 string CDes \b, Convergent Design
|
||||
>8 string da0a \b, DMB MAF w/ MPEG Layer II aud, MOT slides, DLS, JPG/PNG/MNG
|
||||
>8 string da0b \b, DMB MAF, ext DA0A, with 3GPP timed text, DID, TVA, REL, IPMP
|
||||
>8 string da1a \b, DMB MAF audio with ER-BSAC audio, JPG/PNG/MNG images
|
||||
>8 string da1b \b, DMB MAF, ext da1a, with 3GPP timed text, DID, TVA, REL, IPMP
|
||||
>8 string da2a \b, DMB MAF aud w/ HE-AAC v2 aud, MOT slides, DLS, JPG/PNG/MNG
|
||||
>8 string da2b \b, DMB MAF, ext da2a, with 3GPP timed text, DID, TVA, REL, IPMP
|
||||
>8 string da3a \b, DMB MAF aud with HE-AAC aud, JPG/PNG/MNG images
|
||||
>8 string da3b \b, DMB MAF, ext da3a w/ BIFS, 3GPP, DID, TVA, REL, IPMP
|
||||
>8 string dmb1 \b, DMB MAF supporting all the components defined in the spec
|
||||
>8 string dmpf \b, Digital Media Project
|
||||
>8 string drc1 \b, Dirac (wavelet compression), encap in ISO base media (MP4)
|
||||
>8 string dv1a \b, DMB MAF vid w/ AVC vid, ER-BSAC aud, BIFS, JPG/PNG/MNG, TS
|
||||
>8 string dv1b \b, DMB MAF, ext dv1a, with 3GPP timed text, DID, TVA, REL, IPMP
|
||||
>8 string dv2a \b, DMB MAF vid w/ AVC vid, HE-AAC v2 aud, BIFS, JPG/PNG/MNG, TS
|
||||
>8 string dv2b \b, DMB MAF, ext dv2a, with 3GPP timed text, DID, TVA, REL, IPMP
|
||||
>8 string dv3a \b, DMB MAF vid w/ AVC vid, HE-AAC aud, BIFS, JPG/PNG/MNG, TS
|
||||
>8 string dv3b \b, DMB MAF, ext dv3a, with 3GPP timed text, DID, TVA, REL, IPMP
|
||||
>8 string dvr1 \b, DVB (.DVB) over RTP
|
||||
!:mime video/vnd.dvb.file
|
||||
>8 string dvt1 \b, DVB (.DVB) over MPEG-2 Transport Stream
|
||||
!:mime video/vnd.dvb.file
|
||||
>8 string F4V \b, Video for Adobe Flash Player 9+ (.F4V)
|
||||
!:mime video/mp4
|
||||
>8 string F4P \b, Protected Video for Adobe Flash Player 9+ (.F4P)
|
||||
!:mime video/mp4
|
||||
>8 string F4A \b, Audio for Adobe Flash Player 9+ (.F4A)
|
||||
!:mime audio/mp4
|
||||
>8 string F4B \b, Audio Book for Adobe Flash Player 9+ (.F4B)
|
||||
!:mime audio/mp4
|
||||
>8 string isc2 \b, ISMACryp 2.0 Encrypted File
|
||||
# ?/enc-isoff-generic
|
||||
>8 string iso2 \b, MP4 Base Media v2 [ISO 14496-12:2005]
|
||||
!:mime video/mp4
|
||||
>8 string isom \b, MP4 Base Media v1 [IS0 14496-12:2003]
|
||||
!:mime video/mp4
|
||||
>8 string/W jp2 \b, JPEG 2000
|
||||
!:mime image/jp2
|
||||
>8 string JP2 \b, JPEG 2000 Image (.JP2) [ISO 15444-1 ?]
|
||||
!:mime image/jp2
|
||||
>8 string JP20 \b, Unknown, from GPAC samples (prob non-existent)
|
||||
>8 string jpm \b, JPEG 2000 Compound Image (.JPM) [ISO 15444-6]
|
||||
!:mime image/jpm
|
||||
>8 string jpx \b, JPEG 2000 w/ extensions (.JPX) [ISO 15444-2]
|
||||
!:mime image/jpx
|
||||
>8 string KDDI \b, 3GPP2 EZmovie for KDDI 3G cellphones
|
||||
!:mime video/3gpp2
|
||||
>8 string M4A \b, Apple iTunes ALAC/AAC-LC (.M4A) Audio
|
||||
!:mime audio/x-m4a
|
||||
>8 string M4B \b, Apple iTunes ALAC/AAC-LC (.M4B) Audio Book
|
||||
!:mime audio/mp4
|
||||
>8 string M4P \b, Apple iTunes ALAC/AAC-LC (.M4P) AES Protected Audio
|
||||
!:mime video/mp4
|
||||
>8 string M4V \b, Apple iTunes Video (.M4V) Video
|
||||
!:mime video/x-m4v
|
||||
>8 string M4VH \b, Apple TV (.M4V)
|
||||
!:mime video/x-m4v
|
||||
>8 string M4VP \b, Apple iPhone (.M4V)
|
||||
!:mime video/x-m4v
|
||||
>8 string mj2s \b, Motion JPEG 2000 [ISO 15444-3] Simple Profile
|
||||
!:mime video/mj2
|
||||
>8 string mjp2 \b, Motion JPEG 2000 [ISO 15444-3] General Profile
|
||||
!:mime video/mj2
|
||||
>8 string mmp4 \b, MPEG-4/3GPP Mobile Profile (.MP4 / .3GP) (for NTT)
|
||||
!:mime video/mp4
|
||||
>8 string mobi \b, MPEG-4, MOBI format
|
||||
!:mime video/mp4
|
||||
>8 string mp21 \b, MPEG-21 [ISO/IEC 21000-9]
|
||||
>8 string mp41 \b, MP4 v1 [ISO 14496-1:ch13]
|
||||
!:mime video/mp4
|
||||
>8 string mp42 \b, MP4 v2 [ISO 14496-14]
|
||||
!:mime video/mp4
|
||||
>8 string mp71 \b, MP4 w/ MPEG-7 Metadata [per ISO 14496-12]
|
||||
>8 string mp7t \b, MPEG v4 system, MPEG v7 XML
|
||||
>8 string mp7b \b, MPEG v4 system, MPEG v7 binary XML
|
||||
>8 string mmp4 \b, MPEG v4 system, 3GPP Mobile
|
||||
!:mime video/mp4
|
||||
>8 string MPPI \b, Photo Player, MAF [ISO/IEC 23000-3]
|
||||
>8 string mqt \b, Sony / Mobile QuickTime (.MQV) US Pat 7,477,830
|
||||
!:mime video/quicktime
|
||||
>8 string MSNV \b, MPEG-4 (.MP4) for SonyPSP
|
||||
!:mime audio/mp4
|
||||
>8 string NDAS \b, MP4 v2 [ISO 14496-14] Nero Digital AAC Audio
|
||||
!:mime audio/mp4
|
||||
>8 string NDSC \b, MPEG-4 (.MP4) Nero Cinema Profile
|
||||
!:mime video/mp4
|
||||
>8 string NDSH \b, MPEG-4 (.MP4) Nero HDTV Profile
|
||||
!:mime video/mp4
|
||||
>8 string NDSM \b, MPEG-4 (.MP4) Nero Mobile Profile
|
||||
!:mime video/mp4
|
||||
>8 string NDSP \b, MPEG-4 (.MP4) Nero Portable Profile
|
||||
!:mime video/mp4
|
||||
>8 string NDSS \b, MPEG-4 (.MP4) Nero Standard Profile
|
||||
!:mime video/mp4
|
||||
>8 string NDXC \b, H.264/MPEG-4 AVC (.MP4) Nero Cinema Profile
|
||||
!:mime video/mp4
|
||||
>8 string NDXH \b, H.264/MPEG-4 AVC (.MP4) Nero HDTV Profile
|
||||
!:mime video/mp4
|
||||
>8 string NDXM \b, H.264/MPEG-4 AVC (.MP4) Nero Mobile Profile
|
||||
!:mime video/mp4
|
||||
>8 string NDXP \b, H.264/MPEG-4 AVC (.MP4) Nero Portable Profile
|
||||
!:mime video/mp4
|
||||
>8 string NDXS \b, H.264/MPEG-4 AVC (.MP4) Nero Standard Profile
|
||||
!:mime video/mp4
|
||||
>8 string odcf \b, OMA DCF DRM Format 2.0 (OMA-TS-DRM-DCF-V2_0-20060303-A)
|
||||
>8 string opf2 \b, OMA PDCF DRM Format 2.1 (OMA-TS-DRM-DCF-V2_1-20070724-C)
|
||||
>8 string opx2 \b, OMA PDCF DRM + XBS ext (OMA-TS-DRM_XBS-V1_0-20070529-C)
|
||||
>8 string pana \b, Panasonic Digital Camera
|
||||
>8 string qt \b, Apple QuickTime (.MOV/QT)
|
||||
!:mime video/quicktime
|
||||
>8 string ROSS \b, Ross Video
|
||||
>8 string sdv \b, SD Memory Card Video
|
||||
>8 string ssc1 \b, Samsung stereo, single stream (patent pending)
|
||||
>8 string ssc2 \b, Samsung stereo, dual stream (patent pending)
|
||||
|
||||
# MPEG sequences
|
||||
# Scans for all common MPEG header start codes
|
||||
|
@ -1,5 +1,5 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: archive,v 1.87 2014/06/03 19:15:58 christos Exp $
|
||||
# $File: archive,v 1.88 2014/08/16 10:42:17 christos Exp $
|
||||
# archive: file(1) magic for archive formats (see also "msdos" for self-
|
||||
# extracting compressed archives)
|
||||
#
|
||||
@ -954,34 +954,3 @@
|
||||
>0xE08 search/7776 \x55\xAA
|
||||
>>&-512 indirect x \b; contains
|
||||
|
||||
# Symantec GHOST image by Joerg Jenderek at May 2014
|
||||
# http://us.norton.com/ghost/
|
||||
# http://www.garykessler.net/library/file_sigs.html
|
||||
0 ubelong&0xFFFFf7f0 0xFEEF0100 Norton GHost image
|
||||
# *.GHO
|
||||
>2 ubyte&0x08 0x00 \b, first file
|
||||
# *.GHS or *.[0-9] with cns program option
|
||||
>2 ubyte&0x08 0x08 \b, split file
|
||||
# part of split index interesting for *.ghs
|
||||
>>4 ubyte x id=0x%x
|
||||
# compression tag minus one equals numeric compression command line switch z[1-9]
|
||||
>3 ubyte 0 \b, no compression
|
||||
>3 ubyte 2 \b, fast compression (Z1)
|
||||
>3 ubyte 3 \b, medium compression (Z2)
|
||||
>3 ubyte >3
|
||||
>>3 ubyte <11 \b, compression (Z%d-1)
|
||||
>2 ubyte&0x08 0x00
|
||||
# ~ 30 byte password field only for *.gho
|
||||
>>12 ubequad !0 \b, password protected
|
||||
>>44 ubyte !1
|
||||
# 1~Image All, sector-by-sector only for *.gho
|
||||
>>>10 ubyte 1 \b, sector copy
|
||||
# 1~Image Boot track only for *.gho
|
||||
>>>43 ubyte 1 \b, boot track
|
||||
# 1~Image Disc only for *.gho implies Image Boot track and sector copy
|
||||
>>44 ubyte 1 \b, disc sector copy
|
||||
# optional image description only *.gho
|
||||
>>0xff string >\0 "%-.254s"
|
||||
# look for DOS sector end sequence
|
||||
>0xE08 search/7776 \x55\xAA
|
||||
>>&-512 indirect x \b; contains
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: blender,v 1.5 2009/09/19 16:28:08 christos Exp $
|
||||
# $File: blender,v 1.6 2014/08/30 08:34:17 christos Exp $
|
||||
# blender: file(1) magic for Blender 3D related files
|
||||
#
|
||||
# Native format rule v1.2. For questions use the developers list
|
||||
@ -35,5 +35,5 @@
|
||||
>>>0x44 string =GLOB \b.
|
||||
>>>>0x60 beshort x \b%.4d
|
||||
|
||||
# Scripts that run in the embeded Python interpreter
|
||||
# Scripts that run in the embedded Python interpreter
|
||||
0 string #!BPY Blender3D BPython script
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: commands,v 1.50 2014/05/30 16:48:44 christos Exp $
|
||||
# $File: commands,v 1.51 2014/09/27 00:12:55 christos Exp $
|
||||
# commands: file(1) magic for various shells and interpreters
|
||||
#
|
||||
#0 string/w : shell archive or script for antique kernel text
|
||||
@ -56,7 +56,7 @@
|
||||
!:mime text/x-awk
|
||||
0 string/wt #!\ /usr/bin/awk awk script text executable
|
||||
!:mime text/x-awk
|
||||
0 regex/4096 =^\\s{0,100}BEGIN\\s{0,100}[{] awk script text
|
||||
0 regex/4096 =^\\s{0,100}BEGIN\\s{0,100}[{] awk or perl script text
|
||||
|
||||
# AT&T Bell Labs' Plan 9 shell
|
||||
0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable
|
||||
|
@ -1,5 +1,5 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: compress,v 1.58 2014/05/07 19:36:59 christos Exp $
|
||||
# $File: compress,v 1.62 2014/09/13 14:27:12 christos Exp $
|
||||
# compress: file(1) magic for pure-compression formats (no archives)
|
||||
#
|
||||
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
|
||||
@ -251,3 +251,13 @@
|
||||
# http://code.google.com/p/snappy/source/browse/trunk/framing_format.txt
|
||||
0 string \377\006\0\0sNaPpY snappy framed data
|
||||
!:mime application/x-snappy-framed
|
||||
|
||||
# qpress, http://www.quicklz.com/
|
||||
0 string qpress10 qpress compressed data
|
||||
!:mime application/x-qpress
|
||||
|
||||
# Zlib https://www.ietf.org/rfc/rfc6713.txt
|
||||
0 beshort%31 =0
|
||||
>0 byte&0xf =8
|
||||
>>0 byte&0x80 =0 zlib compressed data
|
||||
!:mime application/zlib
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: database,v 1.41 2014/06/03 19:17:27 christos Exp $
|
||||
# $File: database,v 1.43 2014/10/28 15:47:39 christos Exp $
|
||||
# database: file(1) magic for various databases
|
||||
#
|
||||
# extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
|
||||
@ -9,9 +9,17 @@
|
||||
# GDBM magic numbers
|
||||
# Will be maintained as part of the GDBM distribution in the future.
|
||||
# <downsj@teeny.org>
|
||||
0 belong 0x13579ace GNU dbm 1.x or ndbm database, big endian
|
||||
0 belong 0x13579acd GNU dbm 1.x or ndbm database, big endian, 32-bit
|
||||
!:mime application/x-gdbm
|
||||
0 lelong 0x13579ace GNU dbm 1.x or ndbm database, little endian
|
||||
0 belong 0x13579ace GNU dbm 1.x or ndbm database, big endian, old
|
||||
!:mime application/x-gdbm
|
||||
0 belong 0x13579acf GNU dbm 1.x or ndbm database, big endian, 64-bit
|
||||
!:mime application/x-gdbm
|
||||
0 lelong 0x13579acd GNU dbm 1.x or ndbm database, little endian, 32-bit
|
||||
!:mime application/x-gdbm
|
||||
0 lelong 0x13579ace GNU dbm 1.x or ndbm database, little endian, old
|
||||
!:mime application/x-gdbm
|
||||
0 lelong 0x13579acf GNU dbm 1.x or ndbm database, little endian, 64-bit
|
||||
!:mime application/x-gdbm
|
||||
0 string GDBM GNU dbm 2.x database
|
||||
!:mime application/x-gdbm
|
||||
@ -202,27 +210,27 @@
|
||||
# for multiple index files (*.MDX) Production flag,tag numbers(<=0x30),tag length(<=0x20), reserverd (NULL)
|
||||
>>>>>>>24 ubelong&0x0133f7ff >0
|
||||
# test for reserved NULL byte
|
||||
>>>>>>>>47 ubyte x
|
||||
>>>>>>>>47 ubyte 0
|
||||
# test for valid TAG key format (0x10 or 0)
|
||||
>>>>>>>>>559 ubyte&0xeF 0
|
||||
# test MM <= 12
|
||||
>>>>>>>>>45 ubeshort <0x0C20
|
||||
>>>>>>>>>>45 ubyte >0
|
||||
>>>>>>>>>>>46 ubyte <32
|
||||
>>>>>>>>>>>>46 ubyte >0
|
||||
>>>>>>>>>>45 ubeshort <0x0C20
|
||||
>>>>>>>>>>>45 ubyte >0
|
||||
>>>>>>>>>>>>46 ubyte <32
|
||||
>>>>>>>>>>>>>46 ubyte >0
|
||||
#!:mime application/x-mdx
|
||||
>>>>>>>>>>>>>0 use xbase-type
|
||||
>>>>>>>>>>>>>0 ubyte x \b MDX
|
||||
>>>>>>>>>>>>>1 ubyte x \b, creation-date
|
||||
>>>>>>>>>>>>>1 use xbase-date
|
||||
>>>>>>>>>>>>>44 ubyte x \b, update-date
|
||||
>>>>>>>>>>>>>44 use xbase-date
|
||||
>>>>>>>>>>>>>>0 use xbase-type
|
||||
>>>>>>>>>>>>>>0 ubyte x \b MDX
|
||||
>>>>>>>>>>>>>>1 ubyte x \b, creation-date
|
||||
>>>>>>>>>>>>>>1 use xbase-date
|
||||
>>>>>>>>>>>>>>44 ubyte x \b, update-date
|
||||
>>>>>>>>>>>>>>44 use xbase-date
|
||||
# No.of tags in use (1,2,5,12)
|
||||
>>>>>>>>>>>>>28 uleshort x \b, %d
|
||||
>>>>>>>>>>>>>>28 uleshort x \b, %d
|
||||
# No. of entries in tag (0x30)
|
||||
>>>>>>>>>>>>>25 ubyte x \b/%d tags
|
||||
>>>>>>>>>>>>>>25 ubyte x \b/%d tags
|
||||
# Length of tag
|
||||
>>>>>>>>>>>>>26 ubyte x * %d
|
||||
>>>>>>>>>>>>>>26 ubyte x * %d
|
||||
# 1st tag name_
|
||||
>>>>>>>>>>>>>548 string x \b, 1st tag "%.11s"
|
||||
# 2nd tag name
|
||||
@ -337,60 +345,103 @@
|
||||
# dBASE III
|
||||
>>>>>>16 ubyte 3
|
||||
# dBASE III DBT
|
||||
>>>>>>>0 use xbase-memo-print
|
||||
# dBASE IV DBT , FoxPro FPT or many PNG , ZIP , DBF garbage
|
||||
>>>>>>>0 use dbase3-memo-print
|
||||
# dBASE III DBT without version, dBASE IV DBT , FoxPro FPT , or many ZIP , DBF garbage
|
||||
>>>>>>16 ubyte 0
|
||||
# dBASE IV DBT with DBF name or DBF garbage
|
||||
>>>>>>>8 ubelong >0x40000000
|
||||
# skip DBF and catch dBASE IV DBT with DBF name and with non big index of next free block
|
||||
>>>>>>>>0 ulelong <0x01010002
|
||||
>>>>>>>>>0 use xbase-memo-print
|
||||
>>>>>>>8 ubelong 0
|
||||
# unusual dBASE III DBT like angest.dbt, dBASE IV DBT with block size 0 , FoxPro FPT , or garbage PCX DBF
|
||||
>>>>>>>20 uleshort 0
|
||||
# FoxPro FPT , unusual dBASE III DBT like biblio.dbt or garbage
|
||||
>>>>>>>>8 ulong =0
|
||||
>>>>>>>>>6 ubeshort >0
|
||||
# skip emacs.PIF
|
||||
>>>>>>>>>>4 ushort 0
|
||||
>>>>>>>>>>>0 use foxpro-memo-print
|
||||
# dBASE III DBT , garbage
|
||||
>>>>>>>>>6 ubeshort 0
|
||||
# skip MM*DD*.bin by test for for reserved NULL byte
|
||||
>>>>>>>>508 ubelong 0
|
||||
# real memo files should contain text here
|
||||
>>>>>>>>>520 ubelong >0x20202019
|
||||
>>>>>>>>>>520 ubelong <0xFEFEFEFF
|
||||
>>>>>>>>>>>0 use xbase-memo-print
|
||||
# garbage PCX , ZIP , JAR , XPI
|
||||
>>>>>>>8 default x
|
||||
>>>>>>>>>>510 ubeshort 0
|
||||
# skip TK-DOS11.img image by looking for memo text
|
||||
>>>>>>>>>>>512 ubelong <0xfeffff03
|
||||
# skip EFI executables by looking for memo text
|
||||
>>>>>>>>>>>>512 ubelong >0x1F202020
|
||||
>>>>>>>>>>>>>513 ubyte >0
|
||||
# unusual dBASE III DBT like adressen.dbt
|
||||
>>>>>>>>>>>>>>0 use dbase3-memo-print
|
||||
# dBASE III DBT like angest.dbt, or garbage PCX DBF
|
||||
>>>>>>>>8 ubelong !0
|
||||
# skip PCX and some DBF by test for for reserved NULL bytes
|
||||
>>>>>>>>>510 ubeshort 0
|
||||
# skip some DBF by test of invalid version
|
||||
>>>>>>>>>>0 ubyte >5
|
||||
>>>>>>>>>>>0 ubyte <48
|
||||
>>>>>>>>>>>>0 use dbase3-memo-print
|
||||
# dBASE IV DBT with positive block size
|
||||
>>>>>>>20 uleshort >0
|
||||
>>>>>>>>0 use dbase4-memo-print
|
||||
|
||||
# Print the information of dBase DBT or FoxPro FPT memo files
|
||||
0 name xbase-memo-print
|
||||
>0 ubyte x
|
||||
# test version
|
||||
# memo file
|
||||
>>16 ubyte 3 dBase III DBT
|
||||
>>16 ubyte 0
|
||||
>>>512 ubelong <0x00000003 FoxPro FPT
|
||||
# Size of blocks for FoxPro
|
||||
>>>>6 ubeshort x \b, blocks size %u
|
||||
# Number of next available block for appending data for FoxPro
|
||||
>>>>0 ubelong =0 \b, next free block index %u
|
||||
>>>>0 ubelong !0 \b, next free block index %u
|
||||
>>>512 default x dBase IV DBT
|
||||
# DBF file name without extension
|
||||
>>>>8 string >\0 \b of %-.8s.DBF
|
||||
# size of blocks ; not reliable 0x2020204C
|
||||
#>>>>4 ulelong =0 \b, blocks size %u
|
||||
>>>>4 ulelong !0 \b, blocks size %u
|
||||
# Block length found 0 , 512
|
||||
#>>>>20 uleshort =0 \b, block length %u
|
||||
>>>>20 uleshort !0 \b, block length %u
|
||||
# Print the information of dBase III DBT memo file
|
||||
0 name dbase3-memo-print
|
||||
>0 ubyte x dBase III DBT
|
||||
# instead 3 as version number 0 for unusual examples like biblio.dbt
|
||||
>16 ubyte !3 \b, version number %u
|
||||
# Number of next available block for appending data
|
||||
>>>>0 ulelong =0 \b, next free block index %u
|
||||
>>>>0 ulelong !0 \b, next free block index %u
|
||||
>>512 ubelong x
|
||||
>>>512 ubelong =0xFFFF0800
|
||||
>>>>520 string >\0 \b, 1st used item "%s"
|
||||
# FoxPro
|
||||
>>>512 ubelong <3
|
||||
# FoxPro memo
|
||||
>>>>512 ubelong =1
|
||||
>>>>520 string >\0 \b, 1st used item "%s"
|
||||
>>>512 default x
|
||||
# may be deleted memo field
|
||||
>>>>512 string >\0 \b, 1st item "%s"
|
||||
#>0 lelong =0 \b, next free block index %u
|
||||
>0 lelong !0 \b, next free block index %u
|
||||
# no positiv block length
|
||||
#>20 uleshort =0 \b, block length %u
|
||||
>20 uleshort !0 \b, block length %u
|
||||
# dBase III memo field terminated by \032\032
|
||||
>512 string >\0 \b, 1st item "%s"
|
||||
# Print the information of dBase IV DBT memo file
|
||||
0 name dbase4-memo-print
|
||||
>0 lelong x dBase IV DBT
|
||||
# 8 character shorted main name of coresponding dBASE IV DBF file
|
||||
>8 ubelong >0x20000000
|
||||
# skip unusual like for angest.dbt
|
||||
>>20 uleshort >0
|
||||
>>>8 string >\0 \b of %-.8s.DBF
|
||||
# value 0 implies 512 as size
|
||||
#>4 ulelong =0 \b, blocks size %u
|
||||
# size of blocks not reliable like 0x2020204C in angest.dbt
|
||||
>4 ulelong !0
|
||||
>>4 ulelong&0x0000003f 0 \b, blocks size %u
|
||||
# dBase IV DBT with positive block length (found 512 , 1024)
|
||||
>20 uleshort >0 \b, block length %u
|
||||
# next available block
|
||||
#>0 lelong =0 \b, next free block index %u
|
||||
>0 lelong !0 \b, next free block index %u
|
||||
>20 uleshort >0
|
||||
>>(20.s) ubelong x
|
||||
>>>&-4 use dbase4-memofield-print
|
||||
# unusual dBase IV DBT without block length (implies 512 as length)
|
||||
>20 uleshort =0
|
||||
>>512 ubelong x
|
||||
>>>&-4 use dbase4-memofield-print
|
||||
# Print the information of dBase IV memo field
|
||||
0 name dbase4-memofield-print
|
||||
# free dBase IV memo field
|
||||
>0 ubelong !0xFFFF0800
|
||||
>>0 lelong x \b, next free block %u
|
||||
>>4 lelong x \b, next used block %u
|
||||
# used dBase IV memo field
|
||||
>0 ubelong =0xFFFF0800
|
||||
# length of memo field
|
||||
>>4 lelong x \b, field length %d
|
||||
>>>8 string >\0 \b, 1st used item "%s"
|
||||
# Print the information of FoxPro FPT memo file
|
||||
0 name foxpro-memo-print
|
||||
>0 belong x FoxPro FPT
|
||||
# Size of blocks for FoxPro ( 64,256 )
|
||||
>6 ubeshort x \b, blocks size %u
|
||||
# next available block
|
||||
#>0 belong =0 \b, next free block index %u
|
||||
>0 belong !0 \b, next free block index %u
|
||||
# field type ( 0~picture, 1~memo, 2~object )
|
||||
>512 ubelong <3 \b, field type %u
|
||||
# length of memo field
|
||||
>512 ubelong 1
|
||||
>>516 belong >0 \b, field length %d
|
||||
>>>520 string >\0 \b, 1st item "%s"
|
||||
|
||||
# TODO:
|
||||
# DBASE index file *.NDX
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: elf,v 1.67 2014/06/12 13:52:48 christos Exp $
|
||||
# $File: elf,v 1.68 2014/09/19 19:05:57 christos Exp $
|
||||
# elf: file(1) magic for ELF executables
|
||||
#
|
||||
# We have to check the byte order flag to see what byte order all the
|
||||
@ -257,6 +257,7 @@
|
||||
>18 leshort 216 Cognitive Smart Memory,
|
||||
>18 leshort 217 iCelero CoolEngine,
|
||||
>18 leshort 218 Nanoradio Optimized RISC,
|
||||
>18 leshort 243 UCB RISC-V,
|
||||
>18 leshort 0x1057 AVR (unofficial),
|
||||
>18 leshort 0x1059 MSP430 (unofficial),
|
||||
>18 leshort 0x1223 Adapteva Epiphany (unofficial),
|
||||
|
@ -1,5 +1,5 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: filesystems,v 1.106 2014/10/23 17:17:09 christos Exp $
|
||||
# $File: filesystems,v 1.107 2014/12/03 18:02:52 christos Exp $
|
||||
# filesystems: file(1) magic for different filesystems
|
||||
#
|
||||
0 name partid
|
||||
@ -2122,6 +2122,7 @@
|
||||
#----------------------------------------------------------
|
||||
#delta ISO Daniel Novotny (dnovotny@redhat.com)
|
||||
0 string DISO Delta ISO data
|
||||
!:strength +50
|
||||
>4 belong x version %d
|
||||
|
||||
# VMS backup savesets - gerardo.cacciari@gmail.com
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: images,v 1.91 2014/04/30 21:41:02 christos Exp $
|
||||
# $File: images,v 1.97 2014/12/08 16:06:19 christos Exp $
|
||||
# images: file(1) magic for image formats (see also "iff", and "c-lang" for
|
||||
# XPM bitmaps)
|
||||
#
|
||||
@ -115,8 +115,92 @@
|
||||
# never changed. The TIFF specification recommends testing for it.
|
||||
0 string MM\x00\x2a TIFF image data, big-endian
|
||||
!:mime image/tiff
|
||||
>(4.L) use tiff_ifd
|
||||
0 string II\x2a\x00 TIFF image data, little-endian
|
||||
!:mime image/tiff
|
||||
>(4.l) use tiff_ifd
|
||||
|
||||
0 name tiff_ifd
|
||||
>0 leshort x \b, direntries=%d
|
||||
>2 use tiff_entry
|
||||
|
||||
0 name tiff_entry
|
||||
>0 leshort 0x100
|
||||
>>4 lelong 1
|
||||
>>>12 use tiff_entry
|
||||
>>>8 lelong x \b, width=%d
|
||||
>0 leshort 0x101
|
||||
>>4 lelong 1
|
||||
>>>8 lelong x \b, height=%d
|
||||
>>>12 use tiff_entry
|
||||
>0 leshort 0x102
|
||||
>>8 lelong x \b, bps=%d
|
||||
>>12 use tiff_entry
|
||||
>0 leshort 0x103
|
||||
>>4 lelong 1 \b, compression=
|
||||
>>>8 lelong 1 \bnone
|
||||
>>>8 lelong 2 \bhuffman
|
||||
>>>8 lelong 3 \bbi-level group 3
|
||||
>>>8 lelong 4 \bbi-level group 4
|
||||
>>>8 lelong 5 \bLZW
|
||||
>>>8 lelong 6 \bJPEG (old)
|
||||
>>>8 lelong 7 \bJPEG
|
||||
>>>8 lelong 8 \bdeflate
|
||||
>>>8 lelong 9 \bJBIG, ITU-T T.85
|
||||
>>>8 lelong 0xa \bJBIG, ITU-T T.43
|
||||
>>>8 lelong 0x7ffe \bNeXT RLE 2-bit
|
||||
>>>8 lelong 0x8005 \bPackBits (Macintosh RLE)
|
||||
>>>8 lelong 0x8029 \bThunderscan RLE
|
||||
>>>8 lelong 0x807f \bRasterPadding (CT or MP)
|
||||
>>>8 lelong 0x8080 \bRLE (Line Work)
|
||||
>>>8 lelong 0x8081 \bRLE (High-Res Cont-Tone)
|
||||
>>>8 lelong 0x8082 \bRLE (Binary Line Work)
|
||||
>>>8 lelong 0x80b2 \bDeflate (PKZIP)
|
||||
>>>8 lelong 0x80b3 \bKodak DCS
|
||||
>>>8 lelong 0x8765 \bJBIG
|
||||
>>>8 lelong 0x8798 \bJPEG2000
|
||||
>>>8 lelong 0x8799 \bNikon NEF Compressed
|
||||
>>>8 default x
|
||||
>>>>8 lelong x \b(unknown 0x%x)
|
||||
>>>12 use tiff_entry
|
||||
>0 leshort 0x106 \b, PhotometricIntepretation=
|
||||
>>8 lelong 0 \bWhiteIsZero
|
||||
>>8 lelong 1 \bBlackIsZero
|
||||
>>8 lelong 2 \bRGB
|
||||
>>8 lelong 3 \bRGB Palette
|
||||
>>8 lelong 4 \bTransparency Mask
|
||||
>>8 lelong 5 \bCMYK
|
||||
>>8 lelong 6 \bYCbCr
|
||||
>>8 lelong 8 \bCIELab
|
||||
>>>8 lelong x \b(unknown=0x%x)
|
||||
>>12 use tiff_entry
|
||||
# FillOrder
|
||||
>0 leshort 0x10a
|
||||
>>4 lelong 1
|
||||
>>>12 use tiff_entry
|
||||
# DocumentName
|
||||
>0 leshort 0x10d
|
||||
>>(8.l) string x \b, name=%s
|
||||
>>>12 use tiff_entry
|
||||
# ImageDescription
|
||||
>0 leshort 0x10e
|
||||
>>(8.l) string x \b, description=%s
|
||||
>>>12 use tiff_entry
|
||||
# StripOffsets
|
||||
>0 leshort 0x111
|
||||
>>12 use tiff_entry
|
||||
# NewSubFileType
|
||||
>0 leshort 0xfe
|
||||
>>12 use tiff_entry
|
||||
# Datetime
|
||||
>0 leshort 0x132
|
||||
>>(8.l) string x \b, datetime=%s
|
||||
>>>12 use tiff_entry
|
||||
# HostComputer
|
||||
>0 leshort 0x13c
|
||||
>>(8.l) string x \b, hostcomputer=%s
|
||||
>>>12 use tiff_entry
|
||||
#>0 leshort x \b, unknown=0x%x
|
||||
|
||||
0 string MM\x00\x2b Big TIFF image data, big-endian
|
||||
!:mime image/tiff
|
||||
@ -892,6 +976,65 @@
|
||||
0 string \x46\x4d\x52\x00 ISO/IEC 19794-2 Format Minutiae Record (FMR)
|
||||
|
||||
# WEBP https://developers.google.com/speed/webp/docs/riff_container
|
||||
0 string RIFF
|
||||
>8 string WEBP Web/P image data
|
||||
>>4 lelong x \b, %d bytes
|
||||
#0 string RIFF
|
||||
#>8 string WEBP Web/P image data
|
||||
#>>4 lelong x \b, %d bytes
|
||||
|
||||
# doc: http://www.shikino.co.jp/eng/products/images/FLOWER.jpg.zip
|
||||
# example: http://www.shikino.co.jp/eng/products/images/FLOWER.wdp.zip
|
||||
90 bequad 0x574D50484F544F00 JPEG-XR Image
|
||||
>98 byte&0x08 =0x08 \b, hard tiling
|
||||
>99 byte&0x80 =0x80 \b, tiling present
|
||||
>99 byte&0x40 =0x40 \b, codestream present
|
||||
>99 byte&0x38 x \b, spatial xform=
|
||||
>99 byte&0x38 0x00 \bTL
|
||||
>99 byte&0x38 0x08 \bBL
|
||||
>99 byte&0x38 0x10 \bTR
|
||||
>99 byte&0x38 0x18 \bBR
|
||||
>99 byte&0x38 0x20 \bBT
|
||||
>99 byte&0x38 0x28 \bRB
|
||||
>99 byte&0x38 0x30 \bLT
|
||||
>99 byte&0x38 0x38 \bLB
|
||||
>100 byte&0x80 =0x80 \b, short header
|
||||
>>102 beshort+1 x \b, %d
|
||||
>>104 beshort+1 x \bx%d
|
||||
>100 byte&0x80 =0x00 \b, long header
|
||||
>>102 belong+1 x \b, %x
|
||||
>>106 belong+1 x \bx%x
|
||||
>101 beshort&0xf x \b, bitdepth=
|
||||
>>101 beshort&0xf 0x0 \b1-WHITE=1
|
||||
>>101 beshort&0xf 0x1 \b8
|
||||
>>101 beshort&0xf 0x2 \b16
|
||||
>>101 beshort&0xf 0x3 \b16-SIGNED
|
||||
>>101 beshort&0xf 0x4 \b16-FLOAT
|
||||
>>101 beshort&0xf 0x5 \b(reserved 5)
|
||||
>>101 beshort&0xf 0x6 \b32-SIGNED
|
||||
>>101 beshort&0xf 0x7 \b32-FLOAT
|
||||
>>101 beshort&0xf 0x8 \b5
|
||||
>>101 beshort&0xf 0x9 \b10
|
||||
>>101 beshort&0xf 0xa \b5-6-5
|
||||
>>101 beshort&0xf 0xb \b(reserved %d)
|
||||
>>101 beshort&0xf 0xc \b(reserved %d)
|
||||
>>101 beshort&0xf 0xd \b(reserved %d)
|
||||
>>101 beshort&0xf 0xe \b(reserved %d)
|
||||
>>101 beshort&0xf 0xf \b1-BLACK=1
|
||||
>101 beshort&0xf0 x \b, colorfmt=
|
||||
>>101 beshort&0xf0 0x00 \bYONLY
|
||||
>>101 beshort&0xf0 0x10 \bYUV240
|
||||
>>101 beshort&0xf0 0x20 \bYWV422
|
||||
>>101 beshort&0xf0 0x30 \bYWV444
|
||||
>>101 beshort&0xf0 0x40 \bCMYK
|
||||
>>101 beshort&0xf0 0x50 \bCMYKDIRECT
|
||||
>>101 beshort&0xf0 0x60 \bNCOMPONENT
|
||||
>>101 beshort&0xf0 0x70 \bRGB
|
||||
>>101 beshort&0xf0 0x80 \bRGBE
|
||||
>>101 beshort&0xf0 >0x80 \b(reserved 0x%x)
|
||||
|
||||
# From: Johan van der Knijff <johan.vanderknijff@kb.nl>
|
||||
#
|
||||
# BPG (Better Portable Graphics) format
|
||||
# http://bellard.org/bpg/
|
||||
# http://fileformats.archiveteam.org/wiki/BPG
|
||||
#
|
||||
0 string \x42\x50\x47\xFB BPG (Better Portable Graphics)
|
||||
!:mime image/bpg
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: jpeg,v 1.19 2013/02/04 15:50:03 christos Exp $
|
||||
# $File: jpeg,v 1.21 2014/09/12 20:47:00 christos Exp $
|
||||
# JPEG images
|
||||
# SunOS 5.5.1 had
|
||||
#
|
||||
@ -22,10 +22,12 @@
|
||||
>>11 byte x \b %d.
|
||||
>>12 byte x \b%02d
|
||||
# Next, the resolution or aspect ratio of the image:
|
||||
#>>13 byte 0 \b, aspect ratio
|
||||
#>>13 byte 1 \b, resolution (DPI)
|
||||
#>>13 byte 2 \b, resolution (DPCM)
|
||||
#>>4 beshort x \b, segment length %d
|
||||
>>13 byte 0 \b, aspect ratio
|
||||
>>13 byte 1 \b, resolution (DPI)
|
||||
>>13 byte 2 \b, resolution (DPCM)
|
||||
>>14 beshort x \b, density %dx
|
||||
>>16 beshort x \b%d
|
||||
>>4 beshort x \b, segment length %d
|
||||
# Next, show thumbnail info, if it exists:
|
||||
>>18 byte !0 \b, thumbnail %dx
|
||||
>>>19 byte x \b%d
|
||||
@ -121,33 +123,52 @@
|
||||
>>>>>(150.L+59) byte x %c
|
||||
>>>>>(150.L+60) byte x \b.%c
|
||||
>>>>>(150.L+61) byte !0x30 \b%c
|
||||
# Here things get sticky. We can do ONE MORE marker segment with
|
||||
# indirect addressing, and that's all. It would be great if we could
|
||||
# do pointer arithemetic like in an assembler language. Christos?
|
||||
# And if there was some sort of looping construct to do searches, plus a few
|
||||
# named accumulators, it would be even more effective...
|
||||
# At least we can show a comment if no other segments got inserted before:
|
||||
>(4.S+5) byte 0xFE \b, comment:
|
||||
>>(4.S+6) pstring/HJ x "%s"
|
||||
# Or, we can show the encoding type (I've included only the three most common)
|
||||
# and image dimensions if we are lucky and the SOFn (image segment) is here:
|
||||
>(4.S+5) byte 0xC0 \b, baseline
|
||||
>>(4.S+6) byte x \b, precision %d
|
||||
>>(4.S+7) beshort x \b, %dx
|
||||
>>(4.S+9) beshort x \b%d
|
||||
>(4.S+5) byte 0xC1 \b, extended sequential
|
||||
>>(4.S+6) byte x \b, precision %d
|
||||
>>(4.S+7) beshort x \b, %dx
|
||||
>>(4.S+9) beshort x \b%d
|
||||
>(4.S+5) byte 0xC2 \b, progressive
|
||||
>>(4.S+6) byte x \b, precision %d
|
||||
>>(4.S+7) beshort x \b, %dx
|
||||
>>(4.S+9) beshort x \b%d
|
||||
# I've commented-out quantisation table reporting. I doubt anyone cares yet.
|
||||
#>(4.S+5) byte 0xDB \b, quantisation table
|
||||
#>>(4.S+6) beshort x \b length=%d
|
||||
#>14 beshort x \b, %d x
|
||||
#>16 beshort x \b %d
|
||||
|
||||
# Jump to the first segment
|
||||
>(4.S+4) use jpeg_segment
|
||||
|
||||
# This uses recursion...
|
||||
0 name jpeg_segment
|
||||
>0 beshort 0xFFFE
|
||||
>>(2.S+2) use jpeg_segment
|
||||
>>2 pstring/HJ x \b, comment: "%s"
|
||||
|
||||
>0 beshort 0xFFC0
|
||||
>>(2.S+2) use jpeg_segment
|
||||
>>4 byte x \b, baseline, precision %d
|
||||
>>7 beshort x \b, %dx
|
||||
>>5 beshort x \b%d
|
||||
>>9 byte x \b, frames %d
|
||||
|
||||
>0 beshort 0xFFC1
|
||||
>>(2.S+2) use jpeg_segment
|
||||
>>4 byte x \b, extended sequential, precision %d
|
||||
>>7 beshort x \b, %dx
|
||||
>>5 beshort x \b%d
|
||||
>>9 byte x \b, frames %d
|
||||
|
||||
>0 beshort 0xFFC2
|
||||
>>(2.S+2) use jpeg_segment
|
||||
>>4 byte x \b, progressive, precision %d
|
||||
>>7 beshort x \b, %dx
|
||||
>>5 beshort x \b%d
|
||||
>>9 byte x \b, frames %d
|
||||
|
||||
# Define Huffman Tables
|
||||
>0 beshort 0xFFC4
|
||||
>>(2.S+2) use jpeg_segment
|
||||
|
||||
# Application specific markers
|
||||
>0 beshort&0xFFE0 =0xFFE0
|
||||
>>(2.S+2) use jpeg_segment
|
||||
|
||||
# DB: Define Quantization tables
|
||||
# DD: Define Restart interval [XXX: wrong here, it is 4 bytes]
|
||||
# D8: Start of image
|
||||
# D9: End of image
|
||||
# Dn: Restart
|
||||
>0 beshort&0xFFD0 =0xFFD0
|
||||
>>(2.S+2) use jpeg_segment
|
||||
|
||||
# HSI is Handmade Software's proprietary JPEG encoding scheme
|
||||
0 string hsi1 JPEG image data, HSI proprietary
|
||||
|
45
contrib/file/magic/Magdir/kerberos
Normal file
45
contrib/file/magic/Magdir/kerberos
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: kerberos,v 1.1 2014/12/10 18:45:43 christos Exp $
|
||||
# kerberos: MIT kerberos file binary formats
|
||||
#
|
||||
|
||||
# This magic entry is for demonstration purposes and could be improved
|
||||
# if the following features were implemented in file:
|
||||
#
|
||||
# Strings inside [[ .. ]] in the descriptions have special meanings and
|
||||
# are not printed.
|
||||
#
|
||||
# - Provide some form of iteration in number of components
|
||||
# [[${counter}=%d]] in the description
|
||||
# then append
|
||||
# [${counter}--] in the offset of the entries
|
||||
# - Provide a way to round the next offset
|
||||
# Add [R:4] after the offset?
|
||||
# - Provide a way to have optional entries
|
||||
# XXX: Syntax:
|
||||
# - Provide a way to "save" entries to print them later.
|
||||
# if the description is [[${name}=%s]], then nothing is
|
||||
# printed and a subsequent entry in the same magic file
|
||||
# can refer to ${name}
|
||||
# - Provide a way to format strings as hex values
|
||||
#
|
||||
# http://www.gnu.org/software/shishi/manual/html_node/\
|
||||
# The-Keytab-Binary-File-Format.html
|
||||
#
|
||||
|
||||
0 name keytab_entry
|
||||
#>0 beshort x \b, size=%d
|
||||
#>2 beshort x \b, components=%d
|
||||
>4 pstring/H x \b, realm=%s
|
||||
>>&0 pstring/H x \b, principal=%s/
|
||||
>>>&0 pstring/H x \b%s
|
||||
>>>>&0 belong x \b, type=%d
|
||||
>>>>>&0 bedate x \b, date=%s
|
||||
>>>>>>&0 byte x \b, kvno=%u
|
||||
#>>>>>>>&0 pstring/H x
|
||||
#>>>>>>>>&0 belong x
|
||||
#>>>>>>>>>>&0 use keytab_entry
|
||||
|
||||
0 belong 0x05020000 Kerberos Keytab file
|
||||
>4 use keytab_entry
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: linux,v 1.57 2014/05/20 20:10:17 christos Exp $
|
||||
# $File: linux,v 1.59 2014/11/03 21:03:36 christos Exp $
|
||||
# linux: file(1) magic for Linux files
|
||||
#
|
||||
# Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com>
|
||||
@ -413,3 +413,22 @@
|
||||
>>>>20 belong >16
|
||||
>>>>>36 belong x \b, DT structure block size=%d
|
||||
|
||||
# glibc locale archive as defined in glibc locale/locarchive.h
|
||||
0 lelong 0xde020109 locale archive
|
||||
>24 lelong x %d strings
|
||||
|
||||
# Summary: Database file for mlocate
|
||||
# Description: A database file as used by mlocate, a fast implementation
|
||||
# of locate/updatedb. It uses merging to reuse the existing
|
||||
# database and avoid rereading most of the filesystem. It's
|
||||
# the default version of locate on Arch Linux (and others).
|
||||
# File path: /var/lib/mlocate/mlocate.db by default (but configurable)
|
||||
# Site: https://fedorahosted.org/mlocate/
|
||||
# Format docs: http://linux.die.net/man/5/mlocate.db
|
||||
# Type: mlocate database file
|
||||
# URL: https://fedorahosted.org/mlocate/
|
||||
# From: Wander Nauta <info@wandernauta.nl>
|
||||
0 string \0mlocate mlocate database
|
||||
>12 byte x \b, version %d
|
||||
>13 byte 1 \b, require visibility
|
||||
>16 string x \b, root %s
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: macintosh,v 1.23 2013/11/19 18:47:58 christos Exp $
|
||||
# $File: macintosh,v 1.25 2014/09/03 13:34:16 christos Exp $
|
||||
# macintosh description
|
||||
#
|
||||
# BinHex is the Macintosh ASCII-encoded file format (see also "apple")
|
||||
@ -165,7 +165,7 @@
|
||||
#>65 string ZSYS (Pre-System 7 system file)
|
||||
#>65 string acf3 (Aldus FreeHand)
|
||||
#>65 string cdev (control panel)
|
||||
#>65 string dfil (Desk Acessory suitcase)
|
||||
#>65 string dfil (Desk Accessory suitcase)
|
||||
#>65 string libr (library)
|
||||
#>65 string nX^d (WriteNow word processor)
|
||||
#>65 string nX^w (WriteNow dictionary)
|
||||
@ -288,20 +288,38 @@
|
||||
>0x412 beshort x number of blocks: %d,
|
||||
>0x424 pstring x volume name: %s
|
||||
|
||||
# *.hfs updated by Joerg Jenderek
|
||||
# http://en.wikipedia.org/wiki/Hierarchical_File_System
|
||||
# "BD" gives many false positives
|
||||
#0x400 beshort 0x4244 Macintosh HFS data
|
||||
#>0 beshort 0x4C4B (bootable)
|
||||
#>0x40a beshort &0x8000 (locked)
|
||||
#>0x40a beshort ^0x0100 (mounted)
|
||||
#>0x40a beshort &0x0200 (spared blocks)
|
||||
#>0x40a beshort &0x0800 (unclean)
|
||||
#>0x47C beshort 0x482B (Embedded HFS+ Volume)
|
||||
#>0x402 beldate-0x7C25B080 x created: %s,
|
||||
#>0x406 beldate-0x7C25B080 x last modified: %s,
|
||||
#>0x440 beldate-0x7C25B080 >0 last backup: %s,
|
||||
#>0x414 belong x block size: %d,
|
||||
#>0x412 beshort x number of blocks: %d,
|
||||
#>0x424 pstring x volume name: %s
|
||||
0x400 beshort 0x4244
|
||||
# ftp://ftp.mars.org/pub/hfs/hfsutils-3.2.6.tar.gz/hfsutils-3.2.6/libhfs/apple.h
|
||||
# first block of volume bit map (always 3)
|
||||
>0x40e ubeshort 0x0003
|
||||
# maximal length of volume name is 27
|
||||
>>0x424 ubyte <28 Macintosh HFS data
|
||||
#!:mime application/octet-stream
|
||||
# these mime and apple types are not sure
|
||||
!:mime application/x-apple-diskimage
|
||||
#!:apple hfsdINIT
|
||||
#!:apple MACSdisk
|
||||
>>>0 beshort 0x4C4B (bootable)
|
||||
#>>>0 beshort 0x0000 (not bootable)
|
||||
>>>0x40a beshort &0x8000 (locked)
|
||||
>>>0x40a beshort ^0x0100 (mounted)
|
||||
>>>0x40a beshort &0x0200 (spared blocks)
|
||||
>>>0x40a beshort &0x0800 (unclean)
|
||||
>>>0x47C beshort 0x482B (Embedded HFS+ Volume)
|
||||
# http://www.epochconverter.com/
|
||||
# 0x7C245F00 seconds ~ 2082758400 ~ 01 Jan 2036 00:00:00 ~ 66 years to 1970
|
||||
# 0x7C25B080 seconds ~ 2082844800 ~ 02 Jan 2036 00:00:00
|
||||
# construct not working
|
||||
#>>>0x402 beldate-0x7C25B080 x created: %s,
|
||||
#>>>0x406 beldate-0x7C25B080 x last modified: %s,
|
||||
#>>>0x440 beldate-0x7C25B080 >0 last backup: %s,
|
||||
# found block sizes 200h,1200h,2800h
|
||||
>>>0x414 belong x block size: %d,
|
||||
>>>0x412 beshort x number of blocks: %d,
|
||||
>>>0x424 pstring x volume name: %s
|
||||
|
||||
0x400 beshort 0x482B Macintosh HFS Extended
|
||||
>&0 beshort x version %d data
|
||||
@ -322,43 +340,9 @@
|
||||
>&42 belong x number of blocks: %d,
|
||||
>&46 belong x free blocks: %d
|
||||
|
||||
# I don't think this is really necessary since it doesn't do much and
|
||||
# anything with a valid driver descriptor will also have a valid
|
||||
# partition map
|
||||
#0 beshort 0x4552 Apple Device Driver data
|
||||
#>&24 beshort =1 \b, MacOS
|
||||
|
||||
# Is that the partition type a cstring or a pstring? Well, IM says "strings
|
||||
# shorter than 32 bytes must be terminated with NULL" so I'll treat it as a
|
||||
# cstring. Of course, partitions can contain more than four entries, but
|
||||
# what're you gonna do?
|
||||
# GRR: This magic is too weak, it is just "PM"
|
||||
#0x200 beshort 0x504D Apple Partition data
|
||||
#>0x2 beshort x (block size: %d):
|
||||
#>0x230 string x first type: %s,
|
||||
#>0x210 string x name: %s,
|
||||
#>0x254 belong x number of blocks: %d,
|
||||
#>0x400 beshort 0x504D
|
||||
#>>0x430 string x second type: %s,
|
||||
#>>0x410 string x name: %s,
|
||||
#>>0x454 belong x number of blocks: %d,
|
||||
#>>0x600 beshort 0x504D
|
||||
#>>>0x630 string x third type: %s,
|
||||
#>>>0x610 string x name: %s,
|
||||
#>>>0x654 belong x number of blocks: %d,
|
||||
#>>0x800 beshort 0x504D
|
||||
#>>>0x830 string x fourth type: %s,
|
||||
#>>>0x810 string x name: %s,
|
||||
#>>>0x854 belong x number of blocks: %d,
|
||||
#>>>0xa00 beshort 0x504D
|
||||
#>>>>0xa30 string x fifth type: %s,
|
||||
#>>>>0xa10 string x name: %s,
|
||||
#>>>>0xa54 belong x number of blocks: %d
|
||||
#>>>0xc00 beshort 0x504D
|
||||
#>>>>0xc30 string x sixth type: %s,
|
||||
#>>>>0xc10 string x name: %s,
|
||||
#>>>>0xc54 belong x number of blocks: %d
|
||||
## AFAIK, only the signature is different
|
||||
# same as Apple Partition Map
|
||||
# GRR: This magic is too weak, it is just "TS"
|
||||
#0x200 beshort 0x5453 Apple Old Partition data
|
||||
#>0x2 beshort x block size: %d,
|
||||
#>0x230 string x first type: %s,
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: rinex,v 1.4 2011/05/03 01:44:17 christos Exp $
|
||||
# $File: meteorological,v 1.1 2014/08/04 06:26:16 christos Exp $
|
||||
# rinex: file(1) magic for RINEX files
|
||||
# http://igscb.jpl.nasa.gov/igscb/data/format/rinex210.txt
|
||||
# ftp://cddis.gsfc.nasa.gov/pub/reports/formats/rinex300.pdf
|
||||
@ -42,3 +42,8 @@
|
||||
>>&32 string x \b, date %15.15s
|
||||
>>5 string x \b, version %6.6s
|
||||
!:mime rinex/observation
|
||||
|
||||
# https://en.wikipedia.org/wiki/GRIB
|
||||
0 string GRIB
|
||||
>7 byte =1 Gridded binary (GRIB) version 1
|
||||
>7 byte =2 Gridded binary (GRIB) version 2
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: msooxml,v 1.4 2014/01/06 18:16:24 rrt Exp $
|
||||
# $File: msooxml,v 1.5 2014/08/05 07:38:45 christos Exp $
|
||||
# msooxml: file(1) magic for Microsoft Office XML
|
||||
# From: Ralf Brown <ralf.brown@gmail.com>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
0 string PK\003\004
|
||||
!:strength +10
|
||||
# make sure the first file is correct
|
||||
>0x1E regex \[Content_Types\]\.xml|_rels/\.rels
|
||||
>0x1E regex \\[Content_Types\\]\\.xml|_rels/\\.rels
|
||||
# skip to the second local file header
|
||||
# since some documents include a 520-byte extra field following the file
|
||||
# header, we need to scan for the next header
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: netbsd,v 1.21 2014/03/29 15:40:34 christos Exp $
|
||||
# $File: netbsd,v 1.22 2014/12/08 20:53:52 christos Exp $
|
||||
# netbsd: file(1) magic for NetBSD objects
|
||||
#
|
||||
# All new-style magic numbers are in network byte order.
|
||||
@ -247,7 +247,7 @@
|
||||
# Kernel core dump format
|
||||
0 belong&0x0000ffff 0x00008fca NetBSD kernel core file
|
||||
>0 belong&0x03ff0000 0x00000000 \b, Unknown
|
||||
>0 belong&0x03ff0000 0x00001000 \b, sun 68010/68020
|
||||
>0 belong&0x03ff0000 0x00010000 \b, sun 68010/68020
|
||||
>0 belong&0x03ff0000 0x00020000 \b, sun 68020
|
||||
>0 belong&0x03ff0000 0x00640000 \b, 386 PC
|
||||
>0 belong&0x03ff0000 0x00860000 \b, i386 BSD
|
||||
@ -262,20 +262,24 @@
|
||||
>0 belong&0x03ff0000 0x008f0000 \b, arm6 BSD
|
||||
>0 belong&0x03ff0000 0x00900000 \b, m68k BSD (2K pages)
|
||||
>0 belong&0x03ff0000 0x00910000 \b, sh3 BSD
|
||||
>0 belong&0x03ff0000 0x00920000 \b, ppc BSD (Big Endian)
|
||||
>0 belong&0x03ff0000 0x00930000 \b, vax BSD (4K pages)
|
||||
>0 belong&0x03ff0000 0x00940000 \b, mips1 BSD
|
||||
>0 belong&0x03ff0000 0x00950000 \b, mips2 BSD
|
||||
>0 belong&0x03ff0000 0x00960000 \b, parisc BSD
|
||||
>0 belong&0x03ff0000 0x00970000 \b, sh5/64 BSD
|
||||
>0 belong&0x03ff0000 0x00980000 \b, SPARC/64 BSD
|
||||
>0 belong&0x03ff0000 0x00990000 \b, amd64 BSD
|
||||
>0 belong&0x03ff0000 0x009a0000 \b, hp200 (68010) BSD
|
||||
>0 belong&0x03ff0000 0x009b0000 \b, hp300 (68020+68881) BSD
|
||||
>0 belong&0x03ff0000 0x009b0000 \b, hp300 (68020+68881) BSD
|
||||
>0 belong&0x03ff0000 0x00c80000 \b, hp200
|
||||
>0 belong&0x03ff0000 0x020b0000 \b, hp300 (68020+68881) HP-UX
|
||||
>0 belong&0x03ff0000 0x020c0000 \b, hp300 (68020+68881) HP-UX
|
||||
>0 belong&0x03ff0000 0x00950000 \b, ppc BSD (Big Endian)
|
||||
>0 belong&0x03ff0000 0x00960000 \b, vax BSD (4K pages)
|
||||
>0 belong&0x03ff0000 0x00970000 \b, mips1 BSD
|
||||
>0 belong&0x03ff0000 0x00980000 \b, mips2 BSD
|
||||
>0 belong&0x03ff0000 0x00990000 \b, m88k BSD
|
||||
>0 belong&0x03ff0000 0x00920000 \b, parisc BSD
|
||||
>0 belong&0x03ff0000 0x009b0000 \b, sh5/64 BSD
|
||||
>0 belong&0x03ff0000 0x009c0000 \b, SPARC/64 BSD
|
||||
>0 belong&0x03ff0000 0x009d0000 \b, amd64 BSD
|
||||
>0 belong&0x03ff0000 0x009e0000 \b, sh5/32 BSD
|
||||
>0 belong&0x03ff0000 0x009f0000 \b, ia64 BSD
|
||||
>0 belong&0x03ff0000 0x00b70000 \b, aarch64 BSD
|
||||
>0 belong&0x03ff0000 0x00b80000 \b, or1k BSD
|
||||
>0 belong&0x03ff0000 0x00b90000 \b, Risk-V BSD
|
||||
>0 belong&0x03ff0000 0x00c80000 \b, hp200 BSD
|
||||
>0 belong&0x03ff0000 0x012c0000 \b, hp300 BSD
|
||||
>0 belong&0x03ff0000 0x020b0000 \b, hp800 HP-UX
|
||||
>0 belong&0x03ff0000 0x020c0000 \b, hp200/hp300 HP-UX
|
||||
>0 belong&0xfc000000 0x04000000 \b, CPU
|
||||
>0 belong&0xfc000000 0x08000000 \b, DATA
|
||||
>0 belong&0xfc000000 0x10000000 \b, STACK
|
||||
|
@ -1,10 +1,10 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: pascal,v 1.1 2011/12/08 12:12:46 rrt Exp $
|
||||
# $File: pascal,v 1.2 2014/07/14 14:21:33 rrt Exp $
|
||||
# pascal: file(1) magic for Pascal source
|
||||
#
|
||||
0 search/8192 (input, Pascal source text
|
||||
!:mime text/x-pascal
|
||||
0 regex \^program Pascal source text
|
||||
!:mime text/x-pascal
|
||||
0 regex \^record Pascal source text
|
||||
!:mime text/x-pascal
|
||||
#0 regex \^program Pascal source text
|
||||
#!:mime text/x-pascal
|
||||
#0 regex \^record Pascal source text
|
||||
#!:mime text/x-pascal
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: pgp,v 1.9 2009/09/19 16:28:11 christos Exp $
|
||||
# $File: pgp,v 1.11 2014/11/11 21:32:38 christos Exp $
|
||||
# pgp: file(1) magic for Pretty Good Privacy
|
||||
# see http://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html
|
||||
#
|
||||
@ -21,7 +21,449 @@
|
||||
|
||||
2 string ---BEGIN\ PGP\ PUBLIC\ KEY\ BLOCK- PGP public key block
|
||||
!:mime application/pgp-keys
|
||||
>10 search/100 \n\n
|
||||
>>&0 use pgp
|
||||
0 string -----BEGIN\040PGP\40MESSAGE- PGP message
|
||||
!:mime application/pgp
|
||||
>10 search/100 \n\n
|
||||
>>&0 use pgp
|
||||
0 string -----BEGIN\040PGP\40SIGNATURE- PGP signature
|
||||
!:mime application/pgp-signature
|
||||
>10 search/100 \n\n
|
||||
>>&0 use pgp
|
||||
|
||||
# Decode the type of the packet based on it's base64 encoding.
|
||||
# Idea from Mark Martinec
|
||||
# The specification is in RFC 4880, section 4.2 and 4.3:
|
||||
# http://tools.ietf.org/html/rfc4880#section-4.2
|
||||
|
||||
0 name pgp
|
||||
>0 byte 0x67 Reserved (old)
|
||||
>0 byte 0x68 Public-Key Encrypted Session Key (old)
|
||||
>0 byte 0x69 Signature (old)
|
||||
>0 byte 0x6a Symmetric-Key Encrypted Session Key (old)
|
||||
>0 byte 0x6b One-Pass Signature (old)
|
||||
>0 byte 0x6c Secret-Key (old)
|
||||
>0 byte 0x6d Public-Key (old)
|
||||
>0 byte 0x6e Secret-Subkey (old)
|
||||
>0 byte 0x6f Compressed Data (old)
|
||||
>0 byte 0x70 Symmetrically Encrypted Data (old)
|
||||
>0 byte 0x71 Marker (old)
|
||||
>0 byte 0x72 Literal Data (old)
|
||||
>0 byte 0x73 Trust (old)
|
||||
>0 byte 0x74 User ID (old)
|
||||
>0 byte 0x75 Public-Subkey (old)
|
||||
>0 byte 0x76 Unused (old)
|
||||
>0 byte 0x77
|
||||
>>1 byte&0xc0 0x00 Reserved
|
||||
>>1 byte&0xc0 0x40 Public-Key Encrypted Session Key
|
||||
>>1 byte&0xc0 0x80 Signature
|
||||
>>1 byte&0xc0 0xc0 Symmetric-Key Encrypted Session Key
|
||||
>0 byte 0x78
|
||||
>>1 byte&0xc0 0x00 One-Pass Signature
|
||||
>>1 byte&0xc0 0x40 Secret-Key
|
||||
>>1 byte&0xc0 0x80 Public-Key
|
||||
>>1 byte&0xc0 0xc0 Secret-Subkey
|
||||
>0 byte 0x79
|
||||
>>1 byte&0xc0 0x00 Compressed Data
|
||||
>>1 byte&0xc0 0x40 Symmetrically Encrypted Data
|
||||
>>1 byte&0xc0 0x80 Marker
|
||||
>>1 byte&0xc0 0xc0 Literal Data
|
||||
>0 byte 0x7a
|
||||
>>1 byte&0xc0 0x00 Trust
|
||||
>>1 byte&0xc0 0x40 User ID
|
||||
>>1 byte&0xc0 0x80 Public-Subkey
|
||||
>>1 byte&0xc0 0xc0 Unused [z%x]
|
||||
>0 byte 0x30
|
||||
>>1 byte&0xc0 0x00 Unused [0%x]
|
||||
>>1 byte&0xc0 0x40 User Attribute
|
||||
>>1 byte&0xc0 0x80 Sym. Encrypted and Integrity Protected Data
|
||||
>>1 byte&0xc0 0xc0 Modification Detection Code
|
||||
|
||||
# magic signatures to detect PGP crypto material (from stef)
|
||||
# detects and extracts metadata from:
|
||||
# - symmetric encrypted packet header
|
||||
# - RSA (e=65537) secret (sub-)keys
|
||||
|
||||
# 1024b RSA encrypted data
|
||||
|
||||
0 string \x84\x8c\x03 PGP RSA encrypted session key -
|
||||
>3 lelong x keyid: %X
|
||||
>7 lelong x %X
|
||||
>11 byte 0x01 RSA (Encrypt or Sign) 1024b
|
||||
>11 byte 0x02 RSA Encrypt-Only 1024b
|
||||
>12 string \x04\x00
|
||||
>12 string \x03\xff
|
||||
>12 string \x03\xfe
|
||||
>12 string \x03\xfd
|
||||
>12 string \x03\xfc
|
||||
>12 string \x03\xfb
|
||||
>12 string \x03\xfa
|
||||
>12 string \x03\xf9
|
||||
>142 byte 0xd2 .
|
||||
|
||||
# 2048b RSA encrypted data
|
||||
|
||||
0 string \x85\x01\x0c\x03 PGP RSA encrypted session key -
|
||||
>4 lelong x keyid: %X
|
||||
>8 lelong x %X
|
||||
>12 byte 0x01 RSA (Encrypt or Sign) 2048b
|
||||
>12 byte 0x02 RSA Encrypt-Only 2048b
|
||||
>13 string \x08\x00
|
||||
>13 string \x07\xff
|
||||
>13 string \x07\xfe
|
||||
>13 string \x07\xfd
|
||||
>13 string \x07\xfc
|
||||
>13 string \x07\xfb
|
||||
>13 string \x07\xfa
|
||||
>13 string \x07\xf9
|
||||
>271 byte 0xd2 .
|
||||
|
||||
# 3072b RSA encrypted data
|
||||
|
||||
0 string \x85\x01\x8c\x03 PGP RSA encrypted session key -
|
||||
>4 lelong x keyid: %X
|
||||
>8 lelong x %X
|
||||
>12 byte 0x01 RSA (Encrypt or Sign) 3072b
|
||||
>12 byte 0x02 RSA Encrypt-Only 3072b
|
||||
>13 string \x0c\x00
|
||||
>13 string \x0b\xff
|
||||
>13 string \x0b\xfe
|
||||
>13 string \x0b\xfd
|
||||
>13 string \x0b\xfc
|
||||
>13 string \x0b\xfb
|
||||
>13 string \x0b\xfa
|
||||
>13 string \x0b\xf9
|
||||
>399 byte 0xd2 .
|
||||
|
||||
# 3072b RSA encrypted data
|
||||
|
||||
0 string \x85\x02\x0c\x03 PGP RSA encrypted session key -
|
||||
>4 lelong x keyid: %X
|
||||
>8 lelong x %X
|
||||
>12 byte 0x01 RSA (Encrypt or Sign) 4096b
|
||||
>12 byte 0x02 RSA Encrypt-Only 4096b
|
||||
>13 string \x10\x00
|
||||
>13 string \x0f\xff
|
||||
>13 string \x0f\xfe
|
||||
>13 string \x0f\xfd
|
||||
>13 string \x0f\xfc
|
||||
>13 string \x0f\xfb
|
||||
>13 string \x0f\xfa
|
||||
>13 string \x0f\xf9
|
||||
>527 byte 0xd2 .
|
||||
|
||||
# 4096b RSA encrypted data
|
||||
|
||||
0 string \x85\x04\x0c\x03 PGP RSA encrypted session key -
|
||||
>4 lelong x keyid: %X
|
||||
>8 lelong x %X
|
||||
>12 byte 0x01 RSA (Encrypt or Sign) 8129b
|
||||
>12 byte 0x02 RSA Encrypt-Only 8129b
|
||||
>13 string \x20\x00
|
||||
>13 string \x1f\xff
|
||||
>13 string \x1f\xfe
|
||||
>13 string \x1f\xfd
|
||||
>13 string \x1f\xfc
|
||||
>13 string \x1f\xfb
|
||||
>13 string \x1f\xfa
|
||||
>13 string \x1f\xf9
|
||||
>1039 byte 0xd2 .
|
||||
|
||||
# crypto algo mapper
|
||||
|
||||
0 name crypto
|
||||
>0 byte 0x00 Plaintext or unencrypted data
|
||||
>0 byte 0x01 IDEA
|
||||
>0 byte 0x02 TripleDES
|
||||
>0 byte 0x03 CAST5 (128 bit key)
|
||||
>0 byte 0x04 Blowfish (128 bit key, 16 rounds)
|
||||
>0 byte 0x07 AES with 128-bit key
|
||||
>0 byte 0x08 AES with 192-bit key
|
||||
>0 byte 0x09 AES with 256-bit key
|
||||
>0 byte 0x0a Twofish with 256-bit key
|
||||
|
||||
# hash algo mapper
|
||||
|
||||
0 name hash
|
||||
>0 byte 0x01 MD5
|
||||
>0 byte 0x02 SHA-1
|
||||
>0 byte 0x03 RIPE-MD/160
|
||||
>0 byte 0x08 SHA256
|
||||
>0 byte 0x09 SHA384
|
||||
>0 byte 0x0a SHA512
|
||||
>0 byte 0x0b SHA224
|
||||
|
||||
# pgp symmetric encrypted data
|
||||
|
||||
0 byte 0x8c PGP symmetric key encrypted data -
|
||||
>1 byte 0x0d
|
||||
>1 byte 0x0c
|
||||
>2 byte 0x04
|
||||
>3 use crypto
|
||||
>4 byte 0x01 salted -
|
||||
>>5 use hash
|
||||
>>14 byte 0xd2 .
|
||||
>>14 byte 0xc9 .
|
||||
>4 byte 0x03 salted & iterated -
|
||||
>>5 use hash
|
||||
>>15 byte 0xd2 .
|
||||
>>15 byte 0xc9 .
|
||||
|
||||
# encrypted keymaterial needs s2k & can be checksummed/hashed
|
||||
|
||||
0 name chkcrypto
|
||||
>0 use crypto
|
||||
>1 byte 0x00 Simple S2K
|
||||
>1 byte 0x01 Salted S2K
|
||||
>1 byte 0x03 Salted&Iterated S2K
|
||||
>2 use hash
|
||||
|
||||
# all PGP keys start with this prolog
|
||||
# containing version, creation date, and purpose
|
||||
|
||||
0 name keyprolog
|
||||
>0 byte 0x04
|
||||
>1 beldate x created on %s -
|
||||
>5 byte 0x01 RSA (Encrypt or Sign)
|
||||
>5 byte 0x02 RSA Encrypt-Only
|
||||
|
||||
# end of secret keys known signature
|
||||
# contains e=65537 and the prolog to
|
||||
# the encrypted parameters
|
||||
|
||||
0 name keyend
|
||||
>0 string \x00\x11\x01\x00\x01 e=65537
|
||||
>5 use crypto
|
||||
>5 byte 0xff checksummed
|
||||
>>6 use chkcrypto
|
||||
>5 byte 0xfe hashed
|
||||
>>6 use chkcrypto
|
||||
|
||||
# PGP secret keys contain also the public parts
|
||||
# these vary by bitsize of the key
|
||||
|
||||
0 name x1024
|
||||
>0 use keyprolog
|
||||
>6 string \x03\xfe
|
||||
>6 string \x03\xff
|
||||
>6 string \x04\x00
|
||||
>136 use keyend
|
||||
|
||||
0 name x2048
|
||||
>0 use keyprolog
|
||||
>6 string \x80\x00
|
||||
>6 string \x07\xfe
|
||||
>6 string \x07\xff
|
||||
>264 use keyend
|
||||
|
||||
0 name x3072
|
||||
>0 use keyprolog
|
||||
>6 string \x0b\xfe
|
||||
>6 string \x0b\xff
|
||||
>6 string \x0c\x00
|
||||
>392 use keyend
|
||||
|
||||
0 name x4096
|
||||
>0 use keyprolog
|
||||
>6 string \x10\x00
|
||||
>6 string \x0f\xfe
|
||||
>6 string \x0f\xff
|
||||
>520 use keyend
|
||||
|
||||
# \x00|\x1f[\xfe\xff]).{1024})'
|
||||
0 name x8192
|
||||
>0 use keyprolog
|
||||
>6 string \x20\x00
|
||||
>6 string \x1f\xfe
|
||||
>6 string \x1f\xff
|
||||
>1032 use keyend
|
||||
|
||||
# depending on the size of the pkt
|
||||
# we branch into the proper key size
|
||||
# signatures defined as x{keysize}
|
||||
|
||||
>0 name pgpkey
|
||||
>0 string \x01\xd8 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x01\xeb 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x01\xfb 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x01\xfd 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x01\xf3 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x01\xee 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x01\xfe 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x01\xf4 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x02\x0d 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x02\x03 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x02\x05 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x02\x15 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x02\x00 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x02\x10 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x02\x04 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x02\x06 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x02\x16 1024b
|
||||
>>2 use x1024
|
||||
>0 string \x03\x98 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xab 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xbb 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xbd 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xcd 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xb3 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xc3 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xc5 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xd5 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xae 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xbe 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xc0 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xd0 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xb4 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xc4 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xc6 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x03\xd6 2048b
|
||||
>>2 use x2048
|
||||
>0 string \x05X 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05k 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05{ 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05} 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x8d 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05s 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x83 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x85 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x95 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05n 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x7e 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x80 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x90 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05t 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x84 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x86 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x05\x96 3072b
|
||||
>>2 use x3072
|
||||
>0 string \x07[ 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07\x18 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07+ 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07; 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07= 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07M 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x073 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07C 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07E 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07U 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07. 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07> 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07@ 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07P 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x074 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07D 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07F 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x07V 4096b
|
||||
>>2 use x4096
|
||||
>0 string \x0e[ 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0e\x18 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0e+ 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0e; 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0e= 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0eM 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0e3 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0eC 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0eE 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0eU 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0e. 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0e> 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0e@ 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0eP 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0e4 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0eD 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0eF 8192b
|
||||
>>2 use x8192
|
||||
>0 string \x0eV 8192b
|
||||
>>2 use x8192
|
||||
|
||||
# PGP RSA (e=65537) secret (sub-)key header
|
||||
|
||||
0 byte 0x95 PGP Secret Key -
|
||||
>1 use pgpkey
|
||||
0 byte 0x97 PGP Secret Sub-key -
|
||||
>1 use pgpkey
|
||||
0 byte 0x9d PGP Secret Sub-key -
|
||||
>1 use pgpkey
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: python,v 1.25 2014/05/06 16:08:32 christos Exp $
|
||||
# $File: python,v 1.26 2014/08/04 05:58:40 christos Exp $
|
||||
# python: file(1) magic for python
|
||||
#
|
||||
# Outlook puts """ too for urgent messages
|
||||
@ -23,6 +23,7 @@
|
||||
0 belong 0x4f0c0d0a python 3.1 byte-compiled
|
||||
0 belong 0x6c0c0d0a python 3.2 byte-compiled
|
||||
0 belong 0x9e0c0d0a python 3.3 byte-compiled
|
||||
0 belong 0xee0c0d0a python 3.4 byte-compiled
|
||||
|
||||
0 search/1/w #!\ /usr/bin/python Python script text executable
|
||||
!:mime text/x-python
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: riff,v 1.27 2014/04/30 21:41:02 christos Exp $
|
||||
# $File: riff,v 1.30 2014/09/23 17:02:12 christos Exp $
|
||||
# riff: file(1) magic for RIFF format
|
||||
# See
|
||||
#
|
||||
@ -45,6 +45,26 @@
|
||||
>>&(4.l+4) use riff-walk
|
||||
>0 string fact
|
||||
>>&(4.l+4) use riff-walk
|
||||
>0 string VP8
|
||||
>>11 byte 0x9d
|
||||
>>>12 byte 0x01
|
||||
>>>>13 byte 0x2a \b, VP8 encoding
|
||||
>>>>>14 leshort&0x3fff x \b, %d
|
||||
>>>>>16 leshort&0x3fff x \bx%d, Scaling:
|
||||
>>>>>14 leshort&0xc000 0x0000 \b [none]
|
||||
>>>>>14 leshort&0xc000 0x1000 \b [5/4]
|
||||
>>>>>14 leshort&0xc000 0x2000 \b [5/3]
|
||||
>>>>>14 leshort&0xc000 0x3000 \b [2]
|
||||
>>>>>14 leshort&0xc000 0x0000 \bx[none]
|
||||
>>>>>14 leshort&0xc000 0x1000 \bx[5/4]
|
||||
>>>>>14 leshort&0xc000 0x2000 \bx[5/3]
|
||||
>>>>>14 leshort&0xc000 0x3000 \bx[2]
|
||||
>>>>>15 byte&0x80 =0x00 \b, YUV color
|
||||
>>>>>15 byte&0x80 =0x80 \b, bad color specification
|
||||
>>>>>15 byte&0x40 =0x40 \b, no clamping required
|
||||
>>>>>15 byte&0x40 =0x00 \b, decoders should clamp
|
||||
#>0 string x we got %s
|
||||
#>>&(4.l+4) use riff-walk
|
||||
|
||||
# AVI section extended by Patrik Radman <patrik+file-magic@iki.fi>
|
||||
#
|
||||
@ -209,6 +229,8 @@
|
||||
>8 string 4XMV \b, 4X Movie file
|
||||
# AMV-type AVI file: http://wiki.multimedia.cx/index.php?title=AMV
|
||||
>8 string AMV\040 \b, AMV
|
||||
>8 string WEBP \b, Web/P image
|
||||
>>12 use riff-walk
|
||||
|
||||
#
|
||||
# XXX - some of the below may only appear in little-endian form.
|
||||
@ -284,4 +306,3 @@
|
||||
>>&6 leshort =2 \b, stereo
|
||||
>>&6 leshort >2 \b, %d channels
|
||||
>>&8 lelong >0 %d Hz
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: sequent,v 1.11 2014/06/02 19:27:54 christos Exp $
|
||||
# $File: sequent,v 1.12 2014/08/16 16:07:12 christos Exp $
|
||||
# sequent: file(1) magic for Sequent machines
|
||||
#
|
||||
# Sequent information updated by Don Dwiggins <atsun!dwiggins>.
|
||||
@ -30,9 +30,6 @@
|
||||
0 leshort 0x32eb SYMMETRY i386 executable (invalid @ 0)
|
||||
>16 lelong >0 not stripped
|
||||
>124 lelong >0 version %d
|
||||
0 leshort 0x42eb SYMMETRY i386 standalone executable
|
||||
>16 lelong >0 not stripped
|
||||
>124 lelong >0 version %d
|
||||
# http://en.wikipedia.org/wiki/Sequent_Computer_Systems
|
||||
# below test line conflicts with MS-DOS 2.11 floppies and Acronis loader
|
||||
#0 leshort 0x42eb SYMMETRY i386 standalone executable
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: sereal,v 1.1 2014/05/14 23:04:59 christos Exp $
|
||||
# $File: sereal,v 1.2 2014/11/11 20:10:49 christos Exp $
|
||||
# sereal: file(1) magic the Sereal binary serialization format
|
||||
#
|
||||
# From: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
|
||||
@ -15,10 +16,10 @@
|
||||
#
|
||||
# See https://github.com/Sereal/Sereal/commit/35372ae01d in the
|
||||
# Sereal.git repository for test Sereal data.
|
||||
0 string \=srl Sereal data
|
||||
0 string \=srl Sereal data
|
||||
!:mime application/sereal
|
||||
>4 byte&0x0F x (version %d,
|
||||
>4 byte&0xF0 0x00 uncompressed)
|
||||
>4 byte&0xF0 0x10 compressed with non-incremental Snappy)
|
||||
>4 byte&0xF0 0x20 compressed with incremental Snappy)
|
||||
>4 byte&0xF0 >0x20 unknown subformat, flag: %d>>4)
|
||||
>4 byte&0x0F x (version %d,
|
||||
>4 byte&0xF0 0x00 uncompressed)
|
||||
>4 byte&0xF0 0x10 compressed with non-incremental Snappy)
|
||||
>4 byte&0xF0 0x20 compressed with incremental Snappy)
|
||||
>4 byte&0xF0 >0x20 unknown subformat, flag: %d>>4)
|
||||
|
@ -3,9 +3,11 @@
|
||||
|
||||
0 string SSH\ PRIVATE\ KEY OpenSSH RSA1 private key,
|
||||
>28 string >\0 version %s
|
||||
0 string -----BEGIN\ OPENSSH\ PRIVATE\ KEY----- OpenSSH private key
|
||||
|
||||
0 string ssh-dss\ OpenSSH DSA public key
|
||||
0 string ssh-rsa\ OpenSSH RSA public key
|
||||
0 string ecdsa-sha2-nistp256 OpenSSH ECDSA public key
|
||||
0 string ecdsa-sha2-nistp384 OpenSSH ECDSA public key
|
||||
0 string ecdsa-sha2-nistp521 OpenSSH ECDSA public key
|
||||
0 string ssh-ed25519 OpenSSH ED25519 public key
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: vms,v 1.7 2013/03/09 22:36:00 christos Exp $
|
||||
# $File: vms,v 1.9 2014/08/17 13:47:59 christos Exp $
|
||||
# vms: file(1) magic for VMS executables (experimental)
|
||||
#
|
||||
# VMS .exe formats, both VAX and AXP (Greg Roelofs, newt@uchicago.edu)
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: vorbis,v 1.18 2014/04/30 21:41:02 christos Exp $
|
||||
# $File: vorbis,v 1.20 2014/09/23 16:35:08 christos Exp $
|
||||
# vorbis: file(1) magic for Ogg/Vorbis files
|
||||
#
|
||||
# From Felix von Leitner <leitner@fefe.de>
|
||||
@ -23,7 +23,6 @@
|
||||
# --- Ogg Framing ---
|
||||
#0 search/1000 OggS Ogg data
|
||||
0 string OggS Ogg data
|
||||
!:mime application/ogg
|
||||
>4 byte !0 UNKNOWN REVISION %u
|
||||
##>4 byte 0 revision 0
|
||||
>4 byte 0
|
||||
@ -31,9 +30,12 @@
|
||||
# non-Vorbis content: FLAC (Free Lossless Audio Codec, http://flac.sourceforge.net)
|
||||
>>28 string \x7fFLAC \b, FLAC audio
|
||||
# non-Vorbis content: Theora
|
||||
!:mime audio/ogg
|
||||
>>28 string \x80theora \b, Theora video
|
||||
!:mime video/ogg
|
||||
# non-Vorbis content: Kate
|
||||
>>28 string \x80kate\0\0\0\0 \b, Kate
|
||||
>>28 string \x80kate\0\0\0\0 \b, Kate (Karaoke and Text)
|
||||
!:mime application/ogg
|
||||
>>>37 ubyte x v%u
|
||||
>>>38 ubyte x \b.%u,
|
||||
>>>40 byte 0 utf8 encoding,
|
||||
@ -44,18 +46,22 @@
|
||||
>>>76 string \0 no category set
|
||||
# non-Vorbis content: Skeleton
|
||||
>>28 string fishead\0 \b, Skeleton
|
||||
!:mime video/ogg
|
||||
>>>36 short x v%u
|
||||
>>>40 short x \b.%u
|
||||
# non-Vorbis content: Speex
|
||||
>>28 string Speex\ \ \ \b, Speex audio
|
||||
!:mime audio/ogg
|
||||
# non-Vorbis content: OGM
|
||||
>>28 string \x01video\0\0\0 \b, OGM video
|
||||
!:mime video/ogg
|
||||
>>>37 string/c div3 (DivX 3)
|
||||
>>>37 string/c divx (DivX 4)
|
||||
>>>37 string/c dx50 (DivX 5)
|
||||
>>>37 string/c xvid (XviD)
|
||||
# --- First vorbis packet - general header ---
|
||||
>>28 string \x01vorbis \b, Vorbis audio,
|
||||
!:mime audio/ogg
|
||||
>>>35 lelong !0 UNKNOWN VERSION %u,
|
||||
##>>>35 lelong 0 version 0,
|
||||
>>>35 lelong 0
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: windows,v 1.8 2014/04/30 21:41:02 christos Exp $
|
||||
# $File: windows,v 1.10 2014/09/24 19:52:46 christos Exp $
|
||||
# windows: file(1) magic for Microsoft Windows
|
||||
#
|
||||
# This file is mainly reserved for files where programs
|
||||
@ -159,8 +159,9 @@
|
||||
>&0 string Version\ 5.00\r\n\r\n Windows Registry text (Win2K or above)
|
||||
|
||||
# Windows *.INF *.INI files updated by Joerg Jenderek at Apr 2013
|
||||
# emtpy ,comment , section , unicode line
|
||||
0 regex/s \\`(\r\n|;|[[]|\xFF\xFE)
|
||||
# empty ,comment , section
|
||||
# PR/383: remove unicode BOM because it is not portable across regex impls
|
||||
0 regex/s \\`(\\r\\n|;|[[])
|
||||
# left bracket in section line
|
||||
>&0 search/8192 [
|
||||
# http://en.wikipedia.org/wiki/Autorun.inf
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $File: Makefile.am,v 1.98 2014/06/03 18:22:34 christos Exp $
|
||||
# $File: Makefile.am,v 1.100 2014/12/10 18:45:43 christos Exp $
|
||||
#
|
||||
MAGIC_FRAGMENT_BASE = Magdir
|
||||
MAGIC_DIR = $(top_srcdir)/magic
|
||||
@ -117,6 +117,7 @@ $(MAGIC_FRAGMENT_DIR)/jpeg \
|
||||
$(MAGIC_FRAGMENT_DIR)/karma \
|
||||
$(MAGIC_FRAGMENT_DIR)/kde \
|
||||
$(MAGIC_FRAGMENT_DIR)/keepass \
|
||||
$(MAGIC_FRAGMENT_DIR)/kerberos \
|
||||
$(MAGIC_FRAGMENT_DIR)/kml \
|
||||
$(MAGIC_FRAGMENT_DIR)/lecter \
|
||||
$(MAGIC_FRAGMENT_DIR)/lex \
|
||||
@ -142,6 +143,7 @@ $(MAGIC_FRAGMENT_DIR)/matroska \
|
||||
$(MAGIC_FRAGMENT_DIR)/mcrypt \
|
||||
$(MAGIC_FRAGMENT_DIR)/mercurial \
|
||||
$(MAGIC_FRAGMENT_DIR)/metastore \
|
||||
$(MAGIC_FRAGMENT_DIR)/meteorological \
|
||||
$(MAGIC_FRAGMENT_DIR)/mime \
|
||||
$(MAGIC_FRAGMENT_DIR)/mips \
|
||||
$(MAGIC_FRAGMENT_DIR)/mirage \
|
||||
@ -198,7 +200,6 @@ $(MAGIC_FRAGMENT_DIR)/pyramid \
|
||||
$(MAGIC_FRAGMENT_DIR)/python \
|
||||
$(MAGIC_FRAGMENT_DIR)/revision \
|
||||
$(MAGIC_FRAGMENT_DIR)/riff \
|
||||
$(MAGIC_FRAGMENT_DIR)/rinex \
|
||||
$(MAGIC_FRAGMENT_DIR)/rpm \
|
||||
$(MAGIC_FRAGMENT_DIR)/rtf \
|
||||
$(MAGIC_FRAGMENT_DIR)/ruby \
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Makefile.in generated by automake 1.14 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
@ -262,7 +262,7 @@ top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
#
|
||||
# $File: Makefile.am,v 1.98 2014/06/03 18:22:34 christos Exp $
|
||||
# $File: Makefile.am,v 1.100 2014/12/10 18:45:43 christos Exp $
|
||||
#
|
||||
MAGIC_FRAGMENT_BASE = Magdir
|
||||
MAGIC_DIR = $(top_srcdir)/magic
|
||||
@ -378,6 +378,7 @@ $(MAGIC_FRAGMENT_DIR)/jpeg \
|
||||
$(MAGIC_FRAGMENT_DIR)/karma \
|
||||
$(MAGIC_FRAGMENT_DIR)/kde \
|
||||
$(MAGIC_FRAGMENT_DIR)/keepass \
|
||||
$(MAGIC_FRAGMENT_DIR)/kerberos \
|
||||
$(MAGIC_FRAGMENT_DIR)/kml \
|
||||
$(MAGIC_FRAGMENT_DIR)/lecter \
|
||||
$(MAGIC_FRAGMENT_DIR)/lex \
|
||||
@ -403,6 +404,7 @@ $(MAGIC_FRAGMENT_DIR)/matroska \
|
||||
$(MAGIC_FRAGMENT_DIR)/mcrypt \
|
||||
$(MAGIC_FRAGMENT_DIR)/mercurial \
|
||||
$(MAGIC_FRAGMENT_DIR)/metastore \
|
||||
$(MAGIC_FRAGMENT_DIR)/meteorological \
|
||||
$(MAGIC_FRAGMENT_DIR)/mime \
|
||||
$(MAGIC_FRAGMENT_DIR)/mips \
|
||||
$(MAGIC_FRAGMENT_DIR)/mirage \
|
||||
@ -459,7 +461,6 @@ $(MAGIC_FRAGMENT_DIR)/pyramid \
|
||||
$(MAGIC_FRAGMENT_DIR)/python \
|
||||
$(MAGIC_FRAGMENT_DIR)/revision \
|
||||
$(MAGIC_FRAGMENT_DIR)/riff \
|
||||
$(MAGIC_FRAGMENT_DIR)/rinex \
|
||||
$(MAGIC_FRAGMENT_DIR)/rpm \
|
||||
$(MAGIC_FRAGMENT_DIR)/rtf \
|
||||
$(MAGIC_FRAGMENT_DIR)/ruby \
|
||||
|
@ -1,7 +1,7 @@
|
||||
#! /bin/sh
|
||||
# Common wrapper for a few potentially missing GNU programs.
|
||||
|
||||
scriptversion=2012-06-26.16; # UTC
|
||||
scriptversion=2013-10-28.13; # UTC
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
@ -160,7 +160,7 @@ give_advice ()
|
||||
;;
|
||||
autom4te*)
|
||||
echo "You might have modified some maintainer files that require"
|
||||
echo "the 'automa4te' program to be rebuilt."
|
||||
echo "the 'autom4te' program to be rebuilt."
|
||||
program_details 'autom4te'
|
||||
;;
|
||||
bison*|yacc*)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Makefile.in generated by automake 1.14 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Makefile.in generated by automake 1.14 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
@ -81,9 +81,9 @@ build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
bin_PROGRAMS = file$(EXEEXT)
|
||||
subdir = src
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am pread.c \
|
||||
ctime_r.c getline.c vasprintf.c asprintf.c asctime_r.c \
|
||||
fmtcheck.c strlcpy.c getopt_long.c strcasestr.c strlcat.c \
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am strcasestr.c \
|
||||
pread.c strlcpy.c vasprintf.c getopt_long.c asctime_r.c \
|
||||
strlcat.c ctime_r.c getline.c asprintf.c fmtcheck.c \
|
||||
$(top_srcdir)/depcomp $(include_HEADERS)
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.211 2014/06/03 19:01:34 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.227 2014/11/28 02:46:39 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@ -86,6 +86,10 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.211 2014/06/03 19:01:34 christos Exp $")
|
||||
#define ALLOC_CHUNK (size_t)10
|
||||
#define ALLOC_INCR (size_t)200
|
||||
|
||||
#define MAP_TYPE_MMAP 0
|
||||
#define MAP_TYPE_MALLOC 1
|
||||
#define MAP_TYPE_USER 2
|
||||
|
||||
struct magic_entry {
|
||||
struct magic *mp;
|
||||
uint32_t cont_count;
|
||||
@ -101,6 +105,7 @@ struct magic_entry_set {
|
||||
struct magic_map {
|
||||
void *p;
|
||||
size_t len;
|
||||
int type;
|
||||
struct magic *magic[MAGIC_SETS];
|
||||
uint32_t nmagic[MAGIC_SETS];
|
||||
};
|
||||
@ -131,7 +136,10 @@ private uint16_t swap2(uint16_t);
|
||||
private uint32_t swap4(uint32_t);
|
||||
private uint64_t swap8(uint64_t);
|
||||
private char *mkdbname(struct magic_set *, const char *, int);
|
||||
private struct magic_map *apprentice_buf(struct magic_set *, struct magic *,
|
||||
size_t);
|
||||
private struct magic_map *apprentice_map(struct magic_set *, const char *);
|
||||
private int check_buffer(struct magic_set *, struct magic_map *, const char *);
|
||||
private void apprentice_unmap(struct magic_map *);
|
||||
private int apprentice_compile(struct magic_set *, struct magic_map *,
|
||||
const char *);
|
||||
@ -396,10 +404,11 @@ add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx)
|
||||
{
|
||||
struct mlist *ml;
|
||||
|
||||
mlp->map = idx == 0 ? map : NULL;
|
||||
if ((ml = CAST(struct mlist *, malloc(sizeof(*ml)))) == NULL)
|
||||
return -1;
|
||||
|
||||
ml->map = idx == 0 ? map : NULL;
|
||||
ml->map = NULL;
|
||||
ml->magic = map->magic[idx];
|
||||
ml->nmagic = map->nmagic[idx];
|
||||
|
||||
@ -416,13 +425,11 @@ add_mlist(struct mlist *mlp, struct magic_map *map, size_t idx)
|
||||
private int
|
||||
apprentice_1(struct magic_set *ms, const char *fn, int action)
|
||||
{
|
||||
#ifndef COMPILE_ONLY
|
||||
struct mlist *ml;
|
||||
#endif /* COMPILE_ONLY */
|
||||
struct magic_map *map;
|
||||
#ifndef COMPILE_ONLY
|
||||
struct mlist *ml;
|
||||
size_t i;
|
||||
#endif /* COMPILE_ONLY */
|
||||
#endif
|
||||
|
||||
if (magicsize != FILE_MAGICSIZE) {
|
||||
file_error(ms, 0, "magic element size %lu != %lu",
|
||||
@ -451,22 +458,29 @@ apprentice_1(struct magic_set *ms, const char *fn, int action)
|
||||
for (i = 0; i < MAGIC_SETS; i++) {
|
||||
if (add_mlist(ms->mlist[i], map, i) == -1) {
|
||||
file_oomem(ms, sizeof(*ml));
|
||||
apprentice_unmap(map);
|
||||
return -1;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (action == FILE_LIST) {
|
||||
for (i = 0; i < MAGIC_SETS; i++) {
|
||||
printf("Set %zu:\nBinary patterns:\n", i);
|
||||
printf("Set %" SIZE_T_FORMAT "u:\nBinary patterns:\n",
|
||||
i);
|
||||
apprentice_list(ms->mlist[i], BINTEST);
|
||||
printf("Text patterns:\n");
|
||||
apprentice_list(ms->mlist[i], TEXTTEST);
|
||||
}
|
||||
}
|
||||
#endif /* COMPILE_ONLY */
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
for (i = 0; i < MAGIC_SETS; i++) {
|
||||
mlist_free(ms->mlist[i]);
|
||||
ms->mlist[i] = NULL;
|
||||
}
|
||||
return -1;
|
||||
#else
|
||||
return 0;
|
||||
#endif /* COMPILE_ONLY */
|
||||
}
|
||||
|
||||
protected void
|
||||
@ -510,6 +524,10 @@ file_ms_alloc(int flags)
|
||||
ms->mlist[i] = NULL;
|
||||
ms->file = "unknown";
|
||||
ms->line = 0;
|
||||
ms->indir_max = FILE_INDIR_MAX;
|
||||
ms->name_max = FILE_NAME_MAX;
|
||||
ms->elf_shnum_max = FILE_ELF_SHNUM_MAX;
|
||||
ms->elf_phnum_max = FILE_ELF_PHNUM_MAX;
|
||||
return ms;
|
||||
free:
|
||||
free(ms);
|
||||
@ -521,17 +539,21 @@ apprentice_unmap(struct magic_map *map)
|
||||
{
|
||||
if (map == NULL)
|
||||
return;
|
||||
if (map->p != NULL) {
|
||||
|
||||
switch (map->type) {
|
||||
#ifdef QUICK
|
||||
if (map->len)
|
||||
case MAP_TYPE_MMAP:
|
||||
if (map->p)
|
||||
(void)munmap(map->p, map->len);
|
||||
else
|
||||
break;
|
||||
#endif
|
||||
case MAP_TYPE_MALLOC:
|
||||
free(map->p);
|
||||
} else {
|
||||
uint32_t j;
|
||||
for (j = 0; j < MAGIC_SETS; j++)
|
||||
free(map->magic[j]);
|
||||
break;
|
||||
case MAP_TYPE_USER:
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
free(map);
|
||||
}
|
||||
@ -550,21 +572,70 @@ mlist_alloc(void)
|
||||
private void
|
||||
mlist_free(struct mlist *mlist)
|
||||
{
|
||||
struct mlist *ml;
|
||||
struct mlist *ml, *next;
|
||||
|
||||
if (mlist == NULL)
|
||||
return;
|
||||
|
||||
for (ml = mlist->next; ml != mlist;) {
|
||||
struct mlist *next = ml->next;
|
||||
ml = mlist->next;
|
||||
for (ml = mlist->next; (next = ml->next) != NULL; ml = next) {
|
||||
if (ml->map)
|
||||
apprentice_unmap(ml->map);
|
||||
free(ml);
|
||||
ml = next;
|
||||
if (ml == mlist)
|
||||
break;
|
||||
}
|
||||
free(ml);
|
||||
}
|
||||
|
||||
#ifndef COMPILE_ONLY
|
||||
/* void **bufs: an array of compiled magic files */
|
||||
protected int
|
||||
buffer_apprentice(struct magic_set *ms, struct magic **bufs,
|
||||
size_t *sizes, size_t nbufs)
|
||||
{
|
||||
size_t i, j;
|
||||
struct mlist *ml;
|
||||
struct magic_map *map;
|
||||
|
||||
if (nbufs == 0)
|
||||
return -1;
|
||||
|
||||
if (ms->mlist[0] != NULL)
|
||||
file_reset(ms);
|
||||
|
||||
init_file_tables();
|
||||
|
||||
for (i = 0; i < MAGIC_SETS; i++) {
|
||||
mlist_free(ms->mlist[i]);
|
||||
if ((ms->mlist[i] = mlist_alloc()) == NULL) {
|
||||
file_oomem(ms, sizeof(*ms->mlist[i]));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nbufs; i++) {
|
||||
map = apprentice_buf(ms, bufs[i], sizes[i]);
|
||||
if (map == NULL)
|
||||
goto fail;
|
||||
|
||||
for (j = 0; j < MAGIC_SETS; j++) {
|
||||
if (add_mlist(ms->mlist[j], map, j) == -1) {
|
||||
file_oomem(ms, sizeof(*ml));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
for (i = 0; i < MAGIC_SETS; i++) {
|
||||
mlist_free(ms->mlist[i]);
|
||||
ms->mlist[i] = NULL;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* const char *fn: list of magic files and directories */
|
||||
protected int
|
||||
file_apprentice(struct magic_set *ms, const char *fn, int action)
|
||||
@ -590,11 +661,9 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
|
||||
mlist_free(ms->mlist[i]);
|
||||
if ((ms->mlist[i] = mlist_alloc()) == NULL) {
|
||||
file_oomem(ms, sizeof(*ms->mlist[i]));
|
||||
if (i != 0) {
|
||||
--i;
|
||||
do
|
||||
mlist_free(ms->mlist[i]);
|
||||
while (i != 0);
|
||||
while (i-- > 0) {
|
||||
mlist_free(ms->mlist[i]);
|
||||
ms->mlist[i] = NULL;
|
||||
}
|
||||
free(mfn);
|
||||
return -1;
|
||||
@ -1317,7 +1386,7 @@ file_signextend(struct magic_set *ms, struct magic *m, uint64_t v)
|
||||
* the sign extension must have happened.
|
||||
*/
|
||||
case FILE_BYTE:
|
||||
v = (char) v;
|
||||
v = (signed char) v;
|
||||
break;
|
||||
case FILE_SHORT:
|
||||
case FILE_BESHORT:
|
||||
@ -2068,9 +2137,15 @@ parse_strength(struct magic_set *ms, struct magic_entry *me, const char *line)
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int
|
||||
goodchar(unsigned char x, const char *extra)
|
||||
{
|
||||
return (isascii(x) && isalnum(x)) || strchr(extra, x);
|
||||
}
|
||||
|
||||
private int
|
||||
parse_extra(struct magic_set *ms, struct magic_entry *me, const char *line,
|
||||
off_t off, size_t len, const char *name, int nt)
|
||||
off_t off, size_t len, const char *name, const char *extra, int nt)
|
||||
{
|
||||
size_t i;
|
||||
const char *l = line;
|
||||
@ -2091,9 +2166,7 @@ parse_extra(struct magic_set *ms, struct magic_entry *me, const char *line,
|
||||
}
|
||||
|
||||
EATAB;
|
||||
for (i = 0; *l && ((isascii((unsigned char)*l) &&
|
||||
isalnum((unsigned char)*l)) || strchr("-+/.", *l)) &&
|
||||
i < len; buf[i++] = *l++)
|
||||
for (i = 0; *l && i < len && goodchar(*l, extra); buf[i++] = *l++)
|
||||
continue;
|
||||
|
||||
if (i == len && *l) {
|
||||
@ -2103,14 +2176,18 @@ parse_extra(struct magic_set *ms, struct magic_entry *me, const char *line,
|
||||
file_magwarn(ms, "%s type `%s' truncated %"
|
||||
SIZE_T_FORMAT "u", name, line, i);
|
||||
} else {
|
||||
if (!isspace((unsigned char)*l) && !goodchar(*l, extra))
|
||||
file_magwarn(ms, "%s type `%s' has bad char '%c'",
|
||||
name, line, *l);
|
||||
if (nt)
|
||||
buf[i] = '\0';
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
|
||||
file_magerror(ms, "Bad magic entry '%s'", line);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2123,7 +2200,7 @@ parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line)
|
||||
struct magic *m = &me->mp[0];
|
||||
|
||||
return parse_extra(ms, me, line, offsetof(struct magic, apple),
|
||||
sizeof(m->apple), "APPLE", 0);
|
||||
sizeof(m->apple), "APPLE", "!+-./", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2136,7 +2213,7 @@ parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line)
|
||||
struct magic *m = &me->mp[0];
|
||||
|
||||
return parse_extra(ms, me, line, offsetof(struct magic, mimetype),
|
||||
sizeof(m->mimetype), "MIME", 1);
|
||||
sizeof(m->mimetype), "MIME", "+-/.", 1);
|
||||
}
|
||||
|
||||
private int
|
||||
@ -2696,6 +2773,28 @@ eatsize(const char **p)
|
||||
*p = l;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle a buffer containing a compiled file.
|
||||
*/
|
||||
private struct magic_map *
|
||||
apprentice_buf(struct magic_set *ms, struct magic *buf, size_t len)
|
||||
{
|
||||
struct magic_map *map;
|
||||
|
||||
if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
|
||||
file_oomem(ms, sizeof(*map));
|
||||
return NULL;
|
||||
}
|
||||
map->len = len;
|
||||
map->p = buf;
|
||||
map->type = MAP_TYPE_USER;
|
||||
if (check_buffer(ms, map, "buffer") != 0) {
|
||||
apprentice_unmap(map);
|
||||
return NULL;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle a compiled file.
|
||||
*/
|
||||
@ -2705,12 +2804,8 @@ apprentice_map(struct magic_set *ms, const char *fn)
|
||||
{
|
||||
int fd;
|
||||
struct stat st;
|
||||
uint32_t *ptr;
|
||||
uint32_t version, entries, nentries;
|
||||
int needsbyteswap;
|
||||
char *dbname = NULL;
|
||||
struct magic_map *map;
|
||||
size_t i;
|
||||
|
||||
fd = -1;
|
||||
if ((map = CAST(struct magic_map *, calloc(1, sizeof(*map)))) == NULL) {
|
||||
@ -2742,6 +2837,7 @@ apprentice_map(struct magic_set *ms, const char *fn)
|
||||
file_error(ms, errno, "cannot map `%s'", dbname);
|
||||
goto error;
|
||||
}
|
||||
map->type = MAP_TYPE_MMAP;
|
||||
#else
|
||||
if ((map->p = CAST(void *, malloc(map->len))) == NULL) {
|
||||
file_oomem(ms, map->len);
|
||||
@ -2751,16 +2847,39 @@ apprentice_map(struct magic_set *ms, const char *fn)
|
||||
file_badread(ms);
|
||||
goto error;
|
||||
}
|
||||
map->len = 0;
|
||||
map->type = MAP_TYPE_MALLOC;
|
||||
#define RET 1
|
||||
#endif
|
||||
(void)close(fd);
|
||||
fd = -1;
|
||||
|
||||
if (check_buffer(ms, map, dbname) != 0)
|
||||
goto error;
|
||||
|
||||
free(dbname);
|
||||
return map;
|
||||
|
||||
error:
|
||||
if (fd != -1)
|
||||
(void)close(fd);
|
||||
apprentice_unmap(map);
|
||||
free(dbname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private int
|
||||
check_buffer(struct magic_set *ms, struct magic_map *map, const char *dbname)
|
||||
{
|
||||
uint32_t *ptr;
|
||||
uint32_t entries, nentries;
|
||||
uint32_t version;
|
||||
int i, needsbyteswap;
|
||||
|
||||
ptr = CAST(uint32_t *, map->p);
|
||||
if (*ptr != MAGICNO) {
|
||||
if (swap4(*ptr) != MAGICNO) {
|
||||
file_error(ms, 0, "bad magic in `%s'", dbname);
|
||||
goto error;
|
||||
return -1;
|
||||
}
|
||||
needsbyteswap = 1;
|
||||
} else
|
||||
@ -2773,15 +2892,14 @@ apprentice_map(struct magic_set *ms, const char *fn)
|
||||
file_error(ms, 0, "File %s supports only version %d magic "
|
||||
"files. `%s' is version %d", VERSION,
|
||||
VERSIONNO, dbname, version);
|
||||
goto error;
|
||||
return -1;
|
||||
}
|
||||
entries = (uint32_t)(st.st_size / sizeof(struct magic));
|
||||
if ((off_t)(entries * sizeof(struct magic)) != st.st_size) {
|
||||
file_error(ms, 0, "Size of `%s' %" INT64_T_FORMAT "u is not "
|
||||
entries = (uint32_t)(map->len / sizeof(struct magic));
|
||||
if ((entries * sizeof(struct magic)) != map->len) {
|
||||
file_error(ms, 0, "Size of `%s' %" SIZE_T_FORMAT "u is not "
|
||||
"a multiple of %" SIZE_T_FORMAT "u",
|
||||
dbname, (unsigned long long)st.st_size,
|
||||
sizeof(struct magic));
|
||||
goto error;
|
||||
dbname, map->len, sizeof(struct magic));
|
||||
return -1;
|
||||
}
|
||||
map->magic[0] = CAST(struct magic *, map->p) + 1;
|
||||
nentries = 0;
|
||||
@ -2797,20 +2915,12 @@ apprentice_map(struct magic_set *ms, const char *fn)
|
||||
if (entries != nentries + 1) {
|
||||
file_error(ms, 0, "Inconsistent entries in `%s' %u != %u",
|
||||
dbname, entries, nentries + 1);
|
||||
goto error;
|
||||
return -1;
|
||||
}
|
||||
if (needsbyteswap)
|
||||
for (i = 0; i < MAGIC_SETS; i++)
|
||||
byteswap(map->magic[i], map->nmagic[i]);
|
||||
free(dbname);
|
||||
return map;
|
||||
|
||||
error:
|
||||
if (fd != -1)
|
||||
(void)close(fd);
|
||||
apprentice_unmap(map);
|
||||
free(dbname);
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: ascmagic.c,v 1.88 2014/02/12 23:20:53 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: ascmagic.c,v 1.91 2014/11/28 02:46:39 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@ -147,7 +147,8 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
|
||||
== NULL)
|
||||
goto done;
|
||||
if ((rv = file_softmagic(ms, utf8_buf,
|
||||
(size_t)(utf8_end - utf8_buf), 0, TEXTTEST, text)) == 0)
|
||||
(size_t)(utf8_end - utf8_buf), 0, NULL,
|
||||
TEXTTEST, text)) == 0)
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: cdf.c,v 1.63 2014/06/09 13:04:37 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: cdf.c,v 1.69 2014/12/04 15:56:46 christos Exp $")
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
@ -73,6 +73,8 @@ static union {
|
||||
#define CDF_TOLE8(x) ((uint64_t)(NEED_SWAP ? _cdf_tole8(x) : (uint64_t)(x)))
|
||||
#define CDF_TOLE4(x) ((uint32_t)(NEED_SWAP ? _cdf_tole4(x) : (uint32_t)(x)))
|
||||
#define CDF_TOLE2(x) ((uint16_t)(NEED_SWAP ? _cdf_tole2(x) : (uint16_t)(x)))
|
||||
#define CDF_TOLE(x) (sizeof(x) == 2 ? CDF_TOLE2(x) : (sizeof(x) == 4 ? \
|
||||
CDF_TOLE4(x) : CDF_TOLE8(x)))
|
||||
#define CDF_GETUINT32(x, y) cdf_getuint32(x, y)
|
||||
|
||||
|
||||
@ -461,6 +463,12 @@ cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
|
||||
/ sizeof(maxsector));
|
||||
|
||||
DPRINTF(("Chain:"));
|
||||
if (sid == CDF_SECID_END_OF_CHAIN) {
|
||||
/* 0-length chain. */
|
||||
DPRINTF((" empty\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (j = i = 0; sid >= 0; i++, j++) {
|
||||
DPRINTF((" %d", sid));
|
||||
if (j >= CDF_LOOP_LIMIT) {
|
||||
@ -817,13 +825,18 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
|
||||
goto out;
|
||||
for (i = 0; i < sh.sh_properties; i++) {
|
||||
size_t tail = (i << 1) + 1;
|
||||
size_t ofs;
|
||||
if (cdf_check_stream_offset(sst, h, p, tail * sizeof(uint32_t),
|
||||
__LINE__) == -1)
|
||||
goto out;
|
||||
size_t ofs = CDF_GETUINT32(p, tail);
|
||||
ofs = CDF_GETUINT32(p, tail);
|
||||
q = (const uint8_t *)(const void *)
|
||||
((const char *)(const void *)p + ofs
|
||||
- 2 * sizeof(uint32_t));
|
||||
if (q < p) {
|
||||
DPRINTF(("Wrapped around %p < %p\n", q, p));
|
||||
goto out;
|
||||
}
|
||||
if (q > e) {
|
||||
DPRINTF(("Ran of the end %p > %p\n", q, e));
|
||||
goto out;
|
||||
@ -985,6 +998,54 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
|
||||
}
|
||||
|
||||
|
||||
#define extract_catalog_field(f, l) \
|
||||
memcpy(&ce[i].f, b + (l), sizeof(ce[i].f)); \
|
||||
ce[i].f = CDF_TOLE(ce[i].f)
|
||||
|
||||
int
|
||||
cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst,
|
||||
cdf_catalog_t **cat)
|
||||
{
|
||||
size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
|
||||
CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
|
||||
const char *b = CAST(const char *, sst->sst_tab);
|
||||
const char *eb = b + ss * sst->sst_len;
|
||||
size_t nr, i, k;
|
||||
cdf_catalog_entry_t *ce;
|
||||
uint16_t reclen;
|
||||
const uint16_t *np;
|
||||
|
||||
for (nr = 0; b < eb; nr++) {
|
||||
memcpy(&reclen, b, sizeof(reclen));
|
||||
reclen = CDF_TOLE2(reclen);
|
||||
if (reclen == 0)
|
||||
break;
|
||||
b += reclen;
|
||||
}
|
||||
*cat = CAST(cdf_catalog_t *,
|
||||
malloc(sizeof(cdf_catalog_t) + nr * sizeof(*ce)));
|
||||
(*cat)->cat_num = nr;
|
||||
ce = (*cat)->cat_e;
|
||||
b = CAST(const char *, sst->sst_tab);
|
||||
for (i = 0; i < nr; i++) {
|
||||
extract_catalog_field(ce_namlen, 0);
|
||||
extract_catalog_field(ce_num, 2);
|
||||
extract_catalog_field(ce_timestamp, 6);
|
||||
reclen = ce[i].ce_namlen;
|
||||
ce[i].ce_namlen =
|
||||
sizeof(ce[i].ce_name) / sizeof(ce[i].ce_name[0]) - 1;
|
||||
if (ce[i].ce_namlen > reclen - 14)
|
||||
ce[i].ce_namlen = reclen - 14;
|
||||
np = CAST(const uint16_t *, (b + 16));
|
||||
for (k = 0; k < ce[i].ce_namlen; k++) {
|
||||
ce[i].ce_name[k] = np[k];
|
||||
CDF_TOLE2(ce[i].ce_name[k]);
|
||||
}
|
||||
ce[i].ce_name[ce[i].ce_namlen] = 0;
|
||||
b += reclen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
cdf_print_classid(char *buf, size_t buflen, const cdf_classid_t *id)
|
||||
@ -1068,6 +1129,15 @@ cdf_print_elapsed_time(char *buf, size_t bufsiz, cdf_timestamp_t ts)
|
||||
return len;
|
||||
}
|
||||
|
||||
char *
|
||||
cdf_u16tos8(char *buf, size_t len, const uint16_t *p)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < len && p[i]; i++)
|
||||
buf[i] = (char)p[i];
|
||||
buf[i] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
#ifdef CDF_DEBUG
|
||||
void
|
||||
@ -1093,7 +1163,7 @@ cdf_dump_header(const cdf_header_t *h)
|
||||
for (i = 0; i < __arraycount(h->h_master_sat); i++) {
|
||||
if (h->h_master_sat[i] == CDF_SECID_FREE)
|
||||
break;
|
||||
(void)fprintf(stderr, "%35.35s[%.3zu] = %d\n",
|
||||
(void)fprintf(stderr, "%35.35s[%.3" SIZE_T_FORMAT "u] = %d\n",
|
||||
"master_sat", i, h->h_master_sat[i]);
|
||||
}
|
||||
}
|
||||
@ -1288,7 +1358,7 @@ cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst)
|
||||
return;
|
||||
(void)fprintf(stderr, "Endian: %x\n", ssi.si_byte_order);
|
||||
(void)fprintf(stderr, "Os Version %d.%d\n", ssi.si_os_version & 0xff,
|
||||
ssi.si_os_version >> 8);
|
||||
ssi.si_os_version >> 8);
|
||||
(void)fprintf(stderr, "Os %d\n", ssi.si_os);
|
||||
cdf_print_classid(buf, sizeof(buf), &ssi.si_class);
|
||||
(void)fprintf(stderr, "Class %s\n", buf);
|
||||
@ -1297,6 +1367,27 @@ cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst)
|
||||
free(info);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cdf_dump_catalog(const cdf_header_t *h, const cdf_stream_t *sst)
|
||||
{
|
||||
cdf_catalog_t *cat;
|
||||
cdf_unpack_catalog(h, sst, &cat);
|
||||
const cdf_catalog_entry_t *ce = cat->cat_e;
|
||||
struct timespec ts;
|
||||
char tbuf[64], sbuf[256];
|
||||
size_t i;
|
||||
|
||||
printf("Catalog:\n");
|
||||
for (i = 0; i < cat->cat_num; i++) {
|
||||
cdf_timestamp_to_timespec(&ts, ce[i].ce_timestamp);
|
||||
printf("\t%d %s %s", ce[i].ce_num,
|
||||
cdf_u16tos8(sbuf, ce[i].ce_namlen, ce[i].ce_name),
|
||||
cdf_ctime(&ts.tv_sec, tbuf));
|
||||
}
|
||||
free(cat);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
@ -1309,6 +1400,7 @@ main(int argc, char *argv[])
|
||||
cdf_stream_t sst, scn;
|
||||
cdf_dir_t dir;
|
||||
cdf_info_t info;
|
||||
const cdf_directory_t *root;
|
||||
|
||||
if (argc < 2) {
|
||||
(void)fprintf(stderr, "Usage: %s <filename>\n", getprogname());
|
||||
@ -1342,7 +1434,8 @@ main(int argc, char *argv[])
|
||||
if (cdf_read_dir(&info, &h, &sat, &dir) == -1)
|
||||
err(1, "Cannot read dir");
|
||||
|
||||
if (cdf_read_short_stream(&info, &h, &sat, &dir, &sst) == -1)
|
||||
if (cdf_read_short_stream(&info, &h, &sat, &dir, &sst, &root)
|
||||
== -1)
|
||||
err(1, "Cannot read short stream");
|
||||
#ifdef CDF_DEBUG
|
||||
cdf_dump_stream(&h, &sst);
|
||||
@ -1355,9 +1448,17 @@ main(int argc, char *argv[])
|
||||
|
||||
if (cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
|
||||
&scn) == -1)
|
||||
err(1, "Cannot read summary info");
|
||||
warn("Cannot read summary info");
|
||||
#ifdef CDF_DEBUG
|
||||
cdf_dump_summary_info(&h, &scn);
|
||||
else
|
||||
cdf_dump_summary_info(&h, &scn);
|
||||
#endif
|
||||
if (cdf_read_catalog(&info, &h, &sat, &ssat, &sst, &dir,
|
||||
&scn) == -1)
|
||||
warn("Cannot read catalog");
|
||||
#ifdef CDF_DEBUG
|
||||
else
|
||||
cdf_dump_catalog(&h, &scn);
|
||||
#endif
|
||||
|
||||
(void)close(info.i_fd);
|
||||
|
@ -267,6 +267,19 @@ typedef struct {
|
||||
size_t i_len;
|
||||
} cdf_info_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t ce_namlen;
|
||||
uint32_t ce_num;
|
||||
uint64_t ce_timestamp;
|
||||
uint16_t ce_name[256];
|
||||
} cdf_catalog_entry_t;
|
||||
|
||||
typedef struct {
|
||||
size_t cat_num;
|
||||
cdf_catalog_entry_t cat_e[0];
|
||||
} cdf_catalog_t;
|
||||
|
||||
struct timespec;
|
||||
int cdf_timestamp_to_timespec(struct timespec *, cdf_timestamp_t);
|
||||
int cdf_timespec_to_timestamp(cdf_timestamp_t *, const struct timespec *);
|
||||
@ -301,11 +314,19 @@ int cdf_read_property_info(const cdf_stream_t *, const cdf_header_t *, uint32_t,
|
||||
int cdf_read_user_stream(const cdf_info_t *, const cdf_header_t *,
|
||||
const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
|
||||
const cdf_dir_t *, const char *, cdf_stream_t *);
|
||||
#define cdf_read_catalog(info, header, sat, ssat, stream, dir, scn) \
|
||||
cdf_read_user_stream(info, header, sat, ssat, stream, dir, "Catalog", \
|
||||
scn)
|
||||
#define cdf_read_encrypted_package(info, header, sat, ssat, stream, dir, scn) \
|
||||
cdf_read_user_stream(info, header, sat, ssat, stream, dir, \
|
||||
"EncryptedPackage", scn)
|
||||
int cdf_read_summary_info(const cdf_info_t *, const cdf_header_t *,
|
||||
const cdf_sat_t *, const cdf_sat_t *, const cdf_stream_t *,
|
||||
const cdf_dir_t *, cdf_stream_t *);
|
||||
int cdf_unpack_summary_info(const cdf_stream_t *, const cdf_header_t *,
|
||||
cdf_summary_info_header_t *, cdf_property_info_t **, size_t *);
|
||||
int cdf_unpack_catalog(const cdf_header_t *, const cdf_stream_t *,
|
||||
cdf_catalog_t **);
|
||||
int cdf_print_classid(char *, size_t, const cdf_classid_t *);
|
||||
int cdf_print_property_name(char *, size_t, uint32_t);
|
||||
int cdf_print_elapsed_time(char *, size_t, cdf_timestamp_t);
|
||||
@ -313,6 +334,7 @@ uint16_t cdf_tole2(uint16_t);
|
||||
uint32_t cdf_tole4(uint32_t);
|
||||
uint64_t cdf_tole8(uint64_t);
|
||||
char *cdf_ctime(const time_t *, char *);
|
||||
char *cdf_u16tos8(char *, size_t, const uint16_t *);
|
||||
|
||||
#ifdef CDF_DEBUG
|
||||
void cdf_dump_header(const cdf_header_t *);
|
||||
@ -323,6 +345,7 @@ void cdf_dump_dir(const cdf_info_t *, const cdf_header_t *, const cdf_sat_t *,
|
||||
const cdf_sat_t *, const cdf_stream_t *, const cdf_dir_t *);
|
||||
void cdf_dump_property_info(const cdf_property_info_t *, size_t);
|
||||
void cdf_dump_summary_info(const cdf_header_t *, const cdf_stream_t *);
|
||||
void cdf_dump_catalog(const cdf_header_t *, const cdf_stream_t *);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.73 2014/01/05 15:55:21 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.75 2014/12/04 15:56:46 christos Exp $")
|
||||
#endif
|
||||
|
||||
#include "magic.h"
|
||||
@ -45,7 +45,7 @@ FILE_RCSID("@(#)$File: compress.c,v 1.73 2014/01/05 15:55:21 christos Exp $")
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifndef __MINGW32__
|
||||
#if !defined(__MINGW32__) && !defined(WIN32)
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
@ -377,6 +377,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
|
||||
const unsigned char *old, unsigned char **newch, size_t n)
|
||||
{
|
||||
int fdin[2], fdout[2];
|
||||
int status;
|
||||
ssize_t r;
|
||||
pid_t pid;
|
||||
|
||||
@ -459,7 +460,17 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
|
||||
/*NOTREACHED*/
|
||||
|
||||
default: /* parent */
|
||||
break;
|
||||
if (wait(&status) == -1) {
|
||||
#ifdef DEBUG
|
||||
(void)fprintf(stderr,
|
||||
"Wait failed (%s)\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
exit(WIFEXITED(status) ?
|
||||
WEXITSTATUS(status) : 1);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
(void) close(fdin[1]);
|
||||
fdin[1] = -1;
|
||||
@ -470,7 +481,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
|
||||
(void)fprintf(stderr, "Malloc failed (%s)\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
n = 0;
|
||||
n = NODATA;
|
||||
goto err;
|
||||
}
|
||||
if ((r = sread(fdout[0], *newch, HOWMANY, 0)) <= 0) {
|
||||
@ -479,7 +490,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
|
||||
strerror(errno));
|
||||
#endif
|
||||
free(*newch);
|
||||
n = 0;
|
||||
n = NODATA;
|
||||
*newch = NULL;
|
||||
goto err;
|
||||
} else {
|
||||
@ -491,12 +502,19 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
|
||||
if (fdin[1] != -1)
|
||||
(void) close(fdin[1]);
|
||||
(void) close(fdout[0]);
|
||||
#ifdef WNOHANG
|
||||
while (waitpid(pid, NULL, WNOHANG) != -1)
|
||||
continue;
|
||||
#else
|
||||
(void)wait(NULL);
|
||||
if (wait(&status) == -1) {
|
||||
#ifdef DEBUG
|
||||
(void)fprintf(stderr, "Wait failed (%s)\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
n = NODATA;
|
||||
} else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||
#ifdef DEBUG
|
||||
(void)fprintf(stderr, "Child status (0x%x)\n", status);
|
||||
#endif
|
||||
n = NODATA;
|
||||
}
|
||||
|
||||
(void) close(fdin[0]);
|
||||
|
||||
return n;
|
||||
|
@ -36,7 +36,7 @@
|
||||
#ifdef ELFCORE
|
||||
case ET_CORE:
|
||||
phnum = elf_getu16(swap, elfhdr.e_phnum);
|
||||
if (phnum > MAX_PHNUM)
|
||||
if (phnum > ms->elf_phnum_max)
|
||||
return toomany(ms, "program", phnum);
|
||||
flags |= FLAGS_IS_CORE;
|
||||
if (dophn_core(ms, clazz, swap, fd,
|
||||
@ -49,10 +49,10 @@
|
||||
case ET_EXEC:
|
||||
case ET_DYN:
|
||||
phnum = elf_getu16(swap, elfhdr.e_phnum);
|
||||
if (phnum > MAX_PHNUM)
|
||||
if (phnum > ms->elf_phnum_max)
|
||||
return toomany(ms, "program", phnum);
|
||||
shnum = elf_getu16(swap, elfhdr.e_shnum);
|
||||
if (shnum > MAX_SHNUM)
|
||||
if (shnum > ms->elf_shnum_max)
|
||||
return toomany(ms, "section", shnum);
|
||||
if (dophn_exec(ms, clazz, swap, fd,
|
||||
(off_t)elf_getu(swap, elfhdr.e_phoff), phnum,
|
||||
@ -62,7 +62,7 @@
|
||||
/*FALLTHROUGH*/
|
||||
case ET_REL:
|
||||
shnum = elf_getu16(swap, elfhdr.e_shnum);
|
||||
if (shnum > MAX_SHNUM)
|
||||
if (shnum > ms->elf_shnum_max)
|
||||
return toomany(ms, "section", shnum);
|
||||
if (doshn(ms, clazz, swap, fd,
|
||||
(off_t)elf_getu(swap, elfhdr.e_shoff), shnum,
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: encoding.c,v 1.9 2013/11/19 20:45:50 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: encoding.c,v 1.10 2014/09/11 12:08:52 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@ -97,7 +97,6 @@ file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, uni
|
||||
*code_mime = "utf-8";
|
||||
} else if (file_looks_utf8(buf, nbytes, *ubuf, ulen) > 1) {
|
||||
DPRINTF(("utf8 %" SIZE_T_FORMAT "u\n", *ulen));
|
||||
*code = "UTF-8 Unicode (with BOM)";
|
||||
*code = "UTF-8 Unicode";
|
||||
*code_mime = "utf-8";
|
||||
} else if ((ucs_type = looks_ucs16(buf, nbytes, *ubuf, ulen)) != 0) {
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: file.c,v 1.153 2014/02/11 15:41:04 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: file.c,v 1.159 2014/11/28 02:46:39 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@ -54,9 +54,6 @@ FILE_RCSID("@(#)$File: file.c,v 1.153 2014/02/11 15:41:04 christos Exp $")
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for read() */
|
||||
#endif
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
#ifdef HAVE_WCHAR_H
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
@ -101,7 +98,7 @@ private const struct option long_options[] = {
|
||||
#undef OPT_LONGONLY
|
||||
{0, 0, NULL, 0}
|
||||
};
|
||||
#define OPTSTRING "bcCde:Ef:F:hiklLm:nNprsvz0"
|
||||
#define OPTSTRING "bcCde:Ef:F:hiklLm:nNpP:rsvz0"
|
||||
|
||||
private const struct {
|
||||
const char *name;
|
||||
@ -119,6 +116,17 @@ private const struct {
|
||||
{ "tokens", MAGIC_NO_CHECK_TOKENS }, /* OBSOLETE: ignored for backwards compatibility */
|
||||
};
|
||||
|
||||
private struct {
|
||||
const char *name;
|
||||
int tag;
|
||||
size_t value;
|
||||
} pm[] = {
|
||||
{ "indir", MAGIC_PARAM_INDIR_MAX, 0 },
|
||||
{ "name", MAGIC_PARAM_NAME_MAX, 0 },
|
||||
{ "elf_phnum", MAGIC_PARAM_ELF_PHNUM_MAX, 0 },
|
||||
{ "elf_shnum", MAGIC_PARAM_ELF_SHNUM_MAX, 0 },
|
||||
};
|
||||
|
||||
private char *progname; /* used throughout */
|
||||
|
||||
private void usage(void);
|
||||
@ -128,6 +136,8 @@ private void help(void);
|
||||
private int unwrap(struct magic_set *, const char *);
|
||||
private int process(struct magic_set *ms, const char *, int);
|
||||
private struct magic_set *load(const char *, int);
|
||||
private void setparam(const char *);
|
||||
private void applyparam(magic_t);
|
||||
|
||||
|
||||
/*
|
||||
@ -145,7 +155,9 @@ main(int argc, char *argv[])
|
||||
const char *magicfile = NULL; /* where the magic is */
|
||||
|
||||
/* makes islower etc work for other langs */
|
||||
#ifdef HAVE_SETLOCALE
|
||||
(void)setlocale(LC_CTYPE, "");
|
||||
#endif
|
||||
|
||||
#ifdef __EMX__
|
||||
/* sh-like wildcard expansion! Shouldn't hurt at least ... */
|
||||
@ -243,9 +255,13 @@ main(int argc, char *argv[])
|
||||
flags |= MAGIC_PRESERVE_ATIME;
|
||||
break;
|
||||
#endif
|
||||
case 'P':
|
||||
setparam(optarg);
|
||||
break;
|
||||
case 'r':
|
||||
flags |= MAGIC_RAW;
|
||||
break;
|
||||
break;
|
||||
case 's':
|
||||
flags |= MAGIC_DEVICES;
|
||||
break;
|
||||
@ -298,6 +314,8 @@ main(int argc, char *argv[])
|
||||
strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
switch(action) {
|
||||
case FILE_CHECK:
|
||||
c = magic_check(magic, magicfile);
|
||||
@ -321,7 +339,7 @@ main(int argc, char *argv[])
|
||||
if (magic == NULL)
|
||||
if ((magic = load(magicfile, flags)) == NULL)
|
||||
return 1;
|
||||
break;
|
||||
applyparam(magic);
|
||||
}
|
||||
|
||||
if (optind == argc) {
|
||||
@ -351,6 +369,41 @@ main(int argc, char *argv[])
|
||||
return e;
|
||||
}
|
||||
|
||||
private void
|
||||
applyparam(magic_t magic)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < __arraycount(pm); i++) {
|
||||
if (pm[i].value == 0)
|
||||
continue;
|
||||
if (magic_setparam(magic, pm[i].tag, &pm[i].value) == -1) {
|
||||
(void)fprintf(stderr, "%s: Can't set %s %s\n", progname,
|
||||
pm[i].name, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void
|
||||
setparam(const char *p)
|
||||
{
|
||||
size_t i;
|
||||
char *s;
|
||||
|
||||
if ((s = strchr(p, '=')) == NULL)
|
||||
goto badparm;
|
||||
|
||||
for (i = 0; i < __arraycount(pm); i++) {
|
||||
if (strncmp(p, pm[i].name, s - p) != 0)
|
||||
continue;
|
||||
pm[i].value = atoi(s + 1);
|
||||
return;
|
||||
}
|
||||
badparm:
|
||||
(void)fprintf(stderr, "%s: Unknown param %s\n", progname, p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
private struct magic_set *
|
||||
/*ARGSUSED*/
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
/*
|
||||
* file.h - definitions for file(1) program
|
||||
* @(#)$File: file.h,v 1.152 2014/06/03 19:01:34 christos Exp $
|
||||
* @(#)$File: file.h,v 1.161 2014/12/04 15:56:46 christos Exp $
|
||||
*/
|
||||
|
||||
#ifndef __file_h__
|
||||
@ -64,7 +64,9 @@
|
||||
#include <regex.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#ifndef WIN32
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
/* Do this here and now, because struct stat gets re-defined on solaris */
|
||||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
@ -401,6 +403,14 @@ struct magic_set {
|
||||
/* FIXME: Make the string dynamically allocated so that e.g.
|
||||
strings matched in files can be longer than MAXstring */
|
||||
union VALUETYPE ms_value; /* either number or string */
|
||||
uint16_t indir_max;
|
||||
uint16_t name_max;
|
||||
uint16_t elf_shnum_max;
|
||||
uint16_t elf_phnum_max;
|
||||
#define FILE_INDIR_MAX 15
|
||||
#define FILE_NAME_MAX 30
|
||||
#define FILE_ELF_SHNUM_MAX 32768
|
||||
#define FILE_ELF_PHNUM_MAX 128
|
||||
};
|
||||
|
||||
/* Type for Unicode characters */
|
||||
@ -440,8 +450,10 @@ protected int file_encoding(struct magic_set *, const unsigned char *, size_t,
|
||||
unichar **, size_t *, const char **, const char **, const char **);
|
||||
protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
|
||||
protected int file_softmagic(struct magic_set *, const unsigned char *, size_t,
|
||||
size_t, int, int);
|
||||
uint16_t, uint16_t *, int, int);
|
||||
protected int file_apprentice(struct magic_set *, const char *, int);
|
||||
protected int buffer_apprentice(struct magic_set *, struct magic **,
|
||||
size_t *, size_t);
|
||||
protected int file_magicfind(struct magic_set *, const char *, struct mlist *);
|
||||
protected uint64_t file_signextend(struct magic_set *, struct magic *,
|
||||
uint64_t);
|
||||
@ -469,9 +481,20 @@ protected int file_os2_apptype(struct magic_set *, const char *, const void *,
|
||||
size_t);
|
||||
#endif /* __EMX__ */
|
||||
|
||||
#if defined(HAVE_LOCALE_H)
|
||||
#include <locale.h>
|
||||
#endif
|
||||
#if defined(HAVE_XLOCALE_H)
|
||||
#include <xlocale.h>
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
const char *pat;
|
||||
char *old_lc_ctype;
|
||||
#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE) && defined(HAVE_FREELOCALE)
|
||||
#define USE_C_LOCALE
|
||||
locale_t old_lc_ctype;
|
||||
locale_t c_lc_ctype;
|
||||
#endif
|
||||
int rc;
|
||||
regex_t rx;
|
||||
} file_regex_t;
|
||||
|
@ -44,6 +44,7 @@ OPT('0', "print0", 0, " terminate filenames with ASCII NUL\n")
|
||||
OPT('p', "preserve-date", 0, " preserve access times on files\n")
|
||||
#endif
|
||||
OPT('r', "raw", 0, " don't translate unprintable chars to \\ooo\n")
|
||||
OPT('R', "recursion", 0, " set maximum recursion level\n")
|
||||
OPT('s', "special-files", 0, " treat special (block/char devices) files as\n"
|
||||
" ordinary ones\n")
|
||||
OPT('C', "compile", 0, " compile file specified by -m\n")
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: fsmagic.c,v 1.73 2014/05/14 23:15:42 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: fsmagic.c,v 1.75 2014/12/04 15:56:46 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@ -75,10 +75,10 @@ bad_link(struct magic_set *ms, int err, char *buf)
|
||||
else if (!mime) {
|
||||
if (ms->flags & MAGIC_ERROR) {
|
||||
file_error(ms, err,
|
||||
"broken symbolic link to `%s'", buf);
|
||||
"broken symbolic link to %s", buf);
|
||||
return -1;
|
||||
}
|
||||
if (file_printf(ms, "broken symbolic link to `%s'", buf) == -1)
|
||||
if (file_printf(ms, "broken symbolic link to %s", buf) == -1)
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
@ -129,7 +129,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
|
||||
|
||||
#ifdef WIN32
|
||||
{
|
||||
HANDLE hFile = CreateFile(fn, 0, FILE_SHARE_DELETE |
|
||||
HANDLE hFile = CreateFile((LPCSTR)fn, 0, FILE_SHARE_DELETE |
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0,
|
||||
NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE) {
|
||||
@ -352,7 +352,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
|
||||
if (mime) {
|
||||
if (handle_mime(ms, mime, "symlink") == -1)
|
||||
return -1;
|
||||
} else if (file_printf(ms, "%ssymbolic link to `%s'",
|
||||
} else if (file_printf(ms, "%ssymbolic link to %s",
|
||||
COMMA, buf) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.72 2014/05/14 23:15:42 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.77 2014/11/28 02:46:39 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@ -45,9 +45,6 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.72 2014/05/14 23:15:42 christos Exp $")
|
||||
#if defined(HAVE_LIMITS_H)
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#if defined(HAVE_LOCALE_H)
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX ((size_t)~0)
|
||||
@ -230,7 +227,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((unu
|
||||
|
||||
/* try soft magic tests */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0)
|
||||
if ((m = file_softmagic(ms, ubuf, nb, 0, BINTEST,
|
||||
if ((m = file_softmagic(ms, ubuf, nb, 0, NULL, BINTEST,
|
||||
looks_text)) != 0) {
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void)fprintf(stderr, "softmagic %d\n", m);
|
||||
@ -455,13 +452,14 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep)
|
||||
protected int
|
||||
file_regcomp(file_regex_t *rx, const char *pat, int flags)
|
||||
{
|
||||
rx->old_lc_ctype = setlocale(LC_CTYPE, NULL);
|
||||
assert(rx->old_lc_ctype != NULL);
|
||||
rx->old_lc_ctype = strdup(rx->old_lc_ctype);
|
||||
#ifdef USE_C_LOCALE
|
||||
rx->c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0);
|
||||
assert(rx->c_lc_ctype != NULL);
|
||||
rx->old_lc_ctype = uselocale(rx->c_lc_ctype);
|
||||
assert(rx->old_lc_ctype != NULL);
|
||||
#endif
|
||||
rx->pat = pat;
|
||||
|
||||
(void)setlocale(LC_CTYPE, "C");
|
||||
return rx->rc = regcomp(&rx->rx, pat, flags);
|
||||
}
|
||||
|
||||
@ -478,8 +476,10 @@ file_regfree(file_regex_t *rx)
|
||||
{
|
||||
if (rx->rc == 0)
|
||||
regfree(&rx->rx);
|
||||
(void)setlocale(LC_CTYPE, rx->old_lc_ctype);
|
||||
free(rx->old_lc_ctype);
|
||||
#ifdef USE_C_LOCALE
|
||||
(void)uselocale(rx->old_lc_ctype);
|
||||
freelocale(rx->c_lc_ctype);
|
||||
#endif
|
||||
}
|
||||
|
||||
protected void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fgetln.c,v 1.9 2008/04/29 06:53:03 martin Exp $ */
|
||||
/* $NetBSD: getline.c,v 1.2 2014/09/16 17:23:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
@ -52,10 +52,14 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
|
||||
for (ptr = *buf, eptr = *buf + *bufsiz;;) {
|
||||
int c = fgetc(fp);
|
||||
if (c == -1) {
|
||||
if (feof(fp))
|
||||
return ptr == *buf ? -1 : ptr - *buf;
|
||||
else
|
||||
return -1;
|
||||
if (feof(fp)) {
|
||||
ssize_t diff = (ssize_t)(ptr - *buf);
|
||||
if (diff != 0) {
|
||||
*ptr = '\0';
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
*ptr++ = c;
|
||||
if (c == delimiter) {
|
||||
@ -93,7 +97,7 @@ main(int argc, char *argv[])
|
||||
size_t n = 0;
|
||||
|
||||
while ((len = getline(&p, &n, stdin)) != -1)
|
||||
(void)printf("%zd %s", len, p);
|
||||
(void)printf("%" SIZE_T_FORMAT "d %s", len, p);
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.84 2014/05/14 23:15:42 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.90 2014/12/04 15:56:46 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@ -128,6 +128,7 @@ get_default_magic(void)
|
||||
#else
|
||||
char *hmagicp;
|
||||
char *tmppath = NULL;
|
||||
LPTSTR dllpath;
|
||||
hmagicpath = NULL;
|
||||
|
||||
#define APPENDPATH() \
|
||||
@ -173,7 +174,7 @@ get_default_magic(void)
|
||||
}
|
||||
|
||||
/* Third, try to get magic file relative to dll location */
|
||||
LPTSTR dllpath = malloc(sizeof(*dllpath) * (MAX_PATH + 1));
|
||||
dllpath = malloc(sizeof(*dllpath) * (MAX_PATH + 1));
|
||||
dllpath[MAX_PATH] = 0; /* just in case long path gets truncated and not null terminated */
|
||||
if (GetModuleFileNameA(NULL, dllpath, MAX_PATH)){
|
||||
PathRemoveFileSpecA(dllpath);
|
||||
@ -257,6 +258,20 @@ magic_load(struct magic_set *ms, const char *magicfile)
|
||||
return file_apprentice(ms, magicfile, FILE_LOAD);
|
||||
}
|
||||
|
||||
#ifndef COMPILE_ONLY
|
||||
/*
|
||||
* Install a set of compiled magic buffers.
|
||||
*/
|
||||
public int
|
||||
magic_load_buffers(struct magic_set *ms, void **bufs, size_t *sizes,
|
||||
size_t nbufs)
|
||||
{
|
||||
if (ms == NULL)
|
||||
return -1;
|
||||
return buffer_apprentice(ms, (struct magic **)bufs, sizes, nbufs);
|
||||
}
|
||||
#endif
|
||||
|
||||
public int
|
||||
magic_compile(struct magic_set *ms, const char *magicfile)
|
||||
{
|
||||
@ -522,3 +537,47 @@ magic_version(void)
|
||||
{
|
||||
return MAGIC_VERSION;
|
||||
}
|
||||
|
||||
public int
|
||||
magic_setparam(struct magic_set *ms, int param, const void *val)
|
||||
{
|
||||
switch (param) {
|
||||
case MAGIC_PARAM_INDIR_MAX:
|
||||
ms->indir_max = *(const size_t *)val;
|
||||
return 0;
|
||||
case MAGIC_PARAM_NAME_MAX:
|
||||
ms->name_max = *(const size_t *)val;
|
||||
return 0;
|
||||
case MAGIC_PARAM_ELF_PHNUM_MAX:
|
||||
ms->elf_phnum_max = *(const size_t *)val;
|
||||
return 0;
|
||||
case MAGIC_PARAM_ELF_SHNUM_MAX:
|
||||
ms->elf_shnum_max = *(const size_t *)val;
|
||||
return 0;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public int
|
||||
magic_getparam(struct magic_set *ms, int param, void *val)
|
||||
{
|
||||
switch (param) {
|
||||
case MAGIC_PARAM_INDIR_MAX:
|
||||
*(size_t *)val = ms->indir_max;
|
||||
return 0;
|
||||
case MAGIC_PARAM_NAME_MAX:
|
||||
*(size_t *)val = ms->name_max;
|
||||
return 0;
|
||||
case MAGIC_PARAM_ELF_PHNUM_MAX:
|
||||
*(size_t *)val = ms->elf_phnum_max;
|
||||
return 0;
|
||||
case MAGIC_PARAM_ELF_SHNUM_MAX:
|
||||
*(size_t *)val = ms->elf_shnum_max;
|
||||
return 0;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@
|
||||
#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */
|
||||
#define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */
|
||||
|
||||
#define MAGIC_VERSION 518 /* This implementation */
|
||||
#define MAGIC_VERSION 521 /* This implementation */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -96,11 +96,21 @@ int magic_setflags(magic_t, int);
|
||||
|
||||
int magic_version(void);
|
||||
int magic_load(magic_t, const char *);
|
||||
int magic_load_buffers(magic_t, void **, size_t *, size_t);
|
||||
|
||||
int magic_compile(magic_t, const char *);
|
||||
int magic_check(magic_t, const char *);
|
||||
int magic_list(magic_t, const char *);
|
||||
int magic_errno(magic_t);
|
||||
|
||||
#define MAGIC_PARAM_INDIR_MAX 0
|
||||
#define MAGIC_PARAM_NAME_MAX 1
|
||||
#define MAGIC_PARAM_ELF_PHNUM_MAX 2
|
||||
#define MAGIC_PARAM_ELF_SHNUM_MAX 3
|
||||
|
||||
int magic_setparam(magic_t, int, const void *);
|
||||
int magic_getparam(magic_t, int, void *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -96,11 +96,21 @@ int magic_setflags(magic_t, int);
|
||||
|
||||
int magic_version(void);
|
||||
int magic_load(magic_t, const char *);
|
||||
int magic_load_buffers(magic_t, void **, size_t *, size_t);
|
||||
|
||||
int magic_compile(magic_t, const char *);
|
||||
int magic_check(magic_t, const char *);
|
||||
int magic_list(magic_t, const char *);
|
||||
int magic_errno(magic_t);
|
||||
|
||||
#define MAGIC_PARAM_INDIR_MAX 0
|
||||
#define MAGIC_PARAM_NAME_MAX 1
|
||||
#define MAGIC_PARAM_ELF_PHNUM_MAX 2
|
||||
#define MAGIC_PARAM_ELF_SHNUM_MAX 3
|
||||
|
||||
int magic_setparam(magic_t, int, const void *);
|
||||
int magic_getparam(magic_t, int, void *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -1,14 +1,23 @@
|
||||
#include "file.h"
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: pread.c,v 1.2 2013/04/02 16:23:07 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: pread.c,v 1.3 2014/09/15 19:11:25 christos Exp $")
|
||||
#endif /* lint */
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
ssize_t
|
||||
pread(int fd, void *buf, size_t len, off_t off) {
|
||||
if (lseek(fd, off, SEEK_SET) == (off_t)-1)
|
||||
off_t old;
|
||||
ssize_t rv;
|
||||
|
||||
if ((old = lseek(fd, off, SEEK_SET)) == -1)
|
||||
return -1;
|
||||
|
||||
return read(fd, buf, len);
|
||||
if ((rv = read(fd, buf, len)) == -1)
|
||||
return -1;
|
||||
|
||||
if (lseek(fd, old, SEEK_SET) == -1)
|
||||
return -1;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: readcdf.c,v 1.44 2014/05/14 23:22:48 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: readcdf.c,v 1.49 2014/12/04 15:56:46 christos Exp $")
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
@ -35,9 +35,6 @@ FILE_RCSID("@(#)$File: readcdf.c,v 1.44 2014/05/14 23:22:48 christos Exp $")
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#if defined(HAVE_LOCALE_H)
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include "cdf.h"
|
||||
#include "magic.h"
|
||||
@ -75,7 +72,7 @@ static const struct cv {
|
||||
const char *mime;
|
||||
} clsid2mime[] = {
|
||||
{
|
||||
{ 0x00000000000c1084LLU, 0x46000000000000c0LLU },
|
||||
{ 0x00000000000c1084ULL, 0x46000000000000c0ULL },
|
||||
"x-msi",
|
||||
},
|
||||
{ { 0, 0 },
|
||||
@ -83,7 +80,7 @@ static const struct cv {
|
||||
},
|
||||
}, clsid2desc[] = {
|
||||
{
|
||||
{ 0x00000000000c1084LLU, 0x46000000000000c0LLU },
|
||||
{ 0x00000000000c1084ULL, 0x46000000000000c0ULL },
|
||||
"MSI Installer",
|
||||
},
|
||||
{ { 0, 0 },
|
||||
@ -107,20 +104,23 @@ cdf_app_to_mime(const char *vbuf, const struct nv *nv)
|
||||
{
|
||||
size_t i;
|
||||
const char *rv = NULL;
|
||||
char *old_lc_ctype;
|
||||
#ifdef USE_C_LOCALE
|
||||
locale_t old_lc_ctype, c_lc_ctype;
|
||||
|
||||
old_lc_ctype = setlocale(LC_CTYPE, NULL);
|
||||
c_lc_ctype = newlocale(LC_CTYPE_MASK, "C", 0);
|
||||
assert(c_lc_ctype != NULL);
|
||||
old_lc_ctype = uselocale(c_lc_ctype);
|
||||
assert(old_lc_ctype != NULL);
|
||||
old_lc_ctype = strdup(old_lc_ctype);
|
||||
assert(old_lc_ctype != NULL);
|
||||
(void)setlocale(LC_CTYPE, "C");
|
||||
#endif
|
||||
for (i = 0; nv[i].pattern != NULL; i++)
|
||||
if (strcasestr(vbuf, nv[i].pattern) != NULL) {
|
||||
rv = nv[i].mime;
|
||||
break;
|
||||
}
|
||||
(void)setlocale(LC_CTYPE, old_lc_ctype);
|
||||
free(old_lc_ctype);
|
||||
#ifdef USE_C_LOCALE
|
||||
(void)uselocale(old_lc_ctype);
|
||||
freelocale(c_lc_ctype);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -240,6 +240,37 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
|
||||
return 1;
|
||||
}
|
||||
|
||||
private int
|
||||
cdf_file_catalog(struct magic_set *ms, const cdf_header_t *h,
|
||||
const cdf_stream_t *sst)
|
||||
{
|
||||
cdf_catalog_t *cat;
|
||||
size_t i;
|
||||
char buf[256];
|
||||
cdf_catalog_entry_t *ce;
|
||||
|
||||
if (NOTMIME(ms)) {
|
||||
if (file_printf(ms, "Microsoft Thumbs.db [") == -1)
|
||||
return -1;
|
||||
if (cdf_unpack_catalog(h, sst, &cat) == -1)
|
||||
return -1;
|
||||
ce = cat->cat_e;
|
||||
/* skip first entry since it has a , or paren */
|
||||
for (i = 1; i < cat->cat_num; i++)
|
||||
if (file_printf(ms, "%s%s",
|
||||
cdf_u16tos8(buf, ce[i].ce_namlen, ce[i].ce_name),
|
||||
i == cat->cat_num - 1 ? "]" : ", ") == -1) {
|
||||
free(cat);
|
||||
return -1;
|
||||
}
|
||||
free(cat);
|
||||
} else {
|
||||
if (file_printf(ms, "application/CDFV2") == -1)
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private int
|
||||
cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
|
||||
const cdf_stream_t *sst, const cdf_directory_t *root_storage)
|
||||
@ -285,11 +316,12 @@ cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
|
||||
if (root_storage) {
|
||||
str = cdf_clsid_to_mime(root_storage->d_storage_uuid,
|
||||
clsid2desc);
|
||||
if (str)
|
||||
if (str) {
|
||||
if (file_printf(ms, ", %s", str) == -1)
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m = cdf_file_property_info(ms, info, count, root_storage);
|
||||
free(info);
|
||||
@ -302,11 +334,11 @@ private char *
|
||||
format_clsid(char *buf, size_t len, const uint64_t uuid[2]) {
|
||||
snprintf(buf, len, "%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4"
|
||||
PRIx64 "-%.12" PRIx64,
|
||||
(uuid[0] >> 32) & (uint64_t)0x000000000ffffffffLLU,
|
||||
(uuid[0] >> 16) & (uint64_t)0x0000000000000ffffLLU,
|
||||
(uuid[0] >> 0) & (uint64_t)0x0000000000000ffffLLU,
|
||||
(uuid[1] >> 48) & (uint64_t)0x0000000000000ffffLLU,
|
||||
(uuid[1] >> 0) & (uint64_t)0x0000fffffffffffffLLU);
|
||||
(uuid[0] >> 32) & (uint64_t)0x000000000ffffffffULL,
|
||||
(uuid[0] >> 16) & (uint64_t)0x0000000000000ffffULL,
|
||||
(uuid[0] >> 0) & (uint64_t)0x0000000000000ffffULL,
|
||||
(uuid[1] >> 48) & (uint64_t)0x0000000000000ffffULL,
|
||||
(uuid[1] >> 0) & (uint64_t)0x0000fffffffffffffULL);
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
@ -323,6 +355,7 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
|
||||
int i;
|
||||
const char *expn = "";
|
||||
const char *corrupt = "corrupt: ";
|
||||
const cdf_directory_t *root_storage;
|
||||
|
||||
info.i_fd = fd;
|
||||
info.i_buf = buf;
|
||||
@ -356,7 +389,6 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
|
||||
goto out2;
|
||||
}
|
||||
|
||||
const cdf_directory_t *root_storage;
|
||||
if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst,
|
||||
&root_storage)) == -1) {
|
||||
expn = "Cannot read short stream";
|
||||
@ -404,8 +436,24 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
|
||||
if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
|
||||
&scn)) == -1) {
|
||||
if (errno == ESRCH) {
|
||||
corrupt = expn;
|
||||
expn = "No summary info";
|
||||
if ((i = cdf_read_catalog(&info, &h, &sat, &ssat, &sst,
|
||||
&dir, &scn)) == -1) {
|
||||
corrupt = expn;
|
||||
if ((i = cdf_read_encrypted_package(&info, &h,
|
||||
&sat, &ssat, &sst, &dir, &scn)) == -1)
|
||||
expn = "No summary info";
|
||||
else {
|
||||
expn = "Encrypted";
|
||||
i = -1;
|
||||
}
|
||||
goto out4;
|
||||
}
|
||||
#ifdef CDF_DEBUG
|
||||
cdf_dump_catalog(&h, &scn);
|
||||
#endif
|
||||
if ((i = cdf_file_catalog(ms, &h, &scn))
|
||||
< 0)
|
||||
expn = "Can't expand catalog";
|
||||
} else {
|
||||
expn = "Cannot read summary info";
|
||||
}
|
||||
@ -464,7 +512,8 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
|
||||
if (file_printf(ms, ", %s%s", corrupt, expn) == -1)
|
||||
return -1;
|
||||
} else {
|
||||
if (file_printf(ms, "application/CDFV2-corrupt") == -1)
|
||||
if (file_printf(ms, "application/CDFV2-%s",
|
||||
*corrupt ? "corrupt" : "encrypted") == -1)
|
||||
return -1;
|
||||
}
|
||||
i = 1;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: readelf.c,v 1.103 2014/05/02 02:25:10 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: readelf.c,v 1.111 2014/12/09 02:47:45 christos Exp $")
|
||||
#endif
|
||||
|
||||
#ifdef BUILTIN_ELF
|
||||
@ -60,8 +60,9 @@ private uint16_t getu16(int, uint16_t);
|
||||
private uint32_t getu32(int, uint32_t);
|
||||
private uint64_t getu64(int, uint64_t);
|
||||
|
||||
#define MAX_PHNUM 256
|
||||
#define MAX_SHNUM 1024
|
||||
#define MAX_PHNUM 128
|
||||
#define MAX_SHNUM 32768
|
||||
#define SIZE_UNKNOWN ((off_t)-1)
|
||||
|
||||
private int
|
||||
toomany(struct magic_set *ms, const char *name, uint16_t num)
|
||||
@ -324,7 +325,7 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
}
|
||||
off += size;
|
||||
|
||||
if (xph_offset > fsize) {
|
||||
if (fsize != SIZE_UNKNOWN && xph_offset > fsize) {
|
||||
/* Perhaps warn here */
|
||||
continue;
|
||||
}
|
||||
@ -964,7 +965,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
stripped = 0;
|
||||
break;
|
||||
default:
|
||||
if (xsh_offset > fsize) {
|
||||
if (fsize != SIZE_UNKNOWN && xsh_offset > fsize) {
|
||||
/* Perhaps warn here */
|
||||
continue;
|
||||
}
|
||||
@ -1190,7 +1191,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
shared_libraries = " (uses shared libs)";
|
||||
break;
|
||||
default:
|
||||
if (xph_offset > fsize) {
|
||||
if (fsize != SIZE_UNKNOWN && xph_offset > fsize) {
|
||||
/* Maybe warn here? */
|
||||
continue;
|
||||
}
|
||||
@ -1200,7 +1201,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
/* Things we can determine when we seek */
|
||||
switch (xph_type) {
|
||||
case PT_NOTE:
|
||||
if ((align = xph_align) & 0x80000000UL) {
|
||||
if (((align = xph_align) & 0x80000000UL) != 0 ||
|
||||
align < 4) {
|
||||
if (file_printf(ms,
|
||||
", invalid note alignment 0x%lx",
|
||||
(unsigned long)align) == -1)
|
||||
@ -1283,7 +1285,10 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
|
||||
file_badread(ms);
|
||||
return -1;
|
||||
}
|
||||
fsize = st.st_size;
|
||||
if (S_ISREG(st.st_mode) || st.st_size != 0)
|
||||
fsize = st.st_size;
|
||||
else
|
||||
fsize = SIZE_UNKNOWN;
|
||||
|
||||
clazz = buf[EI_CLASS];
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.191 2014/06/04 17:36:34 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.203 2014/12/04 15:22:05 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@ -41,17 +41,13 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.191 2014/06/04 17:36:34 christos Exp $")
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#if defined(HAVE_LOCALE_H)
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
|
||||
private int match(struct magic_set *, struct magic *, uint32_t,
|
||||
const unsigned char *, size_t, size_t, int, int, int, int, int *, int *,
|
||||
int *);
|
||||
const unsigned char *, size_t, size_t, int, int, int, uint16_t,
|
||||
uint16_t *, int *, int *, int *);
|
||||
private int mget(struct magic_set *, const unsigned char *,
|
||||
struct magic *, size_t, size_t, unsigned int, int, int, int, int, int *,
|
||||
int *, int *);
|
||||
struct magic *, size_t, size_t, unsigned int, int, int, int, uint16_t,
|
||||
uint16_t *, int *, int *, int *);
|
||||
private int magiccheck(struct magic_set *, struct magic *);
|
||||
private int32_t mprint(struct magic_set *, struct magic *);
|
||||
private int32_t moffset(struct magic_set *, struct magic *);
|
||||
@ -68,8 +64,6 @@ private void cvt_64(union VALUETYPE *, const struct magic *);
|
||||
|
||||
#define OFFSET_OOB(n, o, i) ((n) < (o) || (i) > ((n) - (o)))
|
||||
|
||||
#define MAX_RECURSION_LEVEL 10
|
||||
|
||||
/*
|
||||
* softmagic - lookup one file in parsed, in-memory copy of database
|
||||
* Passed the name and FILE * of one file to be typed.
|
||||
@ -77,14 +71,21 @@ private void cvt_64(union VALUETYPE *, const struct magic *);
|
||||
/*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */
|
||||
protected int
|
||||
file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
|
||||
size_t level, int mode, int text)
|
||||
uint16_t indir_level, uint16_t *name_count, int mode, int text)
|
||||
{
|
||||
struct mlist *ml;
|
||||
int rv, printed_something = 0, need_separator = 0;
|
||||
uint16_t nc;
|
||||
|
||||
if (name_count == NULL) {
|
||||
nc = 0;
|
||||
name_count = &nc;
|
||||
}
|
||||
|
||||
for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next)
|
||||
if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, 0, mode,
|
||||
text, 0, level, &printed_something, &need_separator,
|
||||
NULL)) != 0)
|
||||
text, 0, indir_level, name_count,
|
||||
&printed_something, &need_separator, NULL)) != 0)
|
||||
return rv;
|
||||
|
||||
return 0;
|
||||
@ -101,8 +102,8 @@ file_fmtcheck(struct magic_set *ms, const struct magic *m, const char *def,
|
||||
const char *ptr = fmtcheck(m->desc, def);
|
||||
if (ptr == def)
|
||||
file_magerror(ms,
|
||||
"%s, %zu: format `%s' does not match with `%s'",
|
||||
file, line, m->desc, def);
|
||||
"%s, %" SIZE_T_FORMAT "u: format `%s' does not match"
|
||||
" with `%s'", file, line, m->desc, def);
|
||||
return ptr;
|
||||
}
|
||||
#else
|
||||
@ -139,8 +140,8 @@ file_fmtcheck(struct magic_set *ms, const struct magic *m, const char *def,
|
||||
private int
|
||||
match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
const unsigned char *s, size_t nbytes, size_t offset, int mode, int text,
|
||||
int flip, int recursion_level, int *printed_something, int *need_separator,
|
||||
int *returnval)
|
||||
int flip, uint16_t indir_level, uint16_t *name_count,
|
||||
int *printed_something, int *need_separator, int *returnval)
|
||||
{
|
||||
uint32_t magindex = 0;
|
||||
unsigned int cont_level = 0;
|
||||
@ -177,8 +178,8 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
|
||||
/* if main entry matches, print it... */
|
||||
switch (mget(ms, s, m, nbytes, offset, cont_level, mode, text,
|
||||
flip, recursion_level + 1, printed_something,
|
||||
need_separator, returnval)) {
|
||||
flip, indir_level, name_count,
|
||||
printed_something, need_separator, returnval)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 0:
|
||||
@ -238,9 +239,9 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
if (file_check_mem(ms, ++cont_level) == -1)
|
||||
return -1;
|
||||
|
||||
while (++magindex < nmagic &&
|
||||
magic[magindex].cont_level != 0) {
|
||||
m = &magic[magindex];
|
||||
while (magindex + 1 < nmagic &&
|
||||
magic[magindex + 1].cont_level != 0) {
|
||||
m = &magic[++magindex];
|
||||
ms->line = m->lineno; /* for messages */
|
||||
|
||||
if (cont_level < m->cont_level)
|
||||
@ -266,8 +267,8 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
}
|
||||
#endif
|
||||
switch (mget(ms, s, m, nbytes, offset, cont_level, mode,
|
||||
text, flip, recursion_level + 1, printed_something,
|
||||
need_separator, returnval)) {
|
||||
text, flip, indir_level, name_count,
|
||||
printed_something, need_separator, returnval)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 0:
|
||||
@ -403,6 +404,28 @@ strndup(const char *str, size_t n)
|
||||
}
|
||||
#endif /* HAVE_STRNDUP */
|
||||
|
||||
static char *
|
||||
printable(char *buf, size_t bufsiz, const char *str)
|
||||
{
|
||||
char *ptr, *eptr;
|
||||
const unsigned char *s = (const unsigned char *)str;
|
||||
|
||||
for (ptr = buf, eptr = ptr + bufsiz - 1; ptr < eptr && *s; s++) {
|
||||
if (isprint(*s)) {
|
||||
*ptr++ = *s;
|
||||
continue;
|
||||
}
|
||||
if (ptr >= eptr + 4)
|
||||
break;
|
||||
*ptr++ = '\\';
|
||||
*ptr++ = ((*s >> 6) & 7) + '0';
|
||||
*ptr++ = ((*s >> 3) & 7) + '0';
|
||||
*ptr++ = ((*s >> 0) & 7) + '0';
|
||||
}
|
||||
*ptr = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
private int32_t
|
||||
mprint(struct magic_set *ms, struct magic *m)
|
||||
{
|
||||
@ -509,6 +532,7 @@ mprint(struct magic_set *ms, struct magic *m)
|
||||
t = ms->offset + m->vallen;
|
||||
}
|
||||
else {
|
||||
char sbuf[512];
|
||||
char *str = p->s;
|
||||
|
||||
/* compute t before we mangle the string? */
|
||||
@ -530,7 +554,8 @@ mprint(struct magic_set *ms, struct magic *m)
|
||||
*++last = '\0';
|
||||
}
|
||||
|
||||
if (file_printf(ms, F(ms, m, "%s"), str) == -1)
|
||||
if (file_printf(ms, F(ms, m, "%s"),
|
||||
printable(sbuf, sizeof(sbuf), str)) == -1)
|
||||
return -1;
|
||||
|
||||
if (m->type == FILE_PSTRING)
|
||||
@ -946,14 +971,17 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
|
||||
size_t sz = file_pstring_length_size(m);
|
||||
char *ptr1 = p->s, *ptr2 = ptr1 + sz;
|
||||
size_t len = file_pstring_get_length(m, ptr1);
|
||||
if (len >= sizeof(p->s)) {
|
||||
sz = sizeof(p->s) - sz; /* maximum length of string */
|
||||
if (len >= sz) {
|
||||
/*
|
||||
* The size of the pascal string length (sz)
|
||||
* is 1, 2, or 4. We need at least 1 byte for NUL
|
||||
* termination, but we've already truncated the
|
||||
* string by p->s, so we need to deduct sz.
|
||||
* Because we can use one of the bytes of the length
|
||||
* after we shifted as NUL termination.
|
||||
*/
|
||||
len = sizeof(p->s) - sz;
|
||||
len = sz;
|
||||
}
|
||||
while (len--)
|
||||
*ptr1++ = *ptr2++;
|
||||
@ -1063,7 +1091,7 @@ mconvert(struct magic_set *ms, struct magic *m, int flip)
|
||||
private void
|
||||
mdebug(uint32_t offset, const char *str, size_t len)
|
||||
{
|
||||
(void) fprintf(stderr, "mget/%zu @%d: ", len, offset);
|
||||
(void) fprintf(stderr, "mget/%" SIZE_T_FORMAT "u @%d: ", len, offset);
|
||||
file_showstr(stderr, str, len);
|
||||
(void) fputc('\n', stderr);
|
||||
(void) fputc('\n', stderr);
|
||||
@ -1193,8 +1221,8 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
|
||||
private int
|
||||
mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
size_t nbytes, size_t o, unsigned int cont_level, int mode, int text,
|
||||
int flip, int recursion_level, int *printed_something,
|
||||
int *need_separator, int *returnval)
|
||||
int flip, uint16_t indir_level, uint16_t *name_count,
|
||||
int *printed_something, int *need_separator, int *returnval)
|
||||
{
|
||||
uint32_t offset = ms->offset;
|
||||
uint32_t lhs;
|
||||
@ -1204,8 +1232,15 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
union VALUETYPE *p = &ms->ms_value;
|
||||
struct mlist ml;
|
||||
|
||||
if (recursion_level >= MAX_RECURSION_LEVEL) {
|
||||
file_error(ms, 0, "recursion nesting exceeded");
|
||||
if (indir_level >= ms->indir_max) {
|
||||
file_error(ms, 0, "indirect recursion nesting (%hu) exceeded",
|
||||
indir_level);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (*name_count >= ms->name_max) {
|
||||
file_error(ms, 0, "name use count (%hu) exceeded",
|
||||
*name_count);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1214,8 +1249,11 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
return -1;
|
||||
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0) {
|
||||
fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%zu, "
|
||||
"nbytes=%zu)\n", m->type, m->flag, offset, o, nbytes);
|
||||
fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%"
|
||||
SIZE_T_FORMAT "u, " "nbytes=%" SIZE_T_FORMAT
|
||||
"u, il=%hu, nc=%hu)\n",
|
||||
m->type, m->flag, offset, o, nbytes,
|
||||
indir_level, *name_count);
|
||||
mdebug(offset, (char *)(void *)p, sizeof(union VALUETYPE));
|
||||
#ifndef COMPILE_ONLY
|
||||
file_mdump(m);
|
||||
@ -1656,7 +1694,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
return -1;
|
||||
|
||||
rv = file_softmagic(ms, s + offset, nbytes - offset,
|
||||
recursion_level, BINTEST, text);
|
||||
indir_level + 1, name_count, BINTEST, text);
|
||||
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
fprintf(stderr, "indirect @offs=%u[%d]\n", offset, rv);
|
||||
@ -1691,13 +1729,13 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
|
||||
file_error(ms, 0, "cannot find entry `%s'", rbuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
(*name_count)++;
|
||||
oneed_separator = *need_separator;
|
||||
if (m->flag & NOSPACE)
|
||||
*need_separator = 0;
|
||||
rv = match(ms, ml.magic, ml.nmagic, s, nbytes, offset + o,
|
||||
mode, text, flip, recursion_level, printed_something,
|
||||
need_separator, returnval);
|
||||
mode, text, flip, indir_level, name_count,
|
||||
printed_something, need_separator, returnval);
|
||||
if (rv != 1)
|
||||
*need_separator = oneed_separator;
|
||||
return rv;
|
||||
@ -1952,6 +1990,7 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
case FILE_REGEX: {
|
||||
int rc;
|
||||
file_regex_t rx;
|
||||
const char *search;
|
||||
|
||||
if (ms->search.s == NULL)
|
||||
return 0;
|
||||
@ -1968,19 +2007,31 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
size_t slen = ms->search.s_len;
|
||||
#ifndef REG_STARTEND
|
||||
#define REG_STARTEND 0
|
||||
char c;
|
||||
if (slen != 0)
|
||||
slen--;
|
||||
c = ms->search.s[slen];
|
||||
((char *)(intptr_t)ms->search.s)[slen] = '\0';
|
||||
char *copy;
|
||||
if (slen != 0) {
|
||||
copy = malloc(slen);
|
||||
if (copy == NULL) {
|
||||
file_error(ms, errno,
|
||||
"can't allocate %" SIZE_T_FORMAT "u bytes",
|
||||
slen);
|
||||
return -1;
|
||||
}
|
||||
memcpy(copy, ms->search.s, slen);
|
||||
copy[--slen] = '\0';
|
||||
search = copy;
|
||||
} else {
|
||||
search = ms->search.s;
|
||||
copy = NULL;
|
||||
}
|
||||
#else
|
||||
search = ms->search.s;
|
||||
pmatch[0].rm_so = 0;
|
||||
pmatch[0].rm_eo = slen;
|
||||
#endif
|
||||
rc = file_regexec(&rx, (const char *)ms->search.s,
|
||||
rc = file_regexec(&rx, (const char *)search,
|
||||
1, pmatch, REG_STARTEND);
|
||||
#if REG_STARTEND == 0
|
||||
((char *)(intptr_t)ms->search.s)[l] = c;
|
||||
free(copy);
|
||||
#endif
|
||||
switch (rc) {
|
||||
case 0:
|
||||
|
@ -108,7 +108,7 @@ you use strange formats.
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: vasprintf.c,v 1.12 2014/05/14 23:09:21 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: vasprintf.c,v 1.13 2014/12/04 15:56:46 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include <assert.h>
|
||||
@ -633,11 +633,15 @@ int vasprintf(char **ptr, const char *format_string, va_list vargs)
|
||||
#ifdef va_copy
|
||||
va_copy (s.vargs, vargs);
|
||||
#else
|
||||
#ifdef __va_copy
|
||||
# ifdef __va_copy
|
||||
__va_copy (s.vargs, vargs);
|
||||
#else
|
||||
# else
|
||||
# ifdef WIN32
|
||||
s.vargs = vargs;
|
||||
# else
|
||||
memcpy (&s.vargs, &vargs, sizeof (s.va_args));
|
||||
#endif /* __va_copy */
|
||||
# endif /* WIN32 */
|
||||
# endif /* __va_copy */
|
||||
#endif /* va_copy */
|
||||
s.maxlen = (size_t)INT_MAX;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Makefile.in generated by automake 1.14 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
|
@ -1,3 +1,14 @@
|
||||
Pull in r200383 from upstream llvm trunk (by David Majnemer):
|
||||
|
||||
MC: Reorganize macro MC test along dialect lines
|
||||
|
||||
This commit seeks to do two things:
|
||||
- Run the surfeit of tests under the Darwin dialect. This ends up
|
||||
affecting tests which assumed that spaces could deliminate arguments.
|
||||
- The GAS dialect tests should limit their surface area to things that
|
||||
could plausibly work under GAS. For example, Darwin style arguments
|
||||
have no business being in such a test.
|
||||
|
||||
Pull in r201784 from upstream llvm trunk (by Benjamin Kramer):
|
||||
|
||||
AsmParser: Disable Darwin-style macro argument expansion on non-darwin targets.
|
||||
@ -53,3 +64,304 @@ Index: test/MC/AsmParser/exprs.s
|
||||
|
||||
.macro check_expr
|
||||
.if ($0) != ($1)
|
||||
Index: test/MC/AsmParser/macros.s
|
||||
===================================================================
|
||||
--- test/MC/AsmParser/macros.s
|
||||
+++ test/MC/AsmParser/macros.s
|
||||
@@ -1,93 +0,0 @@
|
||||
-// RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t.err | FileCheck %s
|
||||
-// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
|
||||
-
|
||||
-.macro .test0
|
||||
-.macrobody0
|
||||
-.endmacro
|
||||
-.macro .test1
|
||||
-.test0
|
||||
-.endmacro
|
||||
-
|
||||
-.test1
|
||||
-// CHECK-ERRORS: <instantiation>:1:1: error: unknown directive
|
||||
-// CHECK-ERRORS-NEXT: macrobody0
|
||||
-// CHECK-ERRORS-NEXT: ^
|
||||
-// CHECK-ERRORS: <instantiation>:1:1: note: while in macro instantiation
|
||||
-// CHECK-ERRORS-NEXT: .test0
|
||||
-// CHECK-ERRORS-NEXT: ^
|
||||
-// CHECK-ERRORS: 11:1: note: while in macro instantiation
|
||||
-// CHECK-ERRORS-NEXT: .test1
|
||||
-// CHECK-ERRORS-NEXT: ^
|
||||
-
|
||||
-.macro test2
|
||||
-.byte $0
|
||||
-.endmacro
|
||||
-test2 10
|
||||
-
|
||||
-.macro test3
|
||||
-.globl "$0 $1 $2 $$3 $n"
|
||||
-.endmacro
|
||||
-
|
||||
-// CHECK: .globl "1 (23) $3 2"
|
||||
-test3 1, (2 3)
|
||||
-
|
||||
-// CHECK: .globl "1 2 $3 2"
|
||||
-test3 1 2
|
||||
-
|
||||
-.macro test4
|
||||
-.globl "$0 -- $1"
|
||||
-.endmacro
|
||||
-
|
||||
-// CHECK: .globl "(ab)(,)) -- (cd)"
|
||||
-test4 (a b)(,)),(cd)
|
||||
-
|
||||
-// CHECK: .globl "(ab)(,)) -- (cd)"
|
||||
-test4 (a b)(,)),(cd)
|
||||
-
|
||||
-.macro test5 _a
|
||||
-.globl "\_a"
|
||||
-.endm
|
||||
-
|
||||
-// CHECK: .globl zed1
|
||||
-test5 zed1
|
||||
-
|
||||
-.macro test6 $a
|
||||
-.globl "\$a"
|
||||
-.endm
|
||||
-
|
||||
-// CHECK: .globl zed2
|
||||
-test6 zed2
|
||||
-
|
||||
-.macro test7 .a
|
||||
-.globl "\.a"
|
||||
-.endm
|
||||
-
|
||||
-// CHECK: .globl zed3
|
||||
-test7 zed3
|
||||
-
|
||||
-.macro test8 _a, _b, _c
|
||||
-.globl "\_a,\_b,\_c"
|
||||
-.endmacro
|
||||
-
|
||||
-.macro test9 _a _b _c
|
||||
-.globl "\_a \_b \_c"
|
||||
-.endmacro
|
||||
-
|
||||
-// CHECK: .globl "a,b,c"
|
||||
-test8 a, b, c
|
||||
-// CHECK: .globl "%1,%2,%3"
|
||||
-test8 %1 %2 %3 #a comment
|
||||
-// CHECK: .globl "x-y,z,1"
|
||||
-test8 x - y z 1
|
||||
-// CHECK: .globl "1 2 3"
|
||||
-test9 1, 2,3
|
||||
-
|
||||
-test8 1,2 3
|
||||
-// CHECK-ERRORS: error: macro argument '_c' is missing
|
||||
-// CHECK-ERRORS-NEXT: test8 1,2 3
|
||||
-// CHECK-ERRORS-NEXT: ^
|
||||
-
|
||||
-test8 1 2, 3
|
||||
-// CHECK-ERRORS: error: expected ' ' for macro argument separator
|
||||
-// CHECK-ERRORS-NEXT:test8 1 2, 3
|
||||
-// CHECK-ERRORS-NEXT: ^
|
||||
Index: test/MC/AsmParser/macros-darwin.s
|
||||
===================================================================
|
||||
--- test/MC/AsmParser/macros-darwin.s
|
||||
+++ test/MC/AsmParser/macros-darwin.s
|
||||
@@ -1,9 +1,97 @@
|
||||
-// RUN: llvm-mc -triple i386-apple-darwin10 %s | FileCheck %s
|
||||
+// RUN: not llvm-mc -triple i386-apple-darwin10 %s 2> %t.err | FileCheck %s
|
||||
+// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
|
||||
|
||||
-.macro test1
|
||||
+.macro .test0
|
||||
+.macrobody0
|
||||
+.endmacro
|
||||
+.macro .test1
|
||||
+.test0
|
||||
+.endmacro
|
||||
+
|
||||
+.test1
|
||||
+// CHECK-ERRORS: <instantiation>:1:1: error: unknown directive
|
||||
+// CHECK-ERRORS-NEXT: macrobody0
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
+// CHECK-ERRORS: <instantiation>:1:1: note: while in macro instantiation
|
||||
+// CHECK-ERRORS-NEXT: .test0
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
+// CHECK-ERRORS: 11:1: note: while in macro instantiation
|
||||
+// CHECK-ERRORS-NEXT: .test1
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
+
|
||||
+.macro test2
|
||||
+.byte $0
|
||||
+.endmacro
|
||||
+// CHECK: .byte 10
|
||||
+test2 10
|
||||
+
|
||||
+.macro test3
|
||||
.globl "$0 $1 $2 $$3 $n"
|
||||
.endmacro
|
||||
|
||||
// CHECK: .globl "1 23 $3 2"
|
||||
-test1 1, 2 3
|
||||
+test3 1, 2 3
|
||||
|
||||
+// CHECK: .globl "1 (23) $3 2"
|
||||
+test3 1, (2 3)
|
||||
+
|
||||
+// CHECK: .globl "12 $3 1"
|
||||
+test3 1 2
|
||||
+
|
||||
+.macro test4
|
||||
+.globl "$0 -- $1"
|
||||
+.endmacro
|
||||
+
|
||||
+// CHECK: .globl "(ab)(,)) -- (cd)"
|
||||
+test4 (a b)(,)),(cd)
|
||||
+
|
||||
+// CHECK: .globl "(ab)(,)) -- (cd)"
|
||||
+test4 (a b)(,)),(cd)
|
||||
+
|
||||
+.macro test5 _a
|
||||
+.globl "\_a"
|
||||
+.endm
|
||||
+
|
||||
+// CHECK: .globl zed1
|
||||
+test5 zed1
|
||||
+
|
||||
+.macro test6 $a
|
||||
+.globl "\$a"
|
||||
+.endm
|
||||
+
|
||||
+// CHECK: .globl zed2
|
||||
+test6 zed2
|
||||
+
|
||||
+.macro test7 .a
|
||||
+.globl "\.a"
|
||||
+.endm
|
||||
+
|
||||
+// CHECK: .globl zed3
|
||||
+test7 zed3
|
||||
+
|
||||
+.macro test8 _a, _b, _c
|
||||
+.globl "\_a,\_b,\_c"
|
||||
+.endmacro
|
||||
+
|
||||
+.macro test9 _a _b _c
|
||||
+.globl "\_a \_b \_c"
|
||||
+.endmacro
|
||||
+
|
||||
+// CHECK: .globl "a,b,c"
|
||||
+test8 a, b, c
|
||||
+// CHECK: .globl "%1,%2,%3"
|
||||
+test8 %1, %2, %3 #a comment
|
||||
+// CHECK: .globl "x-y,z,1"
|
||||
+test8 x - y, z, 1
|
||||
+// CHECK: .globl "1 2 3"
|
||||
+test9 1, 2,3
|
||||
+
|
||||
+test8 1,2 3
|
||||
+// CHECK-ERRORS: error: macro argument '_c' is missing
|
||||
+// CHECK-ERRORS-NEXT: test8 1,2 3
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
+
|
||||
+test8 1 2, 3
|
||||
+// CHECK-ERRORS: error: macro argument '_c' is missing
|
||||
+// CHECK-ERRORS-NEXT:test8 1 2, 3
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
Index: test/MC/AsmParser/macros-gas.s
|
||||
===================================================================
|
||||
--- test/MC/AsmParser/macros-gas.s
|
||||
+++ test/MC/AsmParser/macros-gas.s
|
||||
@@ -0,0 +1,93 @@
|
||||
+// RUN: not llvm-mc -triple i386-linux-gnu %s 2> %t.err | FileCheck %s
|
||||
+// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
|
||||
+
|
||||
+.macro .test0
|
||||
+.macrobody0
|
||||
+.endm
|
||||
+.macro .test1
|
||||
+.test0
|
||||
+.endm
|
||||
+
|
||||
+.test1
|
||||
+// CHECK-ERRORS: <instantiation>:1:1: error: unknown directive
|
||||
+// CHECK-ERRORS-NEXT: macrobody0
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
+// CHECK-ERRORS: <instantiation>:1:1: note: while in macro instantiation
|
||||
+// CHECK-ERRORS-NEXT: .test0
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
+// CHECK-ERRORS: 11:1: note: while in macro instantiation
|
||||
+// CHECK-ERRORS-NEXT: .test1
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
+
|
||||
+.macro test2 _a
|
||||
+.byte \_a
|
||||
+.endm
|
||||
+// CHECK: .byte 10
|
||||
+test2 10
|
||||
+
|
||||
+.macro test3 _a _b _c
|
||||
+.ascii "\_a \_b \_c \\_c"
|
||||
+.endm
|
||||
+
|
||||
+// CHECK: .ascii "1 2 3 \003"
|
||||
+test3 1, 2, 3
|
||||
+
|
||||
+// FIXME: test3 1, 2 3 should be treated like test 1, 2, 3
|
||||
+
|
||||
+// FIXME: remove the n argument from the remaining test3 examples
|
||||
+// CHECK: .ascii "1 (23) n \n"
|
||||
+test3 1, (2 3), n
|
||||
+
|
||||
+// CHECK: .ascii "1 (23) n \n"
|
||||
+test3 1 (2 3) n
|
||||
+
|
||||
+// CHECK: .ascii "1 2 n \n"
|
||||
+test3 1 2 n
|
||||
+
|
||||
+.macro test5 _a
|
||||
+.globl \_a
|
||||
+.endm
|
||||
+
|
||||
+// CHECK: .globl zed1
|
||||
+test5 zed1
|
||||
+
|
||||
+.macro test6 $a
|
||||
+.globl \$a
|
||||
+.endm
|
||||
+
|
||||
+// CHECK: .globl zed2
|
||||
+test6 zed2
|
||||
+
|
||||
+.macro test7 .a
|
||||
+.globl \.a
|
||||
+.endm
|
||||
+
|
||||
+// CHECK: .globl zed3
|
||||
+test7 zed3
|
||||
+
|
||||
+.macro test8 _a, _b, _c
|
||||
+.ascii "\_a,\_b,\_c"
|
||||
+.endm
|
||||
+
|
||||
+.macro test9 _a _b _c
|
||||
+.ascii "\_a \_b \_c"
|
||||
+.endm
|
||||
+
|
||||
+// CHECK: .ascii "a,b,c"
|
||||
+test8 a, b, c
|
||||
+// CHECK: .ascii "%1,%2,%3"
|
||||
+test8 %1 %2 %3 #a comment
|
||||
+// CHECK: .ascii "x-y,z,1"
|
||||
+test8 x - y z 1
|
||||
+// CHECK: .ascii "1 2 3"
|
||||
+test9 1, 2,3
|
||||
+
|
||||
+test8 1,2 3
|
||||
+// CHECK-ERRORS: error: macro argument '_c' is missing
|
||||
+// CHECK-ERRORS-NEXT: test8 1,2 3
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
+
|
||||
+test8 1 2, 3
|
||||
+// CHECK-ERRORS: error: expected ' ' for macro argument separator
|
||||
+// CHECK-ERRORS-NEXT:test8 1 2, 3
|
||||
+// CHECK-ERRORS-NEXT: ^
|
||||
|
@ -1,3 +1,11 @@
|
||||
Pull in r223170 from upstream llvm trunk (by Michael Zolotukhin):
|
||||
|
||||
Apply loop-rotate to several vectorizer tests.
|
||||
|
||||
Such loops shouldn't be vectorized due to the loops form.
|
||||
After applying loop-rotate (+simplifycfg) the tests again start to check
|
||||
what they are intended to check.
|
||||
|
||||
Pull in r223171 from upstream llvm trunk (by Michael Zolotukhin):
|
||||
|
||||
PR21302. Vectorize only bottom-tested loops.
|
||||
@ -16,8 +24,8 @@ Introduced here: http://svnweb.freebsd.org/changeset/base/275633
|
||||
|
||||
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
|
||||
===================================================================
|
||||
--- lib/Transforms/Vectorize/LoopVectorize.cpp (revision 21)
|
||||
+++ lib/Transforms/Vectorize/LoopVectorize.cpp (revision 22)
|
||||
--- lib/Transforms/Vectorize/LoopVectorize.cpp
|
||||
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
|
||||
@@ -2864,6 +2864,14 @@ bool LoopVectorizationLegality::canVectorize() {
|
||||
if (!TheLoop->getExitingBlock())
|
||||
return false;
|
||||
@ -35,11 +43,11 @@ Index: lib/Transforms/Vectorize/LoopVectorize.cpp
|
||||
TheLoop->getHeader()->getName() << '\n');
|
||||
Index: test/Transforms/LoopVectorize/loop-form.ll
|
||||
===================================================================
|
||||
--- test/Transforms/LoopVectorize/loop-form.ll (revision 0)
|
||||
+++ test/Transforms/LoopVectorize/loop-form.ll (revision 22)
|
||||
--- test/Transforms/LoopVectorize/loop-form.ll
|
||||
+++ test/Transforms/LoopVectorize/loop-form.ll
|
||||
@@ -0,0 +1,31 @@
|
||||
+; RUN: opt -S -loop-vectorize < %s | FileCheck %s
|
||||
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||
+target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
+
|
||||
+; Check that we vectorize only bottom-tested loops.
|
||||
+; This is a reduced testcase from PR21302.
|
||||
@ -69,3 +77,453 @@ Index: test/Transforms/LoopVectorize/loop-form.ll
|
||||
+if.end:
|
||||
+ ret void
|
||||
+}
|
||||
Index: test/Transforms/LoopVectorize/runtime-check-address-space.ll
|
||||
===================================================================
|
||||
--- test/Transforms/LoopVectorize/runtime-check-address-space.ll
|
||||
+++ test/Transforms/LoopVectorize/runtime-check-address-space.ll
|
||||
@@ -31,25 +31,23 @@ define void @foo(i32 addrspace(1)* %a, i32 addrspa
|
||||
; CHECK: ret
|
||||
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ %cmp1 = icmp slt i32 0, %n
|
||||
+ br i1 %cmp1, label %for.body, label %for.end
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp slt i32 %i.0, %n
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %idxprom = sext i32 %i.0 to i64
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
|
||||
+ %idxprom = sext i32 %i.02 to i64
|
||||
%arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %idxprom
|
||||
%0 = load i32 addrspace(1)* %arrayidx, align 4
|
||||
%mul = mul nsw i32 %0, 3
|
||||
- %idxprom1 = sext i32 %i.0 to i64
|
||||
+ %idxprom1 = sext i32 %i.02 to i64
|
||||
%arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %idxprom1
|
||||
store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4
|
||||
- %inc = add nsw i32 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add nsw i32 %i.02, 1
|
||||
+ %cmp = icmp slt i32 %inc, %n
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body, %entry
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -60,25 +58,23 @@ define void @bar0(i32* %a, i32 addrspace(1)* %b, i
|
||||
; CHECK: ret
|
||||
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ %cmp1 = icmp slt i32 0, %n
|
||||
+ br i1 %cmp1, label %for.body, label %for.end
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp slt i32 %i.0, %n
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %idxprom = sext i32 %i.0 to i64
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
|
||||
+ %idxprom = sext i32 %i.02 to i64
|
||||
%arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %idxprom
|
||||
%0 = load i32 addrspace(1)* %arrayidx, align 4
|
||||
%mul = mul nsw i32 %0, 3
|
||||
- %idxprom1 = sext i32 %i.0 to i64
|
||||
+ %idxprom1 = sext i32 %i.02 to i64
|
||||
%arrayidx2 = getelementptr inbounds i32* %a, i64 %idxprom1
|
||||
store i32 %mul, i32* %arrayidx2, align 4
|
||||
- %inc = add nsw i32 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add nsw i32 %i.02, 1
|
||||
+ %cmp = icmp slt i32 %inc, %n
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body, %entry
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -89,25 +85,23 @@ define void @bar1(i32 addrspace(1)* %a, i32* %b, i
|
||||
; CHECK: ret
|
||||
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ %cmp1 = icmp slt i32 0, %n
|
||||
+ br i1 %cmp1, label %for.body, label %for.end
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp slt i32 %i.0, %n
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %idxprom = sext i32 %i.0 to i64
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
|
||||
+ %idxprom = sext i32 %i.02 to i64
|
||||
%arrayidx = getelementptr inbounds i32* %b, i64 %idxprom
|
||||
%0 = load i32* %arrayidx, align 4
|
||||
%mul = mul nsw i32 %0, 3
|
||||
- %idxprom1 = sext i32 %i.0 to i64
|
||||
+ %idxprom1 = sext i32 %i.02 to i64
|
||||
%arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %idxprom1
|
||||
store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4
|
||||
- %inc = add nsw i32 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add nsw i32 %i.02, 1
|
||||
+ %cmp = icmp slt i32 %inc, %n
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body, %entry
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -119,25 +113,23 @@ define void @bar2(i32* noalias %a, i32 addrspace(1
|
||||
; CHECK: ret
|
||||
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ %cmp1 = icmp slt i32 0, %n
|
||||
+ br i1 %cmp1, label %for.body, label %for.end
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp slt i32 %i.0, %n
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %idxprom = sext i32 %i.0 to i64
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
|
||||
+ %idxprom = sext i32 %i.02 to i64
|
||||
%arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %idxprom
|
||||
%0 = load i32 addrspace(1)* %arrayidx, align 4
|
||||
%mul = mul nsw i32 %0, 3
|
||||
- %idxprom1 = sext i32 %i.0 to i64
|
||||
+ %idxprom1 = sext i32 %i.02 to i64
|
||||
%arrayidx2 = getelementptr inbounds i32* %a, i64 %idxprom1
|
||||
store i32 %mul, i32* %arrayidx2, align 4
|
||||
- %inc = add nsw i32 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add nsw i32 %i.02, 1
|
||||
+ %cmp = icmp slt i32 %inc, %n
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body, %entry
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -149,25 +141,23 @@ define void @arst0(i32* %b, i32 %n) #0 {
|
||||
; CHECK: ret
|
||||
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ %cmp1 = icmp slt i32 0, %n
|
||||
+ br i1 %cmp1, label %for.body, label %for.end
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp slt i32 %i.0, %n
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %idxprom = sext i32 %i.0 to i64
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
|
||||
+ %idxprom = sext i32 %i.02 to i64
|
||||
%arrayidx = getelementptr inbounds i32* %b, i64 %idxprom
|
||||
%0 = load i32* %arrayidx, align 4
|
||||
%mul = mul nsw i32 %0, 3
|
||||
- %idxprom1 = sext i32 %i.0 to i64
|
||||
+ %idxprom1 = sext i32 %i.02 to i64
|
||||
%arrayidx2 = getelementptr inbounds [1024 x i32] addrspace(1)* @g_as1, i64 0, i64 %idxprom1
|
||||
store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4
|
||||
- %inc = add nsw i32 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add nsw i32 %i.02, 1
|
||||
+ %cmp = icmp slt i32 %inc, %n
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body, %entry
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -180,25 +170,23 @@ define void @arst1(i32* %b, i32 %n) #0 {
|
||||
; CHECK: ret
|
||||
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ %cmp1 = icmp slt i32 0, %n
|
||||
+ br i1 %cmp1, label %for.body, label %for.end
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp slt i32 %i.0, %n
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %idxprom = sext i32 %i.0 to i64
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
|
||||
+ %idxprom = sext i32 %i.02 to i64
|
||||
%arrayidx = getelementptr inbounds [1024 x i32] addrspace(1)* @g_as1, i64 0, i64 %idxprom
|
||||
%0 = load i32 addrspace(1)* %arrayidx, align 4
|
||||
%mul = mul nsw i32 %0, 3
|
||||
- %idxprom1 = sext i32 %i.0 to i64
|
||||
+ %idxprom1 = sext i32 %i.02 to i64
|
||||
%arrayidx2 = getelementptr inbounds i32* %b, i64 %idxprom1
|
||||
store i32 %mul, i32* %arrayidx2, align 4
|
||||
- %inc = add nsw i32 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add nsw i32 %i.02, 1
|
||||
+ %cmp = icmp slt i32 %inc, %n
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body, %entry
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -210,25 +198,23 @@ define void @aoeu(i32 %n) #0 {
|
||||
; CHECK: ret
|
||||
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ %cmp1 = icmp slt i32 0, %n
|
||||
+ br i1 %cmp1, label %for.body, label %for.end
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp slt i32 %i.0, %n
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %idxprom = sext i32 %i.0 to i64
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
|
||||
+ %idxprom = sext i32 %i.02 to i64
|
||||
%arrayidx = getelementptr inbounds [1024 x i32] addrspace(2)* @q_as2, i64 0, i64 %idxprom
|
||||
%0 = load i32 addrspace(2)* %arrayidx, align 4
|
||||
%mul = mul nsw i32 %0, 3
|
||||
- %idxprom1 = sext i32 %i.0 to i64
|
||||
+ %idxprom1 = sext i32 %i.02 to i64
|
||||
%arrayidx2 = getelementptr inbounds [1024 x i32] addrspace(1)* @g_as1, i64 0, i64 %idxprom1
|
||||
store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4
|
||||
- %inc = add nsw i32 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add nsw i32 %i.02, 1
|
||||
+ %cmp = icmp slt i32 %inc, %n
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body, %entry
|
||||
ret void
|
||||
}
|
||||
|
||||
Index: test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll
|
||||
===================================================================
|
||||
--- test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll
|
||||
+++ test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll
|
||||
@@ -8,26 +8,24 @@ define void @add_ints_1_1_1(i32 addrspace(1)* %a,
|
||||
; CHECK-LABEL: @add_ints_1_1_1(
|
||||
; CHECK: <4 x i32>
|
||||
; CHECK: ret
|
||||
+
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ br label %for.body
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp ult i64 %i.0, 200
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
+ %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01
|
||||
%0 = load i32 addrspace(1)* %arrayidx, align 4
|
||||
- %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.0
|
||||
+ %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.01
|
||||
%1 = load i32 addrspace(1)* %arrayidx1, align 4
|
||||
%add = add nsw i32 %0, %1
|
||||
- %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.0
|
||||
+ %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.01
|
||||
store i32 %add, i32 addrspace(1)* %arrayidx2, align 4
|
||||
- %inc = add i64 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add i64 %i.01, 1
|
||||
+ %cmp = icmp ult i64 %inc, 200
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -35,26 +33,24 @@ define void @add_ints_as_1_0_0(i32 addrspace(1)* %
|
||||
; CHECK-LABEL: @add_ints_as_1_0_0(
|
||||
; CHECK-NOT: <4 x i32>
|
||||
; CHECK: ret
|
||||
+
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ br label %for.body
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp ult i64 %i.0, 200
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %arrayidx = getelementptr inbounds i32* %b, i64 %i.0
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
+ %arrayidx = getelementptr inbounds i32* %b, i64 %i.01
|
||||
%0 = load i32* %arrayidx, align 4
|
||||
- %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.0
|
||||
+ %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.01
|
||||
%1 = load i32* %arrayidx1, align 4
|
||||
%add = add nsw i32 %0, %1
|
||||
- %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.0
|
||||
+ %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.01
|
||||
store i32 %add, i32 addrspace(1)* %arrayidx2, align 4
|
||||
- %inc = add i64 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add i64 %i.01, 1
|
||||
+ %cmp = icmp ult i64 %inc, 200
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -62,26 +58,24 @@ define void @add_ints_as_0_1_0(i32* %a, i32 addrsp
|
||||
; CHECK-LABEL: @add_ints_as_0_1_0(
|
||||
; CHECK-NOT: <4 x i32>
|
||||
; CHECK: ret
|
||||
+
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ br label %for.body
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp ult i64 %i.0, 200
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
+ %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01
|
||||
%0 = load i32 addrspace(1)* %arrayidx, align 4
|
||||
- %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.0
|
||||
+ %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.01
|
||||
%1 = load i32* %arrayidx1, align 4
|
||||
%add = add nsw i32 %0, %1
|
||||
- %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.0
|
||||
+ %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.01
|
||||
store i32 %add, i32* %arrayidx2, align 4
|
||||
- %inc = add i64 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add i64 %i.01, 1
|
||||
+ %cmp = icmp ult i64 %inc, 200
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -89,26 +83,24 @@ define void @add_ints_as_0_1_1(i32* %a, i32 addrsp
|
||||
; CHECK-LABEL: @add_ints_as_0_1_1(
|
||||
; CHECK-NOT: <4 x i32>
|
||||
; CHECK: ret
|
||||
+
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ br label %for.body
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp ult i64 %i.0, 200
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
+ %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01
|
||||
%0 = load i32 addrspace(1)* %arrayidx, align 4
|
||||
- %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.0
|
||||
+ %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.01
|
||||
%1 = load i32 addrspace(1)* %arrayidx1, align 4
|
||||
%add = add nsw i32 %0, %1
|
||||
- %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.0
|
||||
+ %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.01
|
||||
store i32 %add, i32* %arrayidx2, align 4
|
||||
- %inc = add i64 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add i64 %i.01, 1
|
||||
+ %cmp = icmp ult i64 %inc, 200
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -116,26 +108,24 @@ define void @add_ints_as_0_1_2(i32* %a, i32 addrsp
|
||||
; CHECK-LABEL: @add_ints_as_0_1_2(
|
||||
; CHECK-NOT: <4 x i32>
|
||||
; CHECK: ret
|
||||
+
|
||||
entry:
|
||||
- br label %for.cond
|
||||
+ br label %for.body
|
||||
|
||||
-for.cond: ; preds = %for.body, %entry
|
||||
- %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
- %cmp = icmp ult i64 %i.0, 200
|
||||
- br i1 %cmp, label %for.body, label %for.end
|
||||
-
|
||||
-for.body: ; preds = %for.cond
|
||||
- %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0
|
||||
+for.body: ; preds = %entry, %for.body
|
||||
+ %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
|
||||
+ %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01
|
||||
%0 = load i32 addrspace(1)* %arrayidx, align 4
|
||||
- %arrayidx1 = getelementptr inbounds i32 addrspace(2)* %c, i64 %i.0
|
||||
+ %arrayidx1 = getelementptr inbounds i32 addrspace(2)* %c, i64 %i.01
|
||||
%1 = load i32 addrspace(2)* %arrayidx1, align 4
|
||||
%add = add nsw i32 %0, %1
|
||||
- %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.0
|
||||
+ %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.01
|
||||
store i32 %add, i32* %arrayidx2, align 4
|
||||
- %inc = add i64 %i.0, 1
|
||||
- br label %for.cond
|
||||
+ %inc = add i64 %i.01, 1
|
||||
+ %cmp = icmp ult i64 %inc, 200
|
||||
+ br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
-for.end: ; preds = %for.cond
|
||||
+for.end: ; preds = %for.body
|
||||
ret void
|
||||
}
|
||||
|
||||
|
298
contrib/llvm/patches/patch-r275759-clang-r221170-ppc-vaarg.diff
Normal file
298
contrib/llvm/patches/patch-r275759-clang-r221170-ppc-vaarg.diff
Normal file
@ -0,0 +1,298 @@
|
||||
Pull in r221170 from upstream clang trunk (by Roman Divacky):
|
||||
|
||||
Implement vaarg lowering for ppc32. Lowering of scalars and
|
||||
aggregates is supported. Complex numbers are not.
|
||||
|
||||
Pull in r221174 from upstream clang trunk (by Roman Divacky):
|
||||
|
||||
Require asserts to unbreak the buildbots.
|
||||
|
||||
Pull in r221284 from upstream clang trunk (by Roman Divacky):
|
||||
|
||||
Rewrite the test to not require asserts.
|
||||
|
||||
Pull in r221285 from upstream clang trunk (by Roman Divacky):
|
||||
|
||||
Since the file has both ppc and ppc64 tests in it rename it.
|
||||
|
||||
This adds va_args support for PowerPC (32 bit) to clang.
|
||||
|
||||
Introduced here: http://svnweb.freebsd.org/changeset/base/275759
|
||||
|
||||
Index: tools/clang/lib/CodeGen/TargetInfo.cpp
|
||||
===================================================================
|
||||
--- tools/clang/lib/CodeGen/TargetInfo.cpp
|
||||
+++ tools/clang/lib/CodeGen/TargetInfo.cpp
|
||||
@@ -2733,12 +2733,20 @@ llvm::Value *NaClX86_64ABIInfo::EmitVAArg(llvm::Va
|
||||
|
||||
|
||||
// PowerPC-32
|
||||
-
|
||||
namespace {
|
||||
-class PPC32TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
|
||||
+/// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ELF (SVR4) ABI information.
|
||||
+class PPC32_SVR4_ABIInfo : public DefaultABIInfo {
|
||||
public:
|
||||
- PPC32TargetCodeGenInfo(CodeGenTypes &CGT) : DefaultTargetCodeGenInfo(CGT) {}
|
||||
+ PPC32_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
|
||||
|
||||
+ llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
+ CodeGenFunction &CGF) const;
|
||||
+};
|
||||
+
|
||||
+class PPC32TargetCodeGenInfo : public TargetCodeGenInfo {
|
||||
+public:
|
||||
+ PPC32TargetCodeGenInfo(CodeGenTypes &CGT) : TargetCodeGenInfo(new PPC32_SVR4_ABIInfo(CGT)) {}
|
||||
+
|
||||
int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const {
|
||||
// This is recovered from gcc output.
|
||||
return 1; // r1 is the dedicated stack pointer
|
||||
@@ -2750,6 +2758,96 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
+llvm::Value *PPC32_SVR4_ABIInfo::EmitVAArg(llvm::Value *VAListAddr,
|
||||
+ QualType Ty,
|
||||
+ CodeGenFunction &CGF) const {
|
||||
+ if (const ComplexType *CTy = Ty->getAs<ComplexType>()) {
|
||||
+ // TODO: Implement this. For now ignore.
|
||||
+ (void)CTy;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ bool isI64 = Ty->isIntegerType() && getContext().getTypeSize(Ty) == 64;
|
||||
+ bool isInt = Ty->isIntegerType() || Ty->isPointerType() || Ty->isAggregateType();
|
||||
+ llvm::Type *CharPtr = CGF.Int8PtrTy;
|
||||
+ llvm::Type *CharPtrPtr = CGF.Int8PtrPtrTy;
|
||||
+
|
||||
+ CGBuilderTy &Builder = CGF.Builder;
|
||||
+ llvm::Value *GPRPtr = Builder.CreateBitCast(VAListAddr, CharPtr, "gprptr");
|
||||
+ llvm::Value *GPRPtrAsInt = Builder.CreatePtrToInt(GPRPtr, CGF.Int32Ty);
|
||||
+ llvm::Value *FPRPtrAsInt = Builder.CreateAdd(GPRPtrAsInt, Builder.getInt32(1));
|
||||
+ llvm::Value *FPRPtr = Builder.CreateIntToPtr(FPRPtrAsInt, CharPtr);
|
||||
+ llvm::Value *OverflowAreaPtrAsInt = Builder.CreateAdd(FPRPtrAsInt, Builder.getInt32(3));
|
||||
+ llvm::Value *OverflowAreaPtr = Builder.CreateIntToPtr(OverflowAreaPtrAsInt, CharPtrPtr);
|
||||
+ llvm::Value *RegsaveAreaPtrAsInt = Builder.CreateAdd(OverflowAreaPtrAsInt, Builder.getInt32(4));
|
||||
+ llvm::Value *RegsaveAreaPtr = Builder.CreateIntToPtr(RegsaveAreaPtrAsInt, CharPtrPtr);
|
||||
+ llvm::Value *GPR = Builder.CreateLoad(GPRPtr, false, "gpr");
|
||||
+ // Align GPR when TY is i64.
|
||||
+ if (isI64) {
|
||||
+ llvm::Value *GPRAnd = Builder.CreateAnd(GPR, Builder.getInt8(1));
|
||||
+ llvm::Value *CC64 = Builder.CreateICmpEQ(GPRAnd, Builder.getInt8(1));
|
||||
+ llvm::Value *GPRPlusOne = Builder.CreateAdd(GPR, Builder.getInt8(1));
|
||||
+ GPR = Builder.CreateSelect(CC64, GPRPlusOne, GPR);
|
||||
+ }
|
||||
+ llvm::Value *FPR = Builder.CreateLoad(FPRPtr, false, "fpr");
|
||||
+ llvm::Value *OverflowArea = Builder.CreateLoad(OverflowAreaPtr, false, "overflow_area");
|
||||
+ llvm::Value *OverflowAreaAsInt = Builder.CreatePtrToInt(OverflowArea, CGF.Int32Ty);
|
||||
+ llvm::Value *RegsaveArea = Builder.CreateLoad(RegsaveAreaPtr, false, "regsave_area");
|
||||
+ llvm::Value *RegsaveAreaAsInt = Builder.CreatePtrToInt(RegsaveArea, CGF.Int32Ty);
|
||||
+
|
||||
+ llvm::Value *CC = Builder.CreateICmpULT(isInt ? GPR : FPR,
|
||||
+ Builder.getInt8(8), "cond");
|
||||
+
|
||||
+ llvm::Value *RegConstant = Builder.CreateMul(isInt ? GPR : FPR,
|
||||
+ Builder.getInt8(isInt ? 4 : 8));
|
||||
+
|
||||
+ llvm::Value *OurReg = Builder.CreateAdd(RegsaveAreaAsInt, Builder.CreateSExt(RegConstant, CGF.Int32Ty));
|
||||
+
|
||||
+ if (Ty->isFloatingType())
|
||||
+ OurReg = Builder.CreateAdd(OurReg, Builder.getInt32(32));
|
||||
+
|
||||
+ llvm::BasicBlock *UsingRegs = CGF.createBasicBlock("using_regs");
|
||||
+ llvm::BasicBlock *UsingOverflow = CGF.createBasicBlock("using_overflow");
|
||||
+ llvm::BasicBlock *Cont = CGF.createBasicBlock("cont");
|
||||
+
|
||||
+ Builder.CreateCondBr(CC, UsingRegs, UsingOverflow);
|
||||
+
|
||||
+ CGF.EmitBlock(UsingRegs);
|
||||
+
|
||||
+ llvm::Type *PTy = llvm::PointerType::getUnqual(CGF.ConvertType(Ty));
|
||||
+ llvm::Value *Result1 = Builder.CreateIntToPtr(OurReg, PTy);
|
||||
+ // Increase the GPR/FPR indexes.
|
||||
+ if (isInt) {
|
||||
+ GPR = Builder.CreateAdd(GPR, Builder.getInt8(isI64 ? 2 : 1));
|
||||
+ Builder.CreateStore(GPR, GPRPtr);
|
||||
+ } else {
|
||||
+ FPR = Builder.CreateAdd(FPR, Builder.getInt8(1));
|
||||
+ Builder.CreateStore(FPR, FPRPtr);
|
||||
+ }
|
||||
+ CGF.EmitBranch(Cont);
|
||||
+
|
||||
+ CGF.EmitBlock(UsingOverflow);
|
||||
+
|
||||
+ // Increase the overflow area.
|
||||
+ llvm::Value *Result2 = Builder.CreateIntToPtr(OverflowAreaAsInt, PTy);
|
||||
+ OverflowAreaAsInt = Builder.CreateAdd(OverflowAreaAsInt, Builder.getInt32(isInt ? 4 : 8));
|
||||
+ Builder.CreateStore(Builder.CreateIntToPtr(OverflowAreaAsInt, CharPtr), OverflowAreaPtr);
|
||||
+ CGF.EmitBranch(Cont);
|
||||
+
|
||||
+ CGF.EmitBlock(Cont);
|
||||
+
|
||||
+ llvm::PHINode *Result = CGF.Builder.CreatePHI(PTy, 2, "vaarg.addr");
|
||||
+ Result->addIncoming(Result1, UsingRegs);
|
||||
+ Result->addIncoming(Result2, UsingOverflow);
|
||||
+
|
||||
+ if (Ty->isAggregateType()) {
|
||||
+ llvm::Value *AGGPtr = Builder.CreateBitCast(Result, CharPtrPtr, "aggrptr") ;
|
||||
+ return Builder.CreateLoad(AGGPtr, false, "aggr");
|
||||
+ }
|
||||
+
|
||||
+ return Result;
|
||||
+}
|
||||
+
|
||||
bool
|
||||
PPC32TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
|
||||
llvm::Value *Address) const {
|
||||
Index: tools/clang/test/CodeGen/ppc64-varargs-struct.c
|
||||
===================================================================
|
||||
--- tools/clang/test/CodeGen/ppc64-varargs-struct.c
|
||||
+++ tools/clang/test/CodeGen/ppc64-varargs-struct.c
|
||||
@@ -1,30 +0,0 @@
|
||||
-// REQUIRES: ppc64-registered-target
|
||||
-// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
|
||||
-
|
||||
-#include <stdarg.h>
|
||||
-
|
||||
-struct x {
|
||||
- long a;
|
||||
- double b;
|
||||
-};
|
||||
-
|
||||
-void testva (int n, ...)
|
||||
-{
|
||||
- va_list ap;
|
||||
-
|
||||
- struct x t = va_arg (ap, struct x);
|
||||
-// CHECK: bitcast i8* %{{[a-z.0-9]*}} to %struct.x*
|
||||
-// CHECK: bitcast %struct.x* %t to i8*
|
||||
-// CHECK: bitcast %struct.x* %{{[0-9]+}} to i8*
|
||||
-// CHECK: call void @llvm.memcpy
|
||||
-
|
||||
- int v = va_arg (ap, int);
|
||||
-// CHECK: ptrtoint i8* %{{[a-z.0-9]*}} to i64
|
||||
-// CHECK: add i64 %{{[0-9]+}}, 4
|
||||
-// CHECK: inttoptr i64 %{{[0-9]+}} to i8*
|
||||
-// CHECK: bitcast i8* %{{[0-9]+}} to i32*
|
||||
-
|
||||
- __int128_t u = va_arg (ap, __int128_t);
|
||||
-// CHECK: bitcast i8* %{{[a-z.0-9]+}} to i128*
|
||||
-// CHECK-NEXT: load i128* %{{[0-9]+}}
|
||||
-}
|
||||
Index: tools/clang/test/CodeGen/ppc-varargs-struct.c
|
||||
===================================================================
|
||||
--- tools/clang/test/CodeGen/ppc-varargs-struct.c
|
||||
+++ tools/clang/test/CodeGen/ppc-varargs-struct.c
|
||||
@@ -0,0 +1,112 @@
|
||||
+// REQUIRES: ppc64-registered-target
|
||||
+// REQUIRES: asserts
|
||||
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
|
||||
+// RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-PPC
|
||||
+
|
||||
+#include <stdarg.h>
|
||||
+
|
||||
+struct x {
|
||||
+ long a;
|
||||
+ double b;
|
||||
+};
|
||||
+
|
||||
+void testva (int n, ...)
|
||||
+{
|
||||
+ va_list ap;
|
||||
+
|
||||
+ struct x t = va_arg (ap, struct x);
|
||||
+// CHECK: bitcast i8* %{{[a-z.0-9]*}} to %struct.x*
|
||||
+// CHECK: bitcast %struct.x* %t to i8*
|
||||
+// CHECK: bitcast %struct.x* %{{[0-9]+}} to i8*
|
||||
+// CHECK: call void @llvm.memcpy
|
||||
+// CHECK-PPC: [[ARRAYDECAY:%[a-z0-9]+]] = getelementptr inbounds [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
|
||||
+// CHECK-PPC-NEXT: [[GPRPTR:%[a-z0-9]+]] = bitcast %struct.__va_list_tag* [[ARRAYDECAY]] to i8*
|
||||
+// CHECK-PPC-NEXT: [[ZERO:%[0-9]+]] = ptrtoint i8* [[GPRPTR]] to i32
|
||||
+// CHECK-PPC-NEXT: [[ONE:%[0-9]+]] = add i32 [[ZERO]], 1
|
||||
+// CHECK-PPC-NEXT: [[TWO:%[0-9]+]] = inttoptr i32 [[ONE]] to i8*
|
||||
+// CHECK-PPC-NEXT: [[THREE:%[0-9]+]] = add i32 [[ONE]], 3
|
||||
+// CHECK-PPC-NEXT: [[FOUR:%[0-9]+]] = inttoptr i32 [[THREE]] to i8**
|
||||
+// CHECK-PPC-NEXT: [[FIVE:%[0-9]+]] = add i32 [[THREE]], 4
|
||||
+// CHECK-PPC-NEXT: [[SIX:%[0-9]+]] = inttoptr i32 [[FIVE]] to i8**
|
||||
+// CHECK-PPC-NEXT: [[GPR:%[a-z0-9]+]] = load i8* [[GPRPTR]]
|
||||
+// CHECK-PPC-NEXT: [[FPR:%[a-z0-9]+]] = load i8* [[TWO]]
|
||||
+// CHECK-PPC-NEXT: [[OVERFLOW_AREA:%[a-z_0-9]+]] = load i8** [[FOUR]]
|
||||
+// CHECK-PPC-NEXT: [[SEVEN:%[0-9]+]] = ptrtoint i8* [[OVERFLOW_AREA]] to i32
|
||||
+// CHECK-PPC-NEXT: [[REGSAVE_AREA:%[a-z_0-9]+]] = load i8** [[SIX]]
|
||||
+// CHECK-PPC-NEXT: [[EIGHT:%[0-9]+]] = ptrtoint i8* [[REGSAVE_AREA]] to i32
|
||||
+// CHECK-PPC-NEXT: [[COND:%[a-z0-9]+]] = icmp ult i8 [[GPR]], 8
|
||||
+// CHECK-PPC-NEXT: [[NINE:%[0-9]+]] = mul i8 [[GPR]], 4
|
||||
+// CHECK-PPC-NEXT: [[TEN:%[0-9]+]] = sext i8 [[NINE]] to i32
|
||||
+// CHECK-PPC-NEXT: [[ELEVEN:%[0-9]+]] = add i32 [[EIGHT]], [[TEN]]
|
||||
+// CHECK-PPC-NEXT: br i1 [[COND]], label [[USING_REGS:%[a-z_0-9]+]], label [[USING_OVERFLOW:%[a-z_0-9]+]]
|
||||
+//
|
||||
+// CHECK-PPC1:[[USING_REGS]]
|
||||
+// CHECK-PPC: [[TWELVE:%[0-9]+]] = inttoptr i32 [[ELEVEN]] to %struct.x*
|
||||
+// CHECK-PPC-NEXT: [[THIRTEEN:%[0-9]+]] = add i8 [[GPR]], 1
|
||||
+// CHECK-PPC-NEXT: store i8 [[THIRTEEN]], i8* [[GPRPTR]]
|
||||
+// CHECK-PPC-NEXT: br label [[CONT:%[a-z0-9]+]]
|
||||
+//
|
||||
+// CHECK-PPC1:[[USING_OVERFLOW]]
|
||||
+// CHECK-PPC: [[FOURTEEN:%[0-9]+]] = inttoptr i32 [[SEVEN]] to %struct.x*
|
||||
+// CHECK-PPC-NEXT: [[FIFTEEN:%[0-9]+]] = add i32 [[SEVEN]], 4
|
||||
+// CHECK-PPC-NEXT: [[SIXTEEN:%[0-9]+]] = inttoptr i32 [[FIFTEEN]] to i8*
|
||||
+// CHECK-PPC-NEXT: store i8* [[SIXTEEN]], i8** [[FOUR]]
|
||||
+// CHECK-PPC-NEXT: br label [[CONT]]
|
||||
+//
|
||||
+// CHECK-PPC1:[[CONT]]
|
||||
+// CHECK-PPC: [[VAARG_ADDR:%[a-z.0-9]+]] = phi %struct.x* [ [[TWELVE]], [[USING_REGS]] ], [ [[FOURTEEN]], [[USING_OVERFLOW]] ]
|
||||
+// CHECK-PPC-NEXT: [[AGGRPTR:%[a-z0-9]+]] = bitcast %struct.x* [[VAARG_ADDR]] to i8**
|
||||
+// CHECK-PPC-NEXT: [[AGGR:%[a-z0-9]+]] = load i8** [[AGGRPTR]]
|
||||
+// CHECK-PPC-NEXT: [[SEVENTEEN:%[0-9]+]] = bitcast %struct.x* %t to i8*
|
||||
+// CHECK-PPC-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* [[SEVENTEEN]], i8* [[AGGR]], i32 16, i32 8, i1 false)
|
||||
+
|
||||
+ int v = va_arg (ap, int);
|
||||
+// CHECK: ptrtoint i8* %{{[a-z.0-9]*}} to i64
|
||||
+// CHECK: add i64 %{{[0-9]+}}, 4
|
||||
+// CHECK: inttoptr i64 %{{[0-9]+}} to i8*
|
||||
+// CHECK: bitcast i8* %{{[0-9]+}} to i32*
|
||||
+// CHECK-PPC: [[ARRAYDECAY1:%[a-z0-9]+]] = getelementptr inbounds [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
|
||||
+// CHECK-PPC-NEXT: [[GPRPTR1:%[a-z0-9]+]] = bitcast %struct.__va_list_tag* [[ARRAYDECAY1]] to i8*
|
||||
+// CHECK-PPC-NEXT: [[EIGHTEEN:%[0-9]+]] = ptrtoint i8* [[GPRPTR1]] to i32
|
||||
+// CHECK-PPC-NEXT: [[NINETEEN:%[0-9]+]] = add i32 [[EIGHTEEN]], 1
|
||||
+// CHECK-PPC-NEXT: [[TWENTY:%[0-9]+]] = inttoptr i32 [[NINETEEN]] to i8*
|
||||
+// CHECK-PPC-NEXT: [[TWENTYONE:%[0-9]+]] = add i32 [[NINETEEN]], 3
|
||||
+// CHECK-PPC-NEXT: [[TWENTYTWO:%[0-9]+]] = inttoptr i32 [[TWENTYONE]] to i8**
|
||||
+// CHECK-PPC-NEXT: [[TWENTYTHREE:%[0-9]+]] = add i32 [[TWENTYONE]], 4
|
||||
+// CHECK-PPC-NEXT: [[TWENTYFOUR:%[0-9]+]] = inttoptr i32 [[TWENTYTHREE]] to i8**
|
||||
+// CHECK-PPC-NEXT: [[GPR1:%[a-z0-9]+]] = load i8* [[GPRPTR1]]
|
||||
+// CHECK-PPC-NEXT: [[FPR1:%[a-z0-9]+]] = load i8* [[TWENTY]]
|
||||
+// CHECK-PPC-NEXT: [[OVERFLOW_AREA1:%[a-z_0-9]+]] = load i8** [[TWENTYTWO]]
|
||||
+// CHECK-PPC-NEXT: [[TWENTYFIVE:%[0-9]+]] = ptrtoint i8* [[OVERFLOW_AREA1]] to i32
|
||||
+// CHECK-PPC-NEXT: [[REGSAVE_AREA1:%[a-z_0-9]+]] = load i8** [[TWENTYFOUR]]
|
||||
+// CHECK-PPC-NEXT: [[TWENTYSIX:%[0-9]+]] = ptrtoint i8* [[REGSAVE_AREA1]] to i32
|
||||
+// CHECK-PPC-NEXT: [[COND1:%[a-z0-9]+]] = icmp ult i8 [[GPR1]], 8
|
||||
+// CHECK-PPC-NEXT: [[TWENTYSEVEN:%[0-9]+]] = mul i8 [[GPR1]], 4
|
||||
+// CHECK-PPC-NEXT: [[TWENTYEIGHT:%[0-9]+]] = sext i8 [[TWENTYSEVEN]] to i32
|
||||
+// CHECK-PPC-NEXT: [[TWENTYNINE:%[0-9]+]] = add i32 [[TWENTYSIX]], [[TWENTYEIGHT]]
|
||||
+// CHECK-PPC-NEXT: br i1 [[COND1]], label [[USING_REGS1:%[a-z_0-9]+]], label [[USING_OVERFLOW1:%[a-z_0-9]+]]
|
||||
+//
|
||||
+// CHECK-PPC1:[[USING_REGS1]]:
|
||||
+// CHECK-PPC: [[THIRTY:%[0-9]+]] = inttoptr i32 [[TWENTYNINE]] to i32*
|
||||
+// CHECK-PPC-NEXT: [[THIRTYONE:%[0-9]+]] = add i8 [[GPR1]], 1
|
||||
+// CHECK-PPC-NEXT: store i8 [[THIRTYONE]], i8* [[GPRPTR1]]
|
||||
+// CHECK-PPC-NEXT: br label [[CONT1:%[a-z0-9]+]]
|
||||
+//
|
||||
+// CHECK-PPC1:[[USING_OVERFLOW1]]:
|
||||
+// CHECK-PPC: [[THIRTYTWO:%[0-9]+]] = inttoptr i32 [[TWENTYFIVE]] to i32*
|
||||
+// CHECK-PPC-NEXT: [[THIRTYTHREE:%[0-9]+]] = add i32 [[TWENTYFIVE]], 4
|
||||
+// CHECK-PPC-NEXT: [[THIRTYFOUR:%[0-9]+]] = inttoptr i32 [[THIRTYTHREE]] to i8*
|
||||
+// CHECK-PPC-NEXT: store i8* [[THIRTYFOUR]], i8** [[TWENTYTWO]]
|
||||
+// CHECK-PPC-NEXT: br label [[CONT1]]
|
||||
+//
|
||||
+// CHECK-PPC1:[[CONT1]]:
|
||||
+// CHECK-PPC: [[VAARG_ADDR1:%[a-z.0-9]+]] = phi i32* [ [[THIRTY]], [[USING_REGS1]] ], [ [[THIRTYTWO]], [[USING_OVERFLOW1]] ]
|
||||
+// CHECK-PPC-NEXT: [[THIRTYFIVE:%[0-9]+]] = load i32* [[VAARG_ADDR1]]
|
||||
+// CHECK-PPC-NEXT: store i32 [[THIRTYFIVE]], i32* %v, align 4
|
||||
+
|
||||
+#ifdef __powerpc64__
|
||||
+ __int128_t u = va_arg (ap, __int128_t);
|
||||
+#endif
|
||||
+// CHECK: bitcast i8* %{{[a-z.0-9]+}} to i128*
|
||||
+// CHECK-NEXT: load i128* %{{[0-9]+}}
|
||||
+}
|
@ -2733,11 +2733,19 @@ llvm::Value *NaClX86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
|
||||
|
||||
// PowerPC-32
|
||||
|
||||
namespace {
|
||||
class PPC32TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
|
||||
/// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ELF (SVR4) ABI information.
|
||||
class PPC32_SVR4_ABIInfo : public DefaultABIInfo {
|
||||
public:
|
||||
PPC32TargetCodeGenInfo(CodeGenTypes &CGT) : DefaultTargetCodeGenInfo(CGT) {}
|
||||
PPC32_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
|
||||
|
||||
llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const;
|
||||
};
|
||||
|
||||
class PPC32TargetCodeGenInfo : public TargetCodeGenInfo {
|
||||
public:
|
||||
PPC32TargetCodeGenInfo(CodeGenTypes &CGT) : TargetCodeGenInfo(new PPC32_SVR4_ABIInfo(CGT)) {}
|
||||
|
||||
int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const {
|
||||
// This is recovered from gcc output.
|
||||
@ -2750,6 +2758,96 @@ class PPC32TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
|
||||
|
||||
}
|
||||
|
||||
llvm::Value *PPC32_SVR4_ABIInfo::EmitVAArg(llvm::Value *VAListAddr,
|
||||
QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
if (const ComplexType *CTy = Ty->getAs<ComplexType>()) {
|
||||
// TODO: Implement this. For now ignore.
|
||||
(void)CTy;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool isI64 = Ty->isIntegerType() && getContext().getTypeSize(Ty) == 64;
|
||||
bool isInt = Ty->isIntegerType() || Ty->isPointerType() || Ty->isAggregateType();
|
||||
llvm::Type *CharPtr = CGF.Int8PtrTy;
|
||||
llvm::Type *CharPtrPtr = CGF.Int8PtrPtrTy;
|
||||
|
||||
CGBuilderTy &Builder = CGF.Builder;
|
||||
llvm::Value *GPRPtr = Builder.CreateBitCast(VAListAddr, CharPtr, "gprptr");
|
||||
llvm::Value *GPRPtrAsInt = Builder.CreatePtrToInt(GPRPtr, CGF.Int32Ty);
|
||||
llvm::Value *FPRPtrAsInt = Builder.CreateAdd(GPRPtrAsInt, Builder.getInt32(1));
|
||||
llvm::Value *FPRPtr = Builder.CreateIntToPtr(FPRPtrAsInt, CharPtr);
|
||||
llvm::Value *OverflowAreaPtrAsInt = Builder.CreateAdd(FPRPtrAsInt, Builder.getInt32(3));
|
||||
llvm::Value *OverflowAreaPtr = Builder.CreateIntToPtr(OverflowAreaPtrAsInt, CharPtrPtr);
|
||||
llvm::Value *RegsaveAreaPtrAsInt = Builder.CreateAdd(OverflowAreaPtrAsInt, Builder.getInt32(4));
|
||||
llvm::Value *RegsaveAreaPtr = Builder.CreateIntToPtr(RegsaveAreaPtrAsInt, CharPtrPtr);
|
||||
llvm::Value *GPR = Builder.CreateLoad(GPRPtr, false, "gpr");
|
||||
// Align GPR when TY is i64.
|
||||
if (isI64) {
|
||||
llvm::Value *GPRAnd = Builder.CreateAnd(GPR, Builder.getInt8(1));
|
||||
llvm::Value *CC64 = Builder.CreateICmpEQ(GPRAnd, Builder.getInt8(1));
|
||||
llvm::Value *GPRPlusOne = Builder.CreateAdd(GPR, Builder.getInt8(1));
|
||||
GPR = Builder.CreateSelect(CC64, GPRPlusOne, GPR);
|
||||
}
|
||||
llvm::Value *FPR = Builder.CreateLoad(FPRPtr, false, "fpr");
|
||||
llvm::Value *OverflowArea = Builder.CreateLoad(OverflowAreaPtr, false, "overflow_area");
|
||||
llvm::Value *OverflowAreaAsInt = Builder.CreatePtrToInt(OverflowArea, CGF.Int32Ty);
|
||||
llvm::Value *RegsaveArea = Builder.CreateLoad(RegsaveAreaPtr, false, "regsave_area");
|
||||
llvm::Value *RegsaveAreaAsInt = Builder.CreatePtrToInt(RegsaveArea, CGF.Int32Ty);
|
||||
|
||||
llvm::Value *CC = Builder.CreateICmpULT(isInt ? GPR : FPR,
|
||||
Builder.getInt8(8), "cond");
|
||||
|
||||
llvm::Value *RegConstant = Builder.CreateMul(isInt ? GPR : FPR,
|
||||
Builder.getInt8(isInt ? 4 : 8));
|
||||
|
||||
llvm::Value *OurReg = Builder.CreateAdd(RegsaveAreaAsInt, Builder.CreateSExt(RegConstant, CGF.Int32Ty));
|
||||
|
||||
if (Ty->isFloatingType())
|
||||
OurReg = Builder.CreateAdd(OurReg, Builder.getInt32(32));
|
||||
|
||||
llvm::BasicBlock *UsingRegs = CGF.createBasicBlock("using_regs");
|
||||
llvm::BasicBlock *UsingOverflow = CGF.createBasicBlock("using_overflow");
|
||||
llvm::BasicBlock *Cont = CGF.createBasicBlock("cont");
|
||||
|
||||
Builder.CreateCondBr(CC, UsingRegs, UsingOverflow);
|
||||
|
||||
CGF.EmitBlock(UsingRegs);
|
||||
|
||||
llvm::Type *PTy = llvm::PointerType::getUnqual(CGF.ConvertType(Ty));
|
||||
llvm::Value *Result1 = Builder.CreateIntToPtr(OurReg, PTy);
|
||||
// Increase the GPR/FPR indexes.
|
||||
if (isInt) {
|
||||
GPR = Builder.CreateAdd(GPR, Builder.getInt8(isI64 ? 2 : 1));
|
||||
Builder.CreateStore(GPR, GPRPtr);
|
||||
} else {
|
||||
FPR = Builder.CreateAdd(FPR, Builder.getInt8(1));
|
||||
Builder.CreateStore(FPR, FPRPtr);
|
||||
}
|
||||
CGF.EmitBranch(Cont);
|
||||
|
||||
CGF.EmitBlock(UsingOverflow);
|
||||
|
||||
// Increase the overflow area.
|
||||
llvm::Value *Result2 = Builder.CreateIntToPtr(OverflowAreaAsInt, PTy);
|
||||
OverflowAreaAsInt = Builder.CreateAdd(OverflowAreaAsInt, Builder.getInt32(isInt ? 4 : 8));
|
||||
Builder.CreateStore(Builder.CreateIntToPtr(OverflowAreaAsInt, CharPtr), OverflowAreaPtr);
|
||||
CGF.EmitBranch(Cont);
|
||||
|
||||
CGF.EmitBlock(Cont);
|
||||
|
||||
llvm::PHINode *Result = CGF.Builder.CreatePHI(PTy, 2, "vaarg.addr");
|
||||
Result->addIncoming(Result1, UsingRegs);
|
||||
Result->addIncoming(Result2, UsingOverflow);
|
||||
|
||||
if (Ty->isAggregateType()) {
|
||||
llvm::Value *AGGPtr = Builder.CreateBitCast(Result, CharPtrPtr, "aggrptr") ;
|
||||
return Builder.CreateLoad(AGGPtr, false, "aggr");
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool
|
||||
PPC32TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
|
||||
llvm::Value *Address) const {
|
||||
|
@ -120,6 +120,7 @@ iter_new(struct module_qstate* qstate, int id)
|
||||
iq->query_restart_count = 0;
|
||||
iq->referral_count = 0;
|
||||
iq->sent_count = 0;
|
||||
iq->target_count = NULL;
|
||||
iq->wait_priming_stub = 0;
|
||||
iq->refetch_glue = 0;
|
||||
iq->dnssec_expected = 0;
|
||||
@ -445,6 +446,26 @@ handle_cname_response(struct module_qstate* qstate, struct iter_qstate* iq,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** create target count structure for this query */
|
||||
static void
|
||||
target_count_create(struct iter_qstate* iq)
|
||||
{
|
||||
if(!iq->target_count) {
|
||||
iq->target_count = (int*)calloc(2, sizeof(int));
|
||||
/* if calloc fails we simply do not track this number */
|
||||
if(iq->target_count)
|
||||
iq->target_count[0] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
target_count_increase(struct iter_qstate* iq, int num)
|
||||
{
|
||||
target_count_create(iq);
|
||||
if(iq->target_count)
|
||||
iq->target_count[1] += num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a subrequest.
|
||||
* Generate a local request event. Local events are tied to this module, and
|
||||
@ -516,6 +537,10 @@ generate_sub_request(uint8_t* qname, size_t qnamelen, uint16_t qtype,
|
||||
subiq = (struct iter_qstate*)subq->minfo[id];
|
||||
memset(subiq, 0, sizeof(*subiq));
|
||||
subiq->num_target_queries = 0;
|
||||
target_count_create(iq);
|
||||
subiq->target_count = iq->target_count;
|
||||
if(iq->target_count)
|
||||
iq->target_count[0] ++; /* extra reference */
|
||||
subiq->num_current_queries = 0;
|
||||
subiq->depth = iq->depth+1;
|
||||
outbound_list_init(&subiq->outlist);
|
||||
@ -1342,6 +1367,12 @@ query_for_targets(struct module_qstate* qstate, struct iter_qstate* iq,
|
||||
|
||||
if(iq->depth == ie->max_dependency_depth)
|
||||
return 0;
|
||||
if(iq->depth > 0 && iq->target_count &&
|
||||
iq->target_count[1] > MAX_TARGET_COUNT) {
|
||||
verbose(VERB_QUERY, "request has exceeded the maximum "
|
||||
"number of glue fetches %d", iq->target_count[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
iter_mark_cycle_targets(qstate, iq->dp);
|
||||
missing = (int)delegpt_count_missing_targets(iq->dp);
|
||||
@ -1524,6 +1555,7 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
|
||||
return error_response(qstate, id, LDNS_RCODE_SERVFAIL);
|
||||
}
|
||||
iq->num_target_queries += qs;
|
||||
target_count_increase(iq, qs);
|
||||
if(qs != 0) {
|
||||
qstate->ext_state[id] = module_wait_subquery;
|
||||
return 0; /* and wait for them */
|
||||
@ -1533,6 +1565,12 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
|
||||
verbose(VERB_QUERY, "maxdepth and need more nameservers, fail");
|
||||
return error_response_cache(qstate, id, LDNS_RCODE_SERVFAIL);
|
||||
}
|
||||
if(iq->depth > 0 && iq->target_count &&
|
||||
iq->target_count[1] > MAX_TARGET_COUNT) {
|
||||
verbose(VERB_QUERY, "request has exceeded the maximum "
|
||||
"number of glue fetches %d", iq->target_count[1]);
|
||||
return error_response_cache(qstate, id, LDNS_RCODE_SERVFAIL);
|
||||
}
|
||||
/* mark cycle targets for parent-side lookups */
|
||||
iter_mark_pside_cycle_targets(qstate, iq->dp);
|
||||
/* see if we can issue queries to get nameserver addresses */
|
||||
@ -1562,6 +1600,7 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
|
||||
if(query_count != 0) { /* suspend to await results */
|
||||
verbose(VERB_ALGO, "try parent-side glue lookup");
|
||||
iq->num_target_queries += query_count;
|
||||
target_count_increase(iq, query_count);
|
||||
qstate->ext_state[id] = module_wait_subquery;
|
||||
return 0;
|
||||
}
|
||||
@ -1717,6 +1756,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq,
|
||||
return error_response(qstate, id, LDNS_RCODE_SERVFAIL);
|
||||
}
|
||||
iq->num_target_queries += extra;
|
||||
target_count_increase(iq, extra);
|
||||
if(iq->num_target_queries > 0) {
|
||||
/* wait to get all targets, we want to try em */
|
||||
verbose(VERB_ALGO, "wait for all targets for fallback");
|
||||
@ -1757,6 +1797,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq,
|
||||
/* errors ignored, these targets are not strictly necessary for
|
||||
* this result, we do not have to reply with SERVFAIL */
|
||||
iq->num_target_queries += extra;
|
||||
target_count_increase(iq, extra);
|
||||
}
|
||||
|
||||
/* Add the current set of unused targets to our queue. */
|
||||
@ -1802,6 +1843,7 @@ processQueryTargets(struct module_qstate* qstate, struct iter_qstate* iq,
|
||||
return 1;
|
||||
}
|
||||
iq->num_target_queries += qs;
|
||||
target_count_increase(iq, qs);
|
||||
}
|
||||
/* Since a target query might have been made, we
|
||||
* need to check again. */
|
||||
@ -2894,6 +2936,8 @@ iter_clear(struct module_qstate* qstate, int id)
|
||||
iq = (struct iter_qstate*)qstate->minfo[id];
|
||||
if(iq) {
|
||||
outbound_list_clear(&iq->outlist);
|
||||
if(iq->target_count && --iq->target_count[0] == 0)
|
||||
free(iq->target_count);
|
||||
iq->num_current_queries = 0;
|
||||
}
|
||||
qstate->minfo[id] = NULL;
|
||||
|
@ -52,6 +52,8 @@ struct iter_donotq;
|
||||
struct iter_prep_list;
|
||||
struct iter_priv;
|
||||
|
||||
/** max number of targets spawned for a query and its subqueries */
|
||||
#define MAX_TARGET_COUNT 32
|
||||
/** max number of query restarts. Determines max number of CNAME chain. */
|
||||
#define MAX_RESTART_COUNT 8
|
||||
/** max number of referrals. Makes sure resolver does not run away */
|
||||
@ -254,6 +256,10 @@ struct iter_qstate {
|
||||
|
||||
/** number of queries fired off */
|
||||
int sent_count;
|
||||
|
||||
/** number of target queries spawned in [1], for this query and its
|
||||
* subqueries, the malloced-array is shared, [0] refcount. */
|
||||
int* target_count;
|
||||
|
||||
/**
|
||||
* The query must store NS records from referrals as parentside RRs
|
||||
|
@ -361,7 +361,7 @@ MTREES+= mtree/BSD.debug.dist /usr/lib
|
||||
MTREES+= mtree/BSD.groff.dist /usr
|
||||
.endif
|
||||
.if ${MK_TESTS} != "no"
|
||||
MTREES+= mtree/BSD.tests.dist /usr
|
||||
MTREES+= mtree/BSD.tests.dist ${TESTSBASE}
|
||||
.endif
|
||||
.if ${MK_SENDMAIL} != "no"
|
||||
MTREES+= mtree/BSD.sendmail.dist /
|
||||
@ -377,6 +377,7 @@ distrib-dirs: ${MTREES:N/*}
|
||||
shift; \
|
||||
d=${DESTDIR}$$1; \
|
||||
shift; \
|
||||
test -d $$d || mkdir -p $$d; \
|
||||
${ECHO} ${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} \
|
||||
-f $$m -p $$d; \
|
||||
${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
|
||||
@ -390,6 +391,7 @@ distrib-dirs: ${MTREES:N/*}
|
||||
test "$$d" == "/" && d=""; \
|
||||
d=${DISTBASE}$$d; \
|
||||
shift; \
|
||||
test -d $$d || mkdir -p $$d; \
|
||||
${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K uname,gname | " \
|
||||
"sed s#^\.#.$$d# | ${METALOG.add}" ; \
|
||||
${MTREE_CMD:N-W} -C -f $$m -K uname,gname | sed s#^\.#.$$d# | \
|
||||
|
@ -1017,7 +1017,23 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x056e";
|
||||
match "product" "(0x200c|0x4002|0x4005|0x400b|0x4010)";
|
||||
match "product" "(0x200c|0x4002|0x4005)";
|
||||
action "kldload -n if_aue";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x056e";
|
||||
match "product" "0x4008";
|
||||
action "kldload -n if_urtwn";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x056e";
|
||||
match "product" "(0x400b|0x4010)";
|
||||
action "kldload -n if_aue";
|
||||
};
|
||||
|
||||
@ -1177,7 +1193,7 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x05c6";
|
||||
match "product" "(0x1000|0x6000|0x6613|0x9000|0x9204|0x9205)";
|
||||
match "product" "(0x1000|0x6000|0x6500|0x6613|0x9000|0x9204|0x9205)";
|
||||
action "kldload -n u3g";
|
||||
};
|
||||
|
||||
@ -2545,7 +2561,7 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0bda";
|
||||
match "product" "(0x8176|0x8176|0x8177|0x8178|0x8179|0x817a|0x817b|0x817c|0x817d|0x817e)";
|
||||
match "product" "(0x8176|0x8176|0x8177|0x8178|0x8179|0x817a|0x817b|0x817c|0x817d|0x817e|0x817f)";
|
||||
action "kldload -n if_urtwn";
|
||||
};
|
||||
|
||||
@ -3617,7 +3633,7 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x12d1";
|
||||
match "product" "(0x1001|0x1003|0x1004|0x1401|0x1402|0x1403|0x1404|0x1405|0x1406|0x1407|0x1408|0x1409|0x140a|0x140b|0x140c|0x140d|0x140e|0x140f|0x1410|0x1411|0x1412|0x1413|0x1414|0x1415|0x1416|0x1417|0x1418|0x1419|0x141a|0x141b|0x141c|0x141d|0x141e|0x141f|0x1420|0x1421|0x1422|0x1423|0x1424|0x1425|0x1426|0x1427|0x1428|0x1429|0x142a|0x142b|0x142c|0x142d|0x142e|0x142f|0x1430|0x1431|0x1432|0x1433|0x1434|0x1435|0x1436|0x1437|0x1438|0x1439|0x143a|0x143b|0x143c|0x143d|0x143e|0x143f|0x1446|0x1464|0x1465|0x14ac|0x14c9|0x14d1|0x14fe|0x1505|0x1506|0x1520|0x1521)";
|
||||
match "product" "(0x1001|0x1003|0x1004|0x1401|0x1402|0x1403|0x1404|0x1405|0x1406|0x1407|0x1408|0x1409|0x140a|0x140b|0x140c|0x140d|0x140e|0x140f|0x1410|0x1411|0x1412|0x1413|0x1414|0x1415|0x1416|0x1417|0x1418|0x1419|0x141a|0x141b|0x141c|0x141d|0x141e|0x141f|0x1420|0x1421|0x1422|0x1423|0x1424|0x1425|0x1426|0x1427|0x1428|0x1429|0x142a|0x142b|0x142c|0x142d|0x142e|0x142f|0x1430|0x1431|0x1432|0x1433|0x1434|0x1435|0x1436|0x1437|0x1438|0x1439|0x143a|0x143b|0x143c|0x143d|0x143e|0x143f|0x1446|0x1464|0x1465|0x14ac|0x14c9|0x14cf|0x14d1|0x14fe|0x1505|0x1506|0x1520|0x1521|0x1526)";
|
||||
action "kldload -n u3g";
|
||||
};
|
||||
|
||||
@ -4489,7 +4505,15 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x19d2";
|
||||
match "product" "(0x0001|0x0002|0x0003|0x0004|0x0005|0x0006|0x0007|0x0008|0x0009|0x000a|0x000b|0x000c|0x000d|0x000e|0x000f|0x0010|0x0011|0x0012|0x0013|0x0014|0x0015|0x0016|0x0017|0x0018|0x0019|0x0020|0x0021|0x0022|0x0023|0x0024|0x0025|0x0026|0x0027|0x0028|0x0029|0x0030|0x0031|0x0032|0x0033|0x0037|0x0039|0x0042|0x0043|0x0048|0x0049|0x0051|0x0052|0x0053|0x0054|0x0055|0x0057|0x0058|0x0059|0x0060|0x0061|0x0062|0x0063|0x0064|0x0066|0x0069|0x0070|0x0073|0x0076|0x0078|0x0082|0x0086|0x0117|0x1179|0x2000|0x2002|0x2003|0xfff1|0xfff5|0xfffe)";
|
||||
match "product" "(0x0001|0x0002|0x0003|0x0004|0x0005|0x0006|0x0007|0x0008|0x0009|0x000a|0x000b|0x000c|0x000d|0x000e|0x000f|0x0010|0x0011|0x0012|0x0013|0x0014|0x0015|0x0016|0x0017|0x0018|0x0019|0x0020|0x0021|0x0022|0x0023|0x0024|0x0025|0x0026|0x0027|0x0028|0x0029|0x0030|0x0031|0x0032|0x0033|0x0037|0x0039|0x0042|0x0043|0x0048|0x0049|0x0051|0x0052|0x0053|0x0054|0x0055|0x0057|0x0058|0x0059|0x0060|0x0061|0x0062|0x0063|0x0064|0x0066|0x0069|0x0070|0x0073|0x0076|0x0078|0x0082|0x0086|0x0117|0x1179|0x1181|0x1514|0x1516|0x2000|0x2002|0x2003|0xffdd|0xffde|0xfff1|0xfff5|0xfffe)";
|
||||
action "kldload -n u3g";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x19f5";
|
||||
match "product" "0x9909";
|
||||
action "kldload -n u3g";
|
||||
};
|
||||
|
||||
@ -4609,7 +4633,7 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x1cf1";
|
||||
match "product" "(0x0001|0x0004|0x0022)";
|
||||
match "product" "(0x0001|0x0004|0x001c|0x0022)";
|
||||
action "kldload -n uftdi";
|
||||
};
|
||||
|
||||
@ -4697,7 +4721,7 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x2001";
|
||||
match "product" "(0x3307|0x3308|0x3309|0x330a|0x330d|0x330f)";
|
||||
match "product" "(0x3307|0x3308|0x3309|0x330a|0x330d|0x330f|0x3310)";
|
||||
action "kldload -n if_urtwn";
|
||||
};
|
||||
|
||||
@ -4897,7 +4921,23 @@ nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x20f4";
|
||||
match "product" "(0x624d|0x648b)";
|
||||
match "product" "0x624d";
|
||||
action "kldload -n if_urtwn";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x20f4";
|
||||
match "product" "0x646b";
|
||||
action "kldload -n if_rsu";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x20f4";
|
||||
match "product" "0x648b";
|
||||
action "kldload -n if_urtwn";
|
||||
};
|
||||
|
||||
@ -5291,6 +5331,16 @@ nomatch 32 {
|
||||
action "kldload -n if_ipheth";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x0830";
|
||||
match "intclass" "0x02";
|
||||
match "intsubclass" "0x02";
|
||||
match "intprotocol" "0xff";
|
||||
action "kldload -n if_urndis";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -5301,6 +5351,16 @@ nomatch 32 {
|
||||
action "kldload -n ng_ubt";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "vendor" "0x12d1";
|
||||
match "intclass" "0x02";
|
||||
match "intsubclass" "0x02";
|
||||
match "intprotocol" "0xff";
|
||||
action "kldload -n umodem";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -5349,15 +5409,6 @@ nomatch 32 {
|
||||
action "kldload -n umodem";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
match "intclass" "0x02";
|
||||
match "intsubclass" "0x02";
|
||||
match "intprotocol" "0xff";
|
||||
action "kldload -n umodem";
|
||||
};
|
||||
|
||||
nomatch 32 {
|
||||
match "bus" "uhub[0-9]+";
|
||||
match "mode" "host";
|
||||
@ -5501,5 +5552,5 @@ nomatch 32 {
|
||||
action "kldload -n umass";
|
||||
};
|
||||
|
||||
# 2643 USB entries processed
|
||||
# 2658 USB entries processed
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user