Commit graph

38731 commits

Author SHA1 Message Date
Noah Goldstein 535e935a28 Replace {u}int_fast{16|32} with {u}int32_t
On 32-bit machines this has no affect. On 64-bit machines
{u}int_fast{16|32} are set as {u}int64_t which is often not
ideal. Particularly x86_64 this change both saves code size and
may save instruction cost.

Full xcheck passes on x86_64.
2022-04-13 21:23:04 -05:00
Adhemerval Zanella d275970ab5 stdlib: Reflow and sort most variable assignments 2022-04-13 16:52:39 -03:00
Florian Weimer 4a41fc3cd9 elf: Fix memory leak in _dl_find_object_update (bug 29062)
The count can be zero if an object has already been loaded as
an indirect dependency (so that l_searchlist.r_list in its link
map is still NULL) is promoted to global scope via RTLD_GLOBAL.

Fixes commit 5d28a8962d ("elf: Add _dl_find_object function").
2022-04-13 14:19:04 +02:00
Samuel Thibault 45a8e05785 hurd: Define ELIBEXEC
So we can implement it in the exec server.
2022-04-12 22:16:40 +02:00
Samuel Thibault 67ab66541d hurd: Fix arbitrary error code
ELIBBAD is Linux-specific.
2022-04-12 22:15:48 +02:00
Carlos O'Donell 2fe48f5283 NEWS: Move PLT tracking slowdown to glibc 2.35.
In commit 063f9ba220 the NEWS section
was accidentally added to the glibc 2.34 NEWS section. The NEWS entry
should have been added to glibc 2.35 which contained the committed
fix. This moves the NEWS entry to correct section.
2022-04-12 13:26:10 -04:00
Szabolcs Nagy 707efc2955 Remove _dl_skip_args_internal declaration
It does not seem to be used.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-04-12 14:42:26 +01:00
DJ Delorie d2263bf50a test-container: Fix "unused code" warnings on HURD
Comment out bits of code that are only used when we *have* pid
namespaces, to avoid "unused code" warnings.

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Message-Id: <xno817tnds.fsf@greed.delorie.com>
2022-04-12 01:28:41 +02:00
Noah Goldstein ac5f5a92ed Add .clang-format style file
Went with version >= 11.0 since it covers most of the major features
and should be pretty universally accessibly.

There are some issues:

1.  indention of preprocessor directives:
    Unfortunately there doesn't appear to be a switch for a seperate
    'IndentWidth' for preprocessor directives vs. normal code so we
    are stuck either not indenting the directives or over-indenting
    them. i.e:
    Desired:
    ```
    #ifndef A
    # define B
    #endif
    ```
    Options:
    ```
    #ifndef A
    #  define B /* Two spaces instead of one.  */
    #endif

    #ifndef C
    #define D   /* No spaces.  */
    #endif
    ```
    Chose to over-indent as it generally seems easier to script
    halving all pre-processor indentations than counting the nested
    depth and indenting from scratch.

2.  concatenation of lines missing semi-colons:
    Throughout glibc there are macros used to setup aliasing that are
    outside of functions and don't end in semi-colons i.e:
    ```
    libc_hidden_def (__pthread_self)
    weak_alias (__pthread_self, pthread_self)
    ```

    clang-format reformats lines like these to:
    ```
    libc_hidden_def (__pthread_self) weak_alias (__pthread_self, pthread_self)
    ```

    which is generally undesirable.

Other than those two big concerns there are certainly some questions
diffs but for the most part it creates a easy to read and consistent
style.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-04-11 10:51:03 -05:00
Tom Coldrick d2265570a7 manual: Avoid name collision in libm ULP table [BZ #28956]
The 32-bit and 64-bit variants of RISC-V share the same name - "RISC-V"
- when generating the libm error table for the info pages. This
collision, and the way how the table is generated, mean that the values
in the final table for "RISC-V" may be either for the 32- or 64-bit
variant, with no indication as to which.

As an additional side-effect, this makes the build non-reproducible, as
the error table generated is dependent upon the host filesystem
implementation.

To solve this issue, the libm-test-ulps-name files for both variants
have been modified to include their word size, so as to remove the
collision and provide more accurate information in the table.

An alternative proposed was to merge the two variants' ULP values into a
single file, but this would mean that information about error values is
lost, as the two variants are not identical. Some differences are
considerable, notably the values for the exp() function are large.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2022-04-11 11:46:10 -04:00
Alan Modra 1a85970f41 powerpc: Relocate stinfo->main
start_addresses in sysdeps/powerpc/powerpc64/start.S is historical
baggage that should disappear.  Until someone does that, relocating
stinfo->main by hand is one solution to the fact that the field may be
unrelocated at the time it is accessed.  This is similar to what is
done for dynamic tags via the D_PTR macro.  stinfo->init and
stinfo->fini are zero in both powerpc64/start.S and powerpc32/start.S,
so make it a little more obvious they are unused by passing NULLs to
LIBC_START_MAIN.  The makefile change is needed to pick up
elf/dl-static-tls.h from dl-machine.h.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2022-04-10 08:37:38 +09:30
Alan Modra 31a9bc8c55 powerpc64: Set up thread register for _dl_relocate_static_pie
libgcc ifunc resolvers that access hwcap via a field in the tcb can't
be called until the thread pointer is set up.  Other ifunc resolvers
might need access to at_platform.  This patch sets up a fake thread
pointer early to a copy of tcbhead_t.  hwcapinfo.c already had local
variables for hwcap and at_platform, replace them with an entire
tcbhead_t.  It's not that large and this way we easily ensure hwcap
and at_platform are at the same relative offsets as they are in the
real thread block.

The patch also conditionally disables part of tst-tlsifunc-static,
"bar address read from IFUNC resolver is incorrect".  We can't get a
proper address for a thread variable before glibc initialises tls.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2022-04-10 08:33:40 +09:30
Alan Modra d6efcc118e powerpc64: Use medium model toc accesses throughout
The PowerPC64 linker edits medium model toc-indirect code to toc-pointer
relative:
	addis r9,r2,tc_entry_for_var@toc@ha
	ld r9,tc_entry_for_var@toc@l(r9)
becomes
	addis r9,r2,(var-.TOC.)@ha
	addi r9,r9,(var-.TOC.)@l
when "var" is known to be local to the binary.  This isn't done for
small-model toc-indirect code, because "var" is almost guaranteed to
be too far away from .TOC. for a 16-bit signed offset.  And, because
the analysis of which .toc entry can be removed becomes much more
complicated in objects that mix code models, they aren't removed if
any small-model toc sequence appears in an object file.

Unfortunately, glibc's build of ld.so smashes the needed objects
together in a ld -r linking stage.  This means the GOT/TOC is left
with a whole lot of relative relocations which is untidy, but in
itself is not a serious problem.  However, static-pie on powerpc64
bombs due to a segfault caused by one of the small-model accesses
before _dl_relocate_static_pie.  (The very first one in rcrt1.o
passing start_addresses in r8 to __libc_start_main.)

So this patch makes all the toc/got accesses in assembly medium code
model, and a couple of functions hidden.  By itself this is not
enough to give us working static-pie, but it is useful in isolation to
enable better linker optimisation.

There's a serious problem in libgcc too.  libgcc ifuncs access the
AT_HWCAP words stored in the tcb with an offset from the thread
pointer (r13), but r13 isn't set at the time _dl_relocate_static_pie.
A followup patch will fix that.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2022-04-10 08:33:06 +09:30
Alan Modra 30afd8c44d linux: Constify rfv variable in dl_vdso_vsym
Compilers may decide to put the rfv variable in .data rather than on
the stack.  It's slightly better to put it in .data.rel.ro.local
instead.  Regardles of that, making it const may enable further
optimisations.  Found when examining relative relocations (GOT ones
in particular) as part of enabling static-pie for PowerPC64.
2022-04-10 08:33:02 +09:30
Ricardo Bittencourt c0efbf8920 string: Replace outdated comments in strlen().
Copyright The GNU Toolchain Authors.

The comments on strlen() don't match what the actual code does. They
describe an older algorithm which is no longer in use. This change
replace the old comments with new ones describing the algorithm used.

I am a first time contributor, and I believe there is no need for
copyright assignment, since the file changed is not in the shared
source files list.

This patch only changes comments, but for safety I have run the tests in
my x64 ubuntu machine, with the following results:

Summary of test results:
   5051 PASS
     80 UNSUPPORTED
     16 XFAIL
      6 XPASS

Signed-off-by: Ricardo Bittencourt <bluepenguin@gmail.com>
2022-04-09 11:45:31 -05:00
Stefan Liebler 5325233313 S390: Fix elf/tst-audit25[ab]
If glibc is configured with --disable-default-pie and build on
s390 with -O3, the tests elf/tst-audit25a and elf/tst-audit25b are
failing as there are additional la_symbind lines for free and malloc.
It turns out that those belong to the executable. In fact those are
the PLT-stubs. Furthermore la_symbind is also called for calloc and
realloc symbols, but those belong to libc.

Those functions are not called at all, but dlsym'ed in
elf/dl-minimal.c:
__rtld_malloc_init_real (struct link_map *main_map)
{
...
  void *new_calloc = lookup_malloc_symbol (main_map, "calloc", &version);
  void *new_free = lookup_malloc_symbol (main_map, "free", &version);
  void *new_malloc = lookup_malloc_symbol (main_map, "malloc", &version);
  void *new_realloc = lookup_malloc_symbol (main_map, "realloc", &version);
...
}

Therefore, this commit just ignored symbols with LA_SYMB_DLSYM flag.
Reviewed-by: Adheemrval Zanella  <adhemerval.zanella@linaro.org>
2022-04-07 20:38:23 +02:00
Adhemerval Zanella 4f2146c4f4 sparc64: Remove fcopysign{f} implementation
The builtin from generic code generates similar compliant sequence.

Checked on sparc64-linux-gnu.
2022-04-07 15:11:56 -03:00
Adhemerval Zanella 0753be0c8a alpha: Remove fcopysign{f} implementation
The generic code already uses builtins.
2022-04-07 14:56:26 -03:00
Adhemerval Zanella 0a4ae090e0 math: Use builtin for ldbl-96 copysign
All architectures that uses it (x86, ia64, m68k) implement the
builtin.

Checked on x86_64-linux-gnu and ia64-linux-gnu.
2022-04-07 14:54:14 -03:00
Adhemerval Zanella a085346267 ia64: Remove fcopysign{f} implementation
The builtin used by generic code generates similar code.

Checked on ia64-linux-gnu.
2022-04-07 12:27:00 -03:00
Adhemerval Zanella 13d45cf9a7 x86: Remove fcopysign{f} implementation
The builtin used by generic code generates similar code.

Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-04-07 12:17:15 -03:00
Adhemerval Zanella 2a45807e73 powerpc: Remove fcopysign{f} implementation
The builtin and generic implementation from generic files are suffice.

Checked on powerpc64-linux-gnu and powerpc-linux-gnu.
2022-04-07 12:00:16 -03:00
Ilyahoo Proshel 189906b687 Add rif_MA locale [BZ #27781]
Resolves: BZ #27781
2022-04-07 14:59:41 +02:00
Siddhesh Poyarekar 67e3b0c63c tests/string: Drop simple/stupid/builtin tests
In most cases the simple/stupid/builtin functions were in there to
benchmark optimized implementations against.  Only in some cases the
functions are used to check expected results.

Remove these tests from IMPL() and only keep them in wherever they're
used for a specific purpose, e.g. to generate expected results.

This improves timing of `make subdirs=string` by over a minute and a
half (over 15%) on a Whiskey Lake laptop.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Noah Goldstein <libc-alpha@sourceware.org>
2022-04-06 20:53:24 +05:30
Siddhesh Poyarekar dfc7bf8a24 test-memcpy: Actually reverse source and destination
Looks like an oversight in memcpy tests resulted in s2 and s1 not being
swapped for the second iteration of the memcpy test.  Fix it.  Also fix
a formatting nit.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-04-06 12:45:39 +05:30
Adhemerval Zanella cbc2c56bab benchtests: Only build libmvec benchmarks iff $(build-mathvec) is set
Checked on x86_64-linux-gnu.
2022-04-05 12:01:10 -03:00
Adhemerval Zanella 053fe27343 linux: Fix __closefrom_fallback iterates until max int (BZ#28993)
The __closefrom_fallback tries to get a available file descriptor
if the initial open ("/proc/self/fd/", ...) fails.  It assumes the
failure would be only if procfs is not mount (ENOENT), however if
the the proc file is not accessible (due some other kernel filtering
such apparmor) it will iterate over a potentially large file set
issuing close calls.

It should only try the close fallback if open returns EMFILE,
ENFILE, or ENOMEM.

Checked on x86_64-linux-gnu.
2022-04-05 08:08:19 -03:00
Fangrui Song 3ee318c923 Remove -z combreloc and HAVE_Z_COMBRELOC
-z combreloc has been the default regadless of the architecture since
binutils commit f4d733664aabd7bd78c82895e030ec9779a92809 (2002). The
configure check added in commit fdde83499a (2001) has long been
unneeded.

We can therefore treat HAVE_Z_COMBRELOC as always 1 and delete dead code
paths in dl-machine.h files (many were copied from commit a711b01d34
and ee0cb67ec2).

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-04-04 17:19:07 -07:00
Adhemerval Zanella 1c225a2dd1 sparc: Remove s_abs implementations
For sparc64 is the same as the generic implementation, while for
sparc32 the builtin generates the same code.

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
2022-04-04 16:53:24 -03:00
Adhemerval Zanella caee5be74b ia64: Remove fabs implementations
The generic implementation fixes 5 fabs tests on ia64-linux-gnu:

  math/test-double-fabs
  math/test-float-fabs
  math/test-float32-fabs
  math/test-float32x-fabs
  math/test-float64-fabs

Checked on ia64-linux-gnu.
2022-04-04 16:30:38 -03:00
Adhemerval Zanella 7eed708edf x86: Remove fabs{f} implementation
For x86_64 is the same as the generic implementation, while for i686
the builtin generates the same code.
2022-04-04 16:23:11 -03:00
Adhemerval Zanella dc2cfd6a87 alpha: Remove s_abs implementations
The generic implementation already uses builtins.
2022-04-04 16:22:15 -03:00
DJ Delorie 2fe64148a8 Allow for unpriviledged nested containers
If the build itself is run in a container, we may not be able to
fully set up a nested container for test-container testing.
Notably is the mounting of /proc, since it's critical that it
be mounted from within the same PID namespace as its users, and
thus cannot be bind mounted from outside the container like other
mounts.

This patch defaults to using the parent's PID namespace instead of
creating a new one, as this is more likely to be allowed.

If the test needs an isolated PID namespace, it should add the "pidns"
command to its init script.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-04-04 14:17:08 -04:00
Szabolcs Nagy 6ff3c77149 Increase the test timeout of some string tests
Recent changes in test-strncasecmp and test-strncmp pushed the run time
of the tests above the 4 minute limit specified in test-string.h on an
arm tester machine.
2022-04-01 16:02:40 +01:00
Siddhesh Poyarekar b416555431 realpath: Bring back GNU extension on ENOENT and EACCES [BZ #28996]
The GNU extension for realpath states that if the path resolution fails
with ENOENT or EACCES and the resolved buffer is non-NULL, it will
contain part of the path that failed resolution.

commit 949ad78a18 broke this when it
omitted the copy on failure.  Bring it back partially to continue
supporting this GNU extension.

Resolves: BZ #28996

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
2022-03-31 22:00:58 +05:30
Adhemerval Zanella 7f2ddf7400 stdlib: Fix tst-getrandom memcmp call
The idea is to check if the up sizeof (buf) are equal, not only
the first byte.

Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 09:14:10 -03:00
Adhemerval Zanella 3ff447f7df stdlib: Fix tst-rand48.c printf types
Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 09:13:14 -03:00
Adhemerval Zanella bc02f1fa2f elf: Remove unused functions from tst-audit25(a,b) 2022-03-31 09:12:16 -03:00
Adhemerval Zanella 692c2571c8 nptl: Use libc-diag.h with tst-thread-setspecific
And also use libsupport.

Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 09:02:41 -03:00
Adhemerval Zanella 1dedc5bd5c crypt: Remove unused variable on cert test
Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 09:00:54 -03:00
Adhemerval Zanella f60510ddaf elf: Remove unused variables in tests
Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 08:59:23 -03:00
Adhemerval Zanella b2cd93fce6 elf: Fix wrong fscanf usage on tst-pldd
To take in consideration the extra '\0'.

Checked on x86_64-linux-gnu.
2022-03-31 08:57:59 -03:00
Adhemerval Zanella f902892aaf posix: Remove unused variable on tst-_Fork.c
Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 08:57:12 -03:00
Adhemerval Zanella 2fe316888a resolv: Initialize loop variable on tst-resolv-trailing
Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 08:55:48 -03:00
Adhemerval Zanella c5c65de1b2 locale: Remove set but unused variable on ld-collate.c
Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 08:53:40 -03:00
Adhemerval Zanella 74942fd273 localedate: Fix printf type on tst_mbrtowc
Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 08:49:55 -03:00
Adhemerval Zanella d1eefcb2a0 localedata: Remove unused variables in tests
Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-03-31 08:38:35 -03:00
Noah Goldstein 244b415d38 x86: Small improvements for wcslen
Just a few QOL changes.
    1. Prefer `add` > `lea` as it has high execution units it can run
       on.
    2. Don't break macro-fusion between `test` and `jcc`
    3. Reduce code size by removing gratuitous padding bytes (-90
       bytes).

geometric_mean(N=20) of all benchmarks New / Original: 0.959

All string/memory tests pass.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2022-03-28 15:00:03 -05:00
Noah Goldstein f5bff979d0 x86: Small improvements for wcscpy-ssse3
Just a few small QOL changes.
    1. Prefer `add` > `lea` as it has high execution units it can run
       on.
    2. Don't break macro-fusion between `test` and `jcc`

geometric_mean(N=20) of all benchmarks New / Original: 0.973

All string/memory tests pass.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2022-03-28 15:00:03 -05:00
Cristian Rodríguez 811c635dba debug: Improve fdelt_chk error message
It is not a "buffer overflow detected" but an out of range
bit on fd_set

Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-03-28 19:10:30 +05:30