File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,10 @@ let atom_is_static a =
5252 with Not_found ->
5353 false
5454
55- (* Is it possible for symbol [a] to be defined in a DLL? *)
55+ (* Is it possible for symbol [a] to be defined in a DLL?
56+ Yes, unless [a] is defined in the current compilation unit, or is static.
57+ (This criterion is appropriate for macOS and for Cygwin; for ELF,
58+ see [atom_needs_GOT_access] below.) *)
5659let atom_is_external a =
5760 match Hashtbl. find decl_atom a with
5861 | { a_defined = true } -> false
@@ -61,6 +64,18 @@ let atom_is_external a =
6164 | _ -> true
6265 | exception Not_found -> true
6366
67+ (* In ELF PIC code, the rules are different: all non-static symbols
68+ must be accessed through the GOT, even if they are defined in the
69+ current compilation unit. (This is to allow symbol interposition by
70+ the dynamic loader.) *)
71+ let atom_needs_GOT_access a =
72+ ! Clflags. option_fpic &&
73+ begin match Hashtbl. find decl_atom a with
74+ | { a_storage = C. Storage_static } -> false
75+ | _ -> true
76+ | exception Not_found -> true
77+ end
78+
6479let atom_alignof a =
6580 try
6681 (Hashtbl. find decl_atom a).a_alignment
You can’t perform that action at this time.
0 commit comments