aboutsummaryrefslogtreecommitdiffstats
path: root/common/Sections.ml
diff options
context:
space:
mode:
authorSylvain Boulmé <sylvain.boulme@univ-grenoble-alpes.fr>2021-03-23 19:12:19 +0100
committerSylvain Boulmé <sylvain.boulme@univ-grenoble-alpes.fr>2021-03-23 19:12:19 +0100
commitdcb523736e82d72b03fa8d055bf74472dba7345c (patch)
tree71e797c92d45dca509527043d233c51b2ed8fc86 /common/Sections.ml
parent3e953ef41f736ed5b7db699b1adf21d46cb5b8db (diff)
parent6bf310dd678285dc193798e89fc2c441d8430892 (diff)
downloadcompcert-kvx-dcb523736e82d72b03fa8d055bf74472dba7345c.tar.gz
compcert-kvx-dcb523736e82d72b03fa8d055bf74472dba7345c.zip
Merge branch 'master' into merge_master_8.13.1
PARTIAL MERGE (PARTLY BROKEN). See unsolved conflicts in: aarch64/TO_MERGE and riscV/TO_MERGE WARNING: interface of va_args and assembly sections have changed
Diffstat (limited to 'common/Sections.ml')
-rw-r--r--common/Sections.ml70
1 files changed, 47 insertions, 23 deletions
diff --git a/common/Sections.ml b/common/Sections.ml
index ea0b6dbc..a1256600 100644
--- a/common/Sections.ml
+++ b/common/Sections.ml
@@ -15,13 +15,17 @@
(* Handling of linker sections *)
+type initialized =
+ | Uninit (* uninitialized data area *)
+ | Init (* initialized with fixed, non-relocatable data *)
+ | Init_reloc (* initialized with relocatable data (symbol addresses) *)
+
type section_name =
| Section_text
- | Section_data of bool (* true = init data, false = uninit data *)
- * bool (* thread local? *)
- | Section_small_data of bool
- | Section_const of bool
- | Section_small_const of bool
+ | Section_data of initialized * bool (* true = thread local ? *)
+ | Section_small_data of initialized
+ | Section_const of initialized
+ | Section_small_const of initialized
| Section_string
| Section_literal
| Section_jumptable
@@ -41,6 +45,7 @@ type access_mode =
type section_info = {
sec_name_init: section_name;
+ sec_name_init_reloc: section_name;
sec_name_uninit: section_name;
sec_writable: bool;
sec_executable: bool;
@@ -48,8 +53,9 @@ type section_info = {
}
let default_section_info = {
- sec_name_init = Section_data (true, false);
- sec_name_uninit = Section_data (false, false);
+ sec_name_init = Section_data (Init, false);
+ sec_name_init_reloc = Section_data (Init_reloc, false);
+ sec_name_uninit = Section_data (Uninit, false);
sec_writable = true;
sec_executable = false;
sec_access = Access_default
@@ -60,46 +66,55 @@ let default_section_info = {
let builtin_sections = [
"CODE",
{sec_name_init = Section_text;
+ sec_name_init_reloc = Section_text;
sec_name_uninit = Section_text;
sec_writable = false; sec_executable = true;
sec_access = Access_default};
"DATA",
- {sec_name_init = Section_data (true, false);
- sec_name_uninit = Section_data (false, false);
+ {sec_name_init = Section_data (Init, false);
+ sec_name_init_reloc = Section_data (Init_reloc, false);
+ sec_name_uninit = Section_data (Uninit, false);
sec_writable = true; sec_executable = false;
sec_access = Access_default};
"TDATA",
- {sec_name_init = Section_data (true, true);
- sec_name_uninit = Section_data (false, true);
+ {sec_name_init = Section_data (Init, true);
+ sec_name_init_reloc = Section_data (Init_reloc, true);
+ sec_name_uninit = Section_data (Uninit, true);
sec_writable = true; sec_executable = false;
sec_access = Access_default};
"SDATA",
- {sec_name_init = Section_small_data true;
- sec_name_uninit = Section_small_data false;
+ {sec_name_init = Section_small_data Init;
+ sec_name_init_reloc = Section_small_data Init_reloc;
+ sec_name_uninit = Section_small_data Uninit;
sec_writable = true; sec_executable = false;
sec_access = Access_near};
"CONST",
- {sec_name_init = Section_const true;
- sec_name_uninit = Section_const false;
+ {sec_name_init = Section_const Init;
+ sec_name_init_reloc = Section_const Init_reloc;
+ sec_name_uninit = Section_const Uninit;
sec_writable = false; sec_executable = false;
sec_access = Access_default};
"SCONST",
- {sec_name_init = Section_small_const true;
- sec_name_uninit = Section_small_const false;
+ {sec_name_init = Section_small_const Init;
+ sec_name_init_reloc = Section_small_const Init_reloc;
+ sec_name_uninit = Section_small_const Uninit;
sec_writable = false; sec_executable = false;
sec_access = Access_near};
"STRING",
{sec_name_init = Section_string;
+ sec_name_init_reloc = Section_string;
sec_name_uninit = Section_string;
sec_writable = false; sec_executable = false;
sec_access = Access_default};
"LITERAL",
{sec_name_init = Section_literal;
+ sec_name_init_reloc = Section_literal;
sec_name_uninit = Section_literal;
sec_writable = false; sec_executable = false;
sec_access = Access_default};
"JUMPTABLE",
{sec_name_init = Section_jumptable;
+ sec_name_init_reloc = Section_jumptable;
sec_name_uninit = Section_jumptable;
sec_writable = false; sec_executable = false;
sec_access = Access_default}
@@ -134,15 +149,19 @@ let define_section name ?iname ?uname ?writable ?executable ?access () =
match executable with Some b -> b | None -> si.sec_executable
and access =
match access with Some b -> b | None -> si.sec_access in
- let iname =
+ let i =
match iname with Some s -> Section_user(s, writable, executable)
| None -> si.sec_name_init in
- let uname =
+ let ir =
+ match iname with Some s -> Section_user(s, writable, executable)
+ | None -> si.sec_name_init_reloc in
+ let u =
match uname with Some s -> Section_user(s, writable, executable)
| None -> si.sec_name_uninit in
let new_si =
- { sec_name_init = iname;
- sec_name_uninit = uname;
+ { sec_name_init = i;
+ sec_name_init_reloc = ir;
+ sec_name_uninit = u;
sec_writable = writable;
sec_executable = executable;
sec_access = access } in
@@ -162,7 +181,7 @@ let use_section_for id name =
let gcc_section name readonly exec =
let sn = Section_user(name, not readonly, exec) in
- { sec_name_init = sn; sec_name_uninit = sn;
+ { sec_name_init = sn; sec_name_init_reloc = sn; sec_name_uninit = sn;
sec_writable = not readonly; sec_executable = exec;
sec_access = Access_default }
@@ -206,7 +225,12 @@ let for_variable env loc id ty init thrl =
Hashtbl.find current_section_table name
with Not_found ->
assert false in
- ((if init then si.sec_name_init else si.sec_name_uninit), si.sec_access)
+ let secname =
+ match init with
+ | Uninit -> si.sec_name_uninit
+ | Init -> si.sec_name_init
+ | Init_reloc -> si.sec_name_init_reloc in
+ (secname, si.sec_access)
(* Determine sections for a function definition *)