Boot Linux faster!

Check our new training course

Boot Linux faster!

Check our new training course
and Creative Commons CC-BY-SA
lecture and lab materials

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
/*
 * Copyright (c) 2010-2014 Wind River Systems, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file
 * @brief generate offset definition header file
 *
 * genOffsetHeader -i <objectModule> -o <outputHeaderName>
 *
 * This Zephyr development host utility will process an ELF object module that
 * consists of a series of absolute symbols representing the byte offset of a
 * structure member and the size of the structure.  Each absolute symbol will
 * be translated into a C preprocessor '#define' directive.  For example,
 * assuming that the module offsets.o contains the following absolute symbols:
 *
 *   $ nm offsets.o
 *   00000010 A __tNANO_irq_stack_OFFSET
 *   00000008 A __tNANO_current_OFFSET
 *   0000000c A __tNANO_nested_OFFSET
 *   00000000 A __tNANO_fiber_OFFSET
 *   00000004 A __tNANO_task_OFFSET
 *
 * ... the following C preprocessor code will be generated:
 *
 *   #define   __tNANO_irq_stack_OFFSET  0x10
 *   #define   __tNANO_current_OFFSET     0x8
 *   #define   __tNANO_nested_OFFSET      0xC
 *   #define   __tNANO_fiber_OFFSET       0x0
 *   #define   __tNANO_task_OFFSET        0x4
 */

/* includes */

#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "elf.h"
#include <stdlib.h>		/* for malloc()/free()/exit() */
#include <string.h>		/* for strstr() */
#include <getopt.h>
#include <errno.h>

/* defines */

#undef DEBUG

/* the symbol name suffix used to denote structure member offsets */

#define STRUCT_OFF_SUFFIX "_OFFSET"
#define STRUCT_SIZ_SUFFIX "_SIZEOF"

#ifdef DEBUG
#define DBG_PRINT(args...) printf(args)
#else
#define DBG_PRINT(args...)
#endif


/* byte swapping macros */

#define SWAB_Elf32_Half(x)	((x >> 8) | (x << 8))
#define SWAB_Elf32_Word(x)	(((x >> 24) & 0xff) |		\
				((x << 8)  & 0xff0000) |	\
		                ((x >> 8)  & 0xff00) |		\
	                        ((x << 24) & 0xff000000))

#define SWAB_Elf32_Addr	  SWAB_Elf32_Word
#define SWAB_Elf32_Off    SWAB_Elf32_Word
#define SWAB_Elf32_Sword  SWAB_Elf32_Word

#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__WIN32__)
  #define OPEN_FLAGS (O_RDONLY|O_BINARY)
#else
  #define OPEN_FLAGS (O_RDONLY)
#endif

/* locals */

/* global indicating whether ELF structures need to be byte swapped */

static char swabRequired;


/* usage information */

static char usage[] = "usage: %s -i <objectModule> -o <outputHeaderName>\n";


/* output header file preamble */

static char preamble1[] = "\
/* %s - structure member offsets definition header */\n\
\n\
/*\n\
 * Copyright (c) 2010-2014 Wind River Systems, Inc.\n\
 *\n\
 * Licensed under the Apache License, Version 2.0 (the \"License\");\n\
 * you may not use this file except in compliance with the License.\n\
 * You may obtain a copy of the License at\n\
 *\n\
 *     http://www.apache.org/licenses/LICENSE-2.0\n\
 *\n\
 * Unless required by applicable law or agreed to in writing, software\n\
 * distributed under the License is distributed on an \"AS IS\" BASIS,\n\
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\
 * See the License for the specific language governing permissions and\n\
 * limitations under the License.\n\
 */\n\
\n\
/* THIS FILE IS AUTO GENERATED.  PLEASE DO NOT EDIT */\n\
\n\
/*\n\
 * This header file provides macros for the offsets of various structure\n\
 * members.  These offset macros are primarily intended to be used in\n\
 * assembly code.\n\
 */\n\n";

static char preamble2[] = "\
/*\n\
 * Auto-generated header guard.\n\
 */\n\
#ifndef %s\n\
#define %s\n\
 \n\
#ifdef __cplusplus\n\
extern \"C\" {\n\
#endif\n\
\n\
/* defines */\n\n";


/* output header file postscript */

static char postscript[] = "\
\n\
#ifdef __cplusplus\n\
}\n\
#endif\n\
\n\
#endif /* _HGUARD_ */\n";

static Elf32_Ehdr	ehdr;    /* ELF header */
static Elf32_Shdr *	shdr;    /* pointer to array ELF section headers */

/**
 * @brief byte swap the Elf32_Ehdr structure
 *
 * @returns N/A
 */
static void swabElfHdr(Elf32_Ehdr *pHdrToSwab)
{
	if (swabRequired == 0)
	{
		return;  /* do nothing */
	}

	pHdrToSwab->e_type		= SWAB_Elf32_Half(pHdrToSwab->e_type);
	pHdrToSwab->e_machine	= SWAB_Elf32_Half(pHdrToSwab->e_machine);
	pHdrToSwab->e_version	= SWAB_Elf32_Word(pHdrToSwab->e_version);
	pHdrToSwab->e_entry		= SWAB_Elf32_Addr(pHdrToSwab->e_entry);
	pHdrToSwab->e_phoff		= SWAB_Elf32_Off(pHdrToSwab->e_phoff);
	pHdrToSwab->e_shoff		= SWAB_Elf32_Off(pHdrToSwab->e_shoff);
	pHdrToSwab->e_flags		= SWAB_Elf32_Word(pHdrToSwab->e_flags);
	pHdrToSwab->e_ehsize	= SWAB_Elf32_Half(pHdrToSwab->e_ehsize);
	pHdrToSwab->e_phentsize	= SWAB_Elf32_Half(pHdrToSwab->e_phentsize);
	pHdrToSwab->e_phnum		= SWAB_Elf32_Half(pHdrToSwab->e_phnum);
	pHdrToSwab->e_shentsize	= SWAB_Elf32_Half(pHdrToSwab->e_shentsize);
	pHdrToSwab->e_shnum		= SWAB_Elf32_Half(pHdrToSwab->e_shnum);
	pHdrToSwab->e_shstrndx	= SWAB_Elf32_Half(pHdrToSwab->e_shstrndx);
}

/**
 * @brief byte swap the Elf32_Shdr structure
 *
 * @returns N/A
 */
static void swabElfSectionHdr(Elf32_Shdr *pHdrToSwab)
{
	if (swabRequired == 0)
	{
		return;  /* do nothing */
	}

	pHdrToSwab->sh_name		= SWAB_Elf32_Word(pHdrToSwab->sh_name);
	pHdrToSwab->sh_type		= SWAB_Elf32_Word(pHdrToSwab->sh_type);
	pHdrToSwab->sh_flags	= SWAB_Elf32_Word(pHdrToSwab->sh_flags);
	pHdrToSwab->sh_addr		= SWAB_Elf32_Addr(pHdrToSwab->sh_addr);
	pHdrToSwab->sh_offset	= SWAB_Elf32_Off(pHdrToSwab->sh_offset);
	pHdrToSwab->sh_size		= SWAB_Elf32_Word(pHdrToSwab->sh_size);
	pHdrToSwab->sh_link		= SWAB_Elf32_Word(pHdrToSwab->sh_link);
	pHdrToSwab->sh_info		= SWAB_Elf32_Word(pHdrToSwab->sh_info);
	pHdrToSwab->sh_addralign	= SWAB_Elf32_Word(pHdrToSwab->sh_addralign);
	pHdrToSwab->sh_addralign	= SWAB_Elf32_Word(pHdrToSwab->sh_addralign);
}


/**
 *
 * @brief byte swap the Elf32_Sym structure
 *
 * @returns N/A
 */
static void swabElfSym(Elf32_Sym *pHdrToSwab)
{
	if (swabRequired == 0)
	{
		return;  /* do nothing */
	}

	pHdrToSwab->st_name		= SWAB_Elf32_Word(pHdrToSwab->st_name);
	pHdrToSwab->st_value	= SWAB_Elf32_Addr(pHdrToSwab->st_value);
	pHdrToSwab->st_size		= SWAB_Elf32_Word(pHdrToSwab->st_size);
	pHdrToSwab->st_shndx	= SWAB_Elf32_Half(pHdrToSwab->st_shndx);
}

/**
 * @brief load the ELF header
 *
 * @param fd file descriptor of file from which to read
 * @returns 0 on success, -1 on failure
 */
static int ehdrLoad(int fd)
{
	unsigned  ix = 0x12345678;  /* used to auto-detect endian-ness */
	size_t    nBytes;           /* number of bytes read from file */

	if (lseek(fd, 0, SEEK_SET) == -1) {
		fprintf(stderr, "Unable to seek\n");
		return -1;
	}

	nBytes = read(fd, &ehdr, sizeof(ehdr));
	if (nBytes != sizeof(ehdr))
	{
		fprintf(stderr, "Failed to read ELF header\n");
		return -1;
	}

	/* perform some rudimentary ELF file validation */

	if (strncmp((char *)ehdr.e_ident, ELFMAG, 4) != 0)
	{
		fprintf(stderr, "Input object module not ELF format\n");
		return -1;
	}

	/* 64-bit ELF module not supported (for now) */

	if (ehdr.e_ident[EI_CLASS] != ELFCLASS32)
	{
		fprintf(stderr, "ELF64 class not supported\n");
		return -1;
	}

	/*
	 * Dynamically determine the endianess of the host (in the absence of
	 * a compile time macro ala _BYTE_ORDER).  The ELF structures will require
	 * byte swapping if the host and target have different byte ordering.
	 */

	if (((*(char*)&ix == 0x78) && (ehdr.e_ident[EI_DATA] == ELFDATA2MSB)) ||
			((*(char*)&ix == 0x12) && (ehdr.e_ident[EI_DATA] == ELFDATA2LSB)))
	{
		swabRequired = 1;
		DBG_PRINT("Swab required\n");
	}

	swabElfHdr(&ehdr);   /* swap bytes (if required) */

	/* debugging: dump some important ELF header fields */

	DBG_PRINT("Elf header Magic = %s\n", ehdr.e_ident);
	DBG_PRINT("Elf header e_type = %d\n", ehdr.e_type);
	DBG_PRINT("Elf header e_shstrndx = %d\n", ehdr.e_shstrndx);
	DBG_PRINT("Elf header e_shnum = %d\n", ehdr.e_shnum);

	return 0;
}

/**
 * @brief load the section headers
 * @param fd file descriptor of file from which to read
 *
 * @returns 0 on success, -1 on failure
 */
static int shdrsLoad(int fd)
{
	size_t    nBytes;    /* number of bytes read from file */
	unsigned  ix;        /* loop index */

	shdr = malloc(ehdr.e_shnum * sizeof(Elf32_Shdr));
	if (shdr == NULL)
	{
		fprintf(stderr, "No memory for section headers!\n");
		return -1;
	}

	/* Seek to the start of the table of section headers */
	if (lseek(fd, ehdr.e_shoff, SEEK_SET) == -1) {
		fprintf(stderr, "Unable to seek\n");
		return -1;
	}

	for (ix = 0; ix < ehdr.e_shnum; ix++)
	{
		nBytes = read(fd, &shdr[ix], sizeof(Elf32_Shdr));
		if (nBytes != sizeof(Elf32_Shdr))
		{
			fprintf(stderr, "Unable to read entire section header (#%d)\n",
					ix);
			return -1;
		}

		swabElfSectionHdr(&shdr[ix]);   /* swap bytes (if required) */
	}

	return 0;
}

/**
 *
 * symTblFind - search the section headers for the symbol table
 *
 * This routine searches the section headers for the symbol table.  There is
 * expected to be only one symbol table in the section headers.
 *
 * @param pSymTblOffset ptr to symbol table offset
 * @param pSymTblSize ptr to symbol table size
 * @returns 0 if found, -1 if not
 */
static int symTblFind(unsigned *pSymTblOffset, unsigned *pSymTblSize)
{
	unsigned  ix;    /* loop index */

	for (ix = 0; ix < ehdr.e_shnum; ++ix)
	{
		if (shdr[ix].sh_type == SHT_SYMTAB)
		{
			*pSymTblOffset = shdr[ix].sh_offset;
			*pSymTblSize   = shdr[ix].sh_size;

			return 0;
		}
	}

	fprintf(stderr, "Object module missing symbol table!\n");

	return -1;
}

/**
 *
 * @brief search the section headers for the string table
 *
 * This routine searches the section headers for the string table associated
 * with the symbol names.
 *
 * Typically, there are two string tables defined in the section headers.  These
 * are ".shstrtbl" and ".strtbl" for section header names and symbol names
 * respectively.  It has been observed with the DIAB compiler (but not with
 * either the GCC nor ICC compilers) that the two tables may be mashed together
 * into one.  Consequently, the following algorithm is used to select the
 * appropriate string table.
 *
 * 1. Assume that the first found string table is valid.
 * 2. If another string table is found, use that only if its section header
 *    index does not match the index for ".shstrtbl" stored in the ELF header.
 *
 * @param pStrTblIx ptr to string table's index
 * @returns 0 if found, -1 if not
 */
static int strTblFind(unsigned *pStrTblIx)
{
	unsigned  strTblIx = 0xffffffff;
	unsigned  ix;

	for (ix = 0; ix < ehdr.e_shnum; ++ix)
	{
		if (shdr[ix].sh_type == SHT_STRTAB)
		{
			if ((strTblIx == 0xffffffff) ||
					(ix != ehdr.e_shstrndx))
			{
				strTblIx = ix;
			}
		}
	}

	if (strTblIx == 0xffffffff)
	{
		fprintf(stderr, "Object module missing string table!\n");
		return -1;
	}

	*pStrTblIx = strTblIx;

	return 0;
}

/**
 * @brief load the string table
 *
 * @param fd file descriptor of file from which to read
 * @param strTblIx string table's index
 * @param ppStringTable ptr to ptr to string table
 * @returns 0 on success, -1 on failure
 */
static int strTblLoad(int fd, unsigned strTblIx, char **ppStringTable)
{
	char *  pTable;
	int     nBytes;

	DBG_PRINT("Allocating %d bytes for string table\n",
			shdr[strTblIx].sh_size);

	pTable = malloc(shdr[strTblIx].sh_size);
	if (pTable == NULL)
	{
		fprintf(stderr, "No memory for string table!");
		return -1;
	}

	if (lseek(fd, shdr[strTblIx].sh_offset, SEEK_SET) == -1) {
		free(pTable);
		fprintf(stderr, "Unable to seek\n");
		return -1;
	}

	nBytes = read(fd, pTable, shdr[strTblIx].sh_size);
	if (nBytes != shdr[strTblIx].sh_size)
	{
		free(pTable);
		fprintf(stderr, "Unable to read entire string table!\n");
		return -1;
	}

	*ppStringTable = pTable;

	return 0;
}

/**
 *
 * @brief dump the header preamble to the header file
 *
 * @param fd file pointer to which to write
 * @parama filename name of the output file
 * @returns N/A
 */
static void headerPreambleDump(FILE *fp, char *filename)
{
	unsigned hash = 5381;      /* hash value */
	size_t   ix;               /* loop counter */
	char     fileNameHash[20]; /* '_HGUARD_' + 8 character hash + '\0' */

	/* dump header file preamble1[] */

	fprintf(fp, preamble1, filename, filename, filename);

	/*
	 * Dump header file preamble2[]. Hash file name into something that
	 * is small enough to be a C macro name and does not have invalid
	 * characters for a macro name to use as a header guard. The result
	 * of the hash should be unique enough for our purposes.
	 */

	for (ix = 0; ix < sizeof(filename); ++ix)
	{
		hash = (hash * 33) + (unsigned int) filename[ix];
	}

	sprintf(fileNameHash, "_HGUARD_%08x", hash);
	fprintf(fp, preamble2, fileNameHash, fileNameHash);
}

/**
 * @brief dump the absolute symbols to the header file
 *
 * @param fd file descriptor of file from which to read
 * @param fp file pointer to which to write
 * @param symTblOffset symbol table offset
 * @param symTblSize size of the symbol table
 * @param pStringTable ptr to the string table
 * @returns N/A
 */
static void headerAbsoluteSymbolsDump(int fd, FILE *fp, Elf32_Off symTblOffset,
		Elf32_Word symTblSize, char *pStringTable)
{
	Elf32_Sym  aSym;     /* absolute symbol */
	unsigned   ix;       /* loop counter */
	unsigned   numSyms;  /* number of symbols in the symbol table */
	size_t	   nBytes;

	/* context the symbol table: pick out absolute syms */

	numSyms = symTblSize / sizeof(Elf32_Sym);
	if (lseek(fd, symTblOffset, SEEK_SET) == -1) {
		fprintf(stderr, "Unable to seek\n");
		return;
	}

	for (ix = 0; ix < numSyms; ++ix)
	{
		/* read in a single symbol structure */
		nBytes = read(fd, &aSym, sizeof(Elf32_Sym));

		if (nBytes) {
			swabElfSym(&aSym);    /* swap bytes (if required) */
		}

		/*
		 * Only generate definitions for global absolute symbols
		 * of the form *_OFFSET
		 */

		if ((aSym.st_shndx == SHN_ABS) &&
				(ELF_ST_BIND(aSym.st_info) == STB_GLOBAL))
		{
			if ((strstr(&pStringTable[aSym.st_name],
							STRUCT_OFF_SUFFIX) != NULL) ||
					(strstr(&pStringTable[aSym.st_name],
						 STRUCT_SIZ_SUFFIX) != NULL))
			{
				fprintf(fp, "#define\t%s\t0x%X\n",
						&pStringTable[aSym.st_name], aSym.st_value);
			}
		}
	}
}

/**
 *
 * @brief dump the header postscript to the header file
 * @param fp file pointer to which to write
 * @returns N/A
 */
static void headerPostscriptDump(FILE *fp)
{
	fputs(postscript, fp);
}

/**
 * @brief entry point for the genOffsetHeader utility
 *
 * usage: $ genOffsetHeader -i <objectModule> -o <outputHeaderName>
 *
 * @returns 0 on success, 1 on failure
 */
int main(int argc, char *argv[])
{
	Elf32_Off	symTblOffset = 0;
	Elf32_Word	symTblSize;		/* in bytes */
	char *	pStringTable = NULL;
	char *	inFileName = NULL;
	char *	outFileName = NULL;
	int		option;
	int		inFd = -1;
	FILE *	outFile = NULL;
	unsigned    strTblIx;

	/* argument parsing */

	if (argc != 5)
	{
		fprintf(stderr, usage, argv[0]);
		goto errorReturn;
	}

	while ((option = getopt(argc, argv, "i:o:")) != -1)
	{
		switch (option)
		{
			case 'i':
				inFileName = optarg;
				break;
			case 'o':
				outFileName = optarg;
				break;
			default:
				fprintf(stderr, usage, argv[0]);
				goto errorReturn;
		}
	}

	/* open input object ELF module and output header file */

	inFd = open(inFileName, OPEN_FLAGS);

	if (inFd == -1)
	{
		fprintf(stderr, "Cannot open input object module");
		goto errorReturn;
	}

	outFile = fopen(outFileName, "w");

	if (outFile == NULL)
	{
		fprintf(stderr, "Cannot open output header file");
		goto errorReturn;
	}

	/*
	 * In the following order, attempt to ...
	 *  1. Load the ELF header
	 *  2. Load the section headers
	 *  3. Find the symbol table
	 *  4. Find the string table
	 *  5. Load the string table
	 * Bail if any of those steps fail.
	 */

	if ((ehdrLoad(inFd) != 0) ||
			(shdrsLoad(inFd) != 0) ||
			(symTblFind(&symTblOffset, &symTblSize) != 0) ||
			(strTblFind(&strTblIx) != 0) ||
			(strTblLoad(inFd, strTblIx, &pStringTable) != 0))
	{
		goto errorReturn;
	}


	/*
	 * Dump the following to the header file ...
	 *  1. Header file preamble
	 *  2. Absolute symbols
	 *  3. Header file postscript
	 */

	headerPreambleDump(outFile, outFileName);
	headerAbsoluteSymbolsDump(inFd, outFile,
			symTblOffset, symTblSize, pStringTable);
	headerPostscriptDump(outFile);

	/* done: cleanup */

	close(inFd);
	fclose(outFile);
	free(shdr);
	free(pStringTable);

	return 0;

errorReturn:
	if (inFd != -1)
	{
		close(inFd);
	}

	if (outFile != NULL)
	{
		fclose(outFile);
	}

	if (shdr != NULL)
	{
		free(shdr);
	}

	if (pStringTable != NULL)
	{
		free(pStringTable);
	}

	return 1;
}