Commit Graph

21005 Commits

Author SHA1 Message Date
Mike Frysinger 4391d2aed3 libgloss: merge csky into top-level Makefile
Avoid a recursive make to speed things up a bit.
A csky-elf build shows installed objects & libs produce same code.
2023-01-13 17:24:17 -05:00
Corinna Vinschen c8ddd03cb0 Cygwin: add very simple newgrp(1) tool
This tool allows to change the primary group for a child process.
The new primary group MUST be part of the supplementary group list
of newgrp's user token.

The command started as child process is specified on the command line.
If it's missing, start the user's default shell with the new primary
group.

TODO: Implement '-' option.
      Add command description to documentation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-13 20:59:29 +01:00
Jon Turney 6072dcfc34
Cygwin: CI: Run cygserver for tests
Note that cygserver must be run using the same cygwin1.DLL as test
programs, as they communicate over a named pipe whose name contains the
'installation key' (which is a hash of the cygwin1.dll's path).

We run cygserver via 'cmd' to avoid the special code which handles a
cygwin parent process starting a cygwin child process, which assumes the
same version of cygwin in both.
2023-01-13 17:03:59 +00:00
Jon Turney 0965454822
Cygwin: testsuite: Drop appending 'ntsec' to CYGWIN in cygrun wrapper
Don't append 'ntsec' to the CYGWIN env var in the cygrun wrapper. It
doesn't have any effect anymore.
2023-01-13 17:03:58 +00:00
Jon Turney 663922f618
Cygwin: testsuite: Update pthread tests for default SCHED_FIFO
Update for default (and only) thread scheduler policy is SCHED_FIFO.
2023-01-13 17:03:57 +00:00
Jon Turney 736618054c
Cygwin: testsuite: Update mutex tests for changed default mutex type
Default mutex type is PTHREAD_MUTEX_NORMAL.

Attempting to unlock an unowned mutex of that type is specified as
undefined behaviour, not returning EPERM.

mutex7e verfies that attempting to unlock an unowned mutex of type
PTHREAD_MUTEX_ERRORCHECK returns EPERM.
2023-01-13 17:03:56 +00:00
Jon Turney 52983af631
Cygwin: testsuite: 64-bit fixes in pthread testcases
Fix warnings and 64-bit issues in pthread testcases.

See pthread-win32 commit 1183e5ac etc.
2023-01-13 17:03:55 +00:00
Jon Turney 01a0e3e491
Cygwin: testsuite: Fix compilation warnings
Fix the warnings the previous change surfaces.

See ltp commit d5c2112f for mmap fixes.
2023-01-13 17:03:54 +00:00
Jon Turney daeeaa97b3
Cygwin: testsuite: Build testcases using automake
Build all the testcase executables directly using automake, rather than
passing the compiler information into DejaGnu to have it build them.

(This means you get build avoidance for these executables, so they only
get built once, rather than every time you run the test, and makes it
much easier to run them in isolatation against the installed Cygwin,
which is really nice to have when trying to fix broken tests...)

Rename the 'cygrun' subdirectory to 'mingw', and build all the testsuite
MinGW executables there.

Drop sample-miscompile.c (testing that compile failure is detected is
perhaps useful, but not here...)
2023-01-13 17:03:52 +00:00
Jon Turney 50a741e2f1
Cygwin: testsuite: automake doesn't define objdir
objdir isn't a predefined output variable in Automake (any more?), so
this was just using the absolute path /testsuite as the test's temporary
directory.  Use builddir instead.
2023-01-13 17:03:50 +00:00
Xianmiao Qu 7f4c04755e libgloss: csky: use atexit to call fini-array functions.
__libc_fini_array should be called upon exit to call the
global termination functions in fini-array, use atexit to
register it at __start.
2023-01-13 14:08:23 +01:00
Mike Frysinger 3ef006f056 libgloss: merge nios2 into top-level Makefile
Avoid a recursive make to speed things up a bit.
A nios2-elf build shows installed objects & libs produce same code.
2023-01-12 05:26:57 -05:00
Corinna Vinschen e5880bef39 Cygwin: wincap.h: clarify NO_COPY_RO usage
...and drop one unnecessary usage of NO_COPY_RO.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-12 10:51:39 +01:00
Corinna Vinschen e7d0f0eb41 Cygwin: wincap: make capability flags readonly
So far the capability bits were stored in the .cygwin_dll_common
R/W section because we overwrite the is_server bit.  Just don't.
Move the bit to class wincapc instead and define all wincaps
bitfields const.

Fixes: 8937c103ed ("* wincap.cc (all wincaps): Store in .cygwin_dll_common section same as wincap.  Add comment to explain why.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-12 10:34:32 +01:00
Mike Frysinger 0e1c0a02cf libgloss: merge d30v into top-level Makefile
Avoid a recursive make to speed things up a bit.
2023-01-11 08:42:19 -05:00
Mike Frysinger 5401db924f libgloss: merge arc into top-level Makefile
Avoid a recursive make to speed things up a bit.
2023-01-11 08:42:16 -05:00
Mike Frysinger 275b39e219 libgloss: merge arm into top-level Makefile
Avoid a recursive make to speed things up a bit.
2023-01-11 01:00:21 -05:00
Mike Frysinger 26f9cfd7a8 libgloss: arm: break newlib dependency
The libgloss port has been reaching back into newlib internals for a
single header whose contents have been frozen for almost a decade.
To break this backwards libgloss->newlib dependency, move the acle
header to the srcroot include/ so everyone can use the same copy.
2023-01-11 01:00:15 -05:00
Victor L. Do Nascimento 31e5ce10db newlib: libc: setjmp M-profile PACBTI-enablement
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.  Save the PAC value in the jump buffer so that
longjmp can only return to the authenticated location.
2023-01-10 16:47:02 +00:00
Victor L. Do Nascimento adc36ede11 newlib: libc: aeabi_memset M-profile PACBTI-enablement
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.
2023-01-10 14:16:05 +00:00
Victor L. Do Nascimento bddfd64ec2 newlib: libc: aeabi_memmove M-profile PACBTI-enablement
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.
2023-01-10 14:16:05 +00:00
Victor L. Do Nascimento 60a50c2846 newlib: libc: memcpy M-profile PACBTI-enablement
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.
2023-01-10 14:16:05 +00:00
Victor L. Do Nascimento db30cbee41 newlib: libc: memchr M-profile PACBTI-enablement
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.
2023-01-10 14:16:05 +00:00
Victor L. Do Nascimento 5582536896 newlib: libc: strlen M-profile PACBTI-enablement
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.

This patch enables PACBTI for all relevant variants of strlen:
     * Newlib for armv8.1-m.main+pacbti
     * Newlib for armv8.1-m.main+pacbti+mve
     * Newlib-nano
2023-01-10 14:16:05 +00:00
Victor L. Do Nascimento ebd922e77a newlib: libc: strcmp M-profile PACBTI-enablement
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.

This patch enables PACBTI for all relevant variants of strcmp:
     * Newlib for armv8.1-m.main+pacbti
     * Newlib for armv8.1-m.main+pacbti+mve
     * Newlib-nano
2023-01-10 14:16:05 +00:00
Victor L. Do Nascimento 9d6b00511e newlib: libc: define M-profile PACBTI-enablement macros
Augment the arm_asm.h header file to simplify function prologues and
epilogues whilst adding support for PACBTI enablement via macros for
hand-written assembly functions.  For PACBTI, both prologues/epilogues
as well as cfi-related directives are automatically amended
accordingly, depending on the compile-time mbranch-protection argument
values.

It defines the following preprocessor macros:
   * HAVE_PAC_LEAF: Indicates whether pac-signing has been requested for
   leaf functions.
   * PAC_LEAF_PUSH_IP: Whether leaf functions should push the pac code
   to the stack irrespective of whether the ip register is clobbered in
   the function or not.
   * STACK_ALIGN_ENFORCE: Whether a dummy register should be added to
   the push list as necessary in the prologue to ensure stack
   alignment preservation at the start of assembly function.  The
   epilogue behavior is likewise affected by this flag, ensuring any
   pushed dummy registers also get popped on function return.

It also defines the following assembler macros:
   * prologue: In addition to pushing any callee-saved registers onto
   the stack, it generates any requested pacbti instructions.
   Pushed registers are specified via the optional `first', `last',
   `push_ip' and `push_lr' macro argument parameters.
   when a single register number is provided, it pushes that
   register.  When two register numbers are provided, they specify a
   rage to save.  If push_ip and/or push_lr are non-zero, the
   respective registers are also saved.  Stack alignment is requested
   via the `align` argument, which defaults to the value of
   STACK_ALIGN_ENFORCE, unless manually overridden.

   For example:

       prologue push_ip=1 -> push {ip}
       prologue push_ip=1, align8=1 -> push {r2, ip}
       prologue push_ip=1, push_lr=1 -> push {ip, lr}
       prologue 1 -> push {r1}
       prologue 1, align8=1 -> push {r0, r1}
       prologue 1 push_ip=1 -> push {r1, ip}
       prologue 1 4 -> push {r1-r4}
       prologue 1 4 push_ip=1 -> push {r1-r4, ip}

   * epilogue: pops registers off the stack and emits pac key signing
   instruction, if requested. The `first', `last', `push_ip',
   `push_lr' and `align' function as per the prologue macro,
   generating pop instead of push instructions.

   Stack alignment is enforced via the following helper macro
   call-chain:

	{prologue|epilogue} ->_align8 -> _preprocess_reglist ->
	  _preprocess_reglist1 -> {_prologue|_epilogue}

   Finally, the necessary cfi directives for adding debug information
   to prologue and epilogue are generated via the following macros:

   * cfisavelist - prologue macro helper function, generating
   necessary .cfi_offset directives associated with push instruction.
   Therefore, the net effect of calling `prologue 1 2 push_ip=1' is
   to generate the following:

       push {r1-r2, ip}
       .cfi_adjust_cfa_offset 12
       .cfi_offset 143, -4
       .cfi_offset 2, -8
       .cfi_offset 1, -12

   * cfirestorelist - epilogue macro helper function, emitting
   .cfi_restore instructions prior to resetting the cfa offset.  As
   such, calling `epilogue 1 2 push_ip=1' will produce:

        pop {r1-r2, ip}
	.cfi_register 143, 12
	.cfi_restore 2
	.cfi_restore 1
	.cfi_def_cfa_offset 0
2023-01-10 14:16:05 +00:00
Takashi Yano 3b7df69aaa Cygwin: ctty: Add comments for the special values: -1 and -2.
_pinfo::ctty has two special values other than the device id of
the allocated ctty:
-1: CTTY is not initialized yet. Can be associated with the TTY
    which is associated with the session leader.
-2: CTTY has been released by setsid(). Can be associate only with
    new TTY which is not associated with any other session as CTTY,
    but cannot be associate with the TTYs already associated with
    other sessions.
This patch adds the comments in some source files.

Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signedoff-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-10 22:04:40 +09:00
Takashi Yano 8e77725f31 Cygwin: pinfo: Additional fix for CTTY behavior.
The commit 25c4ad6ea5 did not fix the CTTY behavior enough. For
example, in the following test case, TTY will be associated as
a CTTY on the second open() call even though the TTY is already
CTTY of another session. This patch fixes the issue.

  #include <unistd.h>
  #include <sys/fcntl.h>

  int main()
  {
    if (fork () == 0) {
      char *tty = ttyname(0);
      int fd;
      setsid();
      fd = open(tty, O_RDWR);
      close(fd);
      fd = open(tty, O_RDWR);
      usleep (60000000L);
    }
    return 0;
  }

Fixes: 25c4ad6ea5 ("Cygwin: pinfo: Align CTTY behavior to the
statement of POSIX.")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-10 21:35:35 +09:00
Takashi Yano a81fef51cf Cygwin: cygheap: Initialize myself_pinfo before child_copy().
After the commit 30add3e6b3, the problem:
https://cygwin.com/pipermail/cygwin/2022-December/252759.html
occurs rarely. It seems that myself_pinfo should be initialized
where the timing before child_copy() and after cygheap allocation.
This patch moves the initialization there.

Fixes: 30add3e6b3 ("Cygwin: exec: don't access cygheap before it's
initialized")
Reported-by: Brian Inglis <Brian.Inglis@Shaw.ca>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-10 21:04:29 +09:00
Corinna Vinschen 7c14e5a10a Cygwin: /proc/<PID>/status: avoid crash computing signal info
The code computing the mask of pending signals used the per-queued
signal TLS pointer without checking it for NULL.  Fix this by using
the process-wide signal mask in that case.

Fixes: 195169186b ("Cygwin: wait_sig: allow to compute process-wide mask of pending signals")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-10 11:48:02 +01:00
Jon Turney 1a9f95d894
Cygwin: Run testsuite against the just-built DLL
Since 4e7817498e, we're just running the tests against the installed
DLL.  We're arranging to put the build directory on the path, but since
it doesn't contain cygwin1.dll (since it's built with a different name
and renamed on installation), that doesn't have any effect.

Arrange to place the just-built DLL into a directory which the testsuite
can place on it's path (while running the test, but not while compiling
it).

Also fix any remaining references to cygwin0.dll in testsuite,
documentation and comments.

Fixes: 4e7817498e ("Cygwin: Makefile: Drop all the "test dll" considerations")
2023-01-10 10:27:13 +00:00
Mike Frysinger 13a7b16ea3 libgloss: merge aarch64 into top-level Makefile
Avoid a recursive make to speed things up a bit.
2023-01-09 21:49:50 -05:00
Corinna Vinschen 9ee1e1b693 Cygwin: /proc/<PID>/status: simplify code generating signal info
The code generating the signal info in _pinfo::siginfo() and in
commune_process() are doing the same thing.  Create a local static
function commune_process_siginfo() to have the code in one place
only.  Remove a useless sigpending() call.

Fixes: 9a3c058f66 ("Cygwin: /proc/<PID>/status: Fill SigPnd, SigBlk and SigIgn values with life")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-09 18:02:14 +01:00
Corinna Vinschen 7886327fbf Cygwin: reinstantiate exporting _alloca
This basically reverts commit 1556b96b1b.

Turns out that _alloca is actually used, for instance, by clang.
2023-01-09 13:42:53 +01:00
CompilerAI Research Group ad3f9820b1 Fix memccpy to handle end char >= x80
- use unsigned char variables for optimized version of memccpy
2023-01-03 14:52:47 -05:00
Jon Turney b5d4245d5f
Cygwin: CI: Fix thinko of 'ncores' for 'nproc' 2022-12-23 14:02:06 +00:00
Brian Inglis 8a003605c1 fhandler/proc.cc(format_proc_cpuinfo): add Linux 6.1 cpuinfo
Intel 0x00000007:1 EAX:26 lam	Linear Address Masking (& recent entries)
2022-12-23 10:03:23 +01:00
Takashi Yano d0bad6996d Cygwin: Add release message for latest console change.
3721a756b0 ("Cygwin: console: Make the console accessible from other
terminals.")

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 23:20:52 +09:00
Takashi Yano 3721a756b0 Cygwin: console: Make the console accessible from other terminals.
Previously, the console device could not be accessed from other terminals.
Due to this limitation, GNU screen and tmux cannot be opened in console.
With this patch, console device can be accessed from other TTYs, such as
other consoles or ptys. Thanks to this patch, screen and tmux get working
in console.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 21:05:31 +09:00
Takashi Yano 043b6089e2 Cygwin: devices: Make generic console devices invisible from pty.
The devices /dev/conin,conout,console were wrongly visible from ptys,
though they are inaccessible. This is because fhandler_console::exists()
returns true due to existing invisible console. This patch makes these
devices invisible from ptys.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 20:57:29 +09:00
Takashi Yano 25c4ad6ea5 Cygwin: pinfo: Align CTTY behavior to the statement of POSIX.
POSIX states "A terminal may be the controlling terminal for at most
one session."
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap11.html

However, in cygwin, multiple sessions could be associated with the
same TTY. This patch aligns CTTY behavior to the statement of POSIX.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 20:57:17 +09:00
Thomas Schwinge 5841b2f6a4 nvptx: Implement '_exit' instead of 'exit'
... so that all of 'exit', '_exit', '_Exit' work.  'exit' thus becomes the
standard 'newlib/libc/stdlib/exit.c' -- and functions registered via 'atexit'
are now called at return from 'main' or manual 'exit' invocation.
2022-12-22 12:52:15 +01:00
Takashi Yano f6e4e98d30 Cygwin: console: Fix hangup of less on quit after the window is resized.
https://cygwin.com/pipermail/cygwin/2022-December/252737.html

If the less is started from non-cygwin shell and window size is
changed, it will hang-up when quitting. The cause of the proglem is
that less uses longjump() in signal handler. If the signal handler
is called while cygwin is acquiring the mutex, cygwin loses the
chance to release mutex. With this patch, the mutex is released
just before calling kill_pgrp() and re-acquired when kill_pgrp()
returns.

Reported-by: Gregory Mason <grmason@epic.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 20:38:08 +09:00
Mike Frysinger 0a7bf8fc4c remove +x bit on source files
These should never be marked executable as they have no shebang and
are pure source files.
2022-12-21 22:38:57 -05:00
Jon Turney 4e7817498e
Cygwin: Makefile: Drop all the "test dll" considerations
After 90236c3a2c, the testsuite is failing, as the cygwin0.dll
referenced by the implib that testsuite programs are linked with doesn't
exist anymore.

We don't need to make and link the testsuite with a specially named DLL,
as the cygwin DLL (since 526b0fbca3) takes into consideration the path
it's executing from to define separate "Cygwin installations", which
don't interact.

Fixes: 90236c3a2c ("Cygwin: Makefile: build new-cygwin1.dll in a single step")
2022-12-21 17:43:11 +00:00
Corinna Vinschen 09cb4cd294 Cygwin: path_conv: make sure sym.path_flags is always initialized
Commit c1023ee353 introduced a split between mount flags and
path flags.  It didn't initialize symlink_info::path_flags in
path_conv::check, because that's done in symlink_info::check.

However, there are two code paths expecting symlink_info::path_flags
being already initialized and both skip symlink_info::check.

Make sure symlink_info::path_flags is initalized to 0 early in
path_conv::check.

Fixes: c1023ee353 ("Cygwin: path_conv: decouple path_types from mount types")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-21 13:13:24 +01:00
Jon Turney 1b5fc91a1d
Cygwin: configure: Add option to disable building 'dumper'
Rather than guessing, based on just the presence of libbfd, add an
explicit configuration option, to build dumper or not, defaulting to
building it.

This might have some use when bootstrapping Cygwin for a new
architecture, or when building your own Cygwin-targetted cross-compiler,
rather than installing one from the copr, along with the dependencies of
libbfd.
2022-12-21 11:39:28 +00:00
Jon Turney 87968453dd
Cygwin: FAQ: Mention configure options to build with reduced dependencies 2022-12-21 11:39:26 +00:00
Corinna Vinschen 2af7dd9567 Cygwin: x86_64: import swab.S from NetBSD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:19:23 +01:00
Corinna Vinschen 43743ed754 Cygwin: x86_64: import latest NetBSD bcopy.S
Tweak slightly to allow implementing entire {w}mem{p}{cpy,move}
family:

Add WIDE macro processing for wmem* and POST macro processing for
memp* functions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00