summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-01-04 15:39:49 +0000
committerRichard Jones <rjones@redhat.com>2010-01-04 16:23:36 +0000
commit5e180db9eefcd6b459b805c2215ba4d174e4eb83 (patch)
tree343a3858e27041771d15da3dc9e63a2c31ab1e0e /src
parentdb430348cae9f99549a4f7e155a162e71fb9900d (diff)
downloadlibguestfs-5e180db9eefcd6b459b805c2215ba4d174e4eb83.tar.gz
libguestfs-5e180db9eefcd6b459b805c2215ba4d174e4eb83.tar.xz
libguestfs-5e180db9eefcd6b459b805c2215ba4d174e4eb83.zip
Use linker script to control visibility of symbols.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am10
-rwxr-xr-xsrc/generator.ml46
2 files changed, 53 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 619f46ef..fb37167e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,7 +26,8 @@ generator_built = \
guestfs-bindtests.c \
guestfs-actions.pod \
guestfs-availability.pod \
- guestfs-structs.pod
+ guestfs-structs.pod \
+ libguestfs.syms
$(generator_built): stamp-generator
@@ -108,8 +109,10 @@ libprotocol_la_CFLAGS =
#
# Note that this scheme means the real library version will always be
# 'libguestfs.so.0.$(MAX_PROC_NR).0'.
-
libguestfs_la_LDFLAGS = -version-info $(MAX_PROC_NR):0:$(MAX_PROC_NR)
+
+libguestfs_la_LDFLAGS += $(VERSION_SCRIPT_FLAGS)libguestfs.syms
+
libguestfs_la_SOURCES = \
guestfs.c \
guestfs.h \
@@ -118,7 +121,8 @@ libguestfs_la_SOURCES = \
guestfs-bindtests.c \
guestfs-internal.h \
guestfs_protocol.h \
- gettext.h
+ gettext.h \
+ libguestfs.syms
libguestfs_la_LIBADD = $(LTLIBTHREAD)
diff --git a/src/generator.ml b/src/generator.ml
index ebfd45da..4bf4b0f4 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -5607,6 +5607,51 @@ and generate_daemon_actions_h () =
name style;
) daemon_functions
+(* Generate the linker script which controls the visibility of
+ * symbols in the public ABI and ensures no other symbols get
+ * exported accidentally.
+ *)
+and generate_linker_script () =
+ generate_header HashStyle GPLv2plus;
+
+ let globals = [
+ "guestfs_create";
+ "guestfs_close";
+ "guestfs_get_error_handler";
+ "guestfs_get_out_of_memory_handler";
+ "guestfs_last_error";
+ "guestfs_set_error_handler";
+ "guestfs_set_launch_done_callback";
+ "guestfs_set_log_message_callback";
+ "guestfs_set_out_of_memory_handler";
+ "guestfs_set_subprocess_quit_callback";
+
+ (* Unofficial parts of the API: the bindings code use these
+ * functions, so it is useful to export them.
+ *)
+ "guestfs_safe_calloc";
+ "guestfs_safe_malloc";
+ ] in
+ let functions =
+ List.map (fun (name, _, _, _, _, _, _) -> "guestfs_" ^ name)
+ all_functions in
+ let structs =
+ List.concat (
+ List.map (fun (typ, _) ->
+ ["guestfs_free_" ^ typ; "guestfs_free_" ^ typ ^ "_list"])
+ structs
+ ) in
+ let globals = List.sort compare (globals @ functions @ structs) in
+
+ pr "{\n";
+ pr " global:\n";
+ List.iter (pr " %s;\n") globals;
+ pr "\n";
+
+ pr " local:\n";
+ pr " *;\n";
+ pr "};\n"
+
(* Generate the server-side stubs. *)
and generate_daemon_actions () =
generate_header CStyle GPLv2plus;
@@ -11141,6 +11186,7 @@ Run it from the top source directory using the command
output_to "src/guestfs-actions.pod" generate_actions_pod;
output_to "src/guestfs-availability.pod" generate_availability_pod;
output_to "src/MAX_PROC_NR" generate_max_proc_nr;
+ output_to "src/libguestfs.syms" generate_linker_script;
output_to "daemon/actions.h" generate_daemon_actions_h;
output_to "daemon/stubs.c" generate_daemon_actions;
output_to "daemon/names.c" generate_daemon_names;