@@ -60,10 +60,6 @@ type symbol_type =
6060 | Function
6161 | Object
6262
63- type align_padding =
64- | Nop
65- | Zero
66-
6763(* CR sspies: We should use the "STT" forms when they are supported as they are
6864 unambiguous across platforms (cf.
6965 https://sourceware.org/binutils/docs/as/Type.html). *)
@@ -149,15 +145,10 @@ module Directive = struct
149145 | Code
150146 | Machine_width_data
151147
152- type reloc_type = R_X86_64_PLT32
153-
154148 type comment = string
155149
156150 type t =
157- | Align of
158- { bytes : int ;
159- fill_x86_bin_emitter : align_padding
160- }
151+ | Align of { bytes : int }
161152 | Bytes of
162153 { str : string ;
163154 comment : string option
@@ -211,14 +202,6 @@ module Directive = struct
211202 comment : string option
212203 }
213204 | 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- }
222205
223206 let bprintf = Printf. bprintf
224207
@@ -283,8 +266,6 @@ module Directive = struct
283266 bprintf buf " \t .ascii\t\" %s\" "
284267 (string_of_string_literal (String. sub s ! i (l - ! i)))
285268
286- let reloc_type_to_string = function R_X86_64_PLT32 -> " R_X86_64_PLT32"
287-
288269 let print_gas buf t =
289270 let gas_comment_opt comment_opt =
290271 if not (emit_comments () )
@@ -295,10 +276,7 @@ module Directive = struct
295276 | Some comment -> Printf. sprintf " \t /* %s */" comment
296277 in
297278 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 } ->
302280 (* Some assemblers interpret the integer n as a 2^n alignment and others
303281 as a number of bytes. *)
304282 let n =
@@ -398,14 +376,6 @@ module Directive = struct
398376 Misc. fatal_error
399377 " Cannot emit [Direct_assignment] except on macOS-like assemblers" )
400378 | 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
409379
410380 let print_masm buf t =
411381 let unsupported name =
@@ -420,10 +390,7 @@ module Directive = struct
420390 | Some comment -> Printf. sprintf " \t ; %s" comment
421391 in
422392 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
427394 | Bytes { str; comment } ->
428395 buf_bytes_directive buf ~directive: " BYTE" str;
429396 bprintf buf " %s" (masm_comment_opt comment)
@@ -469,11 +436,6 @@ module Directive = struct
469436 | Uleb128 _ -> unsupported " Uleb128"
470437 | Direct_assignment _ -> unsupported " Direct_assignment"
471438 | 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"
477439
478440 let print b t =
479441 match TS. assembler () with
@@ -518,13 +480,6 @@ let const_variable var = Variable var
518480
519481let const_int64 i : expr = Signed_int i
520482
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-
528483let emit_ref = ref None
529484
530485let emit (d : Directive.t ) =
@@ -537,8 +492,7 @@ let emit_non_masm (d : Directive.t) =
537492
538493let section ~names ~flags ~args = emit (Section { names; flags; args })
539494
540- let align ~fill_x86_bin_emitter ~bytes =
541- emit (Align { bytes; fill_x86_bin_emitter })
495+ let align ~bytes = emit (Align { bytes })
542496
543497let should_generate_cfi () =
544498 (* 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))
589543
590544let private_extern symbol = emit (Private_extern (Asm_symbol. encode symbol))
591545
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-
598546let size symbol cst = emit (Size (Asm_symbol. encode symbol, lower_expr cst))
599547
600- let size_const sym n = emit (Size (Asm_symbol. encode sym, Signed_int n))
601-
602548let type_ symbol ~type_ = emit (Type (symbol, type_))
603549
604550let sleb128 ?comment i =
@@ -675,7 +621,7 @@ let label ?comment label = const_machine_width ?comment (Label label)
675621let label_plus_offset ?comment lab ~offset_in_bytes =
676622 let offset_in_bytes = Targetint. to_int64 offset_in_bytes in
677623 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) )
679625
680626let define_label label =
681627 let lbl_section = Asm_label. section label in
@@ -847,7 +793,7 @@ let symbol ?comment sym = const_machine_width ?comment (Symbol sym)
847793
848794let symbol_plus_offset symbol ~offset_in_bytes =
849795 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) )
851797
852798let int8 ?comment i =
853799 const ?comment (Signed_int (Int64. of_int (Int8. to_int i))) Eight
@@ -938,14 +884,9 @@ let between_labels_16_bit ?comment:_ ~upper:_ ~lower:_ () =
938884 (* CR poechsel: use the arguments *)
939885 Misc. fatal_error " between_labels_16_bit not implemented yet"
940886
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"
949890
950891let between_labels_64_bit ?comment :_ ~upper:_ ~lower:_ () =
951892 (* CR poechsel: use the arguments *)
@@ -1118,14 +1059,3 @@ let offset_into_dwarf_section_symbol ?comment:_comment
11181059 match width with
11191060 | Thirty_two -> const expr Thirty_two
11201061 | 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