diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | src/Makefile.am | 10 | ||||
-rwxr-xr-x | src/generator.ml | 46 |
4 files changed, 60 insertions, 3 deletions
@@ -219,6 +219,7 @@ src/guestfs_protocol.h src/guestfs_protocol.x src/guestfs-structs.h src/.libs/libguestfs.so +src/libguestfs.syms src/.pod2text.data src/stamp-generator stamp-h1 diff --git a/configure.ac b/configure.ac index 9a781c75..d7ad7c7c 100644 --- a/configure.ac +++ b/configure.ac @@ -116,6 +116,12 @@ test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant]) AM_PROG_CC_C_O +dnl Work out how to specify the linker script to the linker. +VERSION_SCRIPT_FLAGS=-Wl,--version-script= +`/usr/bin/ld --help 2>&1 | grep -- --version-script >/dev/null` || \ + VERSION_SCRIPT_FLAGS="-Wl,-M -Wl," +AC_SUBST(VERSION_SCRIPT_FLAGS) + dnl Check support for 64 bit file offsets. AC_SYS_LARGEFILE 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; |