From 30feb31c6d6e9235acad42ec5d09d14f3919cc36 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Wed, 30 Dec 2020 11:41:10 +0100 Subject: Introduce and use PrintAsmaux.variable_section This is a generalization of the previous PrintAsmaux.common_section function that - handles initialized variables in addition to uninitialized variables; - can be used for Section_const, not just for Section_data. --- backend/PrintAsmaux.ml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'backend') diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index d31507ff..82621010 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -303,11 +303,16 @@ let print_version_and_options oc comment = fprintf oc " %s" Commandline.argv.(i) done; fprintf oc "\n" -(** Get the name of the common section if it is used otherwise the given section - name, with bss as default *) -let common_section ?(sec = ".bss") () = - if !Clflags.option_fcommon then - "COMM" - else - sec +(** Determine the name of the section to use for a variable. + [i] says whether the variable is initialized (true) or not (false). + [sec] is the name of the section to use if initialized or if + no other cases apply. + [bss] is the name of the section to use if uninitialized and + common declarations are not used. If not provided, [sec] is used. +*) + +let variable_section ~sec ?bss i = + if i then sec + else if !Clflags.option_fcommon then "COMM" + else match bss with None -> sec | Some b -> b -- cgit