Environment Variables Understood by Glibc Toolchains

Note: List of all the utilities and libraries included into Glibc is available from the "Linux From Sratch" project page.

This information is valid for glibc versions 2.x, x >= 2.

1. Locale Settings

GCONV_PATH Directories in which iconv() looks for character encoding libraries

I18NPATH Used by locale tools to find locale input files (char maps etc)

LOCPATH Set locale data path, not for suid or sgid programs

OUTPUT_CHARSET Used by message catalog loader

NLSPATH Directories in which catopen() looks for message catalogs

LANG Which message catalog to use

LANGUAGE Overrides LANG and LC_* settings for message catalogs

LC_ALL Overrides the locales selected by other LC_* variables

LC_CTYPE Character classification and case conversion

LC_COLLATE Collation order (string sorting)

LC_TIME Date and time formats

LC_NUMERIC Non-monetary numeric form

LC_MONETARY Monetary formats

LC_MESSAGES Formats of informative and diagnostic messages and interactive responses

For generic info on C-library locales, see 'info libc Locale'.

2. Library Loading Settings

LD_BIND_NOT Flag: if set, Don't update the GOT (global offset table) and PLT (procedure linkage table) after resolving a symbol

LD_BIND_NOW Flag: Resolve all symbols at program startup, useful with debugger

LD_DEBUG Output verbose debugging information about the dynamic linker. If set to 'all' prints all debugging information it has, if set to 'help' prints a help message

LD_DEBUG_PATH Filename for LD_DEBUG output (otherwise it goes to stdout)

LD_DYNAMIC_WEAK Allow weak symbols to be overridden (old glibc behaviour)

LD_HWCAP_MASK Set hardware capability / platform mask

LD_LIBRARY_PATH A colon-separated list of directories in which to search for ELF libraries at execution-time

LD_PRELOAD A whitespace-separated list of additional, user-specified, ELF shared libraries to be loaded before all others. This can be used to selectively override functions in other shared libraries. For setuid/setgid ELF binaries, only libraries in the standard search directories that are also setuid will be loaded

LD_ORIGIN_PATH Path where the binary is found

LD_PROFILE Shared object to be profiled

LD_PROFILE_OUTPUT File where LD_PROFILE output should be stored, default is stdout

LD_SHOW_AUXV Show auxiliary array passed up from the kernel

LD_TRACE_LOADED_OBJECTS Flag: if set, list dependencies instead of running (like ldd!)

LD_WARN Flag: if set, warn about about undefined symbols

LD_VERBOSE Flag: If set, output symbol versioning information about the program if querying information about it (see LD_TRACE_LOADED_OBJECTS)

For more information on dynamic linker, see 'man ld.so'.

Note: Dynamic linking code unsets certain environment variables for suid binaries. These environment variables are:

GCONV_PATH HOSTALIASES LD_AOUT_LIBRARY_PATH LD_AOUT_PRELOAD LD_DEBUG_OUTPUT LD_LIBRARY_PATH LD_ORIGIN_PATH LD_PRELOAD LD_PROFILE LOCALDOMAIN LOCPATH MALLOC_TRACE NLSPATH RESOLV_HOST_CONF RES_OPTIONS TMPDIR TZDIR

Unless there's a file '/etc/suid-debug', also MALLOC_CHECK_ variable is unset.

3. Debug Settings

GMON_OUT_PREFIX Change -pg (gcc profiling option) output file from default 'gmon.out' to"${GMON_OUT_PREFIX}.${PID}" MALLOC_CHECK_ Set what to do when corrupt pointer is detected with malloc debugging: 0: do nothing 1: print an error message (default) 2: call abort()

MALLOC_MMAP_MAX_ MALLOC_MMAP_THRESHOLD_ MALLOC_TOP_PAD_ MALLOC_TRIM_THRESHOLD_ Above four variables are used for tuning glibc allocation routines. For (lots of) information on their effect, see documentation in glibc malloc/malloc.c file ("MALLOC_TOP_PAD_" -> M_TOP_PAD etc). MALLOC_TRACE Set malloc trace output file / enable mtrace() use, for example: 1. Add call to mtrace() to start of main() 2. Recompile & link 3. Execute: MALLOC_TRACE=heap.log ./myprog 4. Execute: mtrace myprog heap.log -> list of memory leaks

Note: 'mtrace' is a Perl script coming with glibc. For more information, see 'info libc "Memory Allocation" "Allocation Debugging"'.

MEMUSAGE_BUFFER_SIZE Size (number of elements) in internal buffer, 1=unbuffered

MEMUSAGE_NO_TIMER Flag: if NOT set, stack pointer is recorded at highest possible frequency

MEMUSAGE_OUTPUT Name of the output file

MEMUSAGE_PROG_NAME If not present, every program assumes it should do profiling. Otherwise only the indicated program does profiling

MEMUSAGE_TRACE_MMAP Flag: if set, also mmap functions details are traced

Note: 'memusage' is a shell script coming with glibc which LD_PRELOADs binaries with memusage library understanding above variables.

PCPROFILE_OUTPUT Name of the FIFO for PC (program counter?) profile

SEGFAULT_OUTPUT_NAME Name of the output (backtrace etc) file (default is stderr)

SEGFAULT_SIGNALS List of signals generating segfault: segv, ill, bus, stkflt, abrt, fpe

SEGFAULT_USE_ALTSTACK Flag: if set, allocate separate stack for segfaults

Note: 'catchsegv' is a shell script coming with glibc which LD_PRELOADs binaries with segfault library understanding above variables.

MSGVERB SEV_LEVEL Mask of msgfmt() values to print (label, severity, text, action, tag) and severity level setting for msgfmt()

4. Network Settings

HOSTALIASES Filename for the host aliases file

LOCALDOMAIN Allows user to overide local domain name

RES_OPTIONS Set options at resolver init

RESOLV_HOST_CONF Filename for the host.conf file

RESOLV_ADD_TRIM_DOMAINS RESOLV_MULTI RESOLV_OVERRIDE_TRIM_DOMAINS RESOLV_REORDER RESOLV_SERV_ORDER RESOLV_SPOOF_CHECK Override default resolver behaviour

For more information, see 'man resolv.conf'.

5. Time/Date Settings

DATEMSK Name of template file for getdate() function

HZ On platforms without itimer, this can be used to set clock resolution

TZ Set timezone / daylight savings time, see 'info libc TZ'

TZDIR Alternate path for timezone files (default is /usr/share/zoneinfo)

6. Path Settings

HOME User's home directory

IFS Field separator (e.g. in path lists)

PATH Paths from which executables can be run from

PWD Working directory

TMPDIR Temporary directory path

You can get some more information with 'info libc "Standard Environment".

7. Other Settings

POSIXLY_CORRECT - getopt: without this, arguments have to be given first - fnmatch: affect bracket handling in filename patterns - makes localedef tool verbose

ARGP_HELP_FMT Set help output for argument parser

8. Getconf Variables

You can use 'getconf' utility compiled with glibc to query values in certain variables used by glibc. Here's a list of variables supported by the Scratchbox glibc (ones not starting with underscore). You can get more info on some of these with 'info libc "Variable Index"': AIO_LISTIO_MAX AIO_MAX AIO_PRIO_DELTA_MAX ARG_MAX ATEXIT_MAX BC_BASE_MAX BC_DIM_MAX BC_SCALE_MAX BC_STRING_MAX CHARCLASS_NAME_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX CLK_TCK COLL_WEIGHTS_MAX CS_PATH DELAYTIMER_MAX EQUIV_CLASS_MAX EXPR_NEST_MAX GNU_LIBC_VERSION GNU_LIBPTHREAD_VERSION HOST_NAME_MAX INT_MAX INT_MIN IOV_MAX LFS64_CFLAGS LFS64_LDFLAGS LFS64_LIBS LFS64_LINTFLAGS LFS_CFLAGS LFS_LDFLAGS LFS_LIBS LFS_LINTFLAGS LINE_MAX LOGIN_NAME_MAX LOGNAME_MAX LONG_BIT MB_LEN_MAX MQ_OPEN_MAX MQ_PRIO_MAX NGROUPS_MAX NL_ARGMAX NL_LANGMAX NL_MSGMAX NL_NMAX NL_SETMAX NL_TEXTMAX NSS_BUFLEN_GROUP NSS_BUFLEN_PASSWD NZERO OPEN_MAX PAGESIZE PAGE_SIZE PASS_MAX PATH POSIX2_BC_BASE_MAX POSIX2_BC_DIM_MAX POSIX2_BC_SCALE_MAX POSIX2_BC_STRING_MAX POSIX2_CHAR_TERM POSIX2_COLL_WEIGHTS_MAX POSIX2_C_BIND POSIX2_C_DEV POSIX2_C_VERSION POSIX2_EXPR_NEST_MAX POSIX2_FORT_DEV POSIX2_FORT_RUN POSIX2_LOCALEDEF POSIX2_PBS POSIX2_PBS_ACCOUNTING POSIX2_PBS_LOCATE POSIX2_PBS_MESSAGE POSIX2_PBS_TRACK POSIX2_RE_DUP_MAX POSIX2_SW_DEV POSIX2_UPE POSIX2_VERSION POSIX_V6_ILP32_OFF32_CFLAGS POSIX_V6_ILP32_OFF32_LDFLAGS POSIX_V6_ILP32_OFF32_LIBS POSIX_V6_ILP32_OFF32_LINTFLAGS POSIX_V6_ILP32_OFFBIG_CFLAGS POSIX_V6_ILP32_OFFBIG_LDFLAGS POSIX_V6_ILP32_OFFBIG_LIBS POSIX_V6_ILP32_OFFBIG_LINTFLAGS POSIX_V6_LP64_OFF64_CFLAGS POSIX_V6_LP64_OFF64_LDFLAGS POSIX_V6_LP64_OFF64_LIBS POSIX_V6_LP64_OFF64_LINTFLAGS POSIX_V6_LPBIG_OFFBIG_CFLAGS POSIX_V6_LPBIG_OFFBIG_LDFLAGS POSIX_V6_LPBIG_OFFBIG_LIBS POSIX_V6_LPBIG_OFFBIG_LINTFLAGS PTHREAD_DESTRUCTOR_ITERATIONS PTHREAD_KEYS_MAX PTHREAD_STACK_MIN PTHREAD_THREADS_MAX RE_DUP_MAX RTSIG_MAX SCHAR_MAX SCHAR_MIN SEM_NSEMS_MAX SEM_VALUE_MAX SHRT_MAX SHRT_MIN SIGQUEUE_MAX SSIZE_MAX STREAM_MAX SYMLOOP_MAX TIMER_MAX TTY_NAME_MAX TZNAME_MAX UCHAR_MAX UINT_MAX UIO_MAXIOV ULONG_MAX USHRT_MAX WORD_BIT XBS5_ILP32_OFF32_CFLAGS XBS5_ILP32_OFF32_LDFLAGS XBS5_ILP32_OFF32_LIBS XBS5_ILP32_OFF32_LINTFLAGS XBS5_ILP32_OFFBIG_CFLAGS XBS5_ILP32_OFFBIG_LDFLAGS XBS5_ILP32_OFFBIG_LIBS XBS5_ILP32_OFFBIG_LINTFLAGS XBS5_LP64_OFF64_CFLAGS XBS5_LP64_OFF64_LDFLAGS XBS5_LP64_OFF64_LIBS XBS5_LP64_OFF64_LINTFLAGS XBS5_LPBIG_OFFBIG_CFLAGS XBS5_LPBIG_OFFBIG_LDFLAGS XBS5_LPBIG_OFFBIG_LIBS XBS5_LPBIG_OFFBIG_LINTFLAGS

You can use this script to recreate the above list:

#!/bin/sh # # Script for checking what options glibc getconf supports # (i.e. what limits / options are set in glibc source) src=~/glibc-2.3.2/posix/getconf.c bin=/scratchbox/compilers/i386-linux-glibc/usr/bin/getconf if [ ! -f $src ]; then echo "ERROR: getconf source not found in:" echo " '$src'" exit fi if [ ! -f $bin ]; then echo "ERROR: getconf binary not found in:" echo " '$bin'" exit fi # get all the possible variables in glibc getconf source echo "List of glibc variables supported by getconf:" for i in $(grep '{ "[A-Z_0-9]+"' $src|sed 's/^.*"([A-Z_0-9]+)".*$/1/'|sort) do # check which of them have been compiled to the binary $bin $i >/dev/null 2>&1 if [ $? -eq 0 ]; then echo -e "t$i" fi done