The file configure.in was renamed to configure.ac in libgloss/riscv but
the hard coded name in the Makefile for that directory was not updated.
This patch simply renamed this to configure.ac.
These subdirs were missing aclocal.m4 files pulling in macros from
../acinclude.m4 which caused some macros to not be expanded. For
example, autoconf complains:
configure.ac:25: error: possibly undefined macro: LIB_AC_PROG_CC
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
These were generated with aclocal-1.9 as that seems to be what was
used in these dirs previously, and with whatever version of autoconf
the specific subdir was using. This should minimize diffs.
Autoconf emits a warning for this:
configure.ac:75: warning: AC_CACHE_VAL(libc_symbol_prefix, ...): suspicious cache-id, must contain _cv_ to be cached
Rename the variable to match the naming in libnosys/ subdir.
When running autoconf-2.69 in here, we get:
configure.ac:57: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2503: _AC_PREPROC_IFELSE is expanded from...
../../lib/autoconf/general.m4:2518: AC_PREPROC_IFELSE is expanded from...
configure.ac:57: the top level
configure.ac:61: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2503: _AC_PREPROC_IFELSE is expanded from...
../../lib/autoconf/general.m4:2518: AC_PREPROC_IFELSE is expanded from...
configure.ac:61: the top level
Add AC_LANG_PROGRAM wrappings to fix these.
The current implementation does not reliably initialize t0 once.
Additionally the initialization requires two calls to _gettimeofday().
Let's sacrifice a byte to keep the initialization status
and reduce the maximum number of calls to _gettimeofday().
This has caused issues in an application that invokes clock().
The problematic situation is as follows:
1) The program calls clock() which calls _times().
2) _gettimeofday(&t0, 0) puts 0 in t0.tv_usec (because less than 1 us has
elapsed since the beginning of time).
3) _gettimeofday(&t, 0) puts 1 in t.tv_usec (since now more than 1 us has
elapsed since the beginning of time).
4) That call to clock() returns 1 (the value from step 3 minus the value in
step 2).
5) The program does a second call to clock().
6) The code above still sees 0 in t0 so it tries to update t0 again and
_gettimeofday(&t0, 0) puts 1 in t0.tv_usec.
7) The _gettimeofday(&t, 0) puts 1 in t.tv_usec (since less than 1us has
elapsed since step 3).
8) clock() returns 0 (step 7 minus step 6) and indicates that time is
moving backwards.
Signed-off-by: Christoph Muellner <cmuellner@gcc.gnu.org>
visium and iq2000 have libgloss configure bits that reference
target_makefile_frag, but it's never set. This leads to failures during the
configure process and an empty libgloss/<target>/Makefile. Naturally bad
things happen with an empty Makefile.
This patch initializes target_makefile_frag for both targets in their
configure.in files and updates the generated configure files. This fixes the
build failures. I've been using it in my tester for about a week and both
targets have flipped from consistently failing to consistently passing.
* libgloss/visium/configure.in (target_makefile_frag): Define.
* libgloss/visium/configure: Regenerated.
* libgloss/iq2000/configure.in (target_makefile_frag): Define.
* libgloss/iq2000/configure: Regenerated.
Binutils LD default linker script was recently fixed to allow memory
sizes to be set via command line. Use this feature to remove the special
sim linker script in libgloss.
It is acceptable to require newer Binutils version here because simulator
target is only used for regression testing the toolchain. Real HW
targets are not affected.
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
- RISC-V 32 bits linux/glibc didn't provide gettimeofday anymore
after upstream, because RV32 didn't have backward compatible issue,
so RV32 only support 64 bits time related system call.
- So using clock_gettime64 call instead for rv32 libgloss.
This patch adds support for Armv8-R AArch64.
Armv8-R AArch64 has no EL3, so we don't set vbar_el3, and adjust the
code to set up the MPU for Armv8-R. So build a different flavour of the
startup code to support that.
We also add a specs file that uses this alternative startup code which
can be used with Armv8-R AArch64 models.
The MSP430 target supports both 16-bit and 20-bit size_t and intptr_t.
Some implicit casts in Newlib expect these types to be
"long", (a 32-bit type on MSP430) which causes warnings during
compilation such as:
"cast from pointer to integer of different size"
The main memory region of the GDB simulator ends at address 0xFFBF,
but the simulator linker scripts do not make full use of this available
memory.
>From 61f3d212741acee583e21ff2c2808775584ecad6 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Mon, 3 Aug 2020 19:38:23 +0100
Subject: [PATCH 2/2] MSP430: Increase the amount of main memory available in
sim ld scripts
The main memory region of the GDB simulator ends at address 0xFFBF,
but the simulator linker scripts do not make full use of this available
memory.
__{preinit,init,fini}_array_start symbols must be word aligned in
linker scripts. If the section preceding the __*_array_start symbol
has an odd size, then a NULL byte will be present between the start
symbol and the .*_array section itself, when the section gets
automatically word-aligned.
This results in a branch to an invalid address when the CRT startup
code tries to run through the functions listed in the array sections.
>From de115144d05ecbaa82c9c737cc261715ca4b7d67 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Mon, 3 Aug 2020 19:09:46 +0100
Subject: [PATCH 1/2] MSP430: Word align __*_array_start symbols in sim linker
scripts
__{preinit,init,fini}_array_start symbols must be word aligned in
linker scripts. If the section preceding the __*_array_start symbol
has an odd size, then a NULL byte will be present between the start
symbol and the .*_array section itself, when the section gets
automatically word-aligned.
This results in a branch to an invalid address when the CRT startup
code tries to run through the functions listed in the array sections.
In the initial code I missed one level of pointer indirection. Instead
of storing errno in impure_data, _impure_ptr was corrupted.
Only simulator is impacted. Real targets have no OS and no syscalls.
This resolves a bunch of stdio cases from the GCC testsuite:
FAIL->PASS: gcc.c-torture/execute/printf-2.c -O0 execution test
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
Most code in newlib already uses unified syntax, but just a couple of
laggards remain. This patch removes these and means the the entire
code base has now been converted.
Previously, __internal_syscall() compiled into asm-code that unconditionally
sets the syscall argument registers a0 to a5.
For example, the instruction sequence for a exit syscall looked like
this:
li a0, 1 # in ther caller of exit()
# ... # in newlib:
li a1, 0 # unused arguments
li a2, 0
li a3, 0
li a4, 0
li a5, 0
li a7, 93 # exit syscall number
(i.e. the binary contains then 5 superfluous instructions for this
one argument syscall)
This commit changes the RISC-V syscall code such that only the required
syscall argument registers are set.
GCC detects that argc is known at compile time and thus evaluates all the
if-statements where argc is used at compile time (tested with -O2 and -Os).
When off_t is 32 bits, the value needs to be sign-extended to 64 bits
before shifting right to extract the high-order word. Previously
negative offsets were incorrectly encoded.
Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
The libm gamma functions use the _gamma_signgam field of the reentrant
structure, which changes offset with the --enable-newlib-reent-small
configure option, which means we need to use a newlib nano specific
version of libm in addition to libc in the nano.specs file. Reported
by Keith Packard. There is a riscv-gnu-toolchain patch that goes
along with this to create the new libm_nano.a file.
Signed-off-by: Jim Wilson <jimw@sifive.com>
This edits licenses held by Berkeley and NetBSD, both of which
have removed the advertising requirement from their licenses.
Signed-off-by: Keith Packard <keithp@keithp.com>
Target libraries are considered to be built for GCC's "host", not GCC's
"target". The "host" variable must be set by configure scripts using
"config-ml.in" to determine multilib support, otherwise disabled
multilibs (specified as a configure argument with --disable-<multilib>)
will still be built for the subdirectories those configure scripts
reside in.
Commit 72ff9acad2 caused st_atime,
st_ctime, and st_mtime to be defined as macros. This collided with
use of these identifiers as field names in struct gdb_stat (which
represents the GDB RSP encoding of struct stat) in libgloss
semihosting support for nios2 and m68k. This patch renames the
affected fields of struct gdb_stat.
Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
- revert previous fix which altered sys/stat.h
- fix libgloss/cris/gensyscalls to undef st_atime, st_mtime,
and st_ctime macros which cannot be used with new_stat structure
Applied changes from commit 8d98f95:
* arm/crt0.S: Initialise __heap_limit when ARM_RDI_MONITOR is defined.
* arm/syscalls.c: define __heap_limit global symbol.
* arm/syscalls.c (_sbrk): Honour __heap_limit.
Applied changes from commit 8d98f95:
Fixed semihosting for ARM when heapinfo not provided by debugger
Left-over part of commit 84b2a020da
The _end marker must be aligned to 4-bytes to ensure that the last
element written does not reach beyond the address of _end. This is
also necessary as the termination condition is an equality test
instead of an ordered test so (_end - _fbss) must be a multiple of
4-bytes. The alignment is already correct for mti*.ld files, fix
it for all remaining MIPS scripts that don't already align to at
least 4.
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.
.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.
.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.
The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
SP initialization changes:
1. set default value in semihosting case as well
2. moved existing SP & SL init code for processor modes in separate routine and made it as "hook"
3. init SP for processor modes in Thumb mode as well
Add new macro FN_RETURN, FN_EH_START and FN_EH_END.
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.
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.
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.
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.
The code in trap.S is to support the old APCS chunked stack variant,
which dates back to the Acorn days, so put it under #ifndef
__ARM_EABI__.
* libgloss/arm/trap.S: Use __ARM_EABI rather than PREFER_THUMB.
* newlib/libc/sys/arm/trap.S: Use __ARM_EABI rather than
__thumb2__.
The location of the handler at offset 0x20 from the start of memory,
immediately after the 32-byte reset vector, matches the expectations
of real hardware (e.g., a 3c120 board).
Author: Sandra Loosemore <sandra@codesourcery.com>
Date: Wed Mar 13 20:22:16 2019 -0700
Add semihosting documentation for nios2 and m68k.
QEMU maintainers have asked for a specification of the nios2
semihosting interface. Since it's essentially a copy of the m68k
implementation, this patch adds a document for that target as well.