summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/elf.h
blob: cceb13e256b50411918177f93b38f1a22d5ac7b0 (plain)
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
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * 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.
 */
/*
  Copyright (c) 2001, 2002, 2003 Eliot Dresselhaus

  Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files (the
  "Software"), to deal in the Software without restriction, including
  without limitation the rights to use, copy, modify, merge, publish,
  distribute, sublicense, and/or sell copies of the Software, and to
  permit persons to whom the Software is furnished to do so, subject to
  the following conditions:

  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef included_clib_elf_h
#define included_clib_elf_h

#include <vppinfra/format.h>
#include <vppinfra/hash.h>
#include <vppinfra/vec.h>
#include <vppinfra/byte_order.h>

#define foreach_elf_file_class \
  _ (CLASS_NONE) _ (32BIT) _ (64BIT)

#define foreach_elf_data_encoding		\
  _ (ENCODING_NONE)				\
  _ (TWOS_COMPLEMENT_LITTLE_ENDIAN)		\
  _ (TWOS_COMPLEMENT_BIG_ENDIAN)

#define ELF_VERSION_NONE (0)
#define ELF_VERSION_CURRENT (1)

#define foreach_elf_abi				\
  _ (SYSV, 0)					\
  _ (HPUX, 1)					\
  _ (NETBSD, 2)					\
  _ (LINUX, 3)					\
  _ (SOLARIS, 6)				\
  _ (AIX, 7)					\
  _ (IRIX, 8)					\
  _ (FREEBSD, 9)				\
  _ (COMPAQ_TRU64, 10)				\
  _ (MODESTO, 11)				\
  _ (OPENBSD, 12)				\
  _ (ARM, 97)					\
  _ (STANDALONE, 255)

/* Legal values for type (object file type).  */
#define foreach_elf_file_type			\
  _ (NONE, 0)					\
  _ (RELOC, 1)					\
  _ (EXEC, 2)					\
  _ (SHARED, 3)					\
  _ (CORE, 4)					\
  _ (OS_SPECIFIC_LO, 0xfe00)			\
  _ (OS_SPECIFIC_HI, 0xfeff)			\
  _ (ARCH_SPECIFIC_LO, 0xff00)			\
  _ (ARCH_SPECIFIC_HI, 0xffff)

/* Legal values for architecture.  */
#define foreach_elf_architecture					\
  _ (NONE, 0)			/* No machine */			\
  _ (M32, 1)			/* AT&T WE 32100 */			\
  _ (SPARC, 2)			/* SUN SPARC */				\
  _ (386, 3)			/* Intel 80386 */			\
  _ (68K, 4)			/* Motorola m68k family */		\
  _ (88K, 5)			/* Motorola m88k family */		\
  _ (860, 7)			/* Intel 80860 */			\
  _ (MIPS, 8)			/* MIPS R3000 big-endian */		\
  _ (S370, 9)			/* IBM System/370 */			\
  _ (MIPS_RS3_LE, 10)		/* MIPS R3000 little-endian */		\
  _ (PARISC, 15)		/* HPPA */				\
  _ (VPP500, 17)		/* Fujitsu VPP500 */			\
  _ (SPARC32PLUS, 18)		/* Sun's "v8plus" */			\
  _ (960, 19)			/* Intel 80960 */			\
  _ (PPC, 20)			/* PowerPC */				\
  _ (PPC64, 21)			/* PowerPC 64-bit */			\
  _ (S390, 22)			/* IBM S390 */				\
  _ (V800, 36)			/* NEC V800 series */			\
  _ (FR20, 37)			/* Fujitsu FR20 */			\
  _ (RH32, 38)			/* TRW RH-32 */				\
  _ (RCE, 39)			/* Motorola RCE */			\
  _ (ARM, 40)			/* ARM */				\
  _ (FAKE_ALPHA, 41)		/* Digital Alpha */			\
  _ (SH, 42)			/* Hitachi SH */			\
  _ (SPARCV9, 43)		/* SPARC v9 64-bit */			\
  _ (TRICORE, 44)		/* Siemens Tricore */			\
  _ (ARC, 45)			/* Argonaut RISC Core */		\
  _ (H8_300, 46)		/* Hitachi H8/300 */			\
  _ (H8_300H, 47)		/* Hitachi H8/300H */			\
  _ (H8S, 48)			/* Hitachi H8S */			\
  _ (H8_500, 49)		/* Hitachi H8/500 */			\
  _ (IA_64, 50)			/* Intel Merced */			\
  _ (MIPS_X, 51)		/* Stanford MIPS-X */			\
  _ (COLDFIRE, 52)		/* Motorola Coldfire */			\
  _ (68HC12, 53)		/* Motorola M68HC12 */			\
  _ (MMA, 54)			/* Fujitsu MMA Multimedia Accel. */	\
  _ (PCP, 55)			/* Siemens PCP */			\
  _ (NCPU, 56)			/* Sony nCPU embedded RISC */		\
  _ (NDR1, 57)			/* Denso NDR1 microprocessor */		\
  _ (STARCORE, 58)		/* Motorola Start*Core processor */	\
  _ (ME16, 59)			/* Toyota ME16 processor */		\
  _ (ST100, 60)			/* STMicroelectronic ST100  */		\
  _ (TINYJ, 61)			/* Advanced Logic Corp. Tinyj */	\
  _ (X86_64, 62)		/* AMD x86-64 architecture */		\
  _ (PDSP, 63)			/* Sony DSP Processor */		\
  _ (FX66, 66)			/* Siemens FX66 microcontroller */	\
  _ (ST9PLUS, 67)		/* STMicroelectronics ST9+ 8/16 mc */	\
  _ (ST7, 68)			/* STmicroelectronics ST7 8 bit mc */	\
  _ (68HC16, 69)		/* Motorola MC68HC16 */			\
  _ (68HC11, 70)		/* Motorola MC68HC11 */			\
  _ (68HC08, 71)		/* Motorola MC68HC08 */			\
  _ (68HC05, 72)		/* Motorola MC68HC05 */			\
  _ (SVX, 73)			/* Silicon Graphics SVx */		\
  _ (ST19, 74)			/* STMicroelectronics ST19 8 bit mc */	\
  _ (VAX, 75)			/* Digital VAX */			\
  _ (CRIS, 76)			/* Axis 32-bit embedded proc. */	\
  _ (JAVELIN, 77)		/* Infineon 32-bit embedded proc. */	\
  _ (FIREPATH, 78)		/* Element 14 64-bit DSP Processor */	\
  _ (ZSP, 79)			/* LSI Logic 16-bit DSP Processor */	\
  _ (MMIX, 80)			/* Knuth's 64-bit processor */		\
  _ (HUANY, 81)			/* Harvard machine-independent */	\
  _ (PRISM, 82)			/* SiTera Prism */			\
  _ (AVR, 83)			/* Atmel AVR 8-bit microcontroller */	\
  _ (FR30, 84)			/* Fujitsu FR30 */			\
  _ (D10V, 85)			/* Mitsubishi D10V */			\
  _ (D30V, 86)			/* Mitsubishi D30V */			\
  _ (V850, 87)			/* NEC v850 */				\
  _ (M32R, 88)			/* Mitsubishi M32R */			\
  _ (MN10300, 89)		/* Matsushita MN10300 */		\
  _ (MN10200, 90)		/* Matsushita MN10200 */		\
  _ (PJ, 91)			/* picoJava */				\
  _ (OPENRISC, 92)		/* OpenRISC 32-bit processor */		\
  _ (ARC_A5, 93)		/* ARC Cores Tangent-A5 */		\
  _ (XTENSA, 94)		/* Tensilica Xtensa Architecture */	\
  _ (ALPHA, 0x9026)

#define _(f) ELF_##f,

typedef enum
{
  foreach_elf_file_class ELF_N_FILE_CLASS,
} elf_file_class_t;

typedef enum
{
  foreach_elf_data_encoding ELF_N_DATA_ENCODING,
} elf_data_encoding_t;

#undef _

#define _(f,i) ELF_##f = i,

typedef enum
{
  foreach_elf_abi
} elf_abi_t;

typedef enum
{
  foreach_elf_file_type
} elf_file_type_t;

#undef _

typedef enum
{
#define _(f,i) ELF_ARCH_##f = i,
  foreach_elf_architecture
#undef _
} elf_architecture_t;

typedef struct
{
  /* 0x7f ELF */
  u8 magic[4];

  elf_file_class_t file_class:8;
  elf_data_encoding_t data_encoding:8;
  u8 file_version_ident;
  elf_abi_t abi:8;
  u8 abi_version;

  u8 pad[7];

  elf_file_type_t file_type:16;
  elf_architecture_t architecture:16;

  u32 file_version;
} elf_first_header_t;

/* 32/64 bit file header following basic file header. */
#define foreach_elf32_file_header		\
  _ (u32, entry_point)				\
  _ (u32, segment_header_file_offset)		\
  _ (u32, section_header_file_offset)		\
  _ (u32, flags)				\
  _ (u16, n_bytes_this_header)			\
  _ (u16, segment_header_size)			\
  _ (u16, segment_header_count)			\
  _ (u16, section_header_size)			\
  _ (u16, section_header_count)			\
  _ (u16, section_header_string_table_index)

#define foreach_elf64_file_header		\
  _ (u64, entry_point)				\
  _ (u64, segment_header_file_offset)		\
  _ (u64, section_header_file_offset)		\
  _ (u32, flags)				\
  _ (u16, n_bytes_this_header)			\
  _ (u16, segment_header_size)			\
  _ (u16, segment_header_count)			\
  _ (u16, section_header_size)			\
  _ (u16, section_header_count)			\
  _ (u16, section_header_string_table_index)

/* Section header.  */
#define foreach_elf32_section_header		\
  _ (u32, name)					\
  _ (u32, type)					\
  _ (u32, flags)				\
  _ (u32, exec_address)				\
  _ (u32, file_offset)				\
  _ (u32, file_size)				\
  _ (u32, link)					\
  _ (u32, additional_info)			\
  _ (u32, align)				\
  _ (u32, entry_size)

#define foreach_elf64_section_header		\
  _ (u32, name)					\
  _ (u32, type)					\
  _ (u64, flags)				\
  _ (u64, exec_address)				\
  _ (u64, file_offset)				\
  _ (u64, file_size)				\
  _ (u32, link)					\
  _ (u32, additional_info)			\
  _ (u64, align)				\
  _ (u64, entry_size)

/* Program segment header.  */
#define foreach_elf32_segment_header		\
  _ (u32, type)					\
  _ (u32, file_offset)				\
  _ (u32, virtual_address)			\
  _ (u32, physical_address)			\
  _ (u32, file_size)				\
  _ (u32, memory_size)				\
  _ (u32, flags)				\
  _ (u32, align)

#define foreach_elf64_segment_header		\
  _ (u32, type)					\
  _ (u32, flags)				\
  _ (u64, file_offset)				\
  _ (u64, virtual_address)			\
  _ (u64, physical_address)			\
  _ (u64, file_size)				\
  _ (u64, memory_size)				\
  _ (u64, align)

/* Symbol table.  */
#define foreach_elf32_symbol_header		\
  _ (u32, name)					\
  _ (u32, value)				\
  _ (u32, size)					\
  /* binding upper 4 bits; type lower 4 bits */	\
  _ (u8, binding_and_type)			\
  _ (u8, visibility)				\
  _ (u16, section_index)

#define foreach_elf64_symbol_header		\
  _ (u32, name)					\
  _ (u8, binding_and_type)			\
  _ (u8, visibility)				\
  _ (u16, section_index)			\
  _ (u64, value)				\
  _ (u64, size)

#define _(t,f) t f;

typedef struct
{
foreach_elf32_file_header} elf32_file_header_t;

typedef struct
{
foreach_elf64_file_header} elf64_file_header_t;

typedef struct
{
foreach_elf32_section_header} elf32_section_header_t;

typedef struct
{
foreach_elf64_section_header} elf64_section_header_t;

typedef struct
{
foreach_elf32_segment_header} elf32_segment_header_t;

typedef struct
{
foreach_elf64_segment_header} elf64_segment_header_t;

typedef struct
{
foreach_elf32_symbol_header} elf32_symbol_t;

typedef struct
{
foreach_elf64_symbol_header} elf64_symbol_t;
#undef _

/* Special section names.  */
#define foreach_elf_symbol_reserved_section_index			\
  _ (ABSOLUTE, 0xfff1)		/* Associated symbol is absolute */	\
  _ (COMMON, 0xfff2)		/* Associated symbol is common */	\
  _ (XINDEX, 0xffff)		/* Index is in extra table.  */

#define ELF_SYMBOL_SECTION_RESERVED_LO 0xff00
#define ELF_SYMBOL_SECTION_RESERVED_HI 0xffff
#define ELF_SYMBOL_SECTION_ARCH_SPECIFIC_LO 0xff00
#define ELF_SYMBOL_SECTION_ARCH_SPECIFIC_HI 0xff1f
#define ELF_SYMBOL_SECTION_OS_SPECIFIC_LO 0xff20
#define ELF_SYMBOL_SECTION_OS_SPECIFIC_HI 0xff3f

/* Section types. */
#define foreach_elf_section_type					\
  _ (UNUSED, 0)								\
  _ (PROGRAM_DATA, 1)							\
  _ (SYMBOL_TABLE, 2)							\
  _ (STRING_TABLE, 3)							\
  _ (RELOCATION_ADD, 4)							\
  _ (SYMBOL_TABLE_HASH, 5)						\
  _ (DYNAMIC, 6)		/* Dynamic linking information */	\
  _ (NOTE, 7)			/* Notes */				\
  _ (NO_BITS, 8)		/* Program space with no data (bss) */	\
  _ (RELOCATION, 9)		/* Relocation entries, no addends */	\
  _ (DYNAMIC_SYMBOL_TABLE, 11)	/* Dynamic linker symbol table */	\
  _ (INIT_ARRAY, 14)		/* Array of constructors */		\
  _ (FINI_ARRAY, 15)		/* Array of destructors */		\
  _ (PREINIT_ARRAY, 16)		/* Array of pre-constructors */		\
  _ (GROUP, 17)			/* Section group */			\
  _ (SYMTAB_SHNDX, 18)		/* Extended section indices */		\
  _ (OS_SPECIFIC_LO, 0x60000000) /* Start OS-specific */		\
  _ (GNU_LIBLIST, 0x6ffffff7)	/* Prelink library list */		\
  _ (CHECKSUM, 0x6ffffff8)	/* Checksum for DSO content.  */	\
  _ (SUNW_MOVE, 0x6ffffffa)						\
  _ (SUNW_COMDAT, 0x6ffffffb)						\
  _ (SUNW_SYMINFO, 0x6ffffffc)						\
  _ (GNU_VERDEF, 0x6ffffffd)	/* Version definition section.  */	\
  _ (GNU_VERNEED, 0x6ffffffe) /* Version needs section.  */		\
  _ (GNU_VERSYM, 0x6fffffff)	/* Version symbol table.  */		\
  _ (ARCH_SPECIFIC_LO, 0x70000000) /* Start of processor-specific */	\
  _ (ARCH_SPECIFIC_HI, 0x7fffffff) /* End of processor-specific */	\
  _ (APP_SPECIFIC_LO, 0x80000000) /* Start of application-specific */	\
  _ (APP_SPECIFIC_HI, 0x8fffffff)	/* End of application-specific */

/* Section flags. */
#define foreach_elf_section_flag		\
  _ (WRITE, 0)					\
  _ (ALLOC, 1)					\
  _ (EXEC, 2)					\
  _ (MERGE, 3)					\
  _ (STRING_TABLE, 5)				\
  _ (INFO_LINK, 6)				\
  _ (PRESERVE_LINK_ORDER, 7)			\
  _ (OS_NON_CONFORMING, 8)			\
  _ (GROUP, 9)					\
  _ (TLS, 10)					\
  _ (OS_SPECIFIC_LO, 20)			\
  _ (OS_SPECIFIC_HI, 27)			\
  _ (ARCH_SPECIFIC_LO, 28)			\
  _ (ARCH_SPECIFIC_HI, 31)

typedef enum
{
#define _(f,i) ELF_SECTION_##f = i,
  foreach_elf_section_type
#undef _
    ELF_SECTION_OS_SPECIFIC_HI = 0x6fffffff,
} elf_section_type_t;

typedef enum
{
#define _(f,i) ELF_SECTION_FLAG_BIT_##f = i,
  foreach_elf_section_flag
#undef _
} elf_section_flag_bit_t;

typedef enum
{
#define _(f,i) ELF_SECTION_FLAG_##f = 1 << ELF_SECTION_FLAG_BIT_##f,
  foreach_elf_section_flag
#undef _
} elf_section_flag_t;

/* Symbol bindings (upper 4 bits of binding_and_type). */
#define foreach_elf_symbol_binding					\
  _ (LOCAL, 0)			/* Local symbol */			\
  _ (GLOBAL, 1)			/* Global symbol */			\
  _ (WEAK, 2)			/* Weak symbol */			\
  _ (OS_SPECIFIC_LO, 10)	/* Start of OS-specific */		\
  _ (OS_SPECIFIC_HI, 12)	/* End of OS-specific */		\
  _ (ARCH_SPECIFIC_LO, 13)	/* Start of processor-specific */	\
  _ (ARCH_SPECIFIC_HI, 15)	/* End of processor-specific */

/* Symbol types (lower 4 bits of binding_and_type). */
#define foreach_elf_symbol_type						\
  _ (NONE, 0)								\
  _ (DATA, 1)			/* Symbol is a data object */		\
  _ (CODE, 2)			/* Symbol is a code object */		\
  _ (SECTION, 3)		/* Symbol associated with a section */	\
  _ (FILE, 4)			/* Symbol's name is file name */	\
  _ (COMMON, 5)			/* Symbol is a common data object */	\
  _ (TLS, 6)			/* Symbol is thread-local data */	\
  _ (OS_SPECIFIC_LO, 10)	/* Start of OS-specific */		\
  _ (OS_SPECIFIC_HI, 12)	/* End of OS-specific */		\
  _ (ARCH_SPECIFIC_LO, 13)	/* Start of processor-specific */	\
  _ (ARCH_SPECIFIC_HI, 15)	/* End of processor-specific */

/* Symbol visibility. */
#define foreach_elf_symbol_visibility					\
  _ (DEFAULT, 0)		/* Default symbol visibility rules */	\
  _ (INTERNAL, 1)		/* Processor specific hidden class */	\
  _ (HIDDEN, 2)			/* Unavailable in other modules */	\
  _ (PROTECTED, 3)		/* Not preemptible, not exported */

/* The syminfo section if available contains additional
   information about every dynamic symbol.  */
typedef struct
{
  u16 bound_to;
  u16 flags;
} elf_symbol_info_t;

/* Possible values for bound_to.  */
#define foreach_elf_symbol_info_bound_to			\
  _ (SELF, 0xffff)		/* Symbol bound to self */	\
  _ (PARENT, 0xfffe)		/* Symbol bound to parent */	\
  _ (RESERVED_LO, 0xff00)					\
  _ (RESERVED_HI, 0xffff)

/* Symbol info flags. */
#define foreach_elf_symbol_info_flags					\
  _ (DIRECT)			/* Direct bound symbol */		\
  _ (PASS_THRU)			/* Pass-thru symbol for translator */	\
  _ (COPY)			/* Symbol is a copy-reloc */		\
  _ (LAZY_LOAD)			/* Symbol bound to object to be lazy loaded */

/* Relocation table entry with/without addend. */
typedef struct
{
  u32 address;
  u32 symbol_and_type;		/* high 24 symbol, low 8 type. */
  i32 addend[0];
} elf32_relocation_t;

typedef struct
{
  u64 address;
  u64 symbol_and_type;		/* high 32 symbol, low 32 type. */
  i64 addend[0];
} elf64_relocation_t;

typedef struct
{
  u64 address;
  u64 symbol_and_type;
  u64 addend;
} elf_relocation_with_addend_t;

#define elf_relocation_next(r,type)					\
  ((void *) ((r) + 1)							\
   + ((type) == ELF_SECTION_RELOCATION_ADD ? sizeof ((r)->addend[0]) : 0))

/* Segment type. */
#define foreach_elf_segment_type					\
  _ (UNUSED, 0)								\
  _ (LOAD, 1)			/* Loadable program segment */		\
  _ (DYNAMIC, 2)		/* Dynamic linking information */	\
  _ (INTERP, 3)			/* Program interpreter */		\
  _ (NOTE, 4)			/* Auxiliary information */		\
  _ (SEGMENT_TABLE, 6)		/* Entry for header table itself */	\
  _ (TLS, 7)			/* Thread-local storage segment */	\
  _ (OS_SPECIFIC_LO, 0x60000000) /* Start of OS-specific */		\
  _ (GNU_EH_FRAME, 0x6474e550)	/* GCC .eh_frame_hdr segment */		\
  _ (GNU_STACK, 0x6474e551)	/* Indicates stack executability */	\
  _ (GNU_RELRO, 0x6474e552)	/* Read-only after relocation */	\
  _ (SUNW_BSS, 0x6ffffffa)	/* Sun specific BSS */			\
  _ (SUNW_STACK, 0x6ffffffb)	/* Sun specific stack */		\
  _ (OS_SPECIFIC_HI, 0x6fffffff) /* End of OS-specific */		\
  _ (ARCH_SPECIFIC_LO, 0x70000000) /* Start of processor-specific */	\
  _ (ARCH_SPECIFIC_HI, 0x7fffffff)	/* End of processor-specific */

/* Segment flags. */
#define foreach_elf_segment_flag		\
  _ (EXEC, 0)					\
  _ (WRITE, 1)					\
  _ (READ, 2)					\
  _ (OS_SPECIFIC_LO, 20)			\
  _ (OS_SPECIFIC_HI, 27)			\
  _ (ARCH_SPECIFIC_LO, 28)			\
  _ (ARCH_SPECIFIC_HI, 31)

typedef enum
{
#define _(f,i) ELF_SEGMENT_##f = i,
  foreach_elf_segment_type
#undef _
} elf_segment_type_t;

typedef enum
{
#define _(f,i) ELF_SEGMENT_FLAG_BIT_##f = i,
  foreach_elf_segment_flag
#undef _
} elf_segment_flag_bit_t;

typedef enum
{
#define _(f,i) ELF_SEGMENT_FLAG_##f = 1 << ELF_SEGMENT_FLAG_BIT_##f,
  foreach_elf_segment_flag
#undef _
} elf_segment_flag_t;

#define foreach_elf32_dynamic_entry_header	\
  _ (u32, type)					\
  _ (u32, data)

#define foreach_elf64_dynamic_entry_header	\
  _ (u64, type)					\
  _ (u64, data)

#define _(t,f) t f;

typedef struct
{
foreach_elf32_dynamic_entry_header} elf32_dynamic_entry_t;

typedef struct
{
foreach_elf64_dynamic_entry_header} elf64_dynamic_entry_t;

#undef _

#define foreach_elf_dynamic_entry_type					\
  _ (END, 0)			/* Marks end of dynamic section */	\
  _ (NEEDED_LIBRARY, 1)		/* Name of needed library */		\
  _ (PLT_RELOCATION_SIZE, 2)	/* Size in bytes of PLT relocs */	\
  _ (PLT_GOT, 3)		/* Processor defined value */		\
  _ (SYMBOL_HASH, 4)		/* Address of symbol hash table */	\
  _ (STRING_TABLE, 5)		/* Address of string table */		\
  _ (SYMBOL_TABLE, 6)		/* Address of symbol table */		\
  _ (RELA_ADDRESS, 7)		/* Address of Rela relocs */		\
  _ (RELA_SIZE, 8)		/* Total size of Rela relocs */		\
  _ (RELA_ENTRY_SIZE, 9)	/* Size of one Rela reloc */		\
  _ (STRING_TABLE_SIZE, 10)	/* Size of string table */		\
  _ (SYMBOL_TABLE_ENTRY_SIZE, 11) /* Size of one symbol table entry */	\
  _ (INIT_FUNCTION, 12)		/* Address of init function */		\
  _ (FINI_FUNCTION, 13)		/* Address of termination function */	\
  _ (SONAME, 14)		/* Name of shared object */		\
  _ (RPATH, 15)			/* Library search path (deprecated) */	\
  _ (SYMBOLIC, 16)		/* Start symbol search here */		\
  _ (REL, 17)			/* Address of Rel relocs */		\
  _ (RELSZ, 18)			/* Total size of Rel relocs */		\
  _ (RELENT, 19)		/* Size of one Rel reloc */		\
  _ (PLT_RELOCATION_TYPE, 20)	/* Type of reloc in PLT */		\
  _ (DEBUG, 21)			/* For debugging; unspecified */	\
  _ (TEXTREL, 22)		/* Reloc might modify .text */		\
  _ (PLT_RELOCATION_ADDRESS, 23) /* Address of PLT relocs */		\
  _ (BIND_NOW, 24)		/* Process relocations of object */	\
  _ (INIT_ARRAY, 25)		/* Array with addresses of init fct */	\
  _ (FINI_ARRAY, 26)		/* Array with addresses of fini fct */	\
  _ (INIT_ARRAYSZ, 27)		/* Size in bytes of DT_INIT_ARRAY */	\
  _ (FINI_ARRAYSZ, 28)		/* Size in bytes of DT_FINI_ARRAY */	\
  _ (RUN_PATH, 29)		/* Library search path */		\
  _ (FLAGS, 30)			/* Flags for object being loaded */	\
  _ (ENCODING, 31)		/* Start of encoded range */		\
  _ (PREINIT_ARRAY, 32)		/* Array with addresses of fns */	\
  _ (PREINIT_ARRAY_SIZE, 33)	/* Size of PREINIT_ARRAY in bytes. */	\
  _ (GNU_PRELINKED, 0x6ffffdf5)	/* Prelinking timestamp */		\
  _ (GNU_CONFLICTSZ, 0x6ffffdf6)	/* Size of conflict section */	\
  _ (GNU_LIBLISTSZ, 0x6ffffdf7)	/* Size of library list */		\
  _ (CHECKSUM, 0x6ffffdf8)						\
  _ (PLTPADSZ, 0x6ffffdf9)						\
  _ (MOVEENT, 0x6ffffdfa)						\
  _ (MOVESZ, 0x6ffffdfb)						\
  _ (FEATURE_1,	0x6ffffdfc)	/* Feature selection (DTF_*).  */	\
  _ (POSFLAG_1,	0x6ffffdfd)	/* Flags for following entries.  */	\
  _ (SYMINSZ, 0x6ffffdfe)	/* Size of syminfo table (in bytes) */	\
  _ (SYMINENT, 0x6ffffdff)	/* Entry size of syminfo */		\
  _ (GNU_HASH, 0x6ffffef5)						\
  _ (GNU_CONFLICT, 0x6ffffef8)	/* Start of conflict section */		\
  _ (GNU_LIBLIST, 0x6ffffef9)	/* Library list */			\
  _ (CONFIG, 0x6ffffefa)	/* Configuration information.  */	\
  _ (DEPAUDIT, 0x6ffffefb)	/* Dependency auditing.  */		\
  _ (AUDIT, 0x6ffffefc)	/* Object auditing.  */				\
  _ (PLTPAD, 0x6ffffefd)	/* PLT padding.  */			\
  _ (MOVETAB, 0x6ffffefe)	/* Move table.  */			\
  _ (SYMINFO, 0x6ffffeff)	/* Syminfo table.  */			\
  _ (VERSYM, 0x6ffffff0)						\
  _ (RELACOUNT, 0x6ffffff9)						\
  _ (RELCOUNT, 0x6ffffffa)						\
  _ (FLAGS_1, 0x6ffffffb)	/* State flags, see DF_1_* below.  */	\
  _ (VERSION_DEF, 0x6ffffffc)	/* Address of version definition table */ \
  _ (VERSION_DEF_COUNT, 0x6ffffffd)	/* Number of version definitions */ \
  _ (VERSION_NEED, 0x6ffffffe)	/* Address of table with needed versions */ \
  _ (VERSION_NEED_COUNT, 0x6fffffff)	/* Number of needed versions */	\
  _ (AUXILIARY, 0x7ffffffd)      /* Shared object to load before self */ \
  _ (FILTER, 0x7fffffff)	/* Shared object to get values from */

typedef enum
{
#define _(f,n) ELF_DYNAMIC_ENTRY_##f = (n),
  foreach_elf_dynamic_entry_type
#undef _
} elf_dynamic_entry_type_t;

/* Values of `d_un.d_val' in the DT_FLAGS entry.  */
#define ELF_DYNAMIC_FLAGS_ORIGIN	(1 << 0)	/* Object may use DF_ORIGIN */
#define ELF_DYNAMIC_FLAGS_SYMBOLIC	(1 << 1)	/* Symbol resolutions starts here */
#define ELF_DYNAMIC_FLAGS_TEXT_RELOCATIONS (1 << 2)	/* Object contains text relocations */
#define ELF_DYNAMIC_FLAGS_BIND_NOW	(1 << 3)	/* No lazy binding for this object */
#define ELF_DYNAMIC_FLAGS_STATIC_TLS	(1 << 4)	/* Module uses the static TLS model */

/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
   entry in the dynamic section.  */
#define DF_1_NOW	0x00000001	/* Set RTLD_NOW for this object.  */
#define DF_1_GLOBAL	0x00000002	/* Set RTLD_GLOBAL for this object.  */
#define DF_1_GROUP	0x00000004	/* Set RTLD_GROUP for this object.  */
#define DF_1_NODELETE	0x00000008	/* Set RTLD_NODELETE for this object. */
#define DF_1_LOADFLTR	0x00000010	/* Trigger filtee loading at runtime. */
#define DF_1_INITFIRST	0x00000020	/* Set RTLD_INITFIRST for this object */
#define DF_1_NOOPEN	0x00000040	/* Set RTLD_NOOPEN for this object.  */
#define DF_1_ORIGIN	0x00000080	/* $ORIGIN must be handled.  */
#define DF_1_DIRECT	0x00000100	/* Direct binding enabled.  */
#define DF_1_TRANS	0x00000200
#define DF_1_INTERPOSE	0x00000400	/* Object is used to interpose.  */
#define DF_1_NODEFLIB	0x00000800	/* Ignore default lib search path.  */
#define DF_1_NODUMP	0x00001000	/* Object can't be dldump'ed.  */
#define DF_1_CONFALT	0x00002000	/* Configuration alternative created. */
#define DF_1_ENDFILTEE	0x00004000	/* Filtee terminates filters search. */
#define	DF_1_DISPRELDNE	0x00008000	/* Disp reloc applied at build time. */
#define	DF_1_DISPRELPND	0x00010000	/* Disp reloc applied at run-time.  */

/* Flags for the feature selection in DT_FEATURE_1.  */
#define DTF_1_PARINIT	0x00000001
#define DTF_1_CONFEXP	0x00000002

/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry.  */
#define DF_P1_LAZYLOAD	0x00000001	/* Lazyload following object.  */
#define DF_P1_GROUPPERM	0x00000002	/* Symbols from next object are not
					   generally available.  */

/* Version definition sections.  */
typedef struct
{
  u16 version;
  u16 flags;
  u16 index;
  u16 aux_count;
  u32 name_hash;
  u32 aux_byte_offset;
  u32 byte_offset_next_version_definition;
} elf_dynamic_version_definition_t;

typedef struct
{
  u32 name;
  u32 next_offset;		/* byte offset of ver def aux next entry */
} elf_dynamic_version_definition_aux_t;

/* Version definition flags. */
#define ELF_DYNAMIC_VERSION_FILE (1 << 0)	/* Version definition of file itself */
#define ELF_DYNAMIC_VERSION_WEAK (1 << 1)	/* Weak version identifier */

/* Version symbol index. */
#define	ELF_DYNAMIC_VERSYM_LOCAL 0	/* Symbol is local.  */
#define	ELF_DYNAMIC_VERSYM_GLOBAL 1	/* Symbol is global.  */
#define	ELF_DYNAMIC_VERSYM_RESERVED_LO	0xff00	/* Beginning of reserved entries.  */
#define	ELF_DYNAMIC_VERSYM_ELIMINATE	0xff01	/* Symbol is to be eliminated.  */

/* Version dependency section.  */
#define foreach_elf_dynamic_version_need_field	\
  _ (u16, version)				\
  _ (u16, aux_count)				\
  _ (u32, file_name_offset)			\
  _ (u32, first_aux_offset)			\
  _ (u32, next_offset)

#define foreach_elf_dynamic_version_need_aux_field	\
  _ (u32, hash)						\
  _ (u16, flags)					\
  _ (u16, versym_index)					\
  _ (u32, name)						\
  _ (u32, next_offset)

typedef struct
{
#define _(t,f) t f;
  foreach_elf_dynamic_version_need_field
#undef _
} elf_dynamic_version_need_t;

typedef struct
{
#define _(t,f) t f;
  foreach_elf_dynamic_version_need_aux_field
#undef _
} elf_dynamic_version_need_aux_t;

typedef union
{
  elf_dynamic_version_need_t need;
  elf_dynamic_version_need_aux_t aux;
} elf_dynamic_version_need_union_t;

/* Note section contents.  Each entry in the note section begins with
   a header of a fixed form.  */

typedef struct
{
  u32 name_size;
  u32 descriptor_size;
  u32 type;
} elf_note_t;

/* Known names of notes.  */

/* Solaris entries in the note section have this name.  */
#define ELF_NOTE_SOLARIS	"SUNW Solaris"

/* Note entries for GNU systems have this name.  */
#define ELF_NOTE_GNU		"GNU"


/* Defined types of notes for Solaris.  */

/* Value of descriptor (one word) is desired pagesize for the binary.  */
#define ELF_NOTE_PAGESIZE_HINT	1


/* Defined note types for GNU systems.  */

/* ABI information.  The descriptor consists of words:
   word 0: OS descriptor
   word 1: major version of the ABI
   word 2: minor version of the ABI
   word 3: subminor version of the ABI
*/
#ifndef ELF_NOTE_ABI
#define ELF_NOTE_ABI		1
#endif

/* Known OSes.  These value can appear in word 0 of an ELF_NOTE_ABI
   note section entry.  */
#define ELF_NOTE_OS_LINUX	0
#define ELF_NOTE_OS_GNU		1
#define ELF_NOTE_OS_SOLARIS2	2
#define ELF_NOTE_OS_FREEBSD	3

/* AMD x86-64 relocations.  */
#define foreach_elf_x86_64_relocation_type				\
  _ (NONE, 0)			/* No reloc */				\
  _ (DIRECT_64, 1)		/* Direct 64 bit  */			\
  _ (PC_REL_I32, 2)	        /* PC relative 32 bit signed */		\
  _ (GOT_REL_32, 3)		/* 32 bit GOT entry */			\
  _ (PLT_REL_32, 4)		/* 32 bit PLT address */		\
  _ (COPY, 5)			/* Copy symbol at runtime */		\
  _ (CREATE_GOT, 6)		/* Create GOT entry */			\
  _ (CREATE_PLT, 7)		/* Create PLT entry */			\
  _ (RELATIVE, 8)		/* Adjust by program base */		\
  _ (PC_REL_I32_GOT, 9)	/* 32 bit PC relative offset to GOT */		\
  _ (DIRECT_U32, 10)		/* Direct 32 bit zero extended */	\
  _ (DIRECT_I32, 11)		/* Direct 32 bit sign extended */	\
  _ (DIRECT_U16, 12)		/* Direct 16 bit zero extended */	\
  _ (PC_REL_I16, 13)	/* 16 bit sign extended pc relative */		\
  _ (DIRECT_I8, 14)		/* Direct 8 bit sign extended  */	\
  _ (PC_REL_I8, 15)	/* 8 bit sign extended pc relative */		\
  _ (DTPMOD64, 16)		/* ID of module containing symbol */	\
  _ (DTPOFF64, 17)		/* Offset in module's TLS block */	\
  _ (TPOFF64, 18)		/* Offset in initial TLS block */	\
  _ (TLSGD, 19)	/* 32 bit signed PC relative offset to two GOT entries for GD symbol */	\
  _ (TLSLD, 20) /* 32 bit signed PC relative offset to two GOT entries for LD symbol */	\
  _ (DTPOFF32, 21)		/* Offset in TLS block */		\
  _ (GOTTPOFF, 22) /* 32 bit signed PC relative offset to GOT entry for IE symbol */ \
  _ (TPOFF32, 23)		/* Offset in initial TLS, block) */

typedef struct
{
  elf64_symbol_t *symbols;

  u32 section_index;

  u8 *string_table;

  uword *symbol_by_name;
} elf_symbol_table_t;

always_inline void
elf_symbol_table_free (elf_symbol_table_t * s)
{
  vec_free (s->symbols);
  hash_free (s->symbol_by_name);
}

always_inline u8 *
elf_symbol_name (elf_symbol_table_t * t, elf64_symbol_t * sym)
{
  return vec_elt_at_index (t->string_table, sym->name);
}

typedef struct
{
  elf_relocation_with_addend_t *relocations;

  u32 section_index;
} elf_relocation_table_t;

always_inline void
elf_relocation_table_free (elf_relocation_table_t * r)
{
  vec_free (r->relocations);
}

typedef struct
{
  elf64_section_header_t header;

  u32 index;

  /* Index of segments containing this section. */
  uword *segment_index_bitmap;

  /* Aligned size (included padding not included in
     header.file_size). */
  u64 align_size;

  i64 exec_address_change;

  u8 *contents;
} elf_section_t;

typedef struct
{
  elf64_segment_header_t header;

  /* Sections contained in this segment. */
  uword *section_index_bitmap;

  u32 index;

  u8 *contents;
} elf_segment_t;

typedef struct
{
  u8 need_byte_swap;

  u8 parsed_symbols;

  char *file_name;

  elf_first_header_t first_header;

  elf64_file_header_t file_header;

  elf_segment_t *segments;

  elf_section_t *sections;

  uword *section_by_name;
  uword *section_by_start_address;

  elf_symbol_table_t *symbol_tables;
  elf_relocation_table_t *relocation_tables;

  char *interpreter;

  elf64_dynamic_entry_t *dynamic_entries;
  u8 *dynamic_string_table;
  u32 dynamic_string_table_section_index;
  u32 dynamic_symbol_table_section_index;
  u32 dynamic_symbol_table_index;
  u32 dynamic_section_index;
  u16 *versym;
  u32 versym_section_index;
  elf_dynamic_version_need_union_t *verneed;
  u32 verneed_section_index;
} elf_main_t;

always_inline void
elf_main_init (elf_main_t * em)
{
  clib_memset (em, 0, sizeof (em[0]));
}

always_inline void
elf_main_free (elf_main_t * em)
{
  uword i;

  for (i = 0; i < vec_len (em->segments); i++)
    vec_free (em->segments[i].contents);
  vec_free (em->segments);

  for (i = 0; i < vec_len (em->sections); i++)
    vec_free (em->sections[i].contents);
  vec_free (em->sections);

  hash_free (em->section_by_name);
  for (i = 0; i < vec_len (em->symbol_tables); i++)
    elf_symbol_table_free (em->symbol_tables + i);
  for (i = 0; i < vec_len (em->relocation_tables); i++)
    elf_relocation_table_free (em->relocation_tables + i);

  vec_free (em->dynamic_entries);
  vec_free (em->interpreter);
}

always_inline void
elf_get_segment_contents (elf_main_t * em, void *data, uword segment_index)
{
  elf_segment_t *g = vec_elt_at_index (em->segments, segment_index);
  if (!g->contents)
    vec_add (g->contents, data + g->header.file_offset,
	     g->header.memory_size);
}

always_inline void *
elf_get_section_contents (elf_main_t * em,
			  uword section_index, uword elt_size)
{
  elf_section_t *s;
  void *result;

  s = vec_elt_at_index (em->sections, section_index);

  result = 0;
  if (vec_len (s->contents) > 0)
    {
      /* Make vector copy of contents with given element size. */
      result = _vec_resize (result,
			    vec_len (s->contents) / elt_size,
			    vec_len (s->contents),
			    /* header_bytes */ 0,
			    /* align */ 0);
      clib_memcpy (result, s->contents, vec_len (s->contents));
    }

  return result;
}

always_inline void
elf_set_section_contents (elf_main_t * em,
			  uword section_index,
			  void *new_contents, uword n_content_bytes)
{
  elf_section_t *s;

  s = vec_elt_at_index (em->sections, section_index);
  vec_free (s->contents);
  vec_add (s->contents, new_contents, n_content_bytes);
}

always_inline u8 *
elf_section_name (elf_main_t * em, elf_section_t * s)
{
  elf_section_t *es = vec_elt_at_index (em->sections,
					em->
					file_header.section_header_string_table_index);
  return vec_elt_at_index (es->contents, s->header.name);
}

always_inline u8
elf_swap_u8 (elf_main_t * em, u8 x)
{
  return x;
}

always_inline u16
elf_swap_u16 (elf_main_t * em, u16 x)
{
  return em->need_byte_swap ? clib_byte_swap_u16 (x) : x;
}

always_inline u32
elf_swap_u32 (elf_main_t * em, u32 x)
{
  return em->need_byte_swap ? clib_byte_swap_u32 (x) : x;
}

always_inline u64
elf_swap_u64 (elf_main_t * em, u64 x)
{
  return em->need_byte_swap ? clib_byte_swap_u64 (x) : x;
}

#define FORMAT_ELF_MAIN_SYMBOLS (1 << 0)
#define FORMAT_ELF_MAIN_RELOCATIONS (1 << 1)
#define FORMAT_ELF_MAIN_DYNAMIC (1 << 2)

format_function_t format_elf_main;
format_function_t format_elf_symbol;

clib_error_t *elf_read_file (elf_main_t * em, char *file_name);
clib_error_t *elf_write_file (elf_main_t * em, char *file_name);
clib_error_t *elf_delete_named_section (elf_main_t * em, char *section_name);
clib_error_t *elf_parse (elf_main_t * em, void *data, uword data_bytes);
void elf_parse_symbols (elf_main_t * em);

clib_error_t *elf_get_section_by_name (elf_main_t * em, char *section_name,
				       elf_section_t ** result);
clib_error_t *elf_get_section_by_start_address (elf_main_t * em,
						uword start_address,
						elf_section_t ** result);

void
elf_create_section_with_contents (elf_main_t * em,
				  char *section_name,
				  elf64_section_header_t * header,
				  void *contents, uword n_content_bytes);
uword elf_delete_segment_with_type (elf_main_t * em,
				    elf_segment_type_t segment_type);
void elf_set_dynamic_entries (elf_main_t * em);

#endif /* included_clib_elf_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
='#n3724'>3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100