Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@citrus-it
Last active November 20, 2021 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save citrus-it/ebd654b35037e0b5411c5f5555b9d61f to your computer and use it in GitHub Desktop.
Save citrus-it/ebd654b35037e0b5411c5f5555b9d61f to your computer and use it in GitHub Desktop.

Summary (and TL;TR)

gcc10 defaults to -feliminate-unused-debug-symbols, gcc7 did not.

This seems to improve things in userland but in the kernel we should pass -fno-eliminate-unused-debug-symbols to at least (and probably just) genunix.

libgss.so.1 needs investigating.

gcc10 defaults to -feliminate-unused-debug-symbols, gcc7 did not

There is the option to pass -fno-eliminate-unused-debug-symbols to gcc10 to get output which more closely resembles gcc7.

The first thing is that the size of the CTF section in things is generally smaller. Here is a comparison of some old and new .SUNW_ctf section sizes. I've cherry-picked representative ones and the ones with the biggest changes. gcc7 is on the left, gcc10 on the right, and the last column shows the delta.

usr/bin
              uptime  8,039      -> 6,531      -1.47 KiB
               iconv  3,055      -> 3,059      0.00 KiB
               ztest  79,134     -> 68,345     -10.54 KiB
             svcprop  3,664      -> 3,072      -0.58 KiB
              fsstat  4,449      -> 3,498      -0.93 KiB
                 dis  5,358      -> 5,349      -0.01 KiB
              mpstat  5,417      -> 5,408      -0.01 KiB
            demangle  953        -> 957        0.00 KiB
            diskinfo  25,546     -> 2,940      -22.08 KiB
           vtfontcvt  2,435      -> 2,300      -0.13 KiB
                 tic  18,142     -> 12,289     -5.72 KiB

usr/lib
    libfruutils.so.1  1,419      -> 1,423      0.00 KiB
       librestart.so  8,203      -> 7,671      -0.52 KiB
           mpss.so.1  4,360      -> 2,655      -1.67 KiB
        libcurses.so  22,857     -> 22,869     0.01 KiB
      libresolv.so.2  36,617     -> 36,424     -0.19 KiB
    libzonestat.so.1  6,312      -> 5,740      -0.56 KiB

         libzutil.so  58,057     -> 7,982      -48.90 KiB
     libzonecfg.so.1  40,728     -> 18,564     -21.64 KiB
       libhotplug.so  25,782     -> 3,366      -21.89 KiB
    libzfsbootenv.so  53,655     -> 6,418      -46.13 KiB

           libgss.so  8,996      -> 11,208     2.16 KiB

kernel
             genunix  244,875    -> 229,796    -14.73 KiB
                unix  237,425    -> 208,981    -27.78 KiB
                 arp  37,712     -> 1,170      -35.69 KiB
              e1000g  14,326     -> 14,346     0.02 KiB
                bnxe  79,817     -> 80,218     0.39 KiB
              vioblk  1,659      -> 1,663      0.00 KiB
               mlxcx  26,931     -> 26,926     -0.00 KiB
           mac_ether  2,391      -> 2,394      0.00 KiB
                 zfs  70,039     -> 74,096     3.96 KiB
             pci-ide  17,242     -> 14,871     -2.32 KiB
              nfssrv  26,195     -> 32,789     6.44 KiB
              rpcmod  6,634      -> 10,681     3.95 KiB
              random  3,659      -> 172        -3.41 KiB

This pattern occurs in 313 libraries under /usr/lib and seems reasonable given that most libraries will not use the FILE type.

usr/lib/scsi/plugins/ses/framework/ses2.so
NOTE: ELF .SUNW_ctf difference detected.

@@ -1,11 +1,5 @@
 /* Types */

-typedef __FILE FILE;
-
-typedef struct __FILE __FILE;
-
 typedef enum {
        B_FALSE = 0,
        B_TRUE = 1,
@@ -366,38 +356,11 @@

 typedef unsigned int size_t;

-struct __FILE { /* 0x10 bytes */
-       int _cnt; /* offset: 0 bytes */
-       unsigned char * _ptr; /* offset: 4 bytes */
-       unsigned char * _base; /* offset: 8 bytes */
-       unsigned char _flag; /* offset: 12 bytes */
-       unsigned char _magic; /* offset: 13 bytes */
-       unsigned int __orientation:2; /* offset: 14 bytes */
-       unsigned int __ionolock:1; /* offset: 14 bytes (114 bits) */
-       unsigned int __seekable:1; /* offset: 14 bytes (115 bits) */
-       unsigned int __extendedfd:1; /* offset: 14 bytes (116 bits) */
-       unsigned int __xf_nocheck:1; /* offset: 14 bytes (117 bits) */
-       unsigned int __filler:10; /* offset: 14 bytes (118 bits) */
-};
-

This one occurs in 426 objects, and again it seems reasonable that most objects do not use this type.

-typedef struct { /* 0xa bytes */
-       uint16_t dtr_limit; /* offset: 0 bytes */
-       uint64_t dtr_base; /* offset: 2 bytes */
-} desctbr_t;
-

This shows the number of objects for each typedef that has been removed where at least 50 objects are affected (number of objects on the left, typedef on the right):

  50 ddi_bus_config_op_t
  50 pm_bus_power_op_t
  56 ddi_attach_cmd_t
  56 ddi_ctl_enum_t
  56 ddi_detach_cmd_t
  56 ddi_dma_atyp_t
  56 ddi_hp_op_t
  56 ddi_idevice_cookie_t
  56 ddi_info_cmd_t
  56 ddi_intr_ctlop_t
  56 ddi_intr_op_t
  56 ddi_map_obj_t
  56 ddi_map_op_t
  56 ddi_map_req_t
  56 ddi_map_type_t
  56 ddi_prop_op_t
  56 ddi_reset_cmd_t
  76 ddi_dma_aobj_t
  76 ddi_dma_obj_t
  86 segadvstat_t
  87 hw_pagesize_t
 127 time_res_t
 163 upad128_t
 167 segcapability_t
 168 afd_t
 168 kfpu_t
 168 lwpchan_t
 184 k_sigset_t
 204 dacf_opid_t
 426 desctbr_t

diskinfo has lost a lot

            diskinfo  25,546     -> 2,940      -22.08 KiB

and this seems to be kernel structures, enums, etc. which are not used in there; here are some of them:

-typedef __FILE FILE;
-typedef struct { /* 0x1c bytes */
-typedef struct ani_free ani_free_t;
-typedef struct avl_node avl_node_t;
-typedef struct avl_tree avl_tree_t;
-typedef char * caddr_t;
-typedef void (*callback_func_t)(struct as *, void *, uint_t);
-typedef long clock_t;
-typedef id_t ctid_t;
-typedef struct ctxop ctxop_t;
-typedef void * dacf_arghdl_t;
-typedef void * dacf_infohdl_t;
-enum fault_type {
-enum lock_type {
-enum seg_rw {
-enum vtype {
-typedef struct _kcondvar kcondvar_t;
-typedef struct _kcpc_ctx kcpc_ctx_t;
-typedef struct _kcpc_pic kcpc_pic_t;
-struct vfs;
-struct vnode { /* 0x88 bytes */
-struct vnodeops;
-struct vsd_node { /* 0x10 bytes */

the same is true for other components that are involved with topology such as libhotplug.so and libzonecfg.so.

libzutil.so is in the same boat but also used to have things such as struct cpu as well as a lot of types from ZFS which aren't used in that library.


Looking at libcurses.so, since it had a very slight size increase, the output of ctfdump -c on the old and new files produces identical output, however ctfdump -S shows that the new file has one fewer data objects:

  total number of data objects        = 153

whereas the old shows 154. The missing data object is _lib_version.


For libgss.so, which has gained 2.16 KiB of size, there are now a lot of duplicate function prototypes, for example:

 extern int k5_mutex_finish_init_1(k5_mutex_t *, k5_debug_loc);
+extern int k5_mutex_finish_init_1(k5_mutex_t *, k5_debug_loc);
+extern int k5_mutex_finish_init_1(k5_mutex_t *, k5_debug_loc);
... repeated 28 more times ...
 extern int k5_os_mutex_finish_init(k5_os_mutex *);
+extern int k5_os_mutex_finish_init(k5_os_mutex *);
+extern int k5_os_mutex_finish_init(k5_os_mutex *);
... repeated 28 more times ...

Here are the functions that are duplicated, with their counts:

  30 +extern int k5_mutex_finish_init_1(k5_mutex_t *, k5_debug_loc);
  30 +extern int k5_os_mutex_finish_init(k5_os_mutex *);
  31 +extern int k5_mutex_init_1(k5_mutex_t *, k5_debug_loc);
  31 +extern int k5_os_nothread_mutex_destroy(k5_os_nothread_mutex *);
  31 +extern int k5_os_nothread_mutex_finish_init(k5_os_nothread_mutex *);
  31 +extern int k5_os_nothread_mutex_init(k5_os_nothread_mutex *);
  31 +extern int k5_os_nothread_mutex_lock(k5_os_nothread_mutex *);
  31 +extern int k5_os_nothread_mutex_unlock(k5_os_nothread_mutex *);
  31 +extern void k5_mutex_lock_update_stats(k5_debug_mutex_stats *, k5_mutex_stats_tmp);
  31 +extern void k5_pthread_assert_locked(k5_os_mutex *);
  31 +extern void k5_pthread_assert_unlocked(pthread_mutex_t *);

There are also some new types which were not there before, for example:

+typedef int k5_mutex_stats_tmp;
+typedef char k5_os_nothread_mutex;
+struct mecherrmap__printstat { /* 0x10 bytes */
+       FILE * f; /* offset: 0 bytes */
+       int comma; /* offset: 8 bytes */
+};
         genunix  244,875    -> 229,796    -14.73 KiB
            unix  237,425    -> 208,981    -27.78 KiB
             arp  37,712     -> 1,170      -35.69 KiB
          e1000g  14,326     -> 14,346     0.02 KiB
            bnxe  79,817     -> 80,218     0.39 KiB
          vioblk  1,659      -> 1,663      0.00 KiB
           mlxcx  26,931     -> 26,926     -0.00 KiB
       mac_ether  2,391      -> 2,394      0.00 KiB
             zfs  70,039     -> 74,096     3.96 KiB
         pci-ide  17,242     -> 14,871     -2.32 KiB
          nfssrv  26,195     -> 32,789     6.44 KiB
          rpcmod  6,634      -> 10,681     3.95 KiB
          random  3,659      -> 172        -3.41 KiB

In the kernel, what has mostly happened is that types which are only used in one module have been moved out of genunix. For example:

genunix
-typedef enum {
-       TNFW_B_RUNNING = 0,
-       TNFW_B_NOBUFFER = 1,
-       TNFW_B_BROKEN = 2,
-} TNFW_B_STATE;
-
-
-typedef struct bitmap_data bitmap_data_t;
-typedef uint32_t (*color_map_fn_t)(uint8_t);
-
-typedef union { /* 0x4 bytes */
-       unsigned char mono; /* offset: 0 bytes */
-       unsigned char four; /* offset: 0 bytes */
-       unsigned char eight; /* offset: 0 bytes */
-       unsigned char sixteen[2]; /* offset: 0 bytes */
-       unsigned char twentyfour[3]; /* offset: 0 bytes */
-       unsigned char thirtytwo[4]; /* offset: 0 bytes */
-} color_t;

drv/amd64/tnf
+typedef enum {
+       TNFW_B_RUNNING = 0,
+       TNFW_B_NOBUFFER = 1,
+       TNFW_B_BROKEN = 2,
+} TNFW_B_STATE;

misc/amd64/tem
+typedef struct bitmap_data bitmap_data_t;
+typedef uint32_t (*color_map_fn_t)(uint8_t);
+
+typedef union { /* 0x4 bytes */
+       unsigned char mono; /* offset: 0 bytes */
+       unsigned char four; /* offset: 0 bytes */
+       unsigned char eight; /* offset: 0 bytes */
+       unsigned char sixteen[2]; /* offset: 0 bytes */
+       unsigned char twentyfour[3]; /* offset: 0 bytes */
+       unsigned char thirtytwo[4]; /* offset: 0 bytes */
+} color_t;

However, there are other cases where types which were once uniquified in genunix are now in several modules.

genunix
-typedef struct conn CONN;
-enum nfsstat4 {

kernel/strmod/amd64/rpcmod
+typedef struct conn CONN;

kernel/drv/amd64/rpcib
+typedef struct conn CONN;

kernel/fs/amd64/nfs
+typedef struct conn CONN;
+enum nfsstat4 {

kernel/misc/amd64/nfssrv
+typedef struct conn CONN;
+enum nfsstat4 {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment