diff options
author | Mike Frysinger <vapier@gentoo.org> | 2007-04-13 14:08:16 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2007-04-13 14:08:16 +0000 |
commit | a822d2d11872c10925e7f2bfa65b27e30a9700a5 (patch) | |
tree | 64ac478b67a8396a895d239f4bc3531e29b654b3 | |
parent | fc0606395810db622c0eb4256997117d4baf67d9 (diff) |
kill off internal relocations for librc.so
-rw-r--r-- | src/librc-daemon.c | 34 | ||||
-rw-r--r-- | src/librc-depend.c | 22 | ||||
-rw-r--r-- | src/librc-misc.c | 44 | ||||
-rw-r--r-- | src/librc-strlist.c | 14 | ||||
-rw-r--r-- | src/librc.c | 46 | ||||
-rw-r--r-- | src/librc.h | 124 |
6 files changed, 194 insertions, 90 deletions
diff --git a/src/librc-daemon.c b/src/librc-daemon.c index 240ca6ed..4473cc16 100644 --- a/src/librc-daemon.c +++ b/src/librc-daemon.c @@ -5,34 +5,7 @@ Released under the GPLv2 */ -#include <sys/types.h> -#include <sys/stat.h> - -#if defined(__DragonFly__) || defined(__FreeBSD__) || \ - defined(__NetBSD__) || defined (__OpenBSD__) -#include <sys/param.h> -#include <sys/user.h> -#include <sys/sysctl.h> -#include <kvm.h> -#include <limits.h> -#endif - -#ifndef __linux__ -#include <libgen.h> -#endif - -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "einfo.h" -#include "rc.h" -#include "rc-misc.h" -#include "strlist.h" +#include "librc.h" #if defined(__linux__) static bool pid_is_cmd (pid_t pid, const char *cmd) @@ -171,6 +144,7 @@ pid_t *rc_find_pids (const char *exec, const char *cmd, return (pids); } +librc_hidden_def(rc_find_pids) #elif defined(__DragonFly__) || defined(__FreeBSD__) || \ defined(__NetBSD__) || defined(__OpenBSD__) @@ -248,6 +222,7 @@ pid_t *rc_find_pids (const char *exec, const char *cmd, return (pids); } +librc_hidden_def(rc_find_pids) #else # error "Platform not supported!" @@ -394,6 +369,7 @@ void rc_set_service_daemon (const char *service, const char *exec, free (mpidfile); free (dirpath); } +librc_hidden_def(rc_set_service_daemon) bool rc_service_started_daemon (const char *service, const char *exec, int indx) @@ -437,6 +413,7 @@ bool rc_service_started_daemon (const char *service, const char *exec, free (mexec); return (retval); } +librc_hidden_def(rc_service_started_daemon) bool rc_service_daemons_crashed (const char *service) { @@ -560,3 +537,4 @@ bool rc_service_daemons_crashed (const char *service) return (retval); } +librc_hidden_def(rc_service_daemons_crashed) diff --git a/src/librc-depend.c b/src/librc-depend.c index f9b9bcd7..1c3c764c 100644 --- a/src/librc-depend.c +++ b/src/librc-depend.c @@ -4,20 +4,7 @@ Copyright 2006-2007 Gentoo Foundation */ -#include <sys/types.h> -#include <sys/stat.h> - -#include <errno.h> -#include <limits.h> -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "einfo.h" -#include "rc.h" -#include "rc-misc.h" -#include "strlist.h" +#include "librc.h" #define GENDEP RC_LIBDIR "/sh/gendepends.sh" @@ -70,6 +57,7 @@ void rc_free_deptree (rc_depinfo_t *deptree) di = dip; } } +librc_hidden_def(rc_free_deptree) rc_depinfo_t *rc_load_deptree (void) { @@ -158,6 +146,7 @@ rc_depinfo_t *rc_load_deptree (void) return (deptree); } +librc_hidden_def(rc_load_deptree) rc_depinfo_t *rc_get_depinfo (rc_depinfo_t *deptree, const char *service) { @@ -172,6 +161,7 @@ rc_depinfo_t *rc_get_depinfo (rc_depinfo_t *deptree, const char *service) return (NULL); } +librc_hidden_def(rc_get_depinfo) rc_deptype_t *rc_get_deptype (rc_depinfo_t *depinfo, const char *type) { @@ -186,6 +176,7 @@ rc_deptype_t *rc_get_deptype (rc_depinfo_t *depinfo, const char *type) return (NULL); } +librc_hidden_def(rc_get_deptype) static bool valid_service (const char *runlevel, const char *service) { @@ -456,6 +447,7 @@ char **rc_get_depends (rc_depinfo_t *deptree, rc_strlist_free (visited.list); return (sorted.list); } +librc_hidden_def(rc_get_depends) char **rc_order_services (rc_depinfo_t *deptree, const char *runlevel, int options) @@ -510,6 +502,7 @@ char **rc_order_services (rc_depinfo_t *deptree, const char *runlevel, return (services); } +librc_hidden_def(rc_order_services) static bool is_newer_than (const char *file, const char *target) { @@ -838,3 +831,4 @@ int rc_update_deptree (bool force) eend (retval, "Failed to update the service dependency tree"); return (retval); } +librc_hidden_def(rc_update_deptree) diff --git a/src/librc-misc.c b/src/librc-misc.c index 55a9ac19..b728e8c9 100644 --- a/src/librc-misc.c +++ b/src/librc-misc.c @@ -4,24 +4,7 @@ Copyright 2007 Gentoo Foundation */ -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/utsname.h> - -#include <dirent.h> -#include <errno.h> -#include <limits.h> -#include <regex.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "einfo.h" -#include "rc-misc.h" -#include "rc.h" -#include "strlist.h" +#include "librc.h" #define ERRX eerrorx("out of memory"); @@ -45,6 +28,7 @@ void *rc_xcalloc (size_t n, size_t size) ERRX } +librc_hidden_def(rc_xcalloc) void *rc_xmalloc (size_t size) { @@ -55,6 +39,7 @@ void *rc_xmalloc (size_t size) ERRX } +librc_hidden_def(rc_xmalloc) void *rc_xrealloc (void *ptr, size_t size) { @@ -65,7 +50,7 @@ void *rc_xrealloc (void *ptr, size_t size) ERRX } - +librc_hidden_def(rc_xrealloc) char *rc_xstrdup (const char *str) { @@ -81,6 +66,7 @@ char *rc_xstrdup (const char *str) ERRX } +librc_hidden_def(rc_xstrdup) bool rc_is_env (const char *var, const char *val) { @@ -95,6 +81,7 @@ bool rc_is_env (const char *var, const char *val) return (strcasecmp (v, val) == 0 ? true : false); } +librc_hidden_def(rc_is_env) char *rc_strcatpaths (const char *path1, const char *paths, ...) { @@ -142,6 +129,7 @@ char *rc_strcatpaths (const char *path1, const char *paths, ...) return (path); } +librc_hidden_def(rc_strcatpaths) bool rc_exists (const char *pathname) { @@ -156,6 +144,7 @@ bool rc_exists (const char *pathname) errno = 0; return (false); } +librc_hidden_def(rc_exists) bool rc_is_file (const char *pathname) { @@ -170,13 +159,14 @@ bool rc_is_file (const char *pathname) errno = 0; return (false); } +librc_hidden_def(rc_is_file) bool rc_is_dir (const char *pathname) { struct stat buf; if (! pathname) - return (false); + return (false); if (stat (pathname, &buf) == 0) return (S_ISDIR (buf.st_mode)); @@ -184,13 +174,14 @@ bool rc_is_dir (const char *pathname) errno = 0; return (false); } +librc_hidden_def(rc_is_dir) bool rc_is_link (const char *pathname) { struct stat buf; if (! pathname) - return (false); + return (false); if (lstat (pathname, &buf) == 0) return (S_ISLNK (buf.st_mode)); @@ -198,6 +189,7 @@ bool rc_is_link (const char *pathname) errno = 0; return (false); } +librc_hidden_def(rc_is_link) bool rc_is_exec (const char *pathname) { @@ -212,6 +204,7 @@ bool rc_is_exec (const char *pathname) errno = 0; return (false); } +librc_hidden_def(rc_is_exec) char **rc_ls_dir (char **list, const char *dir, int options) { @@ -257,6 +250,7 @@ char **rc_ls_dir (char **list, const char *dir, int options) return (list); } +librc_hidden_def(rc_ls_dir) bool rc_rm_dir (const char *pathname, bool top) { @@ -304,6 +298,7 @@ bool rc_rm_dir (const char *pathname, bool top) return (true); } +librc_hidden_def(rc_rm_dir) char **rc_get_config (char **list, const char *file) { @@ -365,7 +360,7 @@ char **rc_get_config (char **list, const char *file) if (strcmp (linetok, entry) == 0) { /* We have a match now - to save time we directly replace it */ free (list[i - 1]); - list[i - 1] = newline; + list[i - 1] = newline; replaced = true; free (tmp); break; @@ -383,6 +378,7 @@ char **rc_get_config (char **list, const char *file) return (list); } +librc_hidden_def(rc_get_config) char *rc_get_config_entry (char **list, const char *entry) { @@ -398,6 +394,7 @@ char *rc_get_config_entry (char **list, const char *entry) return (NULL); } +librc_hidden_def(rc_get_config_entry) char **rc_get_list (char **list, const char *file) { @@ -432,6 +429,7 @@ char **rc_get_list (char **list, const char *file) return (list); } +librc_hidden_def(rc_get_list) char **rc_filter_env (void) { @@ -528,6 +526,7 @@ char **rc_filter_env (void) return (env); } +librc_hidden_def(rc_filter_env) /* Other systems may need this at some point, but for now it's Linux only */ #ifdef __linux__ @@ -701,3 +700,4 @@ char **rc_config_env (char **env) return (env); } +librc_hidden_def(rc_config_env) diff --git a/src/librc-strlist.c b/src/librc-strlist.c index b6ba80ac..68491816 100644 --- a/src/librc-strlist.c +++ b/src/librc-strlist.c @@ -7,12 +7,7 @@ Released under the GPLv2 */ -#include <stdbool.h> -#include <stdlib.h> -#include <string.h> - -#include "rc.h" -#include "rc-misc.h" +#include "librc.h" char **rc_strlist_add (char **list, const char *item) { @@ -31,6 +26,7 @@ char **rc_strlist_add (char **list, const char *item) return (newlist); } +librc_hidden_def(rc_strlist_add) static char **_rc_strlist_addsort (char **list, const char *item, int (*sortfunc) (const char *s1, @@ -77,16 +73,19 @@ char **rc_strlist_addsort (char **list, const char *item) { return (_rc_strlist_addsort (list, item, strcoll, false)); } +librc_hidden_def(rc_strlist_addsort) char **rc_strlist_addsortc (char **list, const char *item) { return (_rc_strlist_addsort (list, item, strcmp, false)); } +librc_hidden_def(rc_strlist_addsortc) char **rc_strlist_addsortu (char **list, const char *item) { return (_rc_strlist_addsort (list, item, strcmp, true)); } +librc_hidden_def(rc_strlist_addsortu) char **rc_strlist_delete (char **list, const char *item) { @@ -106,6 +105,7 @@ char **rc_strlist_delete (char **list, const char *item) return (list); } +librc_hidden_def(rc_strlist_delete) void rc_strlist_reverse (char **list) { @@ -128,6 +128,7 @@ void rc_strlist_reverse (char **list) j--; } } +librc_hidden_def(rc_strlist_reverse) void rc_strlist_free (char **list) { @@ -143,3 +144,4 @@ void rc_strlist_free (char **list) free (list); } +librc_hidden_def(rc_strlist_free) diff --git a/src/librc.c b/src/librc.c index 62b5ed89..c2da2347 100644 --- a/src/librc.c +++ b/src/librc.c @@ -5,25 +5,7 @@ Released under the GPLv2 */ -#include <sys/types.h> -#include <sys/select.h> -#include <sys/time.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <errno.h> -#include <libgen.h> -#include <limits.h> -#include <stdarg.h> -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "einfo.h" -#include "rc.h" -#include "rc-misc.h" -#include "strlist.h" +#include "librc.h" /* usecs to wait while we poll the fifo */ #define WAIT_INTERVAL 20000 @@ -50,11 +32,13 @@ bool rc_runlevel_starting (void) { return (rc_is_dir (RC_SVCDIR "softscripts.old")); } +librc_hidden_def(rc_runlevel_starting) bool rc_runlevel_stopping (void) { return (rc_is_dir (RC_SVCDIR "softscripts.new")); } +librc_hidden_def(rc_runlevel_stopping) char **rc_get_runlevels (void) { @@ -73,6 +57,7 @@ char **rc_get_runlevels (void) return (runlevels); } +librc_hidden_def(rc_get_runlevels) char *rc_get_runlevel (void) { @@ -96,6 +81,7 @@ char *rc_get_runlevel (void) snprintf (buffer, sizeof (buffer), "sysinit"); return (buffer); } +librc_hidden_def(rc_get_runlevel) void rc_set_runlevel (const char *runlevel) { @@ -105,6 +91,7 @@ void rc_set_runlevel (const char *runlevel) fprintf (fp, "%s", runlevel); fclose (fp); } +librc_hidden_def(rc_set_runlevel) bool rc_runlevel_exists (const char *runlevel) { @@ -119,6 +106,7 @@ bool rc_runlevel_exists (const char *runlevel) free (path); return (retval); } +librc_hidden_def(rc_runlevel_exists) /* Resolve a service name to it's full path */ char *rc_resolve_service (const char *service) @@ -154,6 +142,7 @@ char *rc_resolve_service (const char *service) snprintf (buffer, sizeof (buffer), RC_INITDIR "%s", service); return (strdup (buffer)); } +librc_hidden_def(rc_resolve_service) bool rc_service_exists (const char *service) { @@ -178,6 +167,7 @@ bool rc_service_exists (const char *service) free (file); return (retval); } +librc_hidden_def(rc_service_exists) bool rc_service_in_runlevel (const char *service, const char *runlevel) { @@ -200,6 +190,7 @@ bool rc_service_in_runlevel (const char *service, const char *runlevel) return (retval); } +librc_hidden_def(rc_service_in_runlevel) bool rc_mark_service (const char *service, const rc_service_state_t state) { @@ -344,6 +335,7 @@ bool rc_mark_service (const char *service, const rc_service_state_t state) free (init); return (true); } +librc_hidden_def(rc_mark_service) bool rc_service_state (const char *service, const rc_service_state_t state) { @@ -383,6 +375,7 @@ bool rc_service_state (const char *service, const rc_service_state_t state) free (file); return (retval); } +librc_hidden_def(rc_service_state) bool rc_get_service_option (const char *service, const char *option, char *value) @@ -410,6 +403,7 @@ bool rc_get_service_option (const char *service, const char *option, free (file); return (retval); } +librc_hidden_def(rc_get_service_option) bool rc_set_service_option (const char *service, const char *option, const char *value) @@ -441,6 +435,7 @@ bool rc_set_service_option (const char *service, const char *option, free (file); return (retval); } +librc_hidden_def(rc_set_service_option) static pid_t _exec_service (const char *service, const char *arg) { @@ -514,7 +509,7 @@ pid_t rc_stop_service (const char *service) return (_exec_service (service, "stop")); } - +librc_hidden_def(rc_stop_service) pid_t rc_start_service (const char *service) { @@ -523,6 +518,7 @@ pid_t rc_start_service (const char *service) return (_exec_service (service, "start")); } +librc_hidden_def(rc_start_service) void rc_schedule_start_service (const char *service, const char *service_to_start) @@ -558,6 +554,7 @@ void rc_schedule_start_service (const char *service, free (file); free (dir); } +librc_hidden_def(rc_schedule_start_service) void rc_schedule_clear (const char *service) { @@ -570,6 +567,7 @@ void rc_schedule_clear (const char *service) rc_rm_dir (dir, true); free (dir); } +librc_hidden_def(rc_schedule_clear) bool rc_wait_service (const char *service) { @@ -615,6 +613,7 @@ bool rc_wait_service (const char *service) free (fifo); return (retval); } +librc_hidden_def(rc_wait_service) char **rc_services_in_runlevel (const char *runlevel) { @@ -638,6 +637,7 @@ char **rc_services_in_runlevel (const char *runlevel) free (dir); return (list); } +librc_hidden_def(rc_services_in_runlevel) char **rc_services_in_state (rc_service_state_t state) { @@ -673,6 +673,7 @@ char **rc_services_in_state (rc_service_state_t state) free (dir); return (list); } +librc_hidden_def(rc_services_in_state) bool rc_service_add (const char *runlevel, const char *service) { @@ -701,6 +702,7 @@ bool rc_service_add (const char *runlevel, const char *service) free (file); return (retval); } +librc_hidden_def(rc_service_add) bool rc_service_delete (const char *runlevel, const char *service) { @@ -721,6 +723,7 @@ bool rc_service_delete (const char *runlevel, const char *service) free (file); return (retval); } +librc_hidden_def(rc_service_delete) char **rc_services_scheduled_by (const char *service) { @@ -740,6 +743,7 @@ char **rc_services_scheduled_by (const char *service) return (list); } +librc_hidden_def(rc_services_scheduled_by) char **rc_services_scheduled (const char *service) { @@ -755,6 +759,7 @@ char **rc_services_scheduled (const char *service) free (dir); return (list); } +librc_hidden_def(rc_services_scheduled) bool rc_allow_plug (char *service) { @@ -793,3 +798,4 @@ bool rc_allow_plug (char *service) free (list); return (allow); } +librc_hidden_def(rc_allow_plug) diff --git a/src/librc.h b/src/librc.h new file mode 100644 index 00000000..66d67776 --- /dev/null +++ b/src/librc.h @@ -0,0 +1,124 @@ +/* + * librc.h + * Internal header file to setup build env for files in librc.so + * Copyright 2007 Gentoo Foundation + * Released under the GPLv2 + */ + +#ifndef _LIBRC_H_ +#define _LIBRC_H_ + +#include <sys/select.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <sys/types.h> +#include <sys/utsname.h> +#include <sys/wait.h> + +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <libgen.h> +#include <limits.h> +#include <regex.h> +#include <stdarg.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#if defined(__DragonFly__) || defined(__FreeBSD__) || \ + defined(__NetBSD__) || defined (__OpenBSD__) +#include <sys/param.h> +#include <sys/user.h> +#include <sys/sysctl.h> +#include <kvm.h> +#endif + +#include "einfo.h" +#include "rc.h" +#include "rc-misc.h" +#include "strlist.h" + +/* internal alias trickery! we dont want internal relocs! */ +#if defined(__ELF__) && defined(__GNUC__) +# define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name) +# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name) +# define __hidden_asmname2(prefix, name) #prefix name +# define __hidden_proto(name, internal) \ + extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \ + __attribute__ ((visibility ("hidden"))); +# define __hidden_ver(local, internal, name) \ + extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \ + extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local)))) +# define librc_hidden_proto(name) __hidden_proto(name, __RC_##name) +# define librc_hidden_def(name) __hidden_ver(__RC_##name, name, name); +#else +# define librc_hidden_proto(name) +# define librc_hidden_def(name) +#endif + +librc_hidden_proto(rc_allow_plug) +librc_hidden_proto(rc_config_env) +librc_hidden_proto(rc_exists) +librc_hidden_proto(rc_filter_env) +librc_hidden_proto(rc_find_pids) +librc_hidden_proto(rc_free_deptree) +librc_hidden_proto(rc_get_config) +librc_hidden_proto(rc_get_config_entry) +librc_hidden_proto(rc_get_depends) +librc_hidden_proto(rc_get_depinfo) +librc_hidden_proto(rc_get_deptype) +librc_hidden_proto(rc_get_list) +librc_hidden_proto(rc_get_runlevel) +librc_hidden_proto(rc_get_runlevels) +librc_hidden_proto(rc_get_service_option) +librc_hidden_proto(rc_is_dir) +librc_hidden_proto(rc_is_env) +librc_hidden_proto(rc_is_exec) +librc_hidden_proto(rc_is_file) +librc_hidden_proto(rc_is_link) +librc_hidden_proto(rc_load_deptree) +librc_hidden_proto(rc_ls_dir) +librc_hidden_proto(rc_mark_service) +librc_hidden_proto(rc_order_services) +librc_hidden_proto(rc_resolve_service) +librc_hidden_proto(rc_rm_dir) +librc_hidden_proto(rc_runlevel_exists) +librc_hidden_proto(rc_runlevel_starting) +librc_hidden_proto(rc_runlevel_stopping) +librc_hidden_proto(rc_schedule_clear) +librc_hidden_proto(rc_schedule_start_service) +librc_hidden_proto(rc_service_add) +librc_hidden_proto(rc_service_daemons_crashed) +librc_hidden_proto(rc_service_delete) +librc_hidden_proto(rc_service_exists) +librc_hidden_proto(rc_service_in_runlevel) +librc_hidden_proto(rc_services_in_runlevel) +librc_hidden_proto(rc_services_in_state) +librc_hidden_proto(rc_services_scheduled) +librc_hidden_proto(rc_services_scheduled_by) +librc_hidden_proto(rc_service_started_daemon) +librc_hidden_proto(rc_service_state) +librc_hidden_proto(rc_set_runlevel) +librc_hidden_proto(rc_set_service_daemon) +librc_hidden_proto(rc_set_service_option) +librc_hidden_proto(rc_start_service) +librc_hidden_proto(rc_stop_service) +librc_hidden_proto(rc_strcatpaths) +librc_hidden_proto(rc_strlist_add) +librc_hidden_proto(rc_strlist_addsort) +librc_hidden_proto(rc_strlist_addsortc) +librc_hidden_proto(rc_strlist_addsortu) +librc_hidden_proto(rc_strlist_delete) +librc_hidden_proto(rc_strlist_free) +librc_hidden_proto(rc_strlist_reverse) +librc_hidden_proto(rc_update_deptree) +librc_hidden_proto(rc_wait_service) +librc_hidden_proto(rc_xcalloc) +librc_hidden_proto(rc_xmalloc) +librc_hidden_proto(rc_xrealloc) +librc_hidden_proto(rc_xstrdup) + +#endif |