-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathecoff.c
5237 lines (4426 loc) · 147 KB
/
ecoff.c
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
/* ECOFF debugging support.
Copyright (C) 1993-2017 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file was put together by Ian Lance Taylor <[email protected]>. A
good deal of it comes directly from mips-tfile.c, by Michael
Meissner <[email protected]>.
This file is part of GAS.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
#include "as.h"
/* This file is compiled conditionally for those targets which use
ECOFF debugging information (e.g., MIPS ELF, Alpha ECOFF). */
#include "ecoff.h"
#ifdef ECOFF_DEBUGGING
#include "coff/internal.h"
#include "coff/symconst.h"
#include "aout/stab_gnu.h"
#include "filenames.h"
#include "safe-ctype.h"
/* Why isn't this in coff/sym.h? */
#define ST_RFDESCAPE 0xfff
/* This file constructs the information used by the ECOFF debugging
format. It just builds a large block of data.
We support both ECOFF style debugging and stabs debugging (the
stabs symbols are encapsulated in ECOFF symbols). This should let
us handle anything the compiler might throw at us. */
/* Here is a brief description of the MIPS ECOFF symbol table, by
Michael Meissner. The MIPS symbol table has the following pieces:
Symbolic Header
|
+-- Auxiliary Symbols
|
+-- Dense number table
|
+-- Optimizer Symbols
|
+-- External Strings
|
+-- External Symbols
|
+-- Relative file descriptors
|
+-- File table
|
+-- Procedure table
|
+-- Line number table
|
+-- Local Strings
|
+-- Local Symbols
The symbolic header points to each of the other tables, and also
contains the number of entries. It also contains a magic number
and MIPS compiler version number, such as 2.0.
The auxiliary table is a series of 32 bit integers, that are
referenced as needed from the local symbol table. Unlike standard
COFF, the aux. information does not follow the symbol that uses
it, but rather is a separate table. In theory, this would allow
the MIPS compilers to collapse duplicate aux. entries, but I've not
noticed this happening with the 1.31 compiler suite. The different
types of aux. entries are:
1) dnLow: Low bound on array dimension.
2) dnHigh: High bound on array dimension.
3) isym: Index to the local symbol which is the start of the
function for the end of function first aux. entry.
4) width: Width of structures and bitfields.
5) count: Count of ranges for variant part.
6) rndx: A relative index into the symbol table. The relative
index field has two parts: rfd which is a pointer into the
relative file index table or ST_RFDESCAPE which says the next
aux. entry is the file number, and index: which is the pointer
into the local symbol within a given file table. This is for
things like references to types defined in another file.
7) Type information: This is like the COFF type bits, except it
is 32 bits instead of 16; they still have room to add new
basic types; and they can handle more than 6 levels of array,
pointer, function, etc. Each type information field contains
the following structure members:
a) fBitfield: a bit that says this is a bitfield, and the
size in bits follows as the next aux. entry.
b) continued: a bit that says the next aux. entry is a
continuation of the current type information (in case
there are more than 6 levels of array/ptr/function).
c) bt: an integer containing the base type before adding
array, pointer, function, etc. qualifiers. The
current base types that I have documentation for are:
btNil -- undefined
btAdr -- address - integer same size as ptr
btChar -- character
btUChar -- unsigned character
btShort -- short
btUShort -- unsigned short
btInt -- int
btUInt -- unsigned int
btLong -- long
btULong -- unsigned long
btFloat -- float (real)
btDouble -- Double (real)
btStruct -- Structure (Record)
btUnion -- Union (variant)
btEnum -- Enumerated
btTypedef -- defined via a typedef isymRef
btRange -- subrange of int
btSet -- pascal sets
btComplex -- fortran complex
btDComplex -- fortran double complex
btIndirect -- forward or unnamed typedef
btFixedDec -- Fixed Decimal
btFloatDec -- Float Decimal
btString -- Varying Length Character String
btBit -- Aligned Bit String
btPicture -- Picture
btVoid -- Void (MIPS cc revision >= 2.00)
d) tq0 - tq5: type qualifier fields as needed. The
current type qualifier fields I have documentation for
are:
tqNil -- no more qualifiers
tqPtr -- pointer
tqProc -- procedure
tqArray -- array
tqFar -- 8086 far pointers
tqVol -- volatile
The dense number table is used in the front ends, and disappears by
the time the .o is created.
With the 1.31 compiler suite, the optimization symbols don't seem
to be used as far as I can tell.
The linker is the first entity that creates the relative file
descriptor table, and I believe it is used so that the individual
file table pointers don't have to be rewritten when the objects are
merged together into the program file.
Unlike COFF, the basic symbol & string tables are split into
external and local symbols/strings. The relocation information
only goes off of the external symbol table, and the debug
information only goes off of the internal symbol table. The
external symbols can have links to an appropriate file index and
symbol within the file to give it the appropriate type information.
Because of this, the external symbols are actually larger than the
internal symbols (to contain the link information), and contain the
local symbol structure as a member, though this member is not the
first member of the external symbol structure (!). I suspect this
split is to make strip easier to deal with.
Each file table has offsets for where the line numbers, local
strings, local symbols, and procedure table starts from within the
global tables, and the indices are reset to 0 for each of those
tables for the file.
The procedure table contains the binary equivalents of the .ent
(start of the function address), .frame (what register is the
virtual frame pointer, constant offset from the register to obtain
the VFP, and what register holds the return address), .mask/.fmask
(bitmask of saved registers, and where the first register is stored
relative to the VFP) assembler directives. It also contains the
low and high bounds of the line numbers if debugging is turned on.
The line number table is a compressed form of the normal COFF line
table. Each line number entry is either 1 or 3 bytes long, and
contains a signed delta from the previous line, and an unsigned
count of the number of instructions this statement takes.
The local symbol table contains the following fields:
1) iss: index to the local string table giving the name of the
symbol.
2) value: value of the symbol (address, register number, etc.).
3) st: symbol type. The current symbol types are:
stNil -- Nuthin' special
stGlobal -- external symbol
stStatic -- static
stParam -- procedure argument
stLocal -- local variable
stLabel -- label
stProc -- External Procedure
stBlock -- beginning of block
stEnd -- end (of anything)
stMember -- member (of anything)
stTypedef -- type definition
stFile -- file name
stRegReloc -- register relocation
stForward -- forwarding address
stStaticProc -- Static procedure
stConstant -- const
4) sc: storage class. The current storage classes are:
scText -- text symbol
scData -- initialized data symbol
scBss -- un-initialized data symbol
scRegister -- value of symbol is register number
scAbs -- value of symbol is absolute
scUndefined -- who knows?
scCdbLocal -- variable's value is IN se->va.??
scBits -- this is a bit field
scCdbSystem -- value is IN debugger's address space
scRegImage -- register value saved on stack
scInfo -- symbol contains debugger information
scUserStruct -- addr in struct user for current process
scSData -- load time only small data
scSBss -- load time only small common
scRData -- load time only read only data
scVar -- Var parameter (fortranpascal)
scCommon -- common variable
scSCommon -- small common
scVarRegister -- Var parameter in a register
scVariant -- Variant record
scSUndefined -- small undefined(external) data
scInit -- .init section symbol
5) index: pointer to a local symbol or aux. entry.
For the following program:
#include <stdio.h>
main(){
printf("Hello World!\n");
return 0;
}
Mips-tdump produces the following information:
Global file header:
magic number 0x162
# sections 2
timestamp 645311799, Wed Jun 13 17:16:39 1990
symbolic header offset 284
symbolic header size 96
optional header 56
flags 0x0
Symbolic header, magic number = 0x7009, vstamp = 1.31:
Info Offset Number Bytes
==== ====== ====== =====
Line numbers 380 4 4 [13]
Dense numbers 0 0 0
Procedures Tables 384 1 52
Local Symbols 436 16 192
Optimization Symbols 0 0 0
Auxiliary Symbols 628 39 156
Local Strings 784 80 80
External Strings 864 144 144
File Tables 1008 2 144
Relative Files 0 0 0
External Symbols 1152 20 320
File #0, "hello2.c"
Name index = 1 Readin = No
Merge = No Endian = LITTLE
Debug level = G2 Language = C
Adr = 0x00000000
Info Start Number Size Offset
==== ===== ====== ==== ======
Local strings 0 15 15 784
Local symbols 0 6 72 436
Line numbers 0 13 13 380
Optimization symbols 0 0 0 0
Procedures 0 1 52 384
Auxiliary symbols 0 14 56 628
Relative Files 0 0 0 0
There are 6 local symbols, starting at 436
Symbol# 0: "hello2.c"
End+1 symbol = 6
String index = 1
Storage class = Text Index = 6
Symbol type = File Value = 0
Symbol# 1: "main"
End+1 symbol = 5
Type = int
String index = 10
Storage class = Text Index = 12
Symbol type = Proc Value = 0
Symbol# 2: ""
End+1 symbol = 4
String index = 0
Storage class = Text Index = 4
Symbol type = Block Value = 8
Symbol# 3: ""
First symbol = 2
String index = 0
Storage class = Text Index = 2
Symbol type = End Value = 28
Symbol# 4: "main"
First symbol = 1
String index = 10
Storage class = Text Index = 1
Symbol type = End Value = 52
Symbol# 5: "hello2.c"
First symbol = 0
String index = 1
Storage class = Text Index = 0
Symbol type = End Value = 0
There are 14 auxiliary table entries, starting at 628.
* #0 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #1 24, [ 24/ 0], [ 6 0:0 0:0:0:0:0:0]
* #2 8, [ 8/ 0], [ 2 0:0 0:0:0:0:0:0]
* #3 16, [ 16/ 0], [ 4 0:0 0:0:0:0:0:0]
* #4 24, [ 24/ 0], [ 6 0:0 0:0:0:0:0:0]
* #5 32, [ 32/ 0], [ 8 0:0 0:0:0:0:0:0]
* #6 40, [ 40/ 0], [10 0:0 0:0:0:0:0:0]
* #7 44, [ 44/ 0], [11 0:0 0:0:0:0:0:0]
* #8 12, [ 12/ 0], [ 3 0:0 0:0:0:0:0:0]
* #9 20, [ 20/ 0], [ 5 0:0 0:0:0:0:0:0]
* #10 28, [ 28/ 0], [ 7 0:0 0:0:0:0:0:0]
* #11 36, [ 36/ 0], [ 9 0:0 0:0:0:0:0:0]
#12 5, [ 5/ 0], [ 1 1:0 0:0:0:0:0:0]
#13 24, [ 24/ 0], [ 6 0:0 0:0:0:0:0:0]
There are 1 procedure descriptor entries, starting at 0.
Procedure descriptor 0:
Name index = 10 Name = "main"
.mask 0x80000000,-4 .fmask 0x00000000,0
.frame $29,24,$31
Opt. start = -1 Symbols start = 1
First line # = 3 Last line # = 6
Line Offset = 0 Address = 0x00000000
There are 4 bytes holding line numbers, starting at 380.
Line 3, delta 0, count 2
Line 4, delta 1, count 3
Line 5, delta 1, count 2
Line 6, delta 1, count 6
File #1, "/usr/include/stdio.h"
Name index = 1 Readin = No
Merge = Yes Endian = LITTLE
Debug level = G2 Language = C
Adr = 0x00000000
Info Start Number Size Offset
==== ===== ====== ==== ======
Local strings 15 65 65 799
Local symbols 6 10 120 508
Line numbers 0 0 0 380
Optimization symbols 0 0 0 0
Procedures 1 0 0 436
Auxiliary symbols 14 25 100 684
Relative Files 0 0 0 0
There are 10 local symbols, starting at 442
Symbol# 0: "/usr/include/stdio.h"
End+1 symbol = 10
String index = 1
Storage class = Text Index = 10
Symbol type = File Value = 0
Symbol# 1: "_iobuf"
End+1 symbol = 9
String index = 22
Storage class = Info Index = 9
Symbol type = Block Value = 20
Symbol# 2: "_cnt"
Type = int
String index = 29
Storage class = Info Index = 4
Symbol type = Member Value = 0
Symbol# 3: "_ptr"
Type = ptr to char
String index = 34
Storage class = Info Index = 15
Symbol type = Member Value = 32
Symbol# 4: "_base"
Type = ptr to char
String index = 39
Storage class = Info Index = 16
Symbol type = Member Value = 64
Symbol# 5: "_bufsiz"
Type = int
String index = 45
Storage class = Info Index = 4
Symbol type = Member Value = 96
Symbol# 6: "_flag"
Type = short
String index = 53
Storage class = Info Index = 3
Symbol type = Member Value = 128
Symbol# 7: "_file"
Type = char
String index = 59
Storage class = Info Index = 2
Symbol type = Member Value = 144
Symbol# 8: ""
First symbol = 1
String index = 0
Storage class = Info Index = 1
Symbol type = End Value = 0
Symbol# 9: "/usr/include/stdio.h"
First symbol = 0
String index = 1
Storage class = Text Index = 0
Symbol type = End Value = 0
There are 25 auxiliary table entries, starting at 642.
* #14 -1, [4095/1048575], [63 1:1 f:f:f:f:f:f]
#15 65544, [ 8/ 16], [ 2 0:0 1:0:0:0:0:0]
#16 65544, [ 8/ 16], [ 2 0:0 1:0:0:0:0:0]
* #17 196656, [ 48/ 48], [12 0:0 3:0:0:0:0:0]
* #18 8191, [4095/ 1], [63 1:1 0:0:0:0:f:1]
* #19 1, [ 1/ 0], [ 0 1:0 0:0:0:0:0:0]
* #20 20479, [4095/ 4], [63 1:1 0:0:0:0:f:4]
* #21 1, [ 1/ 0], [ 0 1:0 0:0:0:0:0:0]
* #22 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #23 2, [ 2/ 0], [ 0 0:1 0:0:0:0:0:0]
* #24 160, [ 160/ 0], [40 0:0 0:0:0:0:0:0]
* #25 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #26 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #27 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #28 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #29 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #30 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #31 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #32 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #33 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #34 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #35 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #36 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #37 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
* #38 0, [ 0/ 0], [ 0 0:0 0:0:0:0:0:0]
There are 0 procedure descriptor entries, starting at 1.
There are 20 external symbols, starting at 1152
Symbol# 0: "_iob"
Type = array [3 {160}] of struct _iobuf { ifd = 1, index = 1 }
String index = 0 Ifd = 1
Storage class = Nil Index = 17
Symbol type = Global Value = 60
Symbol# 1: "fopen"
String index = 5 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 2: "fdopen"
String index = 11 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 3: "freopen"
String index = 18 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 4: "popen"
String index = 26 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 5: "tmpfile"
String index = 32 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 6: "ftell"
String index = 40 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 7: "rewind"
String index = 46 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 8: "setbuf"
String index = 53 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 9: "setbuffer"
String index = 60 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 10: "setlinebuf"
String index = 70 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 11: "fgets"
String index = 81 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 12: "gets"
String index = 87 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 13: "ctermid"
String index = 92 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 14: "cuserid"
String index = 100 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 15: "tempnam"
String index = 108 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 16: "tmpnam"
String index = 116 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 17: "sprintf"
String index = 123 Ifd = 1
Storage class = Nil Index = 1048575
Symbol type = Proc Value = 0
Symbol# 18: "main"
Type = int
String index = 131 Ifd = 0
Storage class = Text Index = 1
Symbol type = Proc Value = 0
Symbol# 19: "printf"
String index = 136 Ifd = 0
Storage class = Undefined Index = 1048575
Symbol type = Proc Value = 0
The following auxiliary table entries were unused:
#0 0 0x00000000 void
#2 8 0x00000008 char
#3 16 0x00000010 short
#4 24 0x00000018 int
#5 32 0x00000020 long
#6 40 0x00000028 float
#7 44 0x0000002c double
#8 12 0x0000000c unsigned char
#9 20 0x00000014 unsigned short
#10 28 0x0000001c unsigned int
#11 36 0x00000024 unsigned long
#14 0 0x00000000 void
#15 24 0x00000018 int
#19 32 0x00000020 long
#20 40 0x00000028 float
#21 44 0x0000002c double
#22 12 0x0000000c unsigned char
#23 20 0x00000014 unsigned short
#24 28 0x0000001c unsigned int
#25 36 0x00000024 unsigned long
#26 48 0x00000030 struct no name { ifd = -1, index = 1048575 }
*/
/* Redefinition of of storage classes as an enumeration for better
debugging. */
typedef enum sc {
sc_Nil = scNil, /* no storage class */
sc_Text = scText, /* text symbol */
sc_Data = scData, /* initialized data symbol */
sc_Bss = scBss, /* un-initialized data symbol */
sc_Register = scRegister, /* value of symbol is register number */
sc_Abs = scAbs, /* value of symbol is absolute */
sc_Undefined = scUndefined, /* who knows? */
sc_CdbLocal = scCdbLocal, /* variable's value is IN se->va.?? */
sc_Bits = scBits, /* this is a bit field */
sc_CdbSystem = scCdbSystem, /* value is IN CDB's address space */
sc_RegImage = scRegImage, /* register value saved on stack */
sc_Info = scInfo, /* symbol contains debugger information */
sc_UserStruct = scUserStruct, /* addr in struct user for current process */
sc_SData = scSData, /* load time only small data */
sc_SBss = scSBss, /* load time only small common */
sc_RData = scRData, /* load time only read only data */
sc_Var = scVar, /* Var parameter (fortran,pascal) */
sc_Common = scCommon, /* common variable */
sc_SCommon = scSCommon, /* small common */
sc_VarRegister = scVarRegister, /* Var parameter in a register */
sc_Variant = scVariant, /* Variant record */
sc_SUndefined = scSUndefined, /* small undefined(external) data */
sc_Init = scInit, /* .init section symbol */
sc_Max = scMax /* Max storage class+1 */
} sc_t;
/* Redefinition of symbol type. */
typedef enum st {
st_Nil = stNil, /* Nuthin' special */
st_Global = stGlobal, /* external symbol */
st_Static = stStatic, /* static */
st_Param = stParam, /* procedure argument */
st_Local = stLocal, /* local variable */
st_Label = stLabel, /* label */
st_Proc = stProc, /* " " Procedure */
st_Block = stBlock, /* beginning of block */
st_End = stEnd, /* end (of anything) */
st_Member = stMember, /* member (of anything - struct/union/enum */
st_Typedef = stTypedef, /* type definition */
st_File = stFile, /* file name */
st_RegReloc = stRegReloc, /* register relocation */
st_Forward = stForward, /* forwarding address */
st_StaticProc = stStaticProc, /* load time only static procs */
st_Constant = stConstant, /* const */
st_Str = stStr, /* string */
st_Number = stNumber, /* pure number (ie. 4 NOR 2+2) */
st_Expr = stExpr, /* 2+2 vs. 4 */
st_Type = stType, /* post-coercion SER */
st_Max = stMax /* max type+1 */
} st_t;
/* Redefinition of type qualifiers. */
typedef enum tq {
tq_Nil = tqNil, /* bt is what you see */
tq_Ptr = tqPtr, /* pointer */
tq_Proc = tqProc, /* procedure */
tq_Array = tqArray, /* duh */
tq_Far = tqFar, /* longer addressing - 8086/8 land */
tq_Vol = tqVol, /* volatile */
tq_Max = tqMax /* Max type qualifier+1 */
} tq_t;
/* Redefinition of basic types. */
typedef enum bt {
bt_Nil = btNil, /* undefined */
bt_Adr = btAdr, /* address - integer same size as pointer */
bt_Char = btChar, /* character */
bt_UChar = btUChar, /* unsigned character */
bt_Short = btShort, /* short */
bt_UShort = btUShort, /* unsigned short */
bt_Int = btInt, /* int */
bt_UInt = btUInt, /* unsigned int */
bt_Long = btLong, /* long */
bt_ULong = btULong, /* unsigned long */
bt_Float = btFloat, /* float (real) */
bt_Double = btDouble, /* Double (real) */
bt_Struct = btStruct, /* Structure (Record) */
bt_Union = btUnion, /* Union (variant) */
bt_Enum = btEnum, /* Enumerated */
bt_Typedef = btTypedef, /* defined via a typedef, isymRef points */
bt_Range = btRange, /* subrange of int */
bt_Set = btSet, /* pascal sets */
bt_Complex = btComplex, /* fortran complex */
bt_DComplex = btDComplex, /* fortran double complex */
bt_Indirect = btIndirect, /* forward or unnamed typedef */
bt_FixedDec = btFixedDec, /* Fixed Decimal */
bt_FloatDec = btFloatDec, /* Float Decimal */
bt_String = btString, /* Varying Length Character String */
bt_Bit = btBit, /* Aligned Bit String */
bt_Picture = btPicture, /* Picture */
bt_Void = btVoid, /* Void */
bt_Max = btMax /* Max basic type+1 */
} bt_t;
#define N_TQ itqMax
/* States for whether to hash type or not. */
typedef enum hash_state {
hash_no = 0, /* Don't hash type */
hash_yes = 1, /* OK to hash type, or use previous hash */
hash_record = 2 /* OK to record hash, but don't use prev. */
} hash_state_t;
/* Types of different sized allocation requests. */
enum alloc_type {
alloc_type_none, /* dummy value */
alloc_type_scope, /* nested scopes linked list */
alloc_type_vlinks, /* glue linking pages in varray */
alloc_type_shash, /* string hash element */
alloc_type_thash, /* type hash element */
alloc_type_tag, /* struct/union/tag element */
alloc_type_forward, /* element to hold unknown tag */
alloc_type_thead, /* head of type hash list */
alloc_type_varray, /* general varray allocation */
alloc_type_lineno, /* line number list */
alloc_type_last /* last+1 element for array bounds */
};
/* Types of auxiliary type information. */
enum aux_type {
aux_tir, /* TIR type information */
aux_rndx, /* relative index into symbol table */
aux_dnLow, /* low dimension */
aux_dnHigh, /* high dimension */
aux_isym, /* symbol table index (end of proc) */
aux_iss, /* index into string space (not used) */
aux_width, /* width for non-default sized struc fields */
aux_count /* count of ranges for variant arm */
};
/* Structures to provide n-number of virtual arrays, each of which can
grow linearly, and which are written in the object file as
sequential pages. On systems with a BSD malloc, the
MAX_CLUSTER_PAGES should be 1 less than a power of two, since
malloc adds it's overhead, and rounds up to the next power of 2.
Pages are linked together via a linked list.
If PAGE_SIZE is > 4096, the string length in the shash_t structure
can't be represented (assuming there are strings > 4096 bytes). */
/* FIXME: Yes, there can be such strings while emitting C++ class debug
info. Templates are the offender here, the test case in question
having a mangled class name of
t7rb_tree4Z4xkeyZt4pair2ZC4xkeyZt7xsocket1Z4UserZt9select1st2Zt4pair\
2ZC4xkeyZt7xsocket1Z4UserZ4xkeyZt4less1Z4xkey
Repeat that a couple dozen times while listing the class members and
you've got strings over 4k. Hack around this for now by increasing
the page size. A proper solution would abandon this structure scheme
certainly for very large strings, and possibly entirely. */
#ifndef PAGE_SIZE
#define PAGE_SIZE (8*1024) /* size of varray pages */
#endif
#define PAGE_USIZE ((unsigned long) PAGE_SIZE)
#ifndef MAX_CLUSTER_PAGES /* # pages to get from system */
#define MAX_CLUSTER_PAGES 63
#endif
/* Linked list connecting separate page allocations. */
typedef struct vlinks {
struct vlinks *prev; /* previous set of pages */
struct vlinks *next; /* next set of pages */
union page *datum; /* start of page */
unsigned long start_index; /* starting index # of page */
} vlinks_t;
/* Virtual array header. */
typedef struct varray {
vlinks_t *first; /* first page link */
vlinks_t *last; /* last page link */
unsigned long num_allocated; /* # objects allocated */
unsigned short object_size; /* size in bytes of each object */
unsigned short objects_per_page; /* # objects that can fit on a page */
unsigned short objects_last_page; /* # objects allocated on last page */
} varray_t;
#ifndef MALLOC_CHECK
#define OBJECTS_PER_PAGE(type) (PAGE_SIZE / sizeof (type))
#else
#define OBJECTS_PER_PAGE(type) ((sizeof (type) > 1) ? 1 : PAGE_SIZE)
#endif
#define INIT_VARRAY(type) { /* macro to initialize a varray */ \
(vlinks_t *)0, /* first */ \
(vlinks_t *)0, /* last */ \
0, /* num_allocated */ \
sizeof (type), /* object_size */ \
OBJECTS_PER_PAGE (type), /* objects_per_page */ \
OBJECTS_PER_PAGE (type), /* objects_last_page */ \
}
/* Master type for indexes within the symbol table. */
typedef unsigned long symint_t;
/* Linked list support for nested scopes (file, block, structure, etc.). */
typedef struct scope {
struct scope *prev; /* previous scope level */
struct scope *free; /* free list pointer */
struct localsym *lsym; /* pointer to local symbol node */
st_t type; /* type of the node */
} scope_t;
/* For a local symbol we store a gas symbol as well as the debugging
information we generate. The gas symbol will be NULL if this is
only a debugging symbol. */
typedef struct localsym {
const char *name; /* symbol name */
symbolS *as_sym; /* symbol as seen by gas */
bfd_vma addend; /* addend to as_sym value */
struct efdr *file_ptr; /* file pointer */
struct ecoff_proc *proc_ptr; /* proc pointer */
struct localsym *begin_ptr; /* symbol at start of block */
struct ecoff_aux *index_ptr; /* index value to be filled in */
struct forward *forward_ref; /* forward references to this symbol */
long sym_index; /* final symbol index */
EXTR ecoff_sym; /* ECOFF debugging symbol */
} localsym_t;
/* For aux information we keep the type and the data. */
typedef struct ecoff_aux {
enum aux_type type; /* aux type */
AUXU data; /* aux data */
} aux_t;
/* For a procedure we store the gas symbol as well as the PDR
debugging information. */
typedef struct ecoff_proc {
localsym_t *sym; /* associated symbol */
PDR pdr; /* ECOFF debugging info */
} proc_t;
/* Number of proc_t structures allocated. */
static unsigned long proc_cnt;
/* Forward reference list for tags referenced, but not yet defined. */
typedef struct forward {
struct forward *next; /* next forward reference */
struct forward *free; /* free list pointer */
aux_t *ifd_ptr; /* pointer to store file index */
aux_t *index_ptr; /* pointer to store symbol index */
} forward_t;
/* Linked list support for tags. The first tag in the list is always
the current tag for that block. */
typedef struct tag {
struct tag *free; /* free list pointer */
struct shash *hash_ptr; /* pointer to the hash table head */
struct tag *same_name; /* tag with same name in outer scope */
struct tag *same_block; /* next tag defined in the same block. */
struct forward *forward_ref; /* list of forward references */
bt_t basic_type; /* bt_Struct, bt_Union, or bt_Enum */
symint_t ifd; /* file # tag defined in */
localsym_t *sym; /* file's local symbols */
} tag_t;
/* Head of a block's linked list of tags. */
typedef struct thead {
struct thead *prev; /* previous block */
struct thead *free; /* free list pointer */
struct tag *first_tag; /* first tag in block defined */
} thead_t;
/* Union containing pointers to each the small structures which are freed up. */
typedef union small_free {
scope_t *f_scope; /* scope structure */
thead_t *f_thead; /* tag head structure */
tag_t *f_tag; /* tag element structure */
forward_t *f_forward; /* forward tag reference */
} small_free_t;
/* String hash table entry. */
typedef struct shash {
char *string; /* string we are hashing */
symint_t indx; /* index within string table */
EXTR *esym_ptr; /* global symbol pointer */
localsym_t *sym_ptr; /* local symbol pointer */
localsym_t *end_ptr; /* symbol pointer to end block */
tag_t *tag_ptr; /* tag pointer */
proc_t *proc_ptr; /* procedure descriptor pointer */
} shash_t;
/* Type hash table support. The size of the hash table must fit
within a page with the other extended file descriptor information.
Because unique types which are hashed are fewer in number than
strings, we use a smaller hash value. */
#define HASHBITS 30
#ifndef THASH_SIZE
#define THASH_SIZE 113
#endif
typedef struct thash {
struct thash *next; /* next hash value */
AUXU type; /* type we are hashing */
symint_t indx; /* index within string table */
} thash_t;
/* Extended file descriptor that contains all of the support necessary
to add things to each file separately. */
typedef struct efdr {
FDR fdr; /* File header to be written out */
FDR *orig_fdr; /* original file header */
char *name; /* filename */
int fake; /* whether this is faked .file */
symint_t void_type; /* aux. pointer to 'void' type */
symint_t int_type; /* aux. pointer to 'int' type */
scope_t *cur_scope; /* current nested scopes */
symint_t file_index; /* current file number */
int nested_scopes; /* # nested scopes */
varray_t strings; /* local strings */
varray_t symbols; /* local symbols */
varray_t procs; /* procedures */
varray_t aux_syms; /* auxiliary symbols */
struct efdr *next_file; /* next file descriptor */
/* string/type hash tables */
struct hash_control *str_hash; /* string hash table */
thash_t *thash_head[THASH_SIZE];
} efdr_t;
/* Pre-initialized extended file structure. */
static const efdr_t init_file = {
{ /* FDR structure */
0, /* adr: memory address of beginning of file */
0, /* rss: file name (of source, if known) */
0, /* issBase: file's string space */
0, /* cbSs: number of bytes in the ss */
0, /* isymBase: beginning of symbols */
0, /* csym: count file's of symbols */
0, /* ilineBase: file's line symbols */
0, /* cline: count of file's line symbols */
0, /* ioptBase: file's optimization entries */
0, /* copt: count of file's optimization entries */
0, /* ipdFirst: start of procedures for this file */
0, /* cpd: count of procedures for this file */
0, /* iauxBase: file's auxiliary entries */
0, /* caux: count of file's auxiliary entries */
0, /* rfdBase: index into the file indirect table */
0, /* crfd: count file indirect entries */
langC, /* lang: language for this file */
1, /* fMerge: whether this file can be merged */
0, /* fReadin: true if read in (not just created) */
TARGET_BYTES_BIG_ENDIAN, /* fBigendian: if 1, compiled on big endian machine */
GLEVEL_2, /* glevel: level this file was compiled with */
0, /* reserved: reserved for future use */
0, /* cbLineOffset: byte offset from header for this file ln's */
0, /* cbLine: size of lines for this file */
},
(FDR *)0, /* orig_fdr: original file header pointer */
(char *)0, /* name: pointer to filename */
0, /* fake: whether this is a faked .file */
0, /* void_type: ptr to aux node for void type */
0, /* int_type: ptr to aux node for int type */
(scope_t *)0, /* cur_scope: current scope being processed */
0, /* file_index: current file # */
0, /* nested_scopes: # nested scopes */
INIT_VARRAY (char), /* strings: local string varray */
INIT_VARRAY (localsym_t), /* symbols: local symbols varray */
INIT_VARRAY (proc_t), /* procs: procedure varray */
INIT_VARRAY (aux_t), /* aux_syms: auxiliary symbols varray */
(struct efdr *)0, /* next_file: next file structure */
(struct hash_control *)0, /* str_hash: string hash table */
{ 0 }, /* thash_head: type hash table */
};