2 #------------------------------------------------------------------------------
3 # $File: freebsd,v 1.7 2009/09/19 16:28:09 christos Exp $
4 # freebsd: file(1) magic for FreeBSD objects
6 # All new-style FreeBSD magic numbers are in host byte order (i.e.,
7 # little-endian on x86).
9 # XXX - this comes from the file "freebsd" in a recent FreeBSD version of
10 # "file"; it, and the NetBSD stuff in "netbsd", appear to use different
11 # schemes for distinguishing between executable images, shared libraries,
16 # Regardless of whether it's pure, demand-paged, or none of the
19 # if the entry point is < 4096, then it's a shared library if
20 # the "has run-time loader information" bit is set, and is
21 # position-independent if the "is position-independent" bit
24 # if the entry point is >= 4096 (or >4095, same thing), then it's
25 # an executable, and is dynamically-linked if the "has run-time
26 # loader information" bit is set.
28 # On x86, NetBSD says:
30 # If it's neither pure nor demand-paged:
32 # if it has the "has run-time loader information" bit set, it's
33 # a dynamically-linked executable;
35 # if it doesn't have that bit set, then:
37 # if it has the "is position-independent" bit set, it's
38 # position-independent;
40 # if the entry point is non-zero, it's an executable, otherwise
41 # it's an object file.
45 # if it has the "has run-time loader information" bit set, it's
46 # a dynamically-linked executable, otherwise it's just an
49 # If it's demand-paged:
51 # if it has the "has run-time loader information" bit set,
54 # if the entry point is < 4096, it's a shared library;
56 # if the entry point is = 4096 or > 4096 (i.e., >= 4096),
57 # it's a dynamically-linked executable);
59 # if it doesn't have the "has run-time loader information" bit
60 # set, then it's just an executable.
62 # (On non-x86, NetBSD does much the same thing, except that it uses
63 # 8192 on 68K - except for "68k4k", which is presumably "68K with 4K
64 # pages - SPARC, and MIPS, presumably because Sun-3's and Sun-4's
65 # had 8K pages; dunno about MIPS.)
67 # I suspect the two will differ only in perverse and uninteresting cases
68 # ("shared" libraries that aren't demand-paged and whose pages probably
69 # won't actually be shared, executables with entry points <4096).
71 # I leave it to those more familiar with FreeBSD and NetBSD to figure out
72 # what the right answer is (although using ">4095", FreeBSD-style, is
73 # probably better than separately checking for "=4096" and ">4096",
74 # NetBSD-style). (The old "netbsd" file analyzed FreeBSD demand paged
75 # executables using the NetBSD technique.)
77 0 lelong&0377777777 041400407 FreeBSD/i386
79 >>3 byte&0xC0 &0x80 shared library
80 >>3 byte&0xC0 0x40 PIC object
81 >>3 byte&0xC0 0x00 object
83 >>3 byte&0x80 0x80 dynamically linked executable
84 >>3 byte&0x80 0x00 executable
85 >16 lelong >0 not stripped
87 0 lelong&0377777777 041400410 FreeBSD/i386 pure
89 >>3 byte&0xC0 &0x80 shared library
90 >>3 byte&0xC0 0x40 PIC object
91 >>3 byte&0xC0 0x00 object
93 >>3 byte&0x80 0x80 dynamically linked executable
94 >>3 byte&0x80 0x00 executable
95 >16 lelong >0 not stripped
97 0 lelong&0377777777 041400413 FreeBSD/i386 demand paged
99 >>3 byte&0xC0 &0x80 shared library
100 >>3 byte&0xC0 0x40 PIC object
101 >>3 byte&0xC0 0x00 object
103 >>3 byte&0x80 0x80 dynamically linked executable
104 >>3 byte&0x80 0x00 executable
105 >16 lelong >0 not stripped
107 0 lelong&0377777777 041400314 FreeBSD/i386 compact demand paged
109 >>3 byte&0xC0 &0x80 shared library
110 >>3 byte&0xC0 0x40 PIC object
111 >>3 byte&0xC0 0x00 object
113 >>3 byte&0x80 0x80 dynamically linked executable
114 >>3 byte&0x80 0x00 executable
115 >16 lelong >0 not stripped
117 # XXX gross hack to identify core files
118 # cores start with a struct tss; we take advantage of the following:
119 # byte 7: highest byte of the kernel stack pointer, always 0xfe
120 # 8/9: kernel (ring 0) ss value, always 0x0010
121 # 10 - 27: ring 1 and 2 ss/esp, unused, thus always 0
122 # 28: low order byte of the current PTD entry, always 0 since the
123 # PTD is page-aligned
125 7 string \357\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 FreeBSD/i386 a.out core file
126 >1039 string >\0 from '%s'
128 # /var/run/ld.so.hints
129 # What are you laughing about?
130 0 lelong 011421044151 ld.so hints file (Little Endian
131 >4 lelong >0 \b, version %d)
133 0 belong 011421044151 ld.so hints file (Big Endian
134 >4 belong >0 \b, version %d)
138 # Files generated by FreeBSD scrshot(1)/vidcontrol(1) utilities
140 0 string SCRSHOT_ scrshot(1) screenshot,
141 >8 byte x version %d,
142 >9 byte 2 %d bytes in header,
143 >>10 byte x %d chars wide by
144 >>11 byte x %d chars high