@@ -111,7 +111,7 @@ module Target : TARGET =
111111(* Generate code to load the address of id + ofs in register r *)
112112
113113 let loadsymbol oc r id ofs =
114- if Archi. pic_code () then begin
114+ if SelectOp. symbol_is_relocatable id then begin
115115 assert (ofs = Integers.Ptrofs. zero);
116116 fprintf oc " la %a, %s\n " ireg r (extern_atom id)
117117 end else begin
@@ -144,6 +144,13 @@ module Target : TARGET =
144144 assert (! latest_auipc = Some (id, ofs));
145145 fprintf oc " %%pcrel_lo(1b)"
146146
147+ (* Emit the target of a call, with a `@plt` suffix in PIC mode. *)
148+
149+ let symbol_plt oc s =
150+ if ! Clflags. option_fpic
151+ then fprintf oc " %a@plt" symbol s
152+ else symbol oc s
153+
147154(* Printing of instructions *)
148155 let print_instruction oc = function
149156 | Pmv (rd , rs ) ->
@@ -277,11 +284,11 @@ module Target : TARGET =
277284 | Pj_l (l ) ->
278285 fprintf oc " j %a\n " print_label l
279286 | Pj_s (s , sg ) ->
280- fprintf oc " jump %a, x31 \n " symbol s
287+ fprintf oc " tail %a\n " symbol_plt s
281288 | Pj_r (r , sg ) ->
282289 fprintf oc " jr %a\n " ireg r
283290 | Pjal_s (s , sg ) ->
284- fprintf oc " call %a\n " symbol s
291+ fprintf oc " call %a\n " symbol_plt s
285292 | Pjal_r (r , sg ) ->
286293 fprintf oc " jalr %a\n " ireg r
287294
@@ -596,7 +603,8 @@ module Target : TARGET =
596603 let address = if Archi. ptr64 then " .quad" else " .long"
597604
598605 let print_prologue oc =
599- fprintf oc " .option %s\n " (if Archi. pic_code() then " pic" else " nopic" );
606+ fprintf oc " .option %s\n "
607+ (if ! Clflags. option_fpic then " pic" else " nopic" );
600608 if ! Clflags. option_g then begin
601609 section oc Section_text ;
602610 end
0 commit comments