Commit Graph

634 Commits

Author SHA1 Message Date
Mike Frysinger 873da400e0 libgloss: regenerate aclocal.m4 & configure w/newer versions
Regenerate the files using automake-1.15 & autoconf-2.69 to match the
binutils/gdb/gcc projects.  Ran:

libgloss $ find -name configure.ac -printf '%h\n' | while read d; do
  (cd $d; export WANT_AUTOCONF=2.69 WANT_AUTOMAKE=1.15;
   aclocal-1.15 -I.. && autoconf-2.69); done
2021-11-06 14:14:50 -04:00
Mike Frysinger 59e83de0b1 libgloss/newlib: update configure.ac in Makefile.in files
The maintainer rules refer to configure.in directly, so update that
after renaming all the configure.ac files.
2021-11-06 14:14:49 -04:00
Lewis Revill 92e488d5b8 libgloss/riscv: Fix hard coded reference to configure.in after rename
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.
2021-10-27 17:44:48 +02:00
Mike Frysinger 1328009bb4 libgloss: add missing aclocal.m4 files
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.
2021-09-15 10:08:20 -04:00
Mike Frysinger e215765041 libgloss: epiphany: rename symbol prefix cache var
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.
2021-09-15 10:08:20 -04:00
Mike Frysinger 63c1f29a1d libgloss: fix AC_LANG_SOURCE warnings w/newer autoconf
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.
2021-09-15 10:08:20 -04:00
Mike Frysinger 920617998e libgloss/newlib: rename configure.in to configure.ac
The .in name has been deprecated for a long time in favor of .ac.
2021-09-13 10:14:37 -04:00
Christoph Muellner 0cb40f415b RISC-V: Reliably initialize t0 in _times()
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>
2021-08-04 11:44:33 +02:00
Jeff Law c01f603df9 Fix builds on iq2000 and visium
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.
2021-07-06 10:46:09 -04:00
Stafford Horne 43999b660f libgloss/or1k: Correct the IMMU SXE and UXE flags
These have been defined incorrectly, as per specification and CPU
implementations SXE is bit 6 and UXE is bit 7.  This was noticed when
tracking down our test suite mmu test failures.

 Test Suite: https://github.com/openrisc/or1k-tests/blob/master/native/or1k/or1k-mmu.c#L68-L72
 Spec: https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf

See section 8.4.8 Instruction Translation Lookaside Buffer Way y Translate
Registers where these are defined.

Signed-off-by: Stafford Horne <shorne@gmail.com>
2021-07-05 18:00:40 -04:00
Dimitar Dimitrov df0ad84e91 libgloss: pru: Remove sim ld script
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>
2021-06-09 14:15:56 -04:00
Dimitar Dimitrov 464c3f5d22 libgloss: pru: Place sim syscalls into their own sections
This should help reduce final ELF size if using --gc-sections linker
option.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2021-06-09 14:12:30 -04:00
Kito Cheng 20d0081998 RISC-V: Using SYS_clock_gettime64 for rv32 libgloss.
- 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.
2021-04-13 12:54:49 +02:00
Yeting Kuo 6aa0ab1c5d RISC-V: Use __bss_start for the starting point of .bss.
It's more flexible for the positions of .bss and .data.
2021-02-05 10:29:21 +01:00
Craig Blackmore 865cd30dcc RISC-V: Add semihosting support 2020-12-16 16:40:34 -05:00
Alex Coplan via Newlib 63a901705e libgloss: aarch64: Add support for Armv8-R AArch64
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.
2020-09-30 11:08:46 +01:00
Jojo R 648365e0e9 Add C-SKY port for libgloss
This patch contain all libgloss for C-SKY

Contributor list:
  - Lifang Xia <lifang_xia@c-sky.com>
  - Jojo R <jiejie_rong@c-sky.com>
  - Xianmiao Qu <xianmiao_qu@c-sky.com>
  - Yunhai Shang <yunhai_shang@c-sky.com>
2020-09-25 11:02:34 -04:00
Jozef Lawrynowicz cae21d17ad MSP430: Fix calculation of string length in sbrk.c 2020-09-04 15:05:17 +02:00
Jozef Lawrynowicz d72ea86d41 MSP430: Fix message in sbrk.c printing binary character
The call to write() in sbrk.c was using the wrong value for the length
argument, causing the NUL terminating character of the string to be
printed.
2020-09-03 12:55:32 +02:00
Jozef Lawrynowicz 754386c7f5 Fix warnings when building for msp430-elf
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"
2020-09-03 12:55:32 +02:00
Jozef Lawrynowicz e3f29b2472 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.

>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.
2020-08-07 15:16:43 +02:00
Jozef Lawrynowicz 748970c833 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.

>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.
2020-08-07 15:16:43 +02:00
Dimitar Dimitrov 70cd4cbe65 pru: Fix memory corruption on syscall return
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>
2020-07-02 11:00:33 +02:00
Richard Earnshaw f973a7d8be arm: Finish moving newlib to unified syntax for Thumb1
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.
2020-03-02 13:33:11 +00:00
Georg Sauthoff 9b51beeb2a Only pass the minimum number of syscall arguments
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).
2020-02-11 09:41:52 +01:00
Sandra Loosemore cd78225a50 libgloss: Fix lseek semihosting bug on nios2 and m68k
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>
2020-02-06 11:02:38 +01:00
Jim Wilson 8ef32f2dcf RISC-V: Use newlib nano specific libm.
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>
2020-01-31 12:42:52 +01:00
Keith Packard 9042d0ce65 Use remove-advertising-clause script to edit BSD licenses
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>
2020-01-29 19:03:31 +01:00
Jozef Lawrynowicz b74ba7dca6 MSP430: Support new msp430-elfbare target
Update the target triplet glob used when configuring for msp430 to
support a new msp430-elfbare target being added to gcc.
2019-12-16 10:15:06 +01:00
Anthony Green 78b7a3b0f8 Implement the unlink system call for the moxie simulator.
Corresponding support for this was just added to the gdb moxie simulator.
Unlink support is required by the GCC testsuite.
2019-12-14 05:27:38 -05:00
Jozef Lawrynowicz fa14f445ba Fix libgloss being built for disabled multilibs
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.
2019-11-02 16:27:20 +01:00
Dimitar Dimitrov 0c7734673a Initial PRU port for libgloss and newlib
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2019-10-31 14:47:19 -04:00
Jozef Lawrynowicz 0574317971 MSP430: Add missing build rule for unlink() to libgloss Makefile 2019-10-25 18:04:46 +02:00
Sandra Loosemore fa29288ef1 Adjust nios2 and m68k semihosting for sys/stat.h changes.
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>
2019-09-04 09:44:35 +02:00
Jeff Law d065170441 Fix regression in visium caused by sys/stat.h change 2019-08-20 18:15:41 +02:00
Jeff Johnston b99887c428 Revert previous change to sys/stat.h and fix cris libgloss
- 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
2019-08-19 18:01:45 -04:00
Alexander Fedotov bf56973edc Align libgloss/arm and libc/sys/arm sources: miscellaneous fixes
1. Trim trailing spaces
2. Align comments, function declarations and definitions
2019-08-05 13:00:53 +01:00
Alexander Fedotov dfffe68303 Align libgloss/arm and libc/sys/arm sources: HeapInfo and __heap_limit
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
2019-08-05 13:00:53 +01:00
Faraz Shahbazker 6661a67747 Align _end symbol to at least 4 in all MIPS scripts
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.
2019-07-30 09:38:13 +02:00
Jozef Lawrynowicz 884b05b54e MSP430: Remove .init/.fini sections
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.
2019-07-24 16:22:00 -04:00
Alexander Fedotov 942f60d714 Stack Pointer and Stack Limit initialization refactored.
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.
2019-07-23 10:00:06 +02:00
Alexander Fedotov a90aa583fb Arm: Use lrdimon-v2m_nano when semihosting v2 and nano selected respectively 2019-06-25 13:38:44 -04:00
Jim Wilson 77ac27dcf8 RISC-V: Add _LITE_EXIT in crt0.S.
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.
2019-05-22 17:41:25 -07:00
Faraz Shahbazker a9a0d219a4 Make .data section placement coincide with _fdata symbol
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.
2019-05-15 15:30:25 -04:00
Faraz Shahbazker ab2901c843 Fix order of eh_frame sections in linker scripts
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.
2019-04-29 10:44:24 +02:00
Jozef Lawrynowicz f811485ffb MSP430: Make the inclusion of run_*_array fns depend on defined assembler symbols
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.
2019-04-18 10:29:24 +02:00
Jozef Lawrynowicz 38ecf252e5 Fix incorrect assembly code in _msp430_run_array 2019-04-16 13:23:46 +02:00
Jozef Lawrynowicz a2e81650d1 Fix definition of write() to use const char * for the type of the buffer 2019-04-15 14:21:59 +02:00
Alexander Fedotov a0b0a4a018 Align comments and spaces in libgloss/arm/crt0.S and newlib/libc/sys/arm/crt0.S to ease further code alignment. 2019-04-12 14:34:47 +01:00
Christophe Lyon cc430406ac Include code in trap.S for APCS only.
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__.
2019-04-11 14:20:21 +00:00