-
Notifications
You must be signed in to change notification settings - Fork 5
/
ld.alm
1567 lines (1469 loc) · 41.4 KB
/
ld.alm
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
macro ?! $ : $ , \
$$ : $$ , \
$@ : $@ , \
@ez80 : @ez80 , \
and : and , \
byte : byte , \
calminstruction: calminstruction, \
defined : defined , \
definite : definite , \
dup : dup , \
dword : dword , \
else : else , \
emit : emit , \
end : end , \
equ : equ , \
err : err , \
from : from , \
if : if , \
irpv : irpv , \
iterate : iterate , \
load : load , \
macro : macro , \
match : match , \
namespace : namespace , \
or : or , \
rawmatch : rawmatch , \
scale : scale , \
shl : shl , \
used : used , \
virtual : virtual , \
word : word
local script, noscript, read, required, cfi, lines, locs, addrs, \
nosection, makesection, sections, declared, globals, publics, \
splitfiles, libraries, sources, offset, defers, output
noscript := 1
element nosection
offset = nosection
include 'commands.alm'
include 'ez80.alm'
calminstruction @ez80.word size*, value*
emit size, value and (1 shl (size shl 3) - 1)
end calminstruction
iterate name, locate, order, range, split, precious, \
library, source, require, provide, map
macro name? line&
if definite noscript
noscript.name line
else
namespace sections
rawmatch raw, line
script equ name raw
else
script equ name
end rawmatch
end namespace
end if
end macro
end iterate
calminstruction makesection name*, base: 0
proxy sections, string
local string, @base, @name
arrange string, name
stringify string
check string and $FF = ''''
jno ident
compute string, name
compute name, +string
ident:
arrange @name, @sections.name?
publish @name:, string
publish :@sections, @name
arrange @base, @name.=base?
compute base, base
publish @base:, base
execute =virtual? =at? @base
execute @name.=area?::
execute =end? =virtual?
end calminstruction
calminstruction splitfiles.update name*, extension
proxy sections, splitfiles
local string, @splitfile
arrange string, name
stringify string
check string and $FF = ''''
jno ident
compute name, +name
ident:
arrange name, @sections.name?
arrange @splitfile, @splitfiles..extension
publish :@splitfile, name
arrange name, name.=split?
publish name:, @splitfile
end calminstruction
calminstruction script.locate expression*
proxy sections, expression
local name, options, base, metadata
match name= options? =at? base, expression, ()
jno errsyntax
match =virtual? options?, options
jno novirtual
call splitfiles.update, name
novirtual:
match =element? metadata?, options
jno noelement
execute =element? @sections.name?.=element? metadata
jump makesection
noelement:
match , options
jno errsyntax
makesection:
call makesection, name, base
exit
errsyntax:
stringify expression
execute =err? 'invalid syntax in linker command: locate ', @expression
end calminstruction
calminstruction script.order names*&
proxy sections
local base
split name, names
jump enter
loop:
split name, names
arrange base, prev.=base? + prev.=length?
call makesection, name, base
enter:
arrange prev, name
stringify name
check name and $FF = ''''
jno ident
compute prev, +prev
ident:
arrange prev, @sections.prev?
match , names
jno loop
end calminstruction
calminstruction script.range expression*
proxy sections, expression
local name, base, high, @high
match name= base : high, expression
jno errsyntax
call makesection, name, base
arrange @high, name
stringify name
check name and $FF = ''''
jno ident
compute @high, +@high
ident:
arrange @high, @sections.@high?.=high?
compute high, high
publish @high:, high
exit
errsyntax:
stringify expression
execute =err? 'invalid syntax in linker command: range ', @expression
end calminstruction
calminstruction script.split names*&
proxy splitfiles, sections, names, string
local extension, @splitfile, string
match extension? : names, names
jno errsyntax
match , extension
jyes loop
arrange @splitfile, @splitfiles..extension
publish :@splitfiles, @splitfile
arrange string, extension
stringify string
execute =virtual? =as? @string
execute @splitfile.=area::
execute =end? =virtual?
loop:
split name, names
call makesection, name
call splitfiles.update, name, extension
match , names
jno loop
exit
errsyntax:
stringify names
execute =err? 'invalid syntax in linker command: split ', @names
end calminstruction
calminstruction script.precious names*&
proxy sections
local condition, string
loop:
split name, names
match name =if? condition, name
jno unconditional
check condition
jno notprecious
unconditional:
arrange string, name
stringify string
check string and $FF = ''''
jno identifier
compute string, name
compute name, +string
identifier:
arrange name, @sections.name?.=precious?
publish name:, offset
notprecious:
match , names
jno loop
end calminstruction
iterate <name*,list*>, library,libraries, source,sources
list.count = 0
calminstruction script.name files&
once arrange @list, list
once arrange @count, list.count
local count
match , files
jyes done
compute count, @count
loop:
split file, files
publish :@list, file
compute count, count + 1
jyes loop
publish @count, count
done:
end calminstruction
end iterate
calminstruction script.require symbols*&
proxy globals
local condition
loop:
split symbol, symbols
match symbol =if? condition, symbol
jno unconditional
check condition
jno notrequired
unconditional:
arrange symbol, @globals.symbol
compute symbol, symbol
notrequired:
match , symbols
jno loop
end calminstruction
calminstruction script.provide expressions*&
proxy globals, publics, expression
local global, public
loop:
split expression, expressions
match symbol == value, expression
jno errsyntax
publish :@globals, symbol
publish :@publics, symbol
arrange global, @globals.symbol
arrange public, @publics.symbol
compute value, value
publish global:, value
publish public:, value
match , expressions
jno loop
exit
errsyntax:
stringify expression
execute =err? 'invalid syntax in linker command: provide ', @expression
end calminstruction
calminstruction script.map
proxy output
execute =virtual? =as? 'map'
execute @output.=map::
execute =end? =virtual?
end calminstruction
irpv line, script
script.line
end irpv
calminstruction noscript.require symbol*
check symbol
end calminstruction
calminstruction read? file*, enabled: 1
proxy if, include, end
check enabled
jyes enabled1
execute @if? enabled
enabled1:
execute @include?! file
jyes enabled2
execute @end? @if?
enabled2:
ignore:
end calminstruction
required equ required.0
calminstruction output.uleb128 value*
proxy value, encoding
local encoding
compute value, value
check value >= 0
jyes enter
err 'uleb128 argument is negative'
exit
loop:
compute encoding, value and $7F or $80
execute =emit? =byte?: @encoding
compute value, value shr 7
enter:
check value < $80
jno loop
execute =emit? =byte?: @value
end calminstruction
calminstruction output.sleb128 value*
proxy value, encoding
local encoding
compute value, value
jump enter
loop:
compute encoding, value and $7F or $80
execute =emit? =byte?: @encoding
compute value, value shr 7
enter:
check value >= -$40 & value < $40
jno loop
compute value, value and $7F
execute =emit? =byte?: @value
end calminstruction
iterate signed, u, s
calminstruction signed#leb128? values*&
loop:
split value, values
call output.signed#leb128, value
jyes loop
end calminstruction
end iterate
calminstruction nosection
next required
end calminstruction
calminstruction section?! name*, flags&
proxy sections
local string
next required
execute =end? =virtual?
execute =end? =if?
arrange string, name
stringify string
check string and $FF = ''''
jno ident
compute name, +name
ident:
execute =if? =definite? @sections.name?.=precious? | =defined? required
execute =virtual? @sections.name?.=area?
end calminstruction
calminstruction ident?! comment*
proxy comment
check defined sections..comment
jno skip
execute =section? .=comment
execute =emit? =byte?: @comment, 0
skip:
end calminstruction
calminstruction public?! symbols*&
proxy declared, globals, publics
local declare, global, public
loop:
split symbol, symbols
arrange declare, @declared.symbol
check definite declare
jyes declared
publish declare:, offset
declared:
arrange global, @globals.symbol
check used symbol | used global
jno notrequired
publish :@globals, symbol
publish :@publics, symbol
arrange public, @publics.symbol
compute symbol, symbol
publish global:, symbol
publish public:, symbol
check definite required
jyes notrequired
publish required:, offset
notrequired:
match , symbols
jno loop
end calminstruction
calminstruction weak?! symbols*&
proxy globals, publics
local global, public
loop:
split symbol, symbols
arrange global, @globals.symbol
check used symbol | used global
jno notrequired
arrange public, @publics.symbol
check definite global | defined public
jno required
check defined required
jyes notrequired
compute global, global
publish symbol:, global
jump notrequired
required:
publish :@globals, symbol
publish :@publics, symbol
compute symbol, symbol
publish global:, symbol
check definite required
jyes notrequired
publish required:, offset
notrequired:
match , symbols
jno loop
end calminstruction
calminstruction private?! symbols*&
proxy globals
loop:
split symbol, symbols
check used symbol
jno notrequired
publish :@globals, symbol
check definite required
jyes notrequired
publish required:, offset
notrequired:
match , symbols
jno loop
end calminstruction
calminstruction extern?! symbols*&
proxy globals
local value
loop:
split symbol, symbols
check used symbol
jno notrequired
arrange value, @globals.symbol
compute value, value
publish symbol:, value
notrequired:
match , symbols
jno loop
end calminstruction
calminstruction ifextern?! symbol*
proxy declared
execute =if? =defined? @declared.symbol
end calminstruction
calminstruction cfi_sections? sections*&
end calminstruction
calminstruction cfi_startproc?
proxy sections, pointer
local @start, start, @length, pointer, @cfa_offset, cfa_offset, \
@location, location, @initial_location, @address_range
next cfi
arrange @start, cfi.=start
arrange @length, cfi.=length
arrange @cfa_offset, cfi.=cfa_offset
arrange @location, cfi.=location
arrange @initial_location, cfi.=initial_location
arrange @address_range, cfi.=address_range
compute pointer, cfi.cie
compute cfa_offset, @ez80.ws
publish @cfa_offset, cfa_offset
compute location, $
publish @location, location
publish @initial_location:, location
execute =virtual? @sections..=debug_frame?.=area?
execute =emit? =dword?: @length
compute start, $
publish @start:, start
execute =emit? =dword?: @pointer
execute =emit? =@ez80.=ws: @initial_location, @address_range
execute =end? =virtual?
end calminstruction
calminstruction cfi_endproc?
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_nop , 0x00
proxy sections
local @start, @length, length, \
@initial_location, @address_range, address_range
arrange @start, cfi.=start
arrange @length, cfi.=length
arrange @initial_location, cfi.=initial_location
arrange @address_range, cfi.=address_range
compute pointer, cfi.cie
compute address_range, $ - @initial_location
publish @address_range:, address_range
execute =virtual? @sections..=debug_frame?.=area?
compute length, $ - @start
publish @length:, length
execute =end? =virtual?
end calminstruction
calminstruction cfi.location
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_advance_loc , 0x1 shl 6
once compute DW_CFA_set_loc , 0x01
once compute DW_CFA_advance_loc1 , 0x02
once compute DW_CFA_advance_loc2 , 0x03
once compute DW_CFA_advance_loc4 , 0x04
proxy sections, opc, adv
local @location, location
arrange @location, cfi.=location
compute location, $
execute =virtual? @sections..=debug_frame?.=area?
compute adv, location - @location
check adv
jno done
publish @location, location
check adv < 1 shl 6
jno loc1
compute opc, DW_CFA_advance_loc or adv
execute =emit? =byte?: @opc
exit
loc1:
check adv < 1 shl 8
jno loc2
execute =emit? =byte?: DW_CFA_advance_loc1, @adv
exit
loc2:
check adv < 1 shl 16
jno loc4
execute =emit? =byte?: DW_CFA_advance_loc2
execute =emit? =word?: @adv
exit
loc4:
execute =emit? =byte?: DW_CFA_advance_loc4
execute =emit? =dword?: @adv
done:
end calminstruction
calminstruction cfi_def_cfa? reg*, off*
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_def_cfa , 0x0c
once compute DW_CFA_def_cfa_sf , 0x12
proxy cfi
local @cfa_offset
arrange @cfa_offset, cfi.=cfa_offset
compute off, off
publish @cfa_offset, off
call cfi.location
check off mod -@ez80.ws
jno sf
execute =emit? =byte?: DW_CFA_def_cfa
arrange reg, @cfi.=reg.reg?
call output.uleb128, reg
call output.uleb128, off
execute =end? =virtual?
exit
sf:
compute off, off / -@ez80.ws
execute =emit? =byte?: DW_CFA_def_cfa_sf
arrange reg, @cfi.=reg.reg?
call output.uleb128, reg
call output.sleb128, off
execute =end? =virtual?
end calminstruction
calminstruction cfi_def_cfa_register? reg*
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_def_cfa_register , 0x0d
proxy cfi
call cfi.location
execute =emit? =byte?: DW_CFA_def_cfa_register
arrange reg, @cfi.=reg.reg?
call output.uleb128, reg
execute =end? =virtual?
end calminstruction
calminstruction cfi_def_cfa_offset? off*
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_def_cfa_offset , 0x0e
once compute DW_CFA_def_cfa_offset_sf , 0x13
local @cfa_offset
arrange @cfa_offset, cfi.=cfa_offset
compute off, off
publish @cfa_offset, off
call cfi.location
check off mod -@ez80.ws
jno sf
execute =emit? =byte?: DW_CFA_def_cfa_offset
call output.uleb128, off
execute =end? =virtual?
exit
sf:
compute off, off / -@ez80.ws
execute =emit? =byte?: DW_CFA_def_cfa_offset_sf
call output.sleb128, off
execute =end? =virtual?
end calminstruction
calminstruction cfi_adjust_cfa_offset? off*
local @cfa_offset
arrange @cfa_offset, cfi.=cfa_offset
compute off, @cfa_offset + off
call cfi_def_cfa_offset?, off
end calminstruction
calminstruction cfi_offset? reg*, off*
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_offset , 0x2 shl 6
once compute DW_CFA_offset_extended , 0x05
once compute DW_CFA_offset_extended_sf , 0x11
proxy cfi, opc
execute @cfi.=location
arrange reg, @cfi.=reg.reg?
compute off, off / -@ez80.ws
check off < 0
jyes sf
check reg < 1 shl 6
jno ext
compute opc, DW_CFA_offset or reg
execute =emit? =byte?: @opc
call output.uleb128, off
execute =end? =virtual?
exit
ext:
execute =emit? =byte?: DW_CFA_offset_extended
call output.uleb128, reg
call output.uleb128, off
execute =end? =virtual?
exit
sf:
execute =emit? =byte?: DW_CFA_offset_extended_sf
call output.uleb128, reg
call output.sleb128, off
execute =end? =virtual?
end calminstruction
calminstruction cfi_val_offset? reg*, off*
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_val_offset , 0x14
once compute DW_CFA_val_offset_sf , 0x15
proxy cfi
execute @cfi.=location
arrange reg, @cfi.=reg.reg?
compute off, off / -@ez80.ws
check off < 0
jyes sf
execute =emit? =byte?: DW_CFA_val_offset
call output.uleb128, reg
call output.uleb128, off
execute =end? =virtual?
exit
sf:
execute =emit? =byte?: DW_CFA_val_offset_sf
call output.uleb128, reg
call output.sleb128, off
execute =end? =virtual?
end calminstruction
calminstruction cfi_rel_offset? reg*, off*
local @cfa_offset
arrange @cfa_offset, cfi.=cfa_offset
compute off, @cfa_offset + off
call cfi_offset?, reg, off
end calminstruction
calminstruction cfi_register? reg1*, reg2*
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_def_cfa_register , 0x09
proxy cfi
execute @cfi.=location
execute =emit? =byte?: DW_CFA_def_cfa_register
arrange reg1, @cfi.=reg.reg1?
call output.uleb128, reg1
arrange reg2, @cfi.=reg.reg2?
call output.uleb128, reg2
execute =end? =virtual?
end calminstruction
calminstruction cfi_restore reg*
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_restore , 0x3 shl 6
once compute DW_CFA_restore_extended , 0x06
proxy cfi, opc
execute @cfi.=location
arrange reg, @cfi.=reg.reg?
check reg < 1 shl 6
jno ext
compute opc, DW_CFA_restore or reg
execute =emit? =byte?: @opc
execute =end? =virtual?
exit
ext:
execute =emit? =byte?: DW_CFA_restore_extended
call output.uleb128, reg
execute =end? =virtual?
end calminstruction
calminstruction cfi_undefined reg*
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_undefined , 0x07
proxy cfi
execute @cfi.=location
arrange reg, @cfi.=reg.reg?
execute =emit? =byte?: DW_CFA_undefined
call output.uleb128, reg
execute =end? =virtual?
end calminstruction
calminstruction cfi_same_value reg*
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_same_value , 0x08
proxy cfi
execute @cfi.=location
arrange reg, @cfi.=reg.reg?
execute =emit? =byte?: DW_CFA_same_value
call output.uleb128, reg
execute =end? =virtual?
end calminstruction
calminstruction cfi_remember_state
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_remember_state , 0x0a
proxy cfi
execute @cfi.=location
execute =emit? =byte?: DW_CFA_remember_state
execute =end? =virtual?
end calminstruction
calminstruction cfi_restore_state
; Table 7.29: Call frame instruction encodings
once compute DW_CFA_restore_state , 0x0b
proxy cfi
execute @cfi.=location
execute =emit? =byte?: DW_CFA_restore_state
execute =end? =virtual?
end calminstruction
calminstruction file?! args
local fileno, path, dirname, filename, md5, index, substr, numfiles, var
match path : index, args
jyes file
compute md5, 0
match args= =md5?= md5, args
compute md5, md5
match fileno= dirname= filename, args
jyes combine
match fileno= path, args
jno file
compute path, path
compute index, lengthof path shl 3
splitloop:
check index
jno simple
compute index, index - 8
compute substr, path shr index and $FF
check substr = '/' | substr = '\'
jno splitloop
compute dirname, string path and (1 shl index - 1)
compute filename, string path shr (index + 8)
jump done
simple:
compute dirname, ''
compute filename, path
jump done
combine:
compute dirname, dirname
compute filename, filename
compute substr, filename and $FF
check substr = '/' | substr = '\'
jyes dropdir
compute substr, filename shr 8 and $FFFF
check substr = ':/' | substr = ':\'
jyes dropdir
compute substr, filename and $FFFF
check substr = './' | substr = '.\'
jno notrim
compute filename, string filename shr 16
notrim:
compute path, string dirname \
or '/' shl (lengthof dirname shl 3) \
or filename shl ((lengthof dirname + 1) shl 3)
jump done
dropdir:
compute path, filename
done:
compute fileno, fileno
arrange var, lines.fileno.=path
publish var:, path
arrange var, lines.fileno.=dirname
publish var:, dirname
arrange var, lines.fileno.=filename
publish var:, filename
arrange var, lines.fileno.=md5
publish var:, md5
arrange var, lines.=numfiles
compute numfiles, var + 1
publish var, numfiles
exit
file:
execute =file? args
end calminstruction
calminstruction loc? args&
local pc
take locs, args
compute pc, $
take addrs, pc
end calminstruction
calminstruction output.debug_line
; Table 7.6: Attribute form encodings
once compute DW_FORM_addr , 0x01
once compute DW_FORM_block2 , 0x03
once compute DW_FORM_block4 , 0x04
once compute DW_FORM_data2 , 0x05
once compute DW_FORM_data4 , 0x06
once compute DW_FORM_data8 , 0x07
once compute DW_FORM_string , 0x08
once compute DW_FORM_block , 0x09
once compute DW_FORM_block1 , 0x0a
once compute DW_FORM_data1 , 0x0b
once compute DW_FORM_flag , 0x0c
once compute DW_FORM_sdata , 0x0d
once compute DW_FORM_strp , 0x0e
once compute DW_FORM_udata , 0x0f
once compute DW_FORM_ref_addr , 0x10
once compute DW_FORM_ref1 , 0x11
once compute DW_FORM_ref2 , 0x12
once compute DW_FORM_ref4 , 0x13
once compute DW_FORM_ref8 , 0x14
once compute DW_FORM_ref_udata , 0x15
once compute DW_FORM_indirect , 0x16
once compute DW_FORM_sec_offset , 0x17
once compute DW_FORM_exprloc , 0x18
once compute DW_FORM_flag_present , 0x19
once compute DW_FORM_strx , 0x1a
once compute DW_FORM_addrx , 0x1b
once compute DW_FORM_ref_sup4 , 0x1c
once compute DW_FORM_strp_sup , 0x1d
once compute DW_FORM_data16 , 0x1e
once compute DW_FORM_line_strp , 0x1f
once compute DW_FORM_ref_sig8 , 0x20
once compute DW_FORM_implicit_const , 0x21
once compute DW_FORM_loclistx , 0x22
once compute DW_FORM_rnglistx , 0x23
once compute DW_FORM_ref_sup8 , 0x24
once compute DW_FORM_strx1 , 0x25
once compute DW_FORM_strx2 , 0x26
once compute DW_FORM_strx3 , 0x27
once compute DW_FORM_strx4 , 0x28
once compute DW_FORM_addrx1 , 0x29
once compute DW_FORM_addrx2 , 0x2a
once compute DW_FORM_addrx3 , 0x2b
once compute DW_FORM_addrx4 , 0x2c
; Table 7.25: Line number standard opcode encodings
once compute DW_LNS_copy , 0x01
once compute DW_LNS_advance_pc , 0x02
once compute DW_LNS_advance_line , 0x03
once compute DW_LNS_set_file , 0x04
once compute DW_LNS_set_column , 0x05
once compute DW_LNS_negate_stmt , 0x06
once compute DW_LNS_set_basic_block , 0x07
once compute DW_LNS_const_add_pc , 0x08
once compute DW_LNS_fixed_advance_pc , 0x09
once compute DW_LNS_set_prologue_end , 0x0a
once compute DW_LNS_set_epilogue_begin , 0x0b
once compute DW_LNS_set_isa , 0x0c
; Table 7.26: Line number extended opcode encodings
once compute DW_LNE_end_sequence , 0x01
once compute DW_LNE_set_address , 0x02
once compute DW_LNE_set_discriminator , 0x04
once compute DW_LNE_lo_user , 0x80
once compute DW_LNE_hi_user , 0xff
; Table 7.27: Line number header entry format encodings
once compute DW_LNCT_path , 0x1
once compute DW_LNCT_directory_index , 0x2
once compute DW_LNCT_timestamp , 0x3
once compute DW_LNCT_size , 0x4
once compute DW_LNCT_MD5 , 0x5
once compute DW_LNCT_lo_user , 0x2000
once compute DW_LNCT_hi_user , 0x3fff
proxy line_base, line_range, opcode_base
once compute segment_selector_size , 0
once compute minimum_instruction_length, 1
once compute maximum_operations_per_instruction, 1
once compute default_is_stmt , 1
once compute line_base , -5
once compute line_range , 14
once compute opcode_base , DW_LNS_set_isa + 1
once compute const_add_pc_off , ($FF - opcode_base) / line_range
once compute const_add_pc_adj , const_add_pc_off * line_range
proxy sections, version, loc, value, address
local version, after, @len, len, @headlen, headlen, \
opcidx, @opclen, opclen, numfiles, dirs, numdirs, filesize, \
cur, curdirname, curdirno, curfilename, \
other, otherdirname, otherdirno, \
loc, nextaddr, addroff, nextline, lineoff, options, value, \
address, file, line, column, is_stmt, isa
take loc, locs
jno skip
execute =load? @version: =word? =from? @sections..=debug_info?.=area?: lines.=version
compute version, +version
check version > 1 & version <= 5
jno errversion
compute numdirs, 0
arrange dirs,
arrange numfiles, lines.=numfiles
compute cur, 0
check version < 5
jyes dirnopre5
jump dirnoenter
dirnoloop:
compute numfiles, numfiles - 1
arrange curdirname, lines.cur.=dirname
compute other, 0
check version < 5
jno dirnouniqueenter
dirnouniqueloop:
compute other, other + 1
dirnouniqueenter:
arrange otherdirname, lines.other.=dirname
check curdirname = otherdirname
jno dirnouniqueloop
arrange curdirno, lines.cur.=dirno
arrange otherdirno, lines.other.=dirno
check definite otherdirno
jyes dirnocopy
arrange dirs, dirs curdirname, 0,
compute otherdirno, numdirs
compute numdirs, numdirs + 1
check version < 5
jno dirnocopy
compute otherdirno, numdirs
dirnocopy:
compute otherdirno, otherdirno
publish curdirno:, otherdirno
dirnopre5:
compute cur, cur + 1
dirnoenter:
check numfiles
jyes dirnoloop
execute =section? .=debug_line
arrange numfiles, lines.=numfiles
compute cur, 0
arrange @len, lines.=len
execute =emit? =dword?: @len
compute len, $
execute =emit? =word?: @version
check version < 5
jyes noaddrinfo
execute =emit? =byte?: =@ez80.=ws, 0
noaddrinfo:
arrange @headlen, lines.=headlen
execute =emit? =dword?: @headlen
compute headlen, $
execute =emit? =byte?: minimum_instruction_length
check version < 4
jyes nomininstlen
execute =emit? =byte?: maximum_operations_per_instruction
nomininstlen:
execute =emit? =byte?: default_is_stmt, @line_base, \
@line_range, @opcode_base, \
0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1
check version < 5
jno entries
execute =emit? =byte?: dirs 0
jump filesnext