@@ -60,10 +60,6 @@ type symbol_type =
60
60
| Function
61
61
| Object
62
62
63
- type align_padding =
64
- | Nop
65
- | Zero
66
-
67
63
(* CR sspies: We should use the "STT" forms when they are supported as they are
68
64
unambiguous across platforms (cf.
69
65
https://sourceware.org/binutils/docs/as/Type.html). *)
@@ -149,15 +145,10 @@ module Directive = struct
149
145
| Code
150
146
| Machine_width_data
151
147
152
- type reloc_type = R_X86_64_PLT32
153
-
154
148
type comment = string
155
149
156
150
type t =
157
- | Align of
158
- { bytes : int ;
159
- fill_x86_bin_emitter : align_padding
160
- }
151
+ | Align of { bytes : int }
161
152
| Bytes of
162
153
{ str : string ;
163
154
comment : string option
@@ -211,14 +202,6 @@ module Directive = struct
211
202
comment : string option
212
203
}
213
204
| Protected of string
214
- | Hidden of string
215
- | Weak of string
216
- | External of string
217
- | Reloc of
218
- { offset : Constant .t ;
219
- name : reloc_type ;
220
- expr : Constant .t
221
- }
222
205
223
206
let bprintf = Printf. bprintf
224
207
@@ -283,8 +266,6 @@ module Directive = struct
283
266
bprintf buf " \t .ascii\t\" %s\" "
284
267
(string_of_string_literal (String. sub s ! i (l - ! i)))
285
268
286
- let reloc_type_to_string = function R_X86_64_PLT32 -> " R_X86_64_PLT32"
287
-
288
269
let print_gas buf t =
289
270
let gas_comment_opt comment_opt =
290
271
if not (emit_comments () )
@@ -295,10 +276,7 @@ module Directive = struct
295
276
| Some comment -> Printf. sprintf " \t /* %s */" comment
296
277
in
297
278
match t with
298
- | Align { bytes = n ; fill_x86_bin_emitter = _ } ->
299
- (* The flag [fill_x86_bin_emitter] is only relevant for the binary
300
- emitter. On GAS, we can ignore it and just use [.align] in both
301
- cases. *)
279
+ | Align { bytes = n } ->
302
280
(* Some assemblers interpret the integer n as a 2^n alignment and others
303
281
as a number of bytes. *)
304
282
let n =
@@ -398,14 +376,6 @@ module Directive = struct
398
376
Misc. fatal_error
399
377
" Cannot emit [Direct_assignment] except on macOS-like assemblers" )
400
378
| Protected s -> bprintf buf " \t .protected\t %s" s
401
- | Hidden s -> bprintf buf " \t .hidden\t %s" s
402
- | Weak s -> bprintf buf " \t .weak\t %s" s
403
- (* masm only *)
404
- | External _ -> assert false
405
- | Reloc { offset; name; expr } ->
406
- bprintf buf " \t .reloc\t %a, %s, %a" Constant. print offset
407
- (reloc_type_to_string name)
408
- Constant. print expr
409
379
410
380
let print_masm buf t =
411
381
let unsupported name =
@@ -420,10 +390,7 @@ module Directive = struct
420
390
| Some comment -> Printf. sprintf " \t ; %s" comment
421
391
in
422
392
match t with
423
- | Align { bytes; fill_x86_bin_emitter = _ } ->
424
- (* The flag [fill_x86_bin_emitter] is only relevant for the x86 binary
425
- emitter. On MASM, we can ignore it. *)
426
- bprintf buf " \t ALIGN\t %d" bytes
393
+ | Align { bytes } -> bprintf buf " \t ALIGN\t %d" bytes
427
394
| Bytes { str; comment } ->
428
395
buf_bytes_directive buf ~directive: " BYTE" str;
429
396
bprintf buf " %s" (masm_comment_opt comment)
@@ -469,11 +436,6 @@ module Directive = struct
469
436
| Uleb128 _ -> unsupported " Uleb128"
470
437
| Direct_assignment _ -> unsupported " Direct_assignment"
471
438
| Protected _ -> unsupported " Protected"
472
- | Hidden _ -> unsupported " Hidden"
473
- | Weak _ -> unsupported " Weak"
474
- | External s -> bprintf buf " \t EXTRN\t %s: NEAR" s
475
- (* The only supported "type" on EXTRN declarations is NEAR. *)
476
- | Reloc _ -> unsupported " Reloc"
477
439
478
440
let print b t =
479
441
match TS. assembler () with
@@ -518,13 +480,6 @@ let const_variable var = Variable var
518
480
519
481
let const_int64 i : expr = Signed_int i
520
482
521
- let const_with_offset const (offset : int64 ) =
522
- if Int64. equal offset 0L
523
- then const
524
- else if Int64. compare offset 0L < 0
525
- then Sub (const, Signed_int (Int64. neg offset))
526
- else Add (const, Signed_int offset)
527
-
528
483
let emit_ref = ref None
529
484
530
485
let emit (d : Directive.t ) =
@@ -537,8 +492,7 @@ let emit_non_masm (d : Directive.t) =
537
492
538
493
let section ~names ~flags ~args = emit (Section { names; flags; args })
539
494
540
- let align ~fill_x86_bin_emitter ~bytes =
541
- emit (Align { bytes; fill_x86_bin_emitter })
495
+ let align ~bytes = emit (Align { bytes })
542
496
543
497
let should_generate_cfi () =
544
498
(* We generate CFI info even if we're not generating any other debugging
@@ -589,16 +543,8 @@ let indirect_symbol symbol = emit (Indirect_symbol (Asm_symbol.encode symbol))
589
543
590
544
let private_extern symbol = emit (Private_extern (Asm_symbol. encode symbol))
591
545
592
- let extrn symbol = emit (External (Asm_symbol. encode symbol))
593
-
594
- let hidden symbol = emit (Hidden (Asm_symbol. encode symbol))
595
-
596
- let weak symbol = emit (Weak (Asm_symbol. encode symbol))
597
-
598
546
let size symbol cst = emit (Size (Asm_symbol. encode symbol, lower_expr cst))
599
547
600
- let size_const sym n = emit (Size (Asm_symbol. encode sym, Signed_int n))
601
-
602
548
let type_ symbol ~type_ = emit (Type (symbol, type_))
603
549
604
550
let sleb128 ?comment i =
@@ -675,7 +621,7 @@ let label ?comment label = const_machine_width ?comment (Label label)
675
621
let label_plus_offset ?comment lab ~offset_in_bytes =
676
622
let offset_in_bytes = Targetint. to_int64 offset_in_bytes in
677
623
let lab = const_label lab in
678
- const_machine_width ?comment (const_with_offset lab offset_in_bytes)
624
+ const_machine_width ?comment (const_add lab (const_int64 offset_in_bytes) )
679
625
680
626
let define_label label =
681
627
let lbl_section = Asm_label. section label in
@@ -847,7 +793,7 @@ let symbol ?comment sym = const_machine_width ?comment (Symbol sym)
847
793
848
794
let symbol_plus_offset symbol ~offset_in_bytes =
849
795
let offset_in_bytes = Targetint. to_int64 offset_in_bytes in
850
- const_machine_width (const_with_offset (Symbol symbol) offset_in_bytes)
796
+ const_machine_width (Add (Symbol symbol, Signed_int offset_in_bytes) )
851
797
852
798
let int8 ?comment i =
853
799
const ?comment (Signed_int (Int64. of_int (Int8. to_int i))) Eight
@@ -938,14 +884,9 @@ let between_labels_16_bit ?comment:_ ~upper:_ ~lower:_ () =
938
884
(* CR poechsel: use the arguments *)
939
885
Misc. fatal_error " between_labels_16_bit not implemented yet"
940
886
941
- let between_labels_32_bit ?comment :_comment ~upper ~lower () =
942
- let expr = const_sub (const_label upper) (const_label lower) in
943
- (* CR sspies: Unlike in most of the other distance computation functions in
944
- this file, we do not force an assembly time constant in this function. This
945
- is to follow the existing/previous implementation of the x86 backend. In
946
- the future, we should investigate whether it would be more appropriate to
947
- force an assembly time constant. *)
948
- const expr Thirty_two
887
+ let between_labels_32_bit ?comment :_ ~upper:_ ~lower:_ () =
888
+ (* CR poechsel: use the arguments *)
889
+ Misc. fatal_error " between_labels_32_bit not implemented yet"
949
890
950
891
let between_labels_64_bit ?comment :_ ~upper:_ ~lower:_ () =
951
892
(* CR poechsel: use the arguments *)
@@ -1118,14 +1059,3 @@ let offset_into_dwarf_section_symbol ?comment:_comment
1118
1059
match width with
1119
1060
| Thirty_two -> const expr Thirty_two
1120
1061
| Sixty_four -> const expr Sixty_four
1121
-
1122
- let reloc_x86_64_plt32 ~offset_from_this ~target_symbol ~rel_offset_from_next =
1123
- emit
1124
- (Reloc
1125
- { offset = Sub (This , Signed_int offset_from_this);
1126
- name = R_X86_64_PLT32 ;
1127
- expr =
1128
- Sub
1129
- ( Named_thing (Asm_symbol. encode target_symbol),
1130
- Signed_int rel_offset_from_next )
1131
- })
0 commit comments