mirror of
https://sourceware.org/git/glibc.git
synced 2026-01-06 11:51:29 +03:00
Linux: Consolidate auxiliary vector parsing
And optimize it slightly. The large switch statement in _dl_sysdep_start can be replaced with a large array. This reduces source code and binary size. On i686-linux-gnu: Before: text data bss dec hex filename 7791 12 0 7803 1e7b elf/dl-sysdep.os After: text data bss dec hex filename 7135 12 0 7147 1beb elf/dl-sysdep.os Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
61
sysdeps/unix/sysv/linux/dl-parse_auxv.h
Normal file
61
sysdeps/unix/sysv/linux/dl-parse_auxv.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* Parse the Linux auxiliary vector.
|
||||
Copyright (C) 1995-2022 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
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <elf.h>
|
||||
#include <entry.h>
|
||||
#include <fpu_control.h>
|
||||
#include <ldsodefs.h>
|
||||
#include <link.h>
|
||||
|
||||
typedef ElfW(Addr) dl_parse_auxv_t[AT_MINSIGSTKSZ + 1];
|
||||
|
||||
/* Copy the auxiliary vector into AUX_VALUES and set up GLRO
|
||||
variables. */
|
||||
static inline
|
||||
void _dl_parse_auxv (ElfW(auxv_t) *av, dl_parse_auxv_t auxv_values)
|
||||
{
|
||||
auxv_values[AT_ENTRY] = (ElfW(Addr)) ENTRY_POINT;
|
||||
auxv_values[AT_PAGESZ] = EXEC_PAGESIZE;
|
||||
auxv_values[AT_FPUCW] = _FPU_DEFAULT;
|
||||
|
||||
/* NB: Default to a constant CONSTANT_MINSIGSTKSZ. */
|
||||
_Static_assert (__builtin_constant_p (CONSTANT_MINSIGSTKSZ),
|
||||
"CONSTANT_MINSIGSTKSZ is constant");
|
||||
auxv_values[AT_MINSIGSTKSZ] = CONSTANT_MINSIGSTKSZ;
|
||||
|
||||
for (; av->a_type != AT_NULL; av++)
|
||||
if (av->a_type <= AT_MINSIGSTKSZ)
|
||||
auxv_values[av->a_type] = av->a_un.a_val;
|
||||
|
||||
GLRO(dl_pagesize) = auxv_values[AT_PAGESZ];
|
||||
__libc_enable_secure = auxv_values[AT_SECURE];
|
||||
GLRO(dl_platform) = (void *) auxv_values[AT_PLATFORM];
|
||||
GLRO(dl_hwcap) = auxv_values[AT_HWCAP];
|
||||
GLRO(dl_hwcap2) = auxv_values[AT_HWCAP2];
|
||||
GLRO(dl_clktck) = auxv_values[AT_CLKTCK];
|
||||
GLRO(dl_fpu_control) = auxv_values[AT_FPUCW];
|
||||
_dl_random = (void *) auxv_values[AT_RANDOM];
|
||||
GLRO(dl_minsigstacksize) = auxv_values[AT_MINSIGSTKSZ];
|
||||
GLRO(dl_sysinfo_dso) = (void *) auxv_values[AT_SYSINFO_EHDR];
|
||||
#ifdef NEED_DL_SYSINFO
|
||||
if (GLRO(dl_sysinfo_dso) != NULL)
|
||||
GLRO(dl_sysinfo) = auxv_values[AT_SYSINFO];
|
||||
#endif
|
||||
|
||||
DL_PLATFORM_AUXV
|
||||
}
|
||||
Reference in New Issue
Block a user