source: trunk/src/kmk/kmkbuiltin/kDepObj.c@ 3324

Last change on this file since 3324 was 3324, checked in by bird, 5 years ago

kDepObj: Added code for parsing /ZH:SHA_256 as produced by 14.16.27023.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 42.1 KB
Line 
1/* $Id: kDepObj.c 3324 2020-04-17 01:14:39Z bird $ */
2/** @file
3 * kDepObj - Extract dependency information from an object file.
4 */
5
6/*
7 * Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
8 *
9 * This file is part of kBuild.
10 *
11 * kBuild is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * kBuild is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild. If not, see <http://www.gnu.org/licenses/>
23 *
24 */
25
26/*******************************************************************************
27* Header Files *
28*******************************************************************************/
29#define MSCFAKES_NO_WINDOWS_H
30#include <stdio.h>
31#include <stdlib.h>
32#include <stddef.h>
33#include <string.h>
34#include <errno.h>
35#include <ctype.h>
36#include <stdarg.h>
37#if !defined(_MSC_VER)
38# include <unistd.h>
39#else
40# include <io.h>
41typedef intptr_t ssize_t;
42#endif
43#include "k/kDefs.h"
44#include "k/kTypes.h"
45#include "k/kLdrFmts/pe.h"
46#ifdef HAVE_CONFIG_H
47# include "config.h"
48#endif
49#include "kDep.h"
50#include "err.h"
51#include "kmkbuiltin.h"
52
53
54/*******************************************************************************
55* Defined Constants And Macros *
56*******************************************************************************/
57#if 0
58# define dprintf(a) printf a
59# define dump(pb, cb, offBase) depHexDump(pb,cb,offBase)
60# define WITH_DPRINTF
61#else
62# define dprintf(a) do {} while (0)
63# define dump(pb, cb, offBase) do {} while (0)
64# undef WITH_DPRINTF
65#endif
66
67/** @name OMF defines
68 * @{ */
69#define KDEPOMF_THEADR 0x80
70#define KDEPOMF_LHEADR 0x82
71#define KDEPOMF_COMENT 0x88
72#define KDEPOMF_CMTCLS_DEPENDENCY 0xe9
73#define KDEPOMF_CMTCLS_DBGTYPE 0xa1
74#define KDEPOMF_LINNUM 0x94
75#define KDEPOMF_LINNUM32 0x95
76/** @} */
77
78
79/*******************************************************************************
80* Structures and Typedefs *
81*******************************************************************************/
82/** @name OMF Structures
83 * @{ */
84#pragma pack(1)
85/** OMF record header. */
86typedef struct KDEPOMFHDR
87{
88 /** The record type. */
89 KU8 bType;
90 /** The size of the record, excluding this header. */
91 KU16 cbRec;
92} KDEPOMFHDR;
93typedef KDEPOMFHDR *PKDEPOMFHDR;
94typedef const KDEPOMFHDR *PCKDEPOMFHDR;
95
96/** OMF string. */
97typedef struct KDEPOMFSTR
98{
99 KU8 cch;
100 char ach[1];
101} KDEPOMFSTR;
102typedef KDEPOMFSTR *PKDEPOMFSTR;
103typedef const KDEPOMFSTR *PCKDEPOMFSTR;
104
105/** THEADR/LHEADR. */
106typedef struct KDEPOMFTHEADR
107{
108 KDEPOMFHDR Hdr;
109 KDEPOMFSTR Name;
110} KDEPOMFTHEADR;
111typedef KDEPOMFTHEADR *PKDEPOMFTHEADR;
112typedef const KDEPOMFTHEADR *PCKDEPOMFTHEADR;
113
114/** Dependency File. */
115typedef struct KDEPOMFDEPFILE
116{
117 KDEPOMFHDR Hdr;
118 KU8 fType;
119 KU8 bClass;
120 KU16 wDosTime;
121 KU16 wDosDate;
122 KDEPOMFSTR Name;
123} KDEPOMFDEPFILE;
124typedef KDEPOMFDEPFILE *PKDEPOMFDEPFILE;
125typedef const KDEPOMFDEPFILE *PCKDEPOMFDEPFILE;
126
127#pragma pack()
128/** @} */
129
130
131/** @name COFF Structures
132 * @{ */
133#pragma pack(1)
134
135typedef struct KDEPCVSYMHDR
136{
137 /** The record size minus the size field. */
138 KU16 cb;
139 /** The record type. */
140 KU16 uType;
141} KDEPCVSYMHDR;
142typedef KDEPCVSYMHDR *PKDEPCVSYMHDR;
143typedef const KDEPCVSYMHDR *PCKDEPCVSYMHDR;
144
145/** @name Selection of KDEPCVSYMHDR::uType values.
146 * @{ */
147#define K_CV8_S_MSTOOL KU16_C(0x1116)
148/** @} */
149
150typedef struct KDEPCV8SYMHDR
151{
152 /** The record type. */
153 KU32 uType;
154 /** The record size minus the size field. */
155 KU32 cb;
156} KDEPCV8SYMHDR;
157typedef KDEPCV8SYMHDR *PKDEPCV8SYMHDR;
158typedef const KDEPCV8SYMHDR *PCKDEPCV8SYMHDR;
159
160/** @name Known KDEPCV8SYMHDR::uType Values.
161 * @{ */
162#define K_CV8_SYMBOL_INFO KU32_C(0x000000f1)
163#define K_CV8_LINE_NUMBERS KU32_C(0x000000f2)
164#define K_CV8_STRING_TABLE KU32_C(0x000000f3)
165#define K_CV8_SOURCE_FILES KU32_C(0x000000f4)
166#define K_CV8_COMDAT_XXXXX KU32_C(0x000000f5) /**< no idea about the format... */
167/** @} */
168
169#pragma pack()
170/** @} */
171
172/**
173 * Globals.
174 */
175typedef struct KDEPOBJGLOBALS
176{
177 /** The command execution context. */
178 PKMKBUILTINCTX pCtx;
179 /** Core instance. */
180 DEPGLOBALS Core;
181 /** The file. */
182 const char *pszFile;
183} KDEPOBJGLOBALS;
184/** Pointer to kDepObj globals. */
185typedef KDEPOBJGLOBALS *PKDEPOBJGLOBALS;
186
187
188
189/**
190 * Prints an error message.
191 *
192 * @returns rc.
193 * @param pThis kObjDep instance data.
194 * @param rc The return code, for making one line return statements.
195 * @param pszFormat The message format string.
196 * @param ... Format arguments.
197 * @todo Promote this to kDep.c.
198 */
199static int kDepErr(PKDEPOBJGLOBALS pThis, int rc, const char *pszFormat, ...)
200{
201 char szMsg[2048];
202 va_list va;
203 va_start(va, pszFormat);
204 vsnprintf(szMsg, sizeof(szMsg) - 1, pszFormat, va);
205 va_end(va);
206 szMsg[sizeof(szMsg) - 1] = '\0';
207
208 if (pThis->pszFile)
209 warnx(pThis->pCtx, "%s: error: %s", pThis->pszFile, szMsg);
210 else
211 errx(pThis->pCtx, rc, "%s", szMsg);
212 return rc;
213}
214
215
216/**
217 * Gets an index from the data.
218 *
219 * @returns The index, KU16_MAX on buffer underflow.
220 * @param puData The current data stream position (in/out).
221 * @param pcbLeft Number of bytes left (in/out).
222 */
223static KU16 kDepObjOMFGetIndex(KPCUINT *puData, KU16 *pcbLeft)
224{
225 KU16 u16;
226
227 if (*pcbLeft >= 1 && *pcbLeft != KU16_MAX)
228 {
229 *pcbLeft -= 1;
230 u16 = *puData->pb++;
231 if (u16 & KU16_C(0x80))
232 {
233 if (*pcbLeft >= 1)
234 {
235 *pcbLeft -= 1;
236 u16 = ((u16 & KU16_C(0x7f)) << 8) | *puData->pb++;
237 }
238 else
239 u16 = KU16_MAX;
240 }
241 }
242 else
243 u16 = KU16_MAX;
244 return u16;
245}
246
247
248/**
249 * Parses the OMF file.
250 *
251 * @returns 0 on success, 1 on failure, 2 if no dependencies was found.
252 * @param pThis The kDepObj instance data.
253 * @param pbFile The start of the file.
254 * @param cbFile The file size.
255 */
256int kDepObjOMFParse(PKDEPOBJGLOBALS pThis, const KU8 *pbFile, KSIZE cbFile)
257{
258 PCKDEPOMFHDR pHdr = (PCKDEPOMFHDR)pbFile;
259 KSIZE cbLeft = cbFile;
260 char uDbgType = 0; /* H or C */
261 KU8 uDbgVer = KU8_MAX;
262 KU32 iSrc = 0;
263 KU32 iMaybeSrc = 0;
264 KU8 uLinNumType = KU8_MAX;
265 KU16 cLinNums = 0;
266 KU32 cLinFiles = 0;
267 KU32 iLinFile = 0;
268
269 /*
270 * Iterate thru the records until we hit the end or an invalid one.
271 */
272 while ( cbLeft >= sizeof(*pHdr)
273 && cbLeft >= pHdr->cbRec + sizeof(*pHdr))
274 {
275 KPCUINT uData;
276 uData.pv = pHdr + 1;
277
278 /* process selected record types. */
279 dprintf(("%#07" KUPTR_PRI ": %#04x %#05x\n", (const KU8*)pHdr - pbFile, pHdr->bType, pHdr->cbRec));
280 switch (pHdr->bType)
281 {
282 /*
283 * The T/L Header contains the source name. When emitting CodeView 4
284 * and earlier (like masm and watcom does), all includes used by the
285 * line number tables have their own THEADR record.
286 */
287 case KDEPOMF_THEADR:
288 case KDEPOMF_LHEADR:
289 {
290 PCKDEPOMFTHEADR pTHeadr = (PCKDEPOMFTHEADR)pHdr;
291 if (1 + pTHeadr->Name.cch + 1 != pHdr->cbRec)
292 return kDepErr(pThis, 1, "%#07x - Bad %cHEADR record, length mismatch.",
293 (const KU8*)pHdr - pbFile, pHdr->bType == KDEPOMF_THEADR ? 'T' : 'L');
294 if ( ( pTHeadr->Name.cch > 2
295 && pTHeadr->Name.ach[pTHeadr->Name.cch - 2] == '.'
296 && ( pTHeadr->Name.ach[pTHeadr->Name.cch - 1] == 'o'
297 || pTHeadr->Name.ach[pTHeadr->Name.cch - 1] == 'O'))
298 || ( pTHeadr->Name.cch > 4
299 && pTHeadr->Name.ach[pTHeadr->Name.cch - 4] == '.'
300 && ( pTHeadr->Name.ach[pTHeadr->Name.cch - 3] == 'o'
301 || pTHeadr->Name.ach[pTHeadr->Name.cch - 3] == 'O')
302 && ( pTHeadr->Name.ach[pTHeadr->Name.cch - 2] == 'b'
303 || pTHeadr->Name.ach[pTHeadr->Name.cch - 2] == 'B')
304 && ( pTHeadr->Name.ach[pTHeadr->Name.cch - 1] == 'j'
305 || pTHeadr->Name.ach[pTHeadr->Name.cch - 1] == 'J'))
306 )
307 dprintf(("%cHEADR: %.*s [ignored]\n", pHdr->bType == KDEPOMF_THEADR ? 'T' : 'L', pTHeadr->Name.cch, pTHeadr->Name.ach));
308 else
309 {
310 dprintf(("%cHEADR: %.*s\n", pHdr->bType == KDEPOMF_THEADR ? 'T' : 'L', pTHeadr->Name.cch, pTHeadr->Name.ach));
311 depAdd(&pThis->Core, pTHeadr->Name.ach, pTHeadr->Name.cch);
312 iMaybeSrc++;
313 }
314 uLinNumType = KU8_MAX;
315 break;
316 }
317
318 case KDEPOMF_COMENT:
319 {
320 KU8 uClass;
321
322 if (pHdr->cbRec < 2 + 1)
323 return kDepErr(pThis, 1, "%#07x - Bad COMMENT record, too small.", (const KU8*)pHdr - pbFile);
324 if (uData.pb[0] & 0x3f)
325 return kDepErr(pThis, 1, "%#07x - Bad COMMENT record, reserved flags set.", (const KU8*)pHdr - pbFile);
326 uClass = uData.pb[1];
327 uData.pb += 2;
328 switch (uClass)
329 {
330 /*
331 * Borland dependency file comment (famously used by wmake and Watcom).
332 */
333 case KDEPOMF_CMTCLS_DEPENDENCY:
334 {
335 PCKDEPOMFDEPFILE pDep = (PCKDEPOMFDEPFILE)pHdr;
336 if (K_OFFSETOF(KDEPOMFDEPFILE, Name.ach[pDep->Name.cch]) + 1 != pHdr->cbRec + sizeof(*pHdr))
337 {
338 /* Empty record indicates the end of the dependency files,
339 no need to go on. */
340 if (pHdr->cbRec == 2 + 1)
341 return 0;
342 return kDepErr(pThis, 1, "%#07lx - Bad DEPENDENCY FILE record, length mismatch. (%u/%u)",
343 (long)((const KU8 *)pHdr - pbFile),
344 K_OFFSETOF(KDEPOMFDEPFILE, Name.ach[pDep->Name.cch]) + 1,
345 (unsigned)(pHdr->cbRec + sizeof(*pHdr)));
346 }
347 depAdd(&pThis->Core, pDep->Name.ach, pDep->Name.cch);
348 iSrc++;
349 break;
350 }
351
352 /*
353 * Pick up the debug type so we can parse the LINNUM records.
354 */
355 case KDEPOMF_CMTCLS_DBGTYPE:
356 if (pHdr->cbRec < 2 + 3 + 1)
357 break; /* ignore, Borland used this for something else apparently. */
358 if ( !(uData.pb[1] == 'C' && uData.pb[2] == 'V')
359 && !(uData.pb[1] == 'H' && uData.pb[2] == 'L'))
360 {
361 dprintf(("Unknown debug type: %c%c (%u)\n", uData.pb[1], uData.pb[2], uData.pb[0]));
362 break;
363 }
364 uDbgType = uData.pb[1];
365 uDbgVer = uData.pb[0];
366 dprintf(("Debug Type %s ver %u\n", uDbgType == 'H' ? "HLL" : "CodeView", uDbgVer));
367 break;
368
369 }
370 break; /* COMENT */
371 }
372
373 /*
374 * LINNUM + THEADR == sigar.
375 */
376 case KDEPOMF_LINNUM:
377 if (uDbgType == 'C')
378 iMaybeSrc |= KU32_C(0x80000000);
379 dprintf(("LINNUM:\n"));
380 break;
381
382 /*
383 * The HLL v4 and v6 file names table will include all files when present, which
384 * is perfect for generating dependencies.
385 */
386 case KDEPOMF_LINNUM32:
387 if ( uDbgType == 'H'
388 && uDbgVer >= 3
389 && uDbgVer <= 6)
390 {
391 /* skip two indexes (group & segment) */
392 KU16 cbRecLeft = pHdr->cbRec - 1;
393 KU16 uGrp = kDepObjOMFGetIndex(&uData, &cbRecLeft);
394 KU16 uSeg = kDepObjOMFGetIndex(&uData, &cbRecLeft);
395 if (uSeg == KU16_MAX)
396 return kDepErr(pThis, 1, "%#07lx - Bad LINNUM32 record", (long)((const KU8 *)pHdr - pbFile));
397 K_NOREF(uGrp);
398
399 if (uLinNumType == KU8_MAX)
400 {
401#ifdef WITH_DPRINTF
402 static const char * const s_apsz[5] =
403 {
404 "source file", "listing file", "source & listing file", "file names table", "path table"
405 };
406#endif
407 KU16 uLine;
408 KU8 uReserved;
409 KU16 uSeg2;
410 KU32 cbLinNames;
411
412 if (cbRecLeft < 2+1+1+2+2+4)
413 return kDepErr(pThis, 1, "%#07lx - Bad LINNUM32 record, too short", (long)((const KU8 *)pHdr - pbFile));
414 cbRecLeft -= 2+1+1+2+2+4;
415 uLine = *uData.pu16++;
416 uLinNumType = *uData.pu8++;
417 uReserved = *uData.pu8++; K_NOREF(uReserved);
418 cLinNums = *uData.pu16++; K_NOREF(cLinNums);
419 uSeg2 = *uData.pu16++; K_NOREF(uSeg2);
420 cbLinNames = *uData.pu32++; K_NOREF(cbLinNames);
421
422 dprintf(("LINNUM32: uGrp=%#x uSeg=%#x uSeg2=%#x uLine=%#x (MBZ) uReserved=%#x\n",
423 uGrp, uSeg, uSeg2, uLine, uReserved));
424 dprintf(("LINNUM32: cLinNums=%#x (%u) cbLinNames=%#x (%u) uLinNumType=%#x (%s)\n",
425 cLinNums, cLinNums, cbLinNames, cbLinNames, uLinNumType,
426 uLinNumType < K_ELEMENTS(s_apsz) ? s_apsz[uLinNumType] : "??"));
427
428 if (uLine != 0)
429 return kDepErr(pThis, 1, "%#07lx - Bad LINNUM32 record, line %#x (MBZ)", (long)((const KU8 *)pHdr - pbFile), uLine);
430 cLinFiles = iLinFile = KU32_MAX;
431 if ( uLinNumType == 3 /* file names table */
432 || uLinNumType == 4 /* path table */)
433 cLinNums = 0; /* no line numbers */
434 else if (uLinNumType > 4)
435 return kDepErr(pThis, 1, "%#07lx - Bad LINNUM32 record, type %#x unknown", (long)((const KU8 *)pHdr - pbFile), uLinNumType);
436 }
437 else
438 dprintf(("LINNUM32: uGrp=%#x uSeg=%#x\n", uGrp, uSeg));
439
440
441 /* Skip file numbers (we parse them to follow the stream correctly). */
442 if (uLinNumType != 3 && uLinNumType != 4)
443 {
444 static const unsigned s_acbTypes[3] = { 2+2+4, 4+4+4, 2+2+4+4+4 };
445 unsigned cbEntry = s_acbTypes[uLinNumType];
446
447 while (cLinNums && cbRecLeft)
448 {
449 if (cbRecLeft < cbEntry)
450 return kDepErr(pThis, 1, "%#07lx - Bad LINNUM32 record, incomplete line entry", (long)((const KU8 *)pHdr - pbFile));
451
452 switch (uLinNumType)
453 {
454 case 0: /* source file */
455 dprintf((" Line %6" KU16_PRI " of file %2" KU16_PRI " at %#010" KX32_PRI "\n",
456 uData.pu16[0], uData.pu16[1], uData.pu32[1]));
457 break;
458 case 1: /* listing file */
459 dprintf((" Line %6" KU32_PRI ", statement %6" KU32_PRI " at %#010" KX32_PRI "\n",
460 uData.pu32[0], uData.pu32[1], uData.pu32[2]));
461 break;
462 case 2: /* source & listing file */
463 dprintf((" Line %6" KU16_PRI " of file %2" KU16_PRI ", listning line %6" KU32_PRI ", statement %6" KU32_PRI " at %#010" KX32_PRI "\n",
464 uData.pu16[0], uData.pu16[1], uData.pu32[1], uData.pu32[2], uData.pu32[3]));
465 break;
466 }
467 uData.pb += cbEntry;
468 cbRecLeft -= cbEntry;
469 cLinNums--;
470 }
471
472 /* If at end of the announced line number entiries, we may find a file names table
473 here (who is actually emitting this?). */
474 if (!cLinNums)
475 {
476 uLinNumType = cbRecLeft > 0 ? 3 : KU8_MAX;
477 dprintf(("End-of-line-numbers; uLinNumType=%u cbRecLeft=%#x\n", uLinNumType, cbRecLeft));
478 }
479 }
480
481 if (uLinNumType == 3 || uLinNumType == 4)
482 {
483 /* Read the file/path table header (first time only). */
484 if (cLinFiles == KU32_MAX && iLinFile == KU32_MAX)
485 {
486 KU32 iFirstCol;
487 KU32 cCols;
488
489 if (cbRecLeft < 4+4+4)
490 return kDepErr(pThis, 1, "%#07lx - Bad LINNUM32 record, incomplete file/path table header", (long)((const KU8 *)pHdr - pbFile));
491 cbRecLeft -= 4+4+4;
492
493 iFirstCol = *uData.pu32++; K_NOREF(iFirstCol);
494 cCols = *uData.pu32++; K_NOREF(cCols);
495 cLinFiles = *uData.pu32++;
496 dprintf(("%s table header: cLinFiles=%#" KX32_PRI " (%" KU32_PRI ") iFirstCol=%" KU32_PRI " cCols=%" KU32_PRI"\n",
497 uLinNumType == 3 ? "file names" : "path", cLinFiles, cLinFiles, iFirstCol, cCols));
498 if (cLinFiles == KU32_MAX)
499 return kDepErr(pThis, 1, "%#07lx - Bad LINNUM32 record, too many file/path table entries.", (long)((const KU8 *)pHdr - pbFile));
500 iLinFile = 0;
501 }
502
503 /* Parse the file names / path table. */
504 while (iLinFile < cLinFiles && cbRecLeft)
505 {
506 int cbName = *uData.pb++;
507 if (cbRecLeft < 1 + cbName)
508 return kDepErr(pThis, 1, "%#07lx - Bad LINNUM32 record, file/path table entry too long.", (long)((const KU8 *)pHdr - pbFile));
509 iLinFile++;
510 dprintf(("#%" KU32_PRI": %.*s\n", iLinFile, cbName, uData.pch));
511 if (uLinNumType == 3)
512 {
513 depAdd(&pThis->Core, uData.pch, cbName);
514 iSrc++;
515 }
516 cbRecLeft -= 1 + cbName;
517 uData.pb += cbName;
518 }
519
520 /* The end? */
521 if (iLinFile == cLinFiles)
522 {
523 uLinNumType = KU8_MAX;
524 dprintf(("End-of-file/path-table; cbRecLeft=%#x\n", cbRecLeft));
525 }
526 }
527 }
528 else
529 dprintf(("LINNUM32: Unknown or unsupported format\n"));
530 break;
531
532 }
533
534 /* advance */
535 cbLeft -= pHdr->cbRec + sizeof(*pHdr);
536 pHdr = (PCKDEPOMFHDR)((const KU8 *)(pHdr + 1) + pHdr->cbRec);
537 }
538
539 if (cbLeft)
540 return kDepErr(pThis, 1, "%#07x - Unexpected EOF. cbLeft=%#x", (const KU8*)pHdr - pbFile, cbLeft);
541
542 if (iSrc == 0 && iMaybeSrc <= 1)
543 {
544 dprintf(("kDepObjOMFParse: No cylindrical smoking thing: iSrc=0 iMaybeSrc=%#" KX32_PRI"\n", iMaybeSrc));
545 return 2;
546 }
547 dprintf(("kDepObjOMFParse: iSrc=%" KU32_PRI " iMaybeSrc=%#" KX32_PRI "\n", iSrc, iMaybeSrc));
548 return 0;
549}
550
551
552/**
553 * Checks if this file is an OMF file or not.
554 *
555 * @returns K_TRUE if it's OMF, K_FALSE otherwise.
556 *
557 * @param pb The start of the file.
558 * @param cb The file size.
559 */
560KBOOL kDepObjOMFTest(const KU8 *pbFile, KSIZE cbFile)
561{
562 PCKDEPOMFTHEADR pHdr = (PCKDEPOMFTHEADR)pbFile;
563
564 if (cbFile <= sizeof(*pHdr))
565 return K_FALSE;
566 if ( pHdr->Hdr.bType != KDEPOMF_THEADR
567 && pHdr->Hdr.bType != KDEPOMF_LHEADR)
568 return K_FALSE;
569 if (pHdr->Hdr.cbRec + sizeof(pHdr->Hdr) >= cbFile)
570 return K_FALSE;
571 if (pHdr->Hdr.cbRec != 1 + pHdr->Name.cch + 1)
572 return K_FALSE;
573
574 return K_TRUE;
575}
576
577
578/**
579 * Parses a CodeView 8 symbol section.
580 *
581 * @returns 0 on success, 1 on failure, 2 if no dependencies was found.
582 * @param pThis The kDepObj instance data.
583 * @param pbSyms Pointer to the start of the symbol section.
584 * @param cbSyms Size of the symbol section.
585 */
586int kDepObjCOFFParseCV8SymbolSection(PKDEPOBJGLOBALS pThis, const KU8 *pbSyms, KU32 cbSyms)
587{
588 char const * pchStrTab = NULL;
589 KU32 cbStrTab = 0;
590 KPCUINT uSrcFiles = {0};
591 KU32 cbSrcFiles = 0;
592 KU32 off = 4;
593 KU32 iSrc = 0;
594
595 if (cbSyms < 16)
596 return 1;
597
598 /*
599 * The parsing loop.
600 */
601 while (off < cbSyms)
602 {
603 PCKDEPCV8SYMHDR pHdr = (PCKDEPCV8SYMHDR)(pbSyms + off);
604 KPCUINT uData;
605 KU32 cbData;
606 uData.pv = pHdr + 1;
607
608 if (off + sizeof(*pHdr) >= cbSyms)
609 {
610 kDepErr(pThis, 1, "CV symbol table entry at %08" KX32_PRI " is too long; cbSyms=%#" KX32_PRI "",
611 off, cbSyms);
612 return 1; /* FIXME */
613 }
614
615 cbData = pHdr->cb;
616 if (off + cbData + sizeof(*pHdr) > cbSyms)
617 {
618 kDepErr(pThis, 1, "CV symbol table entry at %08" KX32_PRI " is too long; cbData=%#" KX32_PRI " cbSyms=%#" KX32_PRI,
619 off, cbData, cbSyms);
620 return 1; /* FIXME */
621 }
622
623 /* If the size is 0, assume it covers the rest of the section. VC++ 2003 has
624 been observed doing thing. */
625 if (!cbData)
626 cbData = cbSyms - off;
627
628 switch (pHdr->uType)
629 {
630 case K_CV8_SYMBOL_INFO:
631 dprintf(("%06" KX32_PRI " %06" KX32_PRI ": Symbol Info\n", off, cbData));
632 /*dump(uData.pb, cbData, 0);*/
633 break;
634
635 case K_CV8_LINE_NUMBERS:
636 dprintf(("%06" KX32_PRI " %06" KX32_PRI ": Line numbers\n", off, cbData));
637 /*dump(uData.pb, cbData, 0);*/
638 break;
639
640 case K_CV8_STRING_TABLE:
641 dprintf(("%06" KX32_PRI " %06" KX32_PRI ": String table\n", off, cbData));
642 if (pchStrTab)
643 warnx(pThis->pCtx, "%s: warning: Found yet another string table!", pThis->pszFile);
644 pchStrTab = uData.pch;
645 cbStrTab = cbData;
646 /*dump(uData.pb, cbData, 0);*/
647 break;
648
649 case K_CV8_SOURCE_FILES:
650 dprintf(("%06" KX32_PRI " %06" KX32_PRI ": Source files\n", off, cbData));
651 if (uSrcFiles.pb)
652 warnx(pThis->pCtx, "%s: warning: Found yet another source files table!", pThis->pszFile);
653 uSrcFiles = uData;
654 cbSrcFiles = cbData;
655 /*dump(uData.pb, cbData, 0);*/
656 break;
657
658 case K_CV8_COMDAT_XXXXX:
659 dprintf(("%06" KX32_PRI " %06" KX32_PRI ": 0xf5 Unknown COMDAT stuff\n", off, cbData));
660 /*dump(uData.pb, cbData, 0);*/
661 break;
662
663 default:
664 dprintf(("%06" KX32_PRI " %06" KX32_PRI ": Unknown type %#" KX32_PRI "\n",
665 off, cbData, pHdr->uType));
666 dump(uData.pb, cbData, 0);
667 break;
668 }
669
670 /* next */
671 cbData = (cbData + 3) & ~KU32_C(3);
672 off += cbData + sizeof(*pHdr);
673 }
674
675 /*
676 * Did we find any source files and strings?
677 */
678 if (!pchStrTab || !uSrcFiles.pv)
679 {
680 dprintf(("kDepObjCOFFParseCV8SymbolSection: No cylindrical smoking thing: pchStrTab=%p uSrcFiles.pv=%p\n", pchStrTab, uSrcFiles.pv));
681 return 2;
682 }
683
684 /*
685 * Iterate the source file table.
686 */
687 off = 0;
688 while (off < cbSrcFiles)
689 {
690 KU32 offFile;
691 const char *pszFile;
692 KSIZE cchFile;
693 KU16 u16Type;
694 KPCUINT uSrc;
695 KU32 cbSrc;
696
697 /*
698 * Validate and parse the entry (variable length record are fun).
699 */
700 if (off + 8 > cbSrcFiles)
701 return kDepErr(pThis, 1, "CV source file entry at %08" KX32_PRI " is too long; cbSrcFiles=%#" KX32_PRI,
702 off, cbSrcFiles);
703 uSrc.pb = uSrcFiles.pb + off;
704 u16Type = uSrc.pu16[2];
705 switch (u16Type)
706 {
707 case 0x0110: cbSrc = 6 + 16 + 2; break; /* MD5 */
708 case 0x0214: cbSrc = 6 + 20 + 2; break; /* SHA1 */ /** @todo check this */
709 case 0x0320: cbSrc = 6 + 32 + 2; break; /* SHA-256 */
710 default: cbSrc = 6 + 0 + 2; break;
711 }
712 if (off + cbSrc > cbSrcFiles)
713 return kDepErr(pThis, 1, "CV source file entry at %08" KX32_PRI " is too long; cbSrc=%#" KX32_PRI " cbSrcFiles=%#" KX32_PRI,
714 off, cbSrc, cbSrcFiles);
715
716 offFile = *uSrc.pu32;
717 if (offFile > cbStrTab)
718 return kDepErr(pThis, 1, "CV source file entry at %08" KX32_PRI " is out side the string table; offFile=%#" KX32_PRI " cbStrTab=%#" KX32_PRI,
719 off, offFile, cbStrTab);
720 pszFile = pchStrTab + offFile;
721 cchFile = strlen(pszFile);
722 if (cchFile == 0)
723 return kDepErr(pThis, 1, "CV source file entry at %08" KX32_PRI " has an empty file name; offFile=%#x" KX32_PRI,
724 off, offFile);
725
726 /*
727 * Display the result and add it to the dependency database.
728 */
729 depAdd(&pThis->Core, pszFile, cchFile);
730#ifdef WITH_DPRINTF
731 dprintf(("#%03" KU32_PRI ": ", iSrc));
732 {
733 KU32 off = 6;
734 for (;off < cbSrc - 2; off++)
735 dprintf(("%02" KX8_PRI, uSrc.pb[off]));
736 if (cbSrc == 6)
737 dprintf(("type=%#06" KX16_PRI, u16Type));
738 dprintf((" '%s'\n", pszFile));
739 }
740#endif
741
742
743 /* next */
744 iSrc++;
745 off += cbSrc;
746 }
747
748 if (iSrc == 0)
749 {
750 dprintf(("kDepObjCOFFParseCV8SymbolSection: No cylindrical smoking thing: iSrc=0\n"));
751 return 2;
752 }
753 dprintf(("kDepObjCOFFParseCV8SymbolSection: iSrc=%" KU32_PRI "\n", iSrc));
754 return 0;
755}
756
757
758/**
759 * Parses the OMF file.
760 *
761 * @returns 0 on success, 1 on failure, 2 if no dependencies was found.
762 * @param pThis The kDepObj instance data.
763 * @param pbFile The start of the file.
764 * @param cbFile The file size.
765 */
766int kDepObjCOFFParse(PKDEPOBJGLOBALS pThis, const KU8 *pbFile, KSIZE cbFile)
767{
768 IMAGE_FILE_HEADER const *pFileHdr = (IMAGE_FILE_HEADER const *)pbFile;
769 ANON_OBJECT_HEADER_BIGOBJ const *pBigObjHdr = (ANON_OBJECT_HEADER_BIGOBJ const *)pbFile;
770 IMAGE_SECTION_HEADER const *paSHdrs;
771 KU32 cSHdrs;
772 unsigned iSHdr;
773 KPCUINT u;
774 int rcRet = 2;
775 int rc;
776
777 if ( pBigObjHdr->Sig1 == 0
778 && pBigObjHdr->Sig2 == KU16_MAX)
779 {
780 paSHdrs = (IMAGE_SECTION_HEADER const *)(pBigObjHdr + 1);
781 cSHdrs = pBigObjHdr->NumberOfSections;
782 }
783 else
784 {
785 paSHdrs = (IMAGE_SECTION_HEADER const *)((KU8 const *)(pFileHdr + 1) + pFileHdr->SizeOfOptionalHeader);
786 cSHdrs = pFileHdr->NumberOfSections;
787 }
788
789
790 dprintf(("COFF file!\n"));
791
792 for (iSHdr = 0; iSHdr < cSHdrs; iSHdr++)
793 {
794 if ( !memcmp(paSHdrs[iSHdr].Name, ".debug$S", sizeof(".debug$S") - 1)
795 && paSHdrs[iSHdr].SizeOfRawData > 4)
796 {
797 u.pb = pbFile + paSHdrs[iSHdr].PointerToRawData;
798 dprintf(("CV symbol table: version=%x\n", *u.pu32));
799 if (*u.pu32 == 0x000000004)
800 rc = kDepObjCOFFParseCV8SymbolSection(pThis, u.pb, paSHdrs[iSHdr].SizeOfRawData);
801 else
802 rc = 2;
803 dprintf(("rc=%d\n", rc));
804 if (rcRet == 2)
805 rcRet = rc;
806 if (rcRet != 2)
807 return rc;
808 }
809 dprintf(("#%d: %.8s\n", iSHdr, paSHdrs[iSHdr].Name));
810 }
811 return rcRet;
812}
813
814
815/**
816 * Checks if this file is a COFF file or not.
817 *
818 * @returns K_TRUE if it's COFF, K_FALSE otherwise.
819 *
820 * @param pThis The kDepObj instance data.
821 * @param pb The start of the file.
822 * @param cb The file size.
823 */
824KBOOL kDepObjCOFFTest(PKDEPOBJGLOBALS pThis, const KU8 *pbFile, KSIZE cbFile)
825{
826 IMAGE_FILE_HEADER const *pFileHdr = (IMAGE_FILE_HEADER const *)pbFile;
827 ANON_OBJECT_HEADER_BIGOBJ const *pBigObjHdr = (ANON_OBJECT_HEADER_BIGOBJ const *)pbFile;
828 IMAGE_SECTION_HEADER const *paSHdrs;
829 KU32 cSHdrs;
830 KU32 iSHdr;
831 KSIZE cbHdrs;
832
833 if (cbFile <= sizeof(*pFileHdr))
834 return K_FALSE;
835
836 /*
837 * Deal with -bigobj output first.
838 */
839 if ( pBigObjHdr->Sig1 == 0
840 && pBigObjHdr->Sig2 == KU16_MAX)
841 {
842 static const KU8 s_abClsId[16] = { ANON_OBJECT_HEADER_BIGOBJ_CLS_ID_BYTES };
843
844 paSHdrs = (IMAGE_SECTION_HEADER const *)(pBigObjHdr + 1);
845 cSHdrs = pBigObjHdr->NumberOfSections;
846 cbHdrs = sizeof(IMAGE_SECTION_HEADER) * cSHdrs;
847
848 if (cbFile <= sizeof(*pBigObjHdr))
849 return K_FALSE;
850
851 if (pBigObjHdr->Version != 2)
852 return K_FALSE;
853 if (memcmp(&pBigObjHdr->ClassID[0], s_abClsId, sizeof(pBigObjHdr->ClassID)) != 0)
854 return K_FALSE;
855
856 if ( pBigObjHdr->Machine != IMAGE_FILE_MACHINE_I386
857 && pBigObjHdr->Machine != IMAGE_FILE_MACHINE_AMD64
858 && pBigObjHdr->Machine != IMAGE_FILE_MACHINE_ARM
859 && pBigObjHdr->Machine != IMAGE_FILE_MACHINE_ARMNT
860 && pBigObjHdr->Machine != IMAGE_FILE_MACHINE_ARM64
861 && pBigObjHdr->Machine != IMAGE_FILE_MACHINE_EBC)
862 {
863 kDepErr(pThis, 1, "bigobj Machine not supported: %#x", pBigObjHdr->Machine);
864 return K_FALSE;
865 }
866 if (pBigObjHdr->Flags != 0)
867 {
868 kDepErr(pThis, 1, "bigobj Flags field is non-zero: %#x", pBigObjHdr->Flags);
869 return K_FALSE;
870 }
871 if (pBigObjHdr->SizeOfData != 0)
872 {
873 kDepErr(pThis, 1, "bigobj SizeOfData field is non-zero: %#x", pBigObjHdr->SizeOfData);
874 return K_FALSE;
875 }
876
877 if ( pBigObjHdr->PointerToSymbolTable != 0
878 && ( pBigObjHdr->PointerToSymbolTable < cbHdrs
879 || pBigObjHdr->PointerToSymbolTable > cbFile))
880 return K_FALSE;
881 if ( pBigObjHdr->PointerToSymbolTable == 0
882 && pBigObjHdr->NumberOfSymbols != 0)
883 return K_FALSE;
884 }
885 /*
886 * Look for normal COFF object.
887 */
888 else
889 {
890 paSHdrs = (IMAGE_SECTION_HEADER const *)((KU8 const *)(pFileHdr + 1) + pFileHdr->SizeOfOptionalHeader);
891 cSHdrs = pFileHdr->NumberOfSections;
892 cbHdrs = (const KU8 *)&paSHdrs[cSHdrs] - (const KU8 *)pbFile;
893
894 if ( pFileHdr->Machine != IMAGE_FILE_MACHINE_I386
895 && pFileHdr->Machine != IMAGE_FILE_MACHINE_AMD64
896 && pFileHdr->Machine != IMAGE_FILE_MACHINE_ARM
897 && pFileHdr->Machine != IMAGE_FILE_MACHINE_ARMNT
898 && pFileHdr->Machine != IMAGE_FILE_MACHINE_ARM64
899 && pFileHdr->Machine != IMAGE_FILE_MACHINE_EBC)
900 return K_FALSE;
901
902 if (pFileHdr->SizeOfOptionalHeader != 0)
903 return K_FALSE; /* COFF files doesn't have an optional header */
904
905 if ( pFileHdr->PointerToSymbolTable != 0
906 && ( pFileHdr->PointerToSymbolTable < cbHdrs
907 || pFileHdr->PointerToSymbolTable > cbFile))
908 return K_FALSE;
909 if ( pFileHdr->PointerToSymbolTable == 0
910 && pFileHdr->NumberOfSymbols != 0)
911 return K_FALSE;
912 if ( pFileHdr->Characteristics
913 & ( IMAGE_FILE_DLL
914 | IMAGE_FILE_SYSTEM
915 | IMAGE_FILE_UP_SYSTEM_ONLY
916 | IMAGE_FILE_NET_RUN_FROM_SWAP
917 | IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP
918 | IMAGE_FILE_EXECUTABLE_IMAGE
919 | IMAGE_FILE_RELOCS_STRIPPED))
920 return K_FALSE;
921 }
922 if ( cSHdrs <= 1
923 || cSHdrs > cbFile)
924 return K_FALSE;
925 if (cbHdrs >= cbFile)
926 return K_FALSE;
927
928 /*
929 * Check the section headers.
930 */
931 for (iSHdr = 0; iSHdr < cSHdrs; iSHdr++)
932 {
933 if ( paSHdrs[iSHdr].PointerToRawData != 0
934 && ( paSHdrs[iSHdr].PointerToRawData < cbHdrs
935 || paSHdrs[iSHdr].PointerToRawData >= cbFile
936 || paSHdrs[iSHdr].PointerToRawData + paSHdrs[iSHdr].SizeOfRawData > cbFile))
937 return K_FALSE;
938 if ( paSHdrs[iSHdr].PointerToRelocations != 0
939 && ( paSHdrs[iSHdr].PointerToRelocations < cbHdrs
940 || paSHdrs[iSHdr].PointerToRelocations >= cbFile
941 || paSHdrs[iSHdr].PointerToRelocations + paSHdrs[iSHdr].NumberOfRelocations * 10 > cbFile)) /* IMAGE_RELOCATION */
942 return K_FALSE;
943 if ( paSHdrs[iSHdr].PointerToLinenumbers != 0
944 && ( paSHdrs[iSHdr].PointerToLinenumbers < cbHdrs
945 || paSHdrs[iSHdr].PointerToLinenumbers >= cbFile
946 || paSHdrs[iSHdr].PointerToLinenumbers + paSHdrs[iSHdr].NumberOfLinenumbers * 6 > cbFile)) /* IMAGE_LINENUMBER */
947 return K_FALSE;
948 }
949
950 return K_TRUE;
951}
952
953
954/**
955 * Read the file into memory and parse it.
956 */
957static int kDepObjProcessFile(PKDEPOBJGLOBALS pThis, FILE *pInput)
958{
959 size_t cbFile;
960 KU8 *pbFile;
961 void *pvOpaque;
962 int rc = 0;
963
964 /*
965 * Read the file into memory.
966 */
967 pbFile = (KU8 *)depReadFileIntoMemory(pInput, &cbFile, &pvOpaque);
968 if (!pbFile)
969 return 1;
970
971 /*
972 * See if it's an OMF file, then process it.
973 */
974 if (kDepObjOMFTest(pbFile, cbFile))
975 rc = kDepObjOMFParse(pThis, pbFile, cbFile);
976 else if (kDepObjCOFFTest(pThis, pbFile, cbFile))
977 rc = kDepObjCOFFParse(pThis, pbFile, cbFile);
978 else
979 rc = kDepErr(pThis, 1, "Doesn't recognize the header of the OMF/COFF file.");
980
981 depFreeFileMemory(pbFile, pvOpaque);
982 return rc;
983}
984
985
986static void kDebObjUsage(PKMKBUILTINCTX pCtx, int fIsErr)
987{
988 kmk_builtin_ctx_printf(pCtx, fIsErr,
989 "usage: %s -o <output> -t <target> [-fqs] [-e <ignore-ext>] <OMF or COFF file>\n"
990 " or: %s --help\n"
991 " or: %s --version\n",
992 pCtx->pszProgName, pCtx->pszProgName, pCtx->pszProgName);
993}
994
995
996int kmk_builtin_kDepObj(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx)
997{
998 int i;
999 KDEPOBJGLOBALS This;
1000
1001 /* Arguments. */
1002 FILE *pOutput = NULL;
1003 const char *pszOutput = NULL;
1004 FILE *pInput = NULL;
1005 const char *pszTarget = NULL;
1006 int fStubs = 0;
1007 int fFixCase = 0;
1008 const char *pszIgnoreExt = NULL;
1009 /* Argument parsing. */
1010 int fInput = 0; /* set when we've found input argument. */
1011 int fQuiet = 0;
1012
1013 /* Init instance data. */
1014 This.pCtx = pCtx;
1015 This.pszFile = NULL;
1016
1017 /*
1018 * Parse arguments.
1019 */
1020 if (argc <= 1)
1021 {
1022 kDebObjUsage(pCtx, 0);
1023 return 1;
1024 }
1025 for (i = 1; i < argc; i++)
1026 {
1027 if (argv[i][0] == '-')
1028 {
1029 const char *pszValue;
1030 const char *psz = &argv[i][1];
1031 char chOpt;
1032 chOpt = *psz++;
1033 if (chOpt == '-')
1034 {
1035 /* Convert long to short option. */
1036 if (!strcmp(psz, "quiet"))
1037 chOpt = 'q';
1038 else if (!strcmp(psz, "help"))
1039 chOpt = '?';
1040 else if (!strcmp(psz, "version"))
1041 chOpt = 'V';
1042 else
1043 {
1044 errx(pCtx, 2, "Invalid argument '%s'.", argv[i]);
1045 kDebObjUsage(pCtx, 1);
1046 return 2;
1047 }
1048 psz = "";
1049 }
1050
1051 /*
1052 * Requires value?
1053 */
1054 switch (chOpt)
1055 {
1056 case 'o':
1057 case 't':
1058 case 'e':
1059 if (*psz)
1060 pszValue = psz;
1061 else if (++i < argc)
1062 pszValue = argv[i];
1063 else
1064 return errx(pCtx, 2, "The '-%c' option takes a value.", chOpt);
1065 break;
1066
1067 default:
1068 pszValue = NULL;
1069 break;
1070 }
1071
1072
1073 switch (chOpt)
1074 {
1075 /*
1076 * Output file.
1077 */
1078 case 'o':
1079 {
1080 if (pOutput)
1081 return errx(pCtx, 2, "only one output file!");
1082 pszOutput = pszValue;
1083 if (pszOutput[0] == '-' && !pszOutput[1])
1084 pOutput = stdout;
1085 else
1086 pOutput = fopen(pszOutput, "w" KMK_FOPEN_NO_INHERIT_MODE);
1087 if (!pOutput)
1088 return err(pCtx, 1, "Failed to create output file '%s'", pszOutput);
1089 break;
1090 }
1091
1092 /*
1093 * Target name.
1094 */
1095 case 't':
1096 {
1097 if (pszTarget)
1098 return errx(pCtx, 2, "only one target!");
1099 pszTarget = pszValue;
1100 break;
1101 }
1102
1103 /*
1104 * Fix case.
1105 */
1106 case 'f':
1107 {
1108 fFixCase = 1;
1109 break;
1110 }
1111
1112 /*
1113 * Quiet.
1114 */
1115 case 'q':
1116 {
1117 fQuiet = 1;
1118 break;
1119 }
1120
1121 /*
1122 * Generate stubs.
1123 */
1124 case 's':
1125 {
1126 fStubs = 1;
1127 break;
1128 }
1129
1130 /*
1131 * Extension to ignore.
1132 */
1133 case 'e':
1134 {
1135 if (pszIgnoreExt)
1136 return errx(pCtx, 2, "The '-e' option can only be used once!");
1137 pszIgnoreExt = pszValue;
1138 break;
1139 }
1140
1141 /*
1142 * The mandatory version & help.
1143 */
1144 case '?':
1145 kDebObjUsage(pCtx, 0);
1146 return 0;
1147 case 'V':
1148 case 'v':
1149 return kbuild_version(argv[0]);
1150
1151 /*
1152 * Invalid argument.
1153 */
1154 default:
1155 errx(pCtx, 2, "Invalid argument '%s'.", argv[i]);
1156 kDebObjUsage(pCtx, 1);
1157 return 2;
1158 }
1159 }
1160 else
1161 {
1162 pInput = fopen(argv[i], "rb" KMK_FOPEN_NO_INHERIT_MODE);
1163 if (!pInput)
1164 return err(pCtx, 1, "Failed to open input file '%s'", argv[i]);
1165 fInput = 1;
1166 }
1167
1168 /*
1169 * End of the line?
1170 */
1171 if (fInput)
1172 {
1173 if (++i < argc)
1174 return errx(pCtx, 2, "No arguments shall follow the input spec.");
1175 break;
1176 }
1177 }
1178
1179 /*
1180 * Got all we require?
1181 */
1182 if (!pInput)
1183 return errx(pCtx, 2, "No input!");
1184 if (!pOutput)
1185 return errx(pCtx, 2, "No output!");
1186 if (!pszTarget)
1187 return errx(pCtx, 2, "No target!");
1188
1189 /*
1190 * Do the parsing.
1191 */
1192 depInit(&This.Core);
1193 i = kDepObjProcessFile(&This, pInput);
1194 fclose(pInput);
1195
1196 /*
1197 * Write the dependecy file.
1198 */
1199 if (!i)
1200 {
1201 depOptimize(&This.Core, fFixCase, fQuiet, pszIgnoreExt);
1202 depPrintTargetWithDeps(&This.Core, pOutput, pszTarget, 1 /*fEscapeTarget*/);
1203 if (fStubs)
1204 depPrintStubs(&This.Core, pOutput);
1205 }
1206
1207 /*
1208 * Close the output, delete output on failure.
1209 */
1210 if (!i && ferror(pOutput))
1211 i = errx(pCtx, 1, "Error writing to '%s'", pszOutput);
1212 fclose(pOutput);
1213 if (i)
1214 {
1215 if (unlink(pszOutput))
1216 warn(pCtx, "warning: failed to remove output file '%s' on failure.", pszOutput);
1217 }
1218
1219 depCleanup(&This.Core);
1220 return i;
1221}
1222
1223#ifdef KMK_BUILTIN_STANDALONE
1224int main(int argc, char **argv, char **envp)
1225{
1226 KMKBUILTINCTX Ctx = { "kDepObj", NULL };
1227 return kmk_builtin_kDepObj(argc, argv, envp, &Ctx);
1228}
1229#endif
1230
Note: See TracBrowser for help on using the repository browser.