diff options
author | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2020-12-30 11:41:10 +0100 |
---|---|---|
committer | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2021-02-23 11:33:14 +0100 |
commit | 30feb31c6d6e9235acad42ec5d09d14f3919cc36 (patch) | |
tree | 8bcf3c6c4a0bd2875d36858979de1a5cd219d677 /backend/PrintAsmaux.ml | |
parent | 25483cf1acce8695a438f4f2164b09fb1ecd9d2e (diff) | |
download | compcert-30feb31c6d6e9235acad42ec5d09d14f3919cc36.tar.gz compcert-30feb31c6d6e9235acad42ec5d09d14f3919cc36.zip |
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.
Diffstat (limited to 'backend/PrintAsmaux.ml')
-rw-r--r-- | backend/PrintAsmaux.ml | 19 |
1 files changed, 12 insertions, 7 deletions
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 |