File tree 3 files changed +15
-7
lines changed
3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ let to_x86_directive (dir : ND.Directive.t) : X86_ast.asm_line list =
110
110
comment_lines comment @ [X86_ast. Sleb128 (to_x86_constant constant)]
111
111
| Space { bytes } -> [Space bytes]
112
112
| Type (n , st ) ->
113
- let typ = match st with Function -> " STT_FUNC " | Object -> " STT_OBJECT " in
113
+ let typ = ND. symbol_type_to_string st in
114
114
[Type (n, typ)]
115
115
| Uleb128 { constant; comment } ->
116
116
comment_lines comment @ [X86_ast. Uleb128 (to_x86_constant constant)]
Original file line number Diff line number Diff line change @@ -65,6 +65,16 @@ type symbol_type =
65
65
| Function
66
66
| Object
67
67
68
+ (* CR sspies: We should use the "STT" forms when they are supported as they are
69
+ unambiguous across platforms (cf.
70
+ https://sourceware.org/binutils/docs/as/Type.html). *)
71
+ let symbol_type_to_string sym =
72
+ match TS. architecture () with
73
+ | AArch64 -> ( match sym with Function -> " %function" | Object -> " %object" )
74
+ | X86_64 -> (
75
+ match sym with Function -> " @function" | Object -> " STT_OBJECT" )
76
+ | _ -> Misc. fatal_error " Symbol types not implemented for this architecture."
77
+
68
78
let bprintf = Printf. bprintf
69
79
70
80
module Directive = struct
@@ -349,12 +359,7 @@ module Directive = struct
349
359
let comment = gas_comment_opt comment in
350
360
bprintf buf " \t .sleb128\t %a%s" Constant. print constant comment
351
361
| Type (s , typ ) ->
352
- (* We use the "STT" forms when they are supported as they are unambiguous
353
- across platforms (cf. https://sourceware.org/binutils/docs/as/Type.html
354
- ). *)
355
- let typ =
356
- match typ with Function -> " STT_FUNC" | Object -> " STT_OBJECT"
357
- in
362
+ let typ = symbol_type_to_string typ in
358
363
bprintf buf " \t .type %s %s" s typ
359
364
| Uleb128 { constant; comment } ->
360
365
let comment = gas_comment_opt comment in
Original file line number Diff line number Diff line change @@ -210,6 +210,9 @@ type symbol_type =
210
210
| Function
211
211
| Object
212
212
213
+ (* * The string representation, architecture dependent at the moment. *)
214
+ val symbol_type_to_string : symbol_type -> string
215
+
213
216
val type_symbol : Asm_symbol .t -> ty :symbol_type -> unit
214
217
215
218
val type_label : Asm_label .t -> ty :symbol_type -> unit
You can’t perform that action at this time.
0 commit comments