mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-26 15:00:06 +00:00
bf079e19f5
glibc's implementation of getopt includes code to parse an environment variable named _XXX_GNU_nonoption_argv_flags_ (where XXX is the current process's PID in decimal); but all of it has been #ifdefed out since 2001, with no official way to turn it back on. According to commentary in our config.h.in, bash version 2.0 set this environment variable to indicate argv elements that were the result of glob expansion and therefore should not be treated as options, but the feature was "disabled later" because "it caused problems". According to bash's CHANGES file, "later" was release 2.01; it gives no more detail about what the problems were. Version 2.0 of bash was released on the last day of 1996, and version 2.01 in June of 1997. Twenty years later, I think it is safe to assume that this environment variable isn't coming back. * config.h.in (USE_NONOPTION_FLAGS): Remove. * csu/init-first.c: Remove all #ifdef USE_NONOPTION_FLAGS blocks. * sysdeps/mach/hurd/i386/init-first.c: Likewise. * posix/getopt_int.h: Likewise. * posix/getopt.c: Likewise. Also remove SWAP_FLAGS and the __libc_argc and __libc_argv externs, which were only used by #ifdef USE_NONOPTION_FLAGS blocks. * posix/getopt_init.c: Remove file. * posix/Makefile (routines): Remove getopt_init. * include/getopt.h: Don't declare __getopt_initialize_environment. * manual/getopt.texi: Remove mention of USE_NONOPTION_FLAGS in a comment.
103 lines
2.8 KiB
C
103 lines
2.8 KiB
C
/* Initialization code run first thing by the ELF startup code. Common version
|
|
Copyright (C) 1995-2017 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#include <ctype.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <sysdep.h>
|
|
#include <fpu_control.h>
|
|
#include <sys/param.h>
|
|
#include <sys/types.h>
|
|
#include <libc-internal.h>
|
|
|
|
#include <ldsodefs.h>
|
|
|
|
/* Set nonzero if we have to be prepared for more than one libc being
|
|
used in the process. Safe assumption if initializer never runs. */
|
|
int __libc_multiple_libcs attribute_hidden = 1;
|
|
|
|
/* Remember the command line argument and enviroment contents for
|
|
later calls of initializers for dynamic libraries. */
|
|
int __libc_argc attribute_hidden;
|
|
char **__libc_argv attribute_hidden;
|
|
|
|
|
|
void
|
|
__libc_init_first (int argc, char **argv, char **envp)
|
|
{
|
|
#ifdef SHARED
|
|
/* For DSOs we do not need __libc_init_first but instead _init. */
|
|
}
|
|
|
|
void
|
|
attribute_hidden
|
|
_init (int argc, char **argv, char **envp)
|
|
{
|
|
#endif
|
|
|
|
__libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
|
|
|
|
/* Make sure we don't initialize twice. */
|
|
if (!__libc_multiple_libcs)
|
|
{
|
|
/* Set the FPU control word to the proper default value if the
|
|
kernel would use a different value. */
|
|
if (__fpu_control != GLRO(dl_fpu_control))
|
|
__setfpucw (__fpu_control);
|
|
}
|
|
|
|
/* Save the command-line arguments. */
|
|
__libc_argc = argc;
|
|
__libc_argv = argv;
|
|
__environ = envp;
|
|
|
|
#ifndef SHARED
|
|
/* First the initialization which normally would be done by the
|
|
dynamic linker. */
|
|
_dl_non_dynamic_init ();
|
|
#endif
|
|
|
|
#ifdef VDSO_SETUP
|
|
VDSO_SETUP ();
|
|
#endif
|
|
|
|
__init_misc (argc, argv, envp);
|
|
|
|
/* Initialize ctype data. */
|
|
__ctype_init ();
|
|
|
|
#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
|
|
__libc_global_ctors ();
|
|
#endif
|
|
}
|
|
|
|
/* This function is defined here so that if this file ever gets into
|
|
ld.so we will get a link error. Having this file silently included
|
|
in ld.so causes disaster, because the _init definition above will
|
|
cause ld.so to gain an init function, which is not a cool thing. */
|
|
|
|
extern void _dl_start (void) __attribute__ ((noreturn));
|
|
|
|
void
|
|
_dl_start (void)
|
|
{
|
|
abort ();
|
|
}
|