diff options
author | Yann Herklotz <git@yannherklotz.com> | 2021-09-17 18:28:55 +0100 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2021-09-17 18:28:55 +0100 |
commit | a1c401a4eba5fc9fcf42933f70005ecb679a4c1c (patch) | |
tree | 26637fca5d1da9b3d049234721d593a60b03a6d3 /backend/PrintAsmaux.ml | |
parent | c49caca4b5f0239b43610fbfe012d6ba0211b364 (diff) | |
parent | 1daf96cdca4d828c333cea5c9a314ef861342984 (diff) | |
download | compcert-a1c401a4eba5fc9fcf42933f70005ecb679a4c1c.tar.gz compcert-a1c401a4eba5fc9fcf42933f70005ecb679a4c1c.zip |
Merge branch 'master' into dev/michalisdev/michalis
Diffstat (limited to 'backend/PrintAsmaux.ml')
-rw-r--r-- | backend/PrintAsmaux.ml | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index d31507ff..e39ba8aa 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -303,11 +303,28 @@ 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] is the initialization status of the variable. + - [sec] is the name of the section to use if initialized (with no + relocations) or if no other cases apply. + - [reloc] is the name of the section to use if initialized and + containing relocations. If not provided, [sec] is used. + - [bss] is the name of the section to use if uninitialized and + common declarations are not used. If not provided, [sec] is used. + - [common] says whether common declarations can be used for uninitialized + variables. It defaults to the status of the [-fcommon] / [-fno-common] + command-line option. Passing [~common:false] is needed when + common declarations cannot be used at all, for example in the context of + small data areas. +*) + +let variable_section ~sec ?bss ?reloc ?(common = !Clflags.option_fcommon) i = + match i with + | Uninit -> + if common + then "COMM" + else begin match bss with Some s -> s | None -> sec end + | Init -> sec + | Init_reloc -> + begin match reloc with Some s -> s | None -> sec end |