platform/upstream/glibc.git
3 years agoposix: Add _Fork [BZ #4737]
Adhemerval Zanella [Tue, 19 Jan 2021 12:26:31 +0000 (09:26 -0300)]
posix: Add _Fork [BZ #4737]

Austin Group issue 62 [1] dropped the async-signal-safe requirement
for fork and provided a async-signal-safe _Fork replacement that
does not run the atfork handlers.  It will be included in the next
POSIX standard.

It allow to close a long standing issue to make fork AS-safe (BZ#4737).
As indicated on the bug, besides the internal lock for the atfork
handlers itself; there is no guarantee that the handlers itself will
not introduce more AS-safe issues.

The idea is synchronize fork with the required internal locks to allow
children in multithread processes to use mostly of standard function
(even though POSIX states only AS-safe function should be used).  On
signal handles, _Fork should be used intead and only AS-safe functions
should be used.

For testing, the new tst-_Fork only check basic usage.  I also added
a new tst-mallocfork3 which uses the same strategy to check for
deadlock of tst-mallocfork2 but using threads instead of subprocesses
(and it does deadlock if it replaces _Fork with fork).

[1] https://austingroupbugs.net/view.php?id=62

3 years agonptl: Add glibc.pthread.stack_cache_size tunable
Florian Weimer [Mon, 28 Jun 2021 13:48:58 +0000 (15:48 +0200)]
nptl: Add glibc.pthread.stack_cache_size tunable

The valgrind/helgrind test suite needs a way to make stack dealloction
more prompt, and this feature seems to be generally useful.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agonptl: Export libthread_db-used symbols under GLIBC_PRIVATE
Florian Weimer [Mon, 28 Jun 2021 12:33:53 +0000 (14:33 +0200)]
nptl: Export libthread_db-used symbols under GLIBC_PRIVATE

This allows distributions to strip debugging information from
libc.so.6 without impacting the debugging experience.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agonptl: Rename nptl_version to __nptl_version
Florian Weimer [Mon, 28 Jun 2021 12:33:53 +0000 (14:33 +0200)]
nptl: Rename nptl_version to __nptl_version

This prepares it for exporting as a dynamic symbol.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agonptl_db: Clean up main/rtld variable handling
Florian Weimer [Mon, 28 Jun 2021 12:33:53 +0000 (14:33 +0200)]
nptl_db: Clean up main/rtld variable handling

Most symbols are now in libc.so.6.  The "main" (exempted from
coverage checks) status is therefore not necessary.  Use
DB_MAIN_VARIABLE for the remaining separate symbol,
__nptl_initial_report_events.  DB_RTLD_VARIABLE is now unused, so
remove it.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoarm: align stack in clone [BZ 28020]
Szabolcs Nagy [Fri, 25 Jun 2021 18:58:59 +0000 (19:58 +0100)]
arm: align stack in clone [BZ 28020]

The arm PCS requires 8 byte aligned stack at function entry.
Previously unaligned stack could crash the clone child.

Fixes bug 28020.

3 years agoLinux: Cleanups after librt move
Florian Weimer [Mon, 28 Jun 2021 07:51:01 +0000 (09:51 +0200)]
Linux: Cleanups after librt move

librt.so is no longer installed for PTHREAD_IN_LIBC, and tests
are not linked against it.  $(librt) is introduced globally for
shared tests that need to be linked for both PTHREAD_IN_LIBC
and !PTHREAD_IN_LIBC.

GLIBC_PRIVATE symbols that were needed during the transition are
removed again.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoLinux: Move timer_settime, __timer_settime64 from librt to libc
Florian Weimer [Mon, 28 Jun 2021 07:51:01 +0000 (09:51 +0200)]
Linux: Move timer_settime, __timer_settime64 from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

The way the ABI intransition is implemented is changed with this
commit: the implementation is now consolidated in one file with a
TIMER_T_WAS_INT_COMPAT check.

The shared librt is now empty, so this commit adds a placeholder
symbol at the base version, GLIBC_2.2, and potentially at the
GLIBC_2.3.3 version as well (the leftover from the int/timer_t ABI
transition).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move timer_gettime, __timer_gettime64 from librt to libc
Florian Weimer [Mon, 28 Jun 2021 07:51:01 +0000 (09:51 +0200)]
Linux: Move timer_gettime, __timer_gettime64 from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

The way the ABI intransition is implemented is changed with this
commit: the implementation is now consolidated in one file with a
TIMER_T_WAS_INT_COMPAT check.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move timer_getoverrun from librt to libc
Florian Weimer [Mon, 28 Jun 2021 07:51:00 +0000 (09:51 +0200)]
Linux: Move timer_getoverrun from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

The way the ABI intransition is implemented is changed with this
commit: the implementation is now consolidated in one file with a
TIMER_T_WAS_INT_COMPAT check.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move timer_create, timer_delete from librt to libc
Florian Weimer [Mon, 28 Jun 2021 07:51:00 +0000 (09:51 +0200)]
Linux: Move timer_create, timer_delete from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

timer_create and timer_delete are tied together via the int/timer_t
compatibility code.  The way the ABI intransition is implemented
is changed with this commit: the implementation is now consolidated
in one file with a TIMER_T_WAS_INT_COMPAT check.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Define TIMER_T_WAS_INT_COMPAT in kernel-posix-timers.h
Florian Weimer [Mon, 28 Jun 2021 07:51:00 +0000 (09:51 +0200)]
Linux: Define TIMER_T_WAS_INT_COMPAT in kernel-posix-timers.h

This is almost equivalent to __WORDSIZE == 64
&& OTHER_SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_3_3), except
that this expression is true for mips64/n64 targets as well,
even though those did not undergo the timer_t transition.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoInstall shared objects under their ABI names
Florian Weimer [Mon, 28 Jun 2021 06:33:57 +0000 (08:33 +0200)]
Install shared objects under their ABI names

Previously, the installed objects were named like libc-2.33.so,
and the ABI soname libc.so.6 was just a symbolic link.

The Makefile targets to install these symbolic links are no longer
needed after this, so they are removed with this commit.  The more
general $(make-link) command (which invokes scripts/rellns-sh) is
retained because other symbolic links are still needed.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@rehdat.com>
3 years agoelf: Generalize name-based DSO recognition in ldconfig
Florian Weimer [Mon, 28 Jun 2021 06:33:57 +0000 (08:33 +0200)]
elf: Generalize name-based DSO recognition in ldconfig

This introduces <dl-is_dso.h> and the _dl_is_dso function.  A
test ensures that the official names of libc.so, ld.so, and their
versioned names are recognized.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoMakerules: Remove lib-version, $(subdir-version)
Florian Weimer [Mon, 28 Jun 2021 06:33:57 +0000 (08:33 +0200)]
Makerules: Remove lib-version, $(subdir-version)

Also clarify that the "versioned" term refers to the soname, not the glibc
version (which also ends up in the installed file name).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agonptl_db: Install libthread_db under a regular implementation name
Florian Weimer [Mon, 28 Jun 2021 06:33:57 +0000 (08:33 +0200)]
nptl_db: Install libthread_db under a regular implementation name

Currently, the name is always libthread_db-1.0.so.  It does not change
with the glibc version, like the other libraries.

GDB hard-codes libthread_db.so.1 (the soname), so this change does not
affect loading libthread_db.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoiconvconfig: Fix multiple issues
Siddhesh Poyarekar [Mon, 28 Jun 2021 03:45:55 +0000 (09:15 +0530)]
iconvconfig: Fix multiple issues

It was noticed on big-endian systems that msgfmt would fail with the
following error:

msgfmt: gconv_builtin.c:70: __gconv_get_builtin_trans: Assertion `cnt < sizeof (map) / sizeof (map[0])' failed.
Aborted (core dumped)

This is only seen on installed systems because it was due to a
corrupted gconv-modules.cache.  iconvconfig had the following issues
(it was specifically freeing fulldir that caused this issue, but other
cleanups are also needed) that this patch fixes.

- Add prefix only if dir starts with '/'
- Use asprintf instead of mempcpy so that the directory string is NULL
  terminated
- Make a copy of the directory reference in new_module so that fulldir
  can be freed within the same scope in handle_dir.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 years agowordexp: handle overflow in positional parameter number (bug 28011)
Andreas Schwab [Fri, 25 Jun 2021 13:02:47 +0000 (15:02 +0200)]
wordexp: handle overflow in positional parameter number (bug 28011)

Use strtoul instead of atoi so that overflow can be detected.

3 years agoUpdate math: redirect roundeven function
H.J. Lu [Wed, 23 Jun 2021 20:29:41 +0000 (13:29 -0700)]
Update math: redirect roundeven function

Redirect target specific roundeven functions for aarch64, ldbl-128ibm
and riscv.

3 years agoUse GCC builtins for roundeven functions if desired.
Shen-Ta Hsieh [Mon, 24 May 2021 01:43:12 +0000 (09:43 +0800)]
Use GCC builtins for roundeven functions if desired.

This patch is using the corresponding GCC builtin for roundevenf,
roundeven and roundevenl if the USE_FUNCTION_BUILTIN macros are defined
to one in math-use-builtins.h.

These builtin functions is supported since GCC 10.

The code of the generic implementation is not changed.

Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agox86_64: roundeven with sse4.1 support
Shen-Ta Hsieh [Mon, 24 May 2021 01:43:11 +0000 (09:43 +0800)]
x86_64: roundeven with sse4.1 support

This patch adds support for the sse4.1 hardware floating point
roundeven.

Here is some benchmark results on my systems:

=AMD Ryzen 9 3900X 12-Core Processor=

* benchmark result before this commit
|            |    roundeven |   roundevenf |
|------------|--------------|--------------|
| duration   |  3.75587e+09 |  3.75114e+09 |
| iterations |  3.93053e+08 |  4.35402e+08 |
| max        | 52.592       | 58.71        |
| min        |  7.98        |  7.22        |
| mean       |  9.55563     |  8.61535     |

* benchmark result after this commit
|            |     roundeven |   roundevenf |
|------------|---------------|--------------|
| duration   |   3.73815e+09 |  3.73738e+09 |
| iterations |   5.82692e+08 |  5.91498e+08 |
| max        |  56.468       | 51.642       |
| min        |   6.27        |  6.156       |
| mean       |   6.41532     |  6.3185      |

=Intel(R) Pentium(R) CPU D1508 @ 2.20GHz=

* benchmark result before this commit
|            |    roundeven |   roundevenf |
|------------|--------------|--------------|
| duration   |  2.18208e+09 |  2.18258e+09 |
| iterations |  2.39932e+08 |  2.46924e+08 |
| max        | 96.378       | 98.035       |
| min        |  6.776       |  5.94        |
| mean       |  9.09456     |  8.83907     |

* benchmark result after this commit
|            |    roundeven |   roundevenf |
|------------|--------------|--------------|
| duration   |  2.17415e+09 |  2.17005e+09 |
| iterations |  3.56193e+08 |  4.09824e+08 |
| max        | 51.693       | 97.192       |
| min        |  5.926       |  5.093       |
| mean       |  6.10385     |  5.29507     |

Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agomath: redirect roundeven function
Shen-Ta Hsieh [Mon, 24 May 2021 01:43:10 +0000 (09:43 +0800)]
math: redirect roundeven function

This patch redirect roundeven function for futhermore changes.

Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agoLinux: Move timer helper routines from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:51:31 +0000 (10:51 +0200)]
Linux: Move timer helper routines from librt to libc

This adds several temporary GLIBC_PRIVATE exports.  The symbol names
are changed so that they all start with __timer_.

It is now possible to invoke the fork handler directly, so
pthread_atfork is no longer necessary.  The associated error cannot
happen anymore, and cancellation handling can be removed from
the helper thread routine.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_unlink from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:54 +0000 (10:42 +0200)]
Linux: Move mq_unlink from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.
A placeholder symbol is needed on some architectures for the
GLIBC_2.3.4 version.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_send, mq_timedsend, __mq_timedsend_time64 to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:54 +0000 (10:42 +0200)]
Linux: Move mq_send, mq_timedsend, __mq_timedsend_time64 to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_receive, mq_timedreceive, __mq_timedreceive_time64 to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:54 +0000 (10:42 +0200)]
Linux: Move mq_receive, mq_timedreceive, __mq_timedreceive_time64 to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_open, __mq_open_2 from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:54 +0000 (10:42 +0200)]
Linux: Move mq_open, __mq_open_2 from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.
A placeholder symbol is required to keep the GLIBC_2.7 version.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_notify from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:52 +0000 (10:42 +0200)]
Linux: Move mq_notify from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

An explicit call from fork into the mq_notify implementation replaces
the previous use of pthread_atfork.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_getattr from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move mq_getattr from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_setattr from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move mq_setattr from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

To introduce the proper symbol versioning, the implementation of
the system call wrapper us moved to a C file.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_close from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move mq_close from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move lio_listio, lio_listio64 from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move lio_listio, lio_listio64 from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.
Placeholder symbols are needed on some architectures, to keep the
GLIBC_2.1 and GLIBC_2.4 symbol versions around.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agort: Rework lio_listio implementation
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
rt: Rework lio_listio implementation

Move the common code into rt/lio_listio-common.c and include
the file in both rt/lio_listio.c and rt/lio_listio64.c.  The common
code automatically defines both public symbols for __WORDSIZE == 64.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_write, aio_write64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_write, aio_write64 into libc

Both symbols have to be moved at the same time because they
are intertwined for __WORDSIZE == 64.  The treatment of this case
is also changed to match more closely how the other files suppress
the declaration of the *64 identifier.

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

There is a minor oddity here: This is generic code shared with Hurd,
and Hurd does not have time64 support.  This is why the
versioned_symbol export for __aio_suspend_time64 is restricted to
the PTHREAD_IN_LIBC code.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_return, aio_return64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_return, aio_return64 into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_read, aio_read64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_read, aio_read64 into libc

Both symbols have to be moved at the same time because they
are intertwined for __WORDSIZE == 64.  The treatment of this case
is also changed to match more closely how the other files suppress
the declaration of the *64 identifier.

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_fsync, aio_fsync64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_fsync, aio_fsync64 into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_error, aio_error64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_error, aio_error64 into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_cancel, aio_cancel64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_cancel, aio_cancel64 into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

A version placeholder symbol is needed on alpha and sparc because
of the additional symbols formerly at version GLIBC_2.3.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>:
3 years agoLinux: Move aio_init from librt into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:35 +0000 (10:30 +0200)]
Linux: Move aio_init from librt into libc

This commit also moves the aio_misc and aio_sigquue helper,
so GLIBC_PRIVATE exports need to be added.

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agosupport: Fix xclone build failures on ia64 and hppa
Florian Weimer [Fri, 25 Jun 2021 07:30:00 +0000 (09:30 +0200)]
support: Fix xclone build failures on ia64 and hppa

3 years agoelf: Disable most of TLS modid gaps processing [BZ #27135]
Florian Weimer [Fri, 25 Jun 2021 06:09:08 +0000 (08:09 +0200)]
elf: Disable most of TLS modid gaps processing [BZ #27135]

Revert "elf: Fix DTV gap reuse logic [BZ #27135]"

This reverts commit 572bd547d57a39b6cf0ea072545dc4048921f4c3.

It turns out that the _dl_next_tls_modid in _dl_map_object_from_fd keeps
returning the same modid over and over again if there is a gap and
more than TLS-using module is loaded in one dlopen call.  This corrupts
TLS data structures.  The bug is still present after a revert, but
empirically it is much more difficult to trigger (because it involves a
dlopen failure).

3 years agoelf: Fix glibc-hwcaps priorities with cache flags mismatches [BZ #27046]
Florian Weimer [Fri, 25 Jun 2021 06:02:30 +0000 (08:02 +0200)]
elf: Fix glibc-hwcaps priorities with cache flags mismatches [BZ #27046]

If lib->flags (in the cache) did not match GLRO (dl_correct_cache_id),
searching for further glibc-hwcaps entries did not happen, and it
was possible that the best glibc-hwcaps was not found.  By accident,
this causes a test failure for elf/tst-glibc-hwcaps-prepend-cache
on armv7l.

This commit changes the cache lookup logic to continue searching
if (a) no match has been found, (b) a named glibc-hwcaps match
has been found(), or (c) non-glibc-hwcaps match has been found
and the entry flags and cache default flags do not match.

_DL_CACHE_DEFAULT_ID is used instead of GLRO (dl_correct_cache_id)
because the latter is only written once on i386 if loading
of libc.so.5 libraries is selected, so GLRO (dl_correct_cache_id)
should probably removed in a future change.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
3 years ago* NEWS: Clarify _TIME_BITS change.
Paul Eggert [Fri, 25 Jun 2021 04:12:19 +0000 (21:12 -0700)]
* NEWS: Clarify _TIME_BITS change.

3 years agox86: Remove unnecessary overflow check from wcsnlen-sse4_1.S
Noah Goldstein [Wed, 23 Jun 2021 23:19:34 +0000 (19:19 -0400)]
x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S

No bug. The way wcsnlen will check if near the end of maxlen
is the following macro:

mov %r11, %rsi; \
subq %rax, %rsi; \
andq $-64, %rax; \
testq $-64, %rsi; \
je L(strnlen_ret)

Which words independently of s + maxlen overflowing. So the
second overflow check is unnecissary for correctness and
just extra overhead in the common no overflow case.

test-strlen.c, test-wcslen.c, test-strnlen.c and test-wcsnlen.c are
all passing

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agoString: Add three more overflow tests cases to test-strnlen.c
Noah Goldstein [Wed, 23 Jun 2021 23:17:29 +0000 (19:17 -0400)]
String: Add three more overflow tests cases to test-strnlen.c

No bug. Just seem like relevant cases given that strnlen will
use s + maxlen in many implementations.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agoConsolidate pthread_atfork
Adhemerval Zanella [Wed, 20 Jan 2021 17:06:56 +0000 (14:06 -0300)]
Consolidate pthread_atfork

The pthread_atfork is similar between Linux and Hurd, only the compat
version bits differs.  The generic version is place at sysdeps/pthread
with a common name.

It also fixes an issue with Hurd license, where the static-only object
did not use LGPL + exception.

Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for
i686-gnu.

3 years agoposix: Do not clobber errno by atfork handlers
Adhemerval Zanella [Thu, 21 Jan 2021 13:20:54 +0000 (10:20 -0300)]
posix: Do not clobber errno by atfork handlers

Checked on x86_64-linux-gnu.

3 years agoposix: Consolidate fork implementation
Adhemerval Zanella [Mon, 18 Jan 2021 18:18:13 +0000 (15:18 -0300)]
posix: Consolidate fork implementation

The Linux nptl implementation is used as base for generic fork
implementation to handle the internal locks and mutexes.  The
system specific bits are moved a new internal _Fork symbol.

(This new implementation will be used to provide a async-signal-safe
_Fork now that POSIX has clarified that fork might not be
async-signal-safe [1]).

For Hurd it means that the __nss_database_fork_prepare_parent and
__nss_database_fork_subprocess will be run in a slight different
order.

[1] https://austingroupbugs.net/view.php?id=62

3 years agosupport: Add xclone
Adhemerval Zanella [Wed, 10 Mar 2021 15:26:30 +0000 (12:26 -0300)]
support: Add xclone

It is a wrapper for Linux clone syscall, to simplify the call to the
use only the most common arguments and remove architecture specific
handling (such as ia64 different name and signature).

3 years agox86: Fix tst-cpu-features-cpuinfo on Ryzen 9 (BZ #27873)
Adhemerval Zanella [Tue, 22 Jun 2021 19:41:28 +0000 (16:41 -0300)]
x86: Fix tst-cpu-features-cpuinfo on Ryzen 9 (BZ #27873)

AMD define different flags for IRPB, IBRS, and STIPBP [1], so new
x86_64_cpu are added and IBRS_IBPB is only tested for Intel.

The SSDB is also defined and implemented different on AMD [2],
and also a new AMD_SSDB flag is added.  It should map to the
cpuinfo 'ssdb' on recent AMD cpus.

It fixes tst-cpu-features-cpuinfo and tst-cpu-features-cpuinfo-static
on recent AMD cpus.

Checked on x86_64-linux-gnu on AMD Ryzen 9 5900X.

[1] https://developer.amd.com/wp-content/resources/Architecture_Guidelines_Update_Indirect_Branch_Control.pdf
[2] https://bugzilla.kernel.org/show_bug.cgi?id=199889

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agox86: Copy IBT and SHSTK usable only if CET is enabled
H.J. Lu [Wed, 23 Jun 2021 21:27:58 +0000 (14:27 -0700)]
x86: Copy IBT and SHSTK usable only if CET is enabled

IBT and SHSTK usable bits are copied from CPUID feature bits and later
cleared if kernel doesn't support CET.  Copy IBT and SHSTK usable only
if CET is enabled so that they aren't set on CET capable processors
with non-CET enabled glibc.

3 years agox86: Fix overflow bug in wcsnlen-sse4_1 and wcsnlen-avx2 [BZ #27974]
Noah Goldstein [Wed, 23 Jun 2021 05:56:29 +0000 (01:56 -0400)]
x86: Fix overflow bug in wcsnlen-sse4_1 and wcsnlen-avx2 [BZ #27974]

This commit fixes the bug mentioned in the previous commit.

The previous implementations of wmemchr in these files relied
on maxlen * sizeof(wchar_t) which was not guranteed by the standard.

The new overflow tests added in the previous commit now
pass (As well as all the other tests).

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agox86: Fix overflow bug with wmemchr-sse2 and wmemchr-avx2 [BZ #27974]
Noah Goldstein [Wed, 9 Jun 2021 20:25:32 +0000 (16:25 -0400)]
x86: Fix overflow bug with wmemchr-sse2 and wmemchr-avx2 [BZ #27974]

This commit fixes the bug mentioned in the previous commit.

The previous implementations of wmemchr in these files relied
on n * sizeof(wchar_t) which was not guranteed by the standard.

The new overflow tests added in the previous commit now
pass (As well as all the other tests).

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agoString: Add overflow tests for strnlen, memchr, and strncat [BZ #27974]
Noah Goldstein [Wed, 9 Jun 2021 20:17:14 +0000 (16:17 -0400)]
String: Add overflow tests for strnlen, memchr, and strncat [BZ #27974]

This commit adds tests for a bug in the wide char variant of the
functions where the implementation may assume that maxlen for wcsnlen
or n for wmemchr/strncat will not overflow when multiplied by
sizeof(wchar_t).

These tests show the following implementations failing on x86_64:

wcsnlen-sse4_1
wcsnlen-avx2

wmemchr-sse2
wmemchr-avx2

strncat would fail as well if it where on a system that prefered
either of the wcsnlen implementations that failed as it relies on
wcsnlen.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agox86-64: Add wcslen optimize for sse4.1
Noah Goldstein [Wed, 23 Jun 2021 05:19:34 +0000 (01:19 -0400)]
x86-64: Add wcslen optimize for sse4.1

No bug. This comment adds the ifunc / build infrastructure
necessary for wcslen to prefer the sse4.1 implementation
in strlen-vec.S. test-wcslen.c is passing.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agox86-64: Move strlen.S to multiarch/strlen-vec.S
H.J. Lu [Wed, 23 Jun 2021 03:42:10 +0000 (20:42 -0700)]
x86-64: Move strlen.S to multiarch/strlen-vec.S

Since strlen.S contains SSE2 version of strlen/strnlen and SSE4.1
version of wcslen/wcsnlen, move strlen.S to multiarch/strlen-vec.S
and include multiarch/strlen-vec.S from SSE2 and SSE4.1 variants.
This also removes the unused symbols, __GI___strlen_sse2 and
__GI___wcsnlen_sse4_1.

3 years agohurd: Fix build after 52a5fe70a2
Adhemerval Zanella [Wed, 23 Jun 2021 17:14:48 +0000 (14:14 -0300)]
hurd: Fix build after 52a5fe70a2

Hurd does not support 64-bit time_t internally.

3 years agonptl: Use SA_RESTART for SIGCANCEL handler
Adhemerval Zanella [Thu, 17 Jun 2021 12:45:03 +0000 (09:45 -0300)]
nptl: Use SA_RESTART for SIGCANCEL handler

The usage of signals to implementation pthread cancellation is an
implementation detail and should not be visible through cancellation
entrypoints.

However now that pthread_cancel always send the SIGCANCEL, some
entrypoint might be interruptable and return EINTR to the caller
(for instance on sem_wait).

Using SA_RESTART hides this, since the cancellation handler should
either act uppon cancellation (if asynchronous cancellation is enable)
or ignore the cancellation internal signal.

Checked on x86_64-linux-gnu and i686-linux-gnu.

3 years agodoc: _TIME_BITS defaults may change
Paul Eggert [Wed, 23 Jun 2021 15:57:35 +0000 (08:57 -0700)]
doc: _TIME_BITS defaults may change

* NEWS: Don't imply the default will always be 32-bit.
* manual/creature.texi (Feature Test Macros):
Say that _TIME_BITS and _FILE_OFFSET_BITS defaults
may change in future releases.

3 years agoMore mcheck -> malloc-check refactoring
Siddhesh Poyarekar [Tue, 22 Jun 2021 10:16:11 +0000 (15:46 +0530)]
More mcheck -> malloc-check refactoring

Refactored malloc-check rules for tests that are automatically
generated and executed with MALLOC_CHECK_=3.

3 years agoAdd NEWS item for gconv-modules.d change
Siddhesh Poyarekar [Thu, 10 Jun 2021 11:15:10 +0000 (16:45 +0530)]
Add NEWS item for gconv-modules.d change

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoHandle DT_UNKNOWN in gconv-modules.d
Siddhesh Poyarekar [Thu, 10 Jun 2021 09:26:37 +0000 (14:56 +0530)]
Handle DT_UNKNOWN in gconv-modules.d

On filesystems that do not support dt_type, a regular file shows up as
DT_UNKNOWN.  Fall back to using lstat64 to read file properties in
such cases.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoiconvconfig: Use common gconv module parsing function
Siddhesh Poyarekar [Thu, 10 Jun 2021 09:01:57 +0000 (14:31 +0530)]
iconvconfig: Use common gconv module parsing function

Drop local copy of gconv file parsing and use the one in
gconv_parseconfdir.h instead.  Now there is a single implementation of
configuration file parsing.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agogconv_conf: Split out configuration file processing
Siddhesh Poyarekar [Thu, 10 Jun 2021 08:37:27 +0000 (14:07 +0530)]
gconv_conf: Split out configuration file processing

Split configuration file processing into a separate header file and
include it.  Macroize all calls that need to go through internal
interfaces so that iconvconfig can also use them.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agogconv_conf: Remove unused variables
Siddhesh Poyarekar [Thu, 10 Jun 2021 04:21:50 +0000 (09:51 +0530)]
gconv_conf: Remove unused variables

The modules and nmodules parameters passed to add_modules, add_alias,
etc. are not used and are hence unnecessary.  Remove them so that
their signatures match the functions in iconvconfig.

Reviewed-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
3 years agoiconv: Remove alloca use in gconv-modules configuration parsing
Siddhesh Poyarekar [Wed, 9 Jun 2021 19:11:35 +0000 (00:41 +0530)]
iconv: Remove alloca use in gconv-modules configuration parsing

The alloca sizes ought to be constrained to PATH_MAX, but replace them
with dynamic allocation to be safe.  A static PATH_MAX array would
have worked too but Hurd does not have PATH_MAX and the code path is
not hot enough to micro-optimise this allocation.  Revisit if any of
those realities change.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoRemove unsused symbols from nptl/Versions
Andreas Schwab [Tue, 15 Jun 2021 21:09:25 +0000 (23:09 +0200)]
Remove unsused symbols from nptl/Versions

The (private) symbols __pthread_clock_gettime, __pthread_clock_settime and
__pthread_initialize_minimal haven't been defined by libpthread for some
time.

3 years agolinux: Only use 64-bit syscall if required for clock_nanosleep
Adhemerval Zanella [Wed, 16 Jun 2021 14:12:25 +0000 (11:12 -0300)]
linux: Only use 64-bit syscall if required for clock_nanosleep

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for internal futex
Adhemerval Zanella [Wed, 16 Jun 2021 14:04:47 +0000 (11:04 -0300)]
linux: Only use 64-bit syscall if required for internal futex

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for utimensat family
Adhemerval Zanella [Wed, 16 Jun 2021 13:43:57 +0000 (10:43 -0300)]
linux: Only use 64-bit syscall if required for utimensat family

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.

The large timeout are already tests by io/tst-utimensat-skeleton.c.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for sigtimedwait
Adhemerval Zanella [Wed, 16 Jun 2021 12:58:29 +0000 (09:58 -0300)]
linux: Only use 64-bit syscall if required for sigtimedwait

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for mq_timedsend
Adhemerval Zanella [Wed, 16 Jun 2021 12:50:53 +0000 (09:50 -0300)]
linux: Only use 64-bit syscall if required for mq_timedsend

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for mq_timedreceive
Adhemerval Zanella [Wed, 16 Jun 2021 02:05:21 +0000 (23:05 -0300)]
linux: Only use 64-bit syscall if required for mq_timedreceive

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for timerfd_settime
Adhemerval Zanella [Wed, 16 Jun 2021 01:56:12 +0000 (22:56 -0300)]
linux: Only use 64-bit syscall if required for timerfd_settime

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for semtimedop
Adhemerval Zanella [Wed, 16 Jun 2021 01:43:51 +0000 (22:43 -0300)]
linux: Only use 64-bit syscall if required for semtimedop

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: timerfd_gettime minor cleanup
Adhemerval Zanella [Wed, 16 Jun 2021 01:59:22 +0000 (22:59 -0300)]
linux: timerfd_gettime minor cleanup

The __NR_timerfd_gettime64 is always defined.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Remove time64-support
Adhemerval Zanella [Wed, 16 Jun 2021 01:17:01 +0000 (22:17 -0300)]
linux: Remove time64-support

It breaks the usage case of live migration like CRIU or similar
and most usages can be optimized away by either building glibc with
a minimum 5.1 kernel or by using the 32-bit syscall for the common
case.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Remove supports_time64 () from clock_gettime
Adhemerval Zanella [Wed, 16 Jun 2021 01:10:26 +0000 (22:10 -0300)]
linux: Remove supports_time64 () from clock_gettime

It breaks the usage case of live migration like CRIU or similar.
The performance drawback is it would require an extra syscall
on older kernels without 64-bit time support.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Remove supports_time64 () from clock_getres
Adhemerval Zanella [Wed, 16 Jun 2021 00:35:10 +0000 (21:35 -0300)]
linux: Remove supports_time64 () from clock_getres

It breaks the usage case of live migration like CRIU or similar.
The performance drawback is it would require an extra syscall
on older kernels without 64-bit time support.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for select
Adhemerval Zanella [Wed, 16 Jun 2021 00:00:50 +0000 (21:00 -0300)]
linux: Only use 64-bit syscall if required for select

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.  This also avoids the need
to use supports_time64() (which breaks the usage case of live migration
like CRIU or similar).

It also fixes an issue on 32-bit select call for !__ASSUME_PSELECT
(microblase with older kernels only) where the expected timeout
is a 'struct timeval' instead of 'struct timespec'.

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for pselect
Adhemerval Zanella [Tue, 15 Jun 2021 19:59:50 +0000 (16:59 -0300)]
linux: Only use 64-bit syscall if required for pselect

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.  This also avoids the need
to use supports_time64() (which breaks the usage case of live migration
like CRIU or similar).

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agolinux: Only use 64-bit syscall if required for ppoll
Adhemerval Zanella [Tue, 15 Jun 2021 18:41:00 +0000 (15:41 -0300)]
linux: Only use 64-bit syscall if required for ppoll

For !__ASSUME_TIME64_SYSCALLS there is no need to issue a 64-bit syscall
if the provided timeout fits in a 32-bit one.  The 64-bit usage should
be rare since the timeout is a relative one.  This also avoids the need
to use supports_time64() (which breaks the usage case of live migration
like CRIU or similar).

Checked on i686-linux-gnu on a 4.15 kernel and on a 5.11 kernel
(with and without --enable-kernel=5.1) and on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agosupport: Add support_create_timer
Adhemerval Zanella [Wed, 16 Jun 2021 16:44:03 +0000 (13:44 -0300)]
support: Add support_create_timer

It is a simple wrapper over timer_create, timer_settime, and
sigaction.  It will be used to check for large timeout to trigger an
EINTR and to avoid use a large timeout (as for alarm()).

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agoUse 64 bit time_t stat internally
Adhemerval Zanella [Tue, 2 Mar 2021 20:06:02 +0000 (17:06 -0300)]
Use 64 bit time_t stat internally

For the legacy ABI with supports 32-bit time_t it calls the 64-bit
time directly, since the LFS symbols calls the 64-bit time_t ones
internally.

Checked on i686-linux-gnu and x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agomalloc: Drop __malloc_initialized from Versions
Siddhesh Poyarekar [Tue, 22 Jun 2021 14:43:40 +0000 (20:13 +0530)]
malloc: Drop __malloc_initialized from Versions

__malloc_initialized is mentioned in Versions when it is actually an
internal symbol.  The resultant binaries are identical.

3 years agotst-mcheck: Rename to tst-malloc-check
Siddhesh Poyarekar [Tue, 22 Jun 2021 08:57:15 +0000 (14:27 +0530)]
tst-mcheck: Rename to tst-malloc-check

MALLOC_CHECK_ and mcheck() are two different malloc checking features.
tst-mcheck does not check mcheck(), instead it checks MALLOC_CHECK_,
so rename the file to avoid confusion.

3 years agoAdd hidden prototypes for fsync, fdatasync
Florian Weimer [Tue, 22 Jun 2021 07:50:27 +0000 (09:50 +0200)]
Add hidden prototypes for fsync, fdatasync

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthreadP.h into sysdeps directory
Florian Weimer [Tue, 22 Jun 2021 07:50:27 +0000 (09:50 +0200)]
nptl: Move pthreadP.h into sysdeps directory

This mirrors the situation on Hurd.  These directories are on
the include search part, so #include <pthreadP.h> works after this
change on both Hurd and nptl.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agort: Move generic implementation from sysdeps/pthread to rt
Florian Weimer [Tue, 22 Jun 2021 07:50:27 +0000 (09:50 +0200)]
rt: Move generic implementation from sysdeps/pthread to rt

The pthread-based implementation is the generic one.  Replacing
the stubs makes it clear that they do not have to be adjusted for
the libpthread move.

Result of:

    git mv -f sysdeps/pthread/aio_misc.h sysdeps/generic/
    git mv sysdeps/pthread/timer_routines.c sysdeps/htl/
    git mv -f sysdeps/pthread/{aio,lio,timer}_*.c rt/

Followed by manual adjustment of the #include paths in
sysdeps/unix/sysv/linux/wordsize-64, and a move of the version
definitions formerly in sysdeps/pthread/Versions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agort: Move shm_unlink into libc
Florian Weimer [Mon, 21 Jun 2021 06:25:15 +0000 (08:25 +0200)]
rt: Move shm_unlink into libc

This function has no dependency on libpthread, so the move is also
applied to Hurd.

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agort: Move shm_open into libc
Florian Weimer [Mon, 21 Jun 2021 06:25:15 +0000 (08:25 +0200)]
rt: Move shm_open into libc

This function has no dependency on libpthread, so the move is also
applied to Hurd.

To avoid localplt failures, use __open64_nocancel instead of
pthread_setcancelstate and open.

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agort: Replace generic stub of shm_unlink with the posix version
Florian Weimer [Mon, 21 Jun 2021 06:25:15 +0000 (08:25 +0200)]
rt: Replace generic stub of shm_unlink with the posix version

Result of: git mv -f sysdeps/posix/shm_unlink.c rt
and manual removal of the _POSIX_MAPPED_FILES preprocessor condition.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agort: Replace generic stub of shm_open with the posix version
Florian Weimer [Mon, 21 Jun 2021 06:25:15 +0000 (08:25 +0200)]
rt: Replace generic stub of shm_open with the posix version

Result of: git mv -f sysdeps/posix/shm_open.c rt
and manual removal of the _POSIX_MAPPED_FILES preprocessor condition.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoFix librt-routines-var issues for !PTHREAD_IN_LIBC
Florian Weimer [Mon, 21 Jun 2021 06:25:15 +0000 (08:25 +0200)]
Fix librt-routines-var issues for !PTHREAD_IN_LIBC

The variable name was incorrect, and the existing librt-routines
variable needs to be augmented (not assigned) in rt/Makefile.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agort: Lexicographically sort Versions file; librt-routines in Makefile
Florian Weimer [Mon, 21 Jun 2021 06:25:15 +0000 (08:25 +0200)]
rt: Lexicographically sort Versions file; librt-routines in Makefile

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Use _dl_catch_error from base namespace in dl-libc.c [BZ #27646]
Florian Weimer [Thu, 17 Jun 2021 13:06:43 +0000 (15:06 +0200)]
elf: Use _dl_catch_error from base namespace in dl-libc.c [BZ #27646]

dlerrror_run in elf/dl-libc.c needs to call GLRO (dl_catch_error)
from the base namespace, just like the exported dlerror
implementation.

Fixes commit b2964eb1d9a6b8ab1250e8a881cf406182da5875 ("dlfcn:
Failures after dlmopen should not terminate process [BZ #24772]").

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoMakeconfig: Fix time64-compat.mk target
Siddhesh Poyarekar [Thu, 17 Jun 2021 08:52:21 +0000 (14:22 +0530)]
Makeconfig: Fix time64-compat.mk target

The time64-compat.i needed for the time64-compat.mk Makeconfig include
ends up trying to include libc-modules.h, which is not generated until
later.  This results in an error during build which is not noticed
because it somehow does not terminate the build.

Exclude the modules cppflags from the pre-processing command and fix
up the time64-compat.mk target so that the build runs without issues.

Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
3 years agonptl: Export _pthread_cleanup_push, _pthread_cleanup_pop again
Florian Weimer [Tue, 15 Jun 2021 15:00:29 +0000 (17:00 +0200)]
nptl: Export _pthread_cleanup_push, _pthread_cleanup_pop again

These were turned into compat symbols as part of the libpthread
move.  It turns out they are used by language run-time libraries
(e.g., the GCC D front end), so it makes to preserve them as
external symbols even though they are not declared in any header
file.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>