Skip to content

Instantly share code, notes, and snippets.

@x-yuri
Last active March 25, 2024 00:36
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 x-yuri/f3e92c27b778f19f4269fe4cfd759e1d to your computer and use it in GitHub Desktop.
Save x-yuri/f3e92c27b778f19f4269fe4cfd759e1d to your computer and use it in GitHub Desktop.
gcc: supposedly non-dependencies

gcc: supposedly non-dependencies

the Stack Overflow question

a.sh:

docker run --rm alpine:3.4 sh -euxc '
    apk update
    apk add build-base linux-pam-dev git
    git clone https://github.com/sudo-project/sudo
    cd sudo
    git checkout 96b7c1f0f
    ./configure
    make
    ldd src/sudo
    { readelf -s src/conversation.o
    readelf -s src/error.o
    readelf -s src/exec.o
    readelf -s src/exec_pty.o
    readelf -s src/get_pty.o
    readelf -s src/net_ifs.o
    readelf -s src/load_plugins.o
    readelf -s src/parse_args.o
    readelf -s src/sudo.o
    readelf -s src/sudo_edit.o
    readelf -s src/tgetpass.o
    readelf -s src/ttysize.o
    readelf -s src/utmp.o
    readelf -s common/.libs/libcommon.a
    readelf -s compat/.libs/libreplace.a; } | grep -E "intl|gettext"
'
$ sh a.sh
...
/bin/sh ../libtool --tag=disable-static --mode=link gcc -o sudo
conversation.o
error.o
exec.o
exec_pty.o
get_pty.o
net_ifs.o
load_plugins.o
parse_args.o
sudo.o
sudo_edit.o
tgetpass.o
ttysize.o
utmp.o
-lintl
../common/libcommon.la
../compat/libreplace.la
-static-libtool-libs

libtool: link: gcc -o sudo
conversation.o
error.o
exec.o
exec_pty.o
get_pty.o
net_ifs.o
load_plugins.o
parse_args.o
sudo.o
sudo_edit.o
tgetpass.o
ttysize.o
utmp.o
-lintl
../common/.libs/libcommon.a
../compat/.libs/libreplace.a
...
+ ldd src/sudo
	/lib/ld-musl-x86_64.so.1 (0x77e7c812f000)
	libintl.so.8 => /usr/lib/libintl.so.8 (0x77e7c7d0d000)
	libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x77e7c812f000)
+ readelf -s src/conversation.o
+ readelf -s src/error.o
+ readelf -s src/exec.o
+ readelf -s src/exec_pty.o
+ readelf -s src/get_pty.o
+ readelf -s src/net_ifs.o
+ readelf -s src/load_plugins.o
+ readelf -s src/parse_args.o
+ readelf -s src/sudo.o
+ readelf -s src/sudo_edit.o
+ readelf -s src/tgetpass.o
+ readelf -s src/ttysize.o
+ readelf -s src/utmp.o
+ readelf -s common/.libs/libcommon.a
+ readelf -s compat/.libs/libreplace.a
+ grep -E intl|gettext

Since gcc adds libintl as a dependency, I suppose it should be in the symbol table of one of its constituents, but that doesn't seem to be the case.

$ readelf -s /usr/lib/libintl.so.8.1.4

Symbol table '.dynsym' contains 127 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000001e70     0 SECTION LOCAL  DEFAULT    5 
     2: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stpcpy
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tsearch
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcpy
     5: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getgid
     6: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND stdout
     7: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vsprintf
     8: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __fsetlocking
     9: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vswprintf
    10: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ungetc
    11: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_rwlock_rdlock
    12: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND geteuid
    13: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_rwlock_init
    14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND snprintf
    15: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND munmap
    16: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getc_unlocked
    17: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getenv
    18: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getegid
    19: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND bsearch
    20: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND qsort
    21: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fscanf
    22: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy
    23: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_cancel
    24: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_mutexattr_destroy
    25: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND __cxa_finalize
    26: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getuid
    27: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tolower
    28: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc
    29: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vsnprintf
    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iconv_open
    31: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtoul
    32: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_rwlock_unlock
    33: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mempcpy
    34: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wmemcpy
    35: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mmap
    36: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND abort
    37: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __stack_chk_fail
    38: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND calloc
    39: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fstat
    40: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __deregister_frame_info
    41: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND swprintf
    42: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_registerTMCloneTable
    43: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND nl_langinfo
    44: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND tfind
    45: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strstr
    46: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND read
    47: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strncmp
    48: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_rwlock_wrlock
    49: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcasecmp
    50: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realloc
    51: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fdopen
    52: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND wcschr
    53: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_deregisterTMCloneTab
    54: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strdup
    55: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fopen
    56: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND uselocale
    57: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vfwprintf
    58: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fclose
    59: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_mutexattr_settype
    60: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND isalnum
    61: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND putc
    62: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcmp
    63: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_mutex_unlock
    64: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getcwd
    65: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcspn
    66: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND iconv
    67: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND feof_unlocked
    68: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_mutexattr_init
    69: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fwrite
    70: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_mutex_destroy
    71: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_mutex_lock
    72: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __errno_location
    73: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fgets_unlocked
    74: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_mutex_init
    75: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND open
    76: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strchr
    77: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fputs
    78: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
    79: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __register_frame_info
    80: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND close
    81: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND vfprintf
    82: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fputwc
    83: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND free
    84: 000000000000b1cf     5 FUNC    GLOBAL DEFAULT    8 dgettext
    85: 0000000000005df5    22 FUNC    GLOBAL DEFAULT    8 libintl_ngettext
    86: 0000000000004391   210 FUNC    GLOBAL DEFAULT    8 libintl_textdomain
    87: 000000000000b1f2     5 FUNC    GLOBAL DEFAULT    8 bind_textdomain_codeset
    88: 000000000000af29   182 FUNC    GLOBAL DEFAULT    8 libintl_wprintf
    89: 00000000000026a9    15 FUNC    GLOBAL DEFAULT    8 libintl_gettext
    90: 000000000000b219     1 FUNC    GLOBAL DEFAULT    9 _fini
    91: 000000000000ad9c   199 FUNC    GLOBAL DEFAULT    8 libintl_vfwprintf
    92: 000000000000b1d9     5 FUNC    GLOBAL DEFAULT    8 ngettext
    93: 000000000000afdf   236 FUNC    GLOBAL DEFAULT    8 libintl_vswprintf
    94: 0000000000005dea    11 FUNC    GLOBAL DEFAULT    8 libintl_dngettext
    95: 0000000000008fe9   223 FUNC    GLOBAL DEFAULT    8 libintl_vsnprintf
    96: 000000000000b1e8     5 FUNC    GLOBAL DEFAULT    8 textdomain
    97: 0000000000008d0c   177 FUNC    GLOBAL DEFAULT    8 libintl_fprintf
    98: 000000000000b1ca     5 FUNC    GLOBAL DEFAULT    8 gettext
    99: 000000000020d010     4 OBJECT  GLOBAL DEFAULT   19 libintl_version
   100: 00000000000091ec   177 FUNC    GLOBAL DEFAULT    8 libintl_asprintf
   101: 000000000000af14    21 FUNC    GLOBAL DEFAULT    8 libintl_vwprintf
   102: 0000000000008c4e   190 FUNC    GLOBAL DEFAULT    8 libintl_vfprintf
   103: 000000000000b1d4     5 FUNC    GLOBAL DEFAULT    8 dcgettext
   104: 0000000000006b32   267 FUNC    GLOBAL DEFAULT    8 libintl_set_relocation_pr
   105: 0000000000004257   314 FUNC    GLOBAL DEFAULT    8 _nl_expand_alias
   106: 000000000000ae63   177 FUNC    GLOBAL DEFAULT    8 libintl_fwprintf
   107: 000000000000b0cb   172 FUNC    GLOBAL DEFAULT    8 libintl_swprintf
   108: 0000000000008dbd    21 FUNC    GLOBAL DEFAULT    8 libintl_vprintf
   109: 000000000020d014     0 NOTYPE  GLOBAL DEFAULT   20 __bss_start
   110: 0000000000005dda    16 FUNC    GLOBAL DEFAULT    8 libintl_dcngettext
   111: 00000000000025da    91 FUNC    GLOBAL DEFAULT    8 libintl_bindtextdomain
   112: 000000000020db08     0 NOTYPE  GLOBAL DEFAULT   20 _end
   113: 0000000000008f38   177 FUNC    GLOBAL DEFAULT    8 libintl_sprintf
   114: 0000000000008dd2   182 FUNC    GLOBAL DEFAULT    8 libintl_printf
   115: 000000000000b1ed     5 FUNC    GLOBAL DEFAULT    8 bindtextdomain
   116: 00000000000090c8   172 FUNC    GLOBAL DEFAULT    8 libintl_snprintf
   117: 000000000020daf8     4 OBJECT  GLOBAL DEFAULT   20 _nl_msg_cat_cntr
   118: 0000000000002690    15 FUNC    GLOBAL DEFAULT    8 libintl_dcgettext
   119: 0000000000008e88   176 FUNC    GLOBAL DEFAULT    8 libintl_vsprintf
   120: 000000000020d014     0 NOTYPE  GLOBAL DEFAULT   19 _edata
   121: 0000000000009174   120 FUNC    GLOBAL DEFAULT    8 libintl_vasprintf
   122: 0000000000002635    91 FUNC    GLOBAL DEFAULT    8 libintl_bind_textdomain_c
   123: 000000000000b1de     5 FUNC    GLOBAL DEFAULT    8 dngettext
   124: 000000000000269f    10 FUNC    GLOBAL DEFAULT    8 libintl_dgettext
   125: 000000000000b1e3     5 FUNC    GLOBAL DEFAULT    8 dcngettext
   126: 0000000000001e70     1 FUNC    GLOBAL DEFAULT    5 _init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment