newlib's vfwscanf(3) (or specifically, __SVFWSCANF_R()) fails to correctly set
the assignment-suppressing character (`*') flag[1] which, when present in the
formatting string, results in undefined behaviour comprising retrieving and
dereferencing a pointer that was not supplied by the caller as such or at all.
When compared to the vfscanf(3) implementation, this would appear to be over
the missing goto match_failure statement preceded by the flags test seen below.
Hence, this patch (re)introduces it.
[1] <http://pubs.opengroup.org/onlinepubs/009695399/functions/fwscanf.html>
--
-Add vendor identification
-Support in get_cpu_cache
Background:
Chengdu Haiguang IC Design Co., Ltd (Hygon) is a Joint Venture
between AMD and Haiguang Information Technology Co.,Ltd., aims at
providing high performance x86 processor for China server market.
Its first generation processor codename is Dhyana, which
originates from AMD technology and shares most of the
architecture with AMD's family 17h, but with different CPU Vendor
ID("HygonGenuine")/Family series number(Family 18h).
Related Hygon kernel patch can be found on:
http://lkml.kernel.org/r/5ce86123a7b9dad925ac583d88d2f921040e859b.1538583282.git.puwen@hygon.cn
Signed-off-by: Jinke Fan <fanjinke@hygon.cn>
A commit from 2016 tried to address this GCC provided <stddef.h> issue
#if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
|| defined(__DragonFly__) \
|| defined(__FreeBSD_kernel__)
/* __size_t is a typedef on FreeBSD 5, must not trash it. */
#elif defined (__VMS__)
/* __size_t is also a typedef on VMS. */
#else
#define __size_t
#endif
with an include of <stddef.h> before <sys/_types.h> in <sys/types.h>.
Is is not robust enough. Do the include of <stddef.h> in <sys/_types.h>
directly and request only the necessary types.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
RTEMS uses a considerable part of FreeBSD kernel and user space sources.
These sources are compiled with a __FreeBSD__ define. On 2018-06-26
Gerald Pfeifer changed the GCC provided <stddef.h> so that it includes
<sys/_types.h> if __FreeBSD__ is defined. The Newlib <sys/_types.h>
included <sys/lock.h> which includes <sys/cdefs.h> on RTEMS which
includes <stddef.h>. To get rid of this cyclic dependency move the
optional _flock_t definition to <sys/reent.h>.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
This patch adds _LITE_EXIT in crt0.S to enable "lite exit" technique in
RISC-V. The changes have been tested in riscv/riscv-gnu-toolchain by
riscv-dejagnu with riscv-sim.exp/riscv-sim-nano.exp.
This patch adds implementations of memcpy, memmove, memset and strcmp
optimized for size. The changes have been tested in
riscv/riscv-gnu-toolchain by riscv-dejagnu with
riscv-sim.exp/riscv-sim-nano.exp.
The _fdata symbol in MIPS linker scripts is aligned to a 16-byte
boundary. The ALIGN function does not implicitly update current
location counter. If sections positioned after the assignment
do not have the same natural alignment as the ALIGN function then
the start of the section group will not coincide with the value
of the symbol.
Given the linker command sequence:
symbol = ALIGN (NN);
(.section*)
where the idiom implies a desire to mark the beginning of .section
with symbol, there must be an assignment to the location counter
between the assignment to symbol and the .section pattern.
libgloss/
* mips/array.ld: Update the location counter to match _fdata.
* mips/cfe.ld: Likewise.
* mips/ddb-kseg0.ld: Likewise.
* mips/ddb.ld: Likewise.
* mips/dve.ld: Likewise.
* mips/idt.ld: Likewise.
* mips/idt32.ld: Likewise.
* mips/idt64.ld: Likewise.
* mips/idtecoff.ld: Likewise.
* mips/jmr3904app-java.ld: Likewise.
* mips/jmr3904app.ld: Likewise.
* mips/jmr3904dram-java.ld: Likewise.
* mips/jmr3904dram.ld: Likewise.
* mips/lsi.ld: Likewise.
* mips/mti32.ld: Likewise.
* mips/mti64.ld: Likewise.
* mips/mti64_64.ld: Likewise.
* mips/mti64_n32.ld: Likewise.
* mips/nullmon.ld: Likewise.
* mips/pmon.ld: Likewise.
* mips/sde32.ld: Likewise.
* mips/sde64.ld: Likewise.
There's no longer a need to consider the connect_evt after fork/exec.
After stopping the listen_client thread, all client handlers should be
in the fc_connected or fc_invalid states, so their connect_evt members
won't be used again.
Also remove code in fhandler_fifo::dup that just repeats things
already done in stop_listen_client.
Add a method fhandler_fifo::check_listen_client_thread that checks
whether the thread is running. Use it in raw_read instead of just
testing the handle listen_client_thr.
On exit from the listen_client thread, make sure there's no pending
FSCTL_PIPE_LISTEN request. Otherwise we might get a client connection
after restarting the thread, and we won't have a handle for
communicating with that client.
Remove the retry loop in the case of STATUS_PIPE_LISTENING; that case
shouldn't occur.
Remove the now-unused fc_connecting value from
fifo_client_connect_state.
It's now up to the caller to pass a handle to open_pipe and, if
desired, to call set_handle on return.
This will be useful for a future commit, in which we will open a
client connection without setting an io_handle.
When opening a duplexer, open a client connection to the first client
handler. Previously we gave the duplexer a bogus write handle, which
was just a duplicate of the first client handler's handle. This meant
that we had a pipe server with no clients connected, and all I/O
attempts failed with STATUS_PIPE_LISTENING.
Extend the last fcntl change to duplexers.
Remove a now unused fifo_client_handler constructor, as well as the
long unusued method fifo_client_handler::connect.
Don't create the pipe in duplex mode; the server handle will only be
used for reading.
NtQueryVirtualMemory for MemorySectionName does not reliable return the
changed dll file name when another process does move the file around,
and we may end up creating forkable hardlinks to wrong dll files.
So query the file id when loading the dll rather than before fork.
Make stat_real_file_once a method of struct dll, to be more flexible on
where to use. Also, debug print memory section name queried for a dll.
This is a preparation to query the file id when loading the dll.
The compiler driver positions the linker script at the end of the linker
command-line, after crtend.o. As a result, any INPUT objects and archive
GROUPs introduced by the linker script are placed after crtend.o and the
end-of-frame marker provided by crtend.o ends up in between .eh_frames
instead of being at the end.
This has always been a problem, but a binutils update to clean-up
redundant NULL markers in .eh_frame exposes it as a execution failure in
exception-handling tests. This patch re-orders .eh_frames in all
MIPS linker scripts so that the one from crtend.o is always placed last.
libgloss/
* mips/array.ld: Re-order to place .eh_frame from crtend.o
after all other .eh_frame sections.
* mips/cfe.ld: Likewise.
* mips/ddb-kseg0.ld: Likewise.
* mips/ddb.ld: Likewise.
* mips/dve.ld: Likewise.
* mips/idt.ld: Likewise.
* mips/idt32.ld: Likewise.
* mips/idt64.ld: Likewise.
* mips/jmr3904app.ld: Likewise.
* mips/lsi.ld: Likewise.
* mips/mti32.ld: Likewise.
* mips/mti64.ld: Likewise.
* mips/mti64_64.ld: Likewise.
* mips/mti64_n32.ld: Likewise.
* mips/nullmon.ld: Likewise.
* mips/pmon.ld: Likewise.
* mips/sde32.ld: Likewise.
* mips/sde64.ld: Likewise.
The blocking mode of the Windows pipe underlying a writer is set to
match that of the writer itself when the latter is opened. Define
fhandler_fifo::fcntl to keep the pipe and the writer in sync if the
blocking mode is changed via fcntl.
* Change default fallback for failed winsock error -> POSIX error
mappings to EACCES, which is a valid errno for more socket-related
syscalls.
* Added a few previously missing entries to the wsock_errmap table
that have obvious POSIX errno.h analogues.
Add methods need_fixup_before, init_fixup_before, and
fixup_before_fork_exec to accomplish this. Stopping the thread makes
sure that the client handler lists of the parent and child remain in
sync while the forking/execing is in progress.
Don't use the same i/o handle for the first client handler as is used
for the fhandler itself; this can lead to a later attempt to close the
same handle twice. Instead use a duplicate.
* Pre-release version still reporting kernel version 6.4.
* Windows 10 1511 is out of support since 2017-10-10.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Define fhandler:fifo::fixup_after_exec, which sets listen_client_thr
and lct_termination_evt to NULL. This forces the listen_client thread
to restart on the first attempt to read after an exec. Previously the
exec'd process could hang in fhandler_fifo::raw_read.
Many of the MSP430 crt functions (e.g. to initialize bss) are linked
"dynamically", based on symbols defined in the program.
The GNU assembler defines the symbols corresponding to the crt
functions by examining the section names in the input file.
If GCC has been configured with --enable-initfini-array, then
.init_array and .fini_array will hold pointers to global
constructors/destructors. These sections can also hold functions that
need to be executed for other purposes.
The attached patch puts the __crt0_run_{preinit,init,fini}_array and
__crt0_run_array functions in their own object files, so they will
only be linked when needed.
Successfully regtested the DejaGNU GCC testsuite using the binutils and
newlib changes together with GCC trunk configured with
--enable-initfini-array.
Remove fifo_client_handler::connect and move its code into
listen_client_thread. That way we can check the return status when a
client handler's connect_evt is signaled. Previously we incorrectly
assumed there was a successful connection.
Also simplify listen_client_thread in the following ways:
- Replace fhandler_fifo::disconnect_and_reconnect by a new
delete_client_handler method. Now we just delete invalid client
handlers rather than trying to re-use them.
- Try to maintain a client handler list that consists of connected
client handlers and exactly one that is listening for a connection.
This allows us to call WaitForMultipleObjects with only two wait
objects.
- Remove 'dummy_evt' from the fifo_client_handler struct; it is no
longer needed.
- On exit from listen_client_thread, delete the "extra" (listening)
client handler. Otherwise there could be a connection that doesn't
get recorded in the client handler list. This could happen when a
file descriptor is being duplicated.
Don't set the write end of the pipe to non-blocking mode if the FIFO
is opened in blocking mode.
In fhandler_fifo::raw_write in blocking mode, wait for the write to
complete rather than returning -1 with EAGAIN.
If the amount to write is large, write in smaller chunks (of size
determined by a new data member max_atomic_write), as in
fhandler_base_overlapped.
For convenience, add two new NTSTATUS codes, STATUS_THREAD_SIGNALED
and STATUS_THREAD_CANCELED, to ntdll.h.
After copyto is called, make the new fhandler's pipe_name point to the
new fhandler's pipe_name_buf, which is a *copy* of the old fhandler's
pipe_name_buf. Previously, get_pipe_name would return the wrong
result after a clone/dup, causing create_pipe_instance and open_pipe
to fail.
Also, stop the listen_client thread when cloning. Otherwise the
thread can keep accepting connections that the cloned fhandler won't
know about.
Do this via a new method fhandler_fifo::stop_listen_client, extracted
from fhandler_fifo::close.
Make read_ready a manual reset event. It should always be set shortly
after startup of the listen_client thread and remain set until the
thread terminates. (We don't want writers to connect without being
recorded in the client handler list.)
Remove the unnecessary code that checks for read_ready when a reader
is opening.