Lovely.

> Diff below makes sure libutil doesn't export any unwanted symbols.
> The immediate motivation here is to prevent exportong certain libgcc
> symbols on armv7 that cause issues when switching from gcc to clang.
> 
> With this diff, only symbols present in man pages and public header
> files are exported.  A few helper functions are made static.  The one
> exception is imsg_fd_overhead which according to the relevant commit
> message is intended as a public API.  Note that this API isn't
> actually used in our tree.  Also note that global variables like this
> are bad API design.
> 
> The check_syms script gives the following output:
> 
> /usr/lib/libutil.so.12.2 --> obj/libutil.so.13.0
> Dynamic export changes:
> removed:
>         __bss_start
>         __data_start
>         _edata
>         _end
>         _fini
>         _init
>         ibuf_dequeue
>         ibuf_enqueue
>         ibuf_realloc
>         imsg_get_fd
> 
> ok?
> 
> 
> Index: lib/libutil/Makefile
> ===================================================================
> RCS file: /cvs/src/lib/libutil/Makefile,v
> retrieving revision 1.39
> diff -u -p -r1.39 Makefile
> --- lib/libutil/Makefile      30 Mar 2016 06:38:43 -0000      1.39
> +++ lib/libutil/Makefile      13 Dec 2017 23:03:05 -0000
> @@ -3,6 +3,8 @@
>  
>  LIB= util
>  
> +VERSION_SCRIPT=      ${.CURDIR}/Symbols.map
> +
>  HDRS=        util.h imsg.h
>  SRCS=        bcrypt_pbkdf.c check_expire.c duid.c getmaxpartitions.c \
>       getrawpartition.c login.c \
> Index: lib/libutil/Symbols.map
> ===================================================================
> RCS file: lib/libutil/Symbols.map
> diff -N lib/libutil/Symbols.map
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ lib/libutil/Symbols.map   13 Dec 2017 23:03:05 -0000
> @@ -0,0 +1,94 @@
> +/*
> + * In order to guarantee that static and shared archs see the same "public"
> + * symbols, this file should always include all the non-static symbols that
> + * are in the application namespace.  So, if a symbol starts with a letter,
> + * don't delete it from here without either making it static or renaming it
> + * to have a leading underbar.
> + */
> +
> +{
> +     global:
> +             bcrypt_pbkdf;
> +             fdforkpty;
> +             fdopenpty;
> +             fmt_scaled;
> +             forkpty;
> +             fparseln;
> +             getmaxpartitions;
> +             getptmfd;
> +             getrawpartition;
> +             ibuf_add;
> +             ibuf_close;
> +             ibuf_dynamic;
> +             ibuf_free;
> +             ibuf_left;
> +             ibuf_open;
> +             ibuf_reserve;
> +             ibuf_seek;
> +             ibuf_size;
> +             ibuf_write;
> +             imsg_add;
> +             imsg_clear;
> +             imsg_close;
> +             imsg_compose;
> +             imsg_composev;
> +             imsg_create;
> +             imsg_fd_overhead;
> +             imsg_flush;
> +             imsg_free;
> +             imsg_get;
> +             #imsg_get_fd
> +             imsg_init;
> +             imsg_read;
> +             isduid;
> +             login;
> +             login_check_expire;
> +             login_fbtab;
> +             login_tty;
> +             logout;
> +             logwtmp;
> +             msgbuf_clear;
> +             msgbuf_drain;
> +             msgbuf_init;
> +             msgbuf_write;
> +             ohash_create_entry;
> +             ohash_delete;
> +             ohash_entries;
> +             ohash_find;
> +             ohash_first;
> +             ohash_init;
> +             ohash_insert;
> +             ohash_interval;
> +             ohash_lookup_interval;
> +             ohash_lookup_memory;
> +             ohash_next;
> +             ohash_qlookup;
> +             ohash_qlookupi;
> +             ohash_remove;
> +             opendev;
> +             opendisk;
> +             openpty;
> +             pidfile;
> +             pkcs5_pbkdf2;
> +             pw_abort;
> +             #pw_cont;
> +             pw_copy;
> +             pw_edit;
> +             pw_error;
> +             pw_file;
> +             pw_init;
> +             pw_lock;
> +             pw_mkdb;
> +             pw_prompt;
> +             pw_scan;
> +             pw_setdir;
> +             readlabelfs;
> +             scan_scaled;
> +             uu_lock;
> +             uu_lock_txfr;
> +             uu_lockerr;
> +             uu_unlock;
> +
> +     local:
> +             *;
> +};
> Index: lib/libutil/imsg-buffer.c
> ===================================================================
> RCS file: /cvs/src/lib/libutil/imsg-buffer.c,v
> retrieving revision 1.10
> diff -u -p -r1.10 imsg-buffer.c
> --- lib/libutil/imsg-buffer.c 11 Apr 2017 09:57:19 -0000      1.10
> +++ lib/libutil/imsg-buffer.c 13 Dec 2017 23:03:05 -0000
> @@ -29,9 +29,9 @@
>  
>  #include "imsg.h"
>  
> -int  ibuf_realloc(struct ibuf *, size_t);
> -void ibuf_enqueue(struct msgbuf *, struct ibuf *);
> -void ibuf_dequeue(struct msgbuf *, struct ibuf *);
> +static int   ibuf_realloc(struct ibuf *, size_t);
> +static void  ibuf_enqueue(struct msgbuf *, struct ibuf *);
> +static void  ibuf_dequeue(struct msgbuf *, struct ibuf *);
>  
>  struct ibuf *
>  ibuf_open(size_t len)
> @@ -67,7 +67,7 @@ ibuf_dynamic(size_t len, size_t max)
>       return (buf);
>  }
>  
> -int
> +static int
>  ibuf_realloc(struct ibuf *buf, size_t len)
>  {
>       u_char  *b;
> @@ -289,14 +289,14 @@ again:
>       return (1);
>  }
>  
> -void
> +static void
>  ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
>  {
>       TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry);
>       msgbuf->queued++;
>  }
>  
> -void
> +static void
>  ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
>  {
>       TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
> Index: lib/libutil/imsg.c
> ===================================================================
> RCS file: /cvs/src/lib/libutil/imsg.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 imsg.c
> --- lib/libutil/imsg.c        11 Apr 2017 09:57:19 -0000      1.15
> +++ lib/libutil/imsg.c        13 Dec 2017 23:03:05 -0000
> @@ -30,7 +30,7 @@
>  
>  int   imsg_fd_overhead = 0;
>  
> -int   imsg_get_fd(struct imsgbuf *);
> +static int    imsg_get_fd(struct imsgbuf *);
>  
>  void
>  imsg_init(struct imsgbuf *ibuf, int fd)
> @@ -266,7 +266,7 @@ imsg_free(struct imsg *imsg)
>       freezero(imsg->data, imsg->hdr.len - IMSG_HEADER_SIZE);
>  }
>  
> -int
> +static int
>  imsg_get_fd(struct imsgbuf *ibuf)
>  {
>       int              fd;
> Index: lib/libutil/shlib_version
> ===================================================================
> RCS file: /cvs/src/lib/libutil/shlib_version,v
> retrieving revision 1.28
> diff -u -p -r1.28 shlib_version
> --- lib/libutil/shlib_version 20 Apr 2017 17:48:30 -0000      1.28
> +++ lib/libutil/shlib_version 13 Dec 2017 23:03:05 -0000
> @@ -1,2 +1,2 @@
> -major=12
> -minor=2
> +major=13
> +minor=0
> 

Reply via email to