diff options
author | Léo Gourdin <leo.gourdin@univ-grenoble-alpes.fr> | 2021-06-10 18:28:26 +0200 |
---|---|---|
committer | Léo Gourdin <leo.gourdin@univ-grenoble-alpes.fr> | 2021-06-10 18:28:26 +0200 |
commit | f16fa31ec9cc90da750c8cc10f447023962cd153 (patch) | |
tree | 28eed4d4b5bc964907f20332d1eed470a393d07b /backend/PrintAsmaux.ml | |
parent | 485a4c0dd450e65745c83e59acdb40b42058e556 (diff) | |
parent | d703ae1ad5e1fcdc63e07b2a50a3e8576a11e61e (diff) | |
download | compcert-kvx-f16fa31ec9cc90da750c8cc10f447023962cd153.tar.gz compcert-kvx-f16fa31ec9cc90da750c8cc10f447023962cd153.zip |
Merge branch 'kvx-work' into BTL
Diffstat (limited to 'backend/PrintAsmaux.ml')
-rw-r--r-- | backend/PrintAsmaux.ml | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index 5cb693af..f1978ad2 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -307,15 +307,32 @@ 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 + (* Profiling *) let profiling_table : (Digest.t, int) Hashtbl.t = Hashtbl.create 1000;; |