summaryrefslogtreecommitdiffstats
path: root/libgloss
Commit message (Collapse)AuthorAgeFilesLines
* RISC-V: Add semihosting supportCraig Blackmore2020-12-1621-1/+692
|
* libgloss: aarch64: Add support for Armv8-R AArch64Alex Coplan via Newlib2020-09-304-4/+38
| | | | | | | | | | | 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.
* Add C-SKY port for libglossJojo R2020-09-2527-0/+6805
| | | | | | | | | | 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>
* MSP430: Fix calculation of string length in sbrk.cJozef Lawrynowicz2020-09-041-1/+1
|
* MSP430: Fix message in sbrk.c printing binary characterJozef Lawrynowicz2020-09-031-2/+2
| | | | | | 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.
* Fix warnings when building for msp430-elfJozef Lawrynowicz2020-09-031-0/+3
| | | | | | | | 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"
* MSP430: Increase the amount of main memory available in sim ld scriptsJozef Lawrynowicz2020-08-072-2/+2
| | | | | | | | | | | | | | | | 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.
* MSP430: Word align __*_array_start symbols in sim linker scriptsJozef Lawrynowicz2020-08-072-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | __{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.
* pru: Fix memory corruption on syscall returnDimitar Dimitrov2020-07-021-0/+1
| | | | | | | | | | | | 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>
* arm: Finish moving newlib to unified syntax for Thumb1Richard Earnshaw2020-03-021-0/+11
| | | | | | 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.
* Only pass the minimum number of syscall argumentsGeorg Sauthoff2020-02-1118-29/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* libgloss: Fix lseek semihosting bug on nios2 and m68kSandra Loosemore2020-02-062-2/+2
| | | | | | | | 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>
* RISC-V: Use newlib nano specific libm.Jim Wilson2020-01-311-1/+1
| | | | | | | | | | | 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>
* Use remove-advertising-clause script to edit BSD licensesKeith Packard2020-01-297-19/+7
| | | | | | | 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>
* MSP430: Support new msp430-elfbare targetJozef Lawrynowicz2019-12-162-2/+2
| | | | | Update the target triplet glob used when configuring for msp430 to support a new msp430-elfbare target being added to gcc.
* Implement the unlink system call for the moxie simulator.Anthony Green2019-12-141-2/+2
| | | | | Corresponding support for this was just added to the gdb moxie simulator. Unlink support is required by the GCC testsuite.
* Fix libgloss being built for disabled multilibsJozef Lawrynowicz2019-11-022-0/+2
| | | | | | | | | 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.
* Initial PRU port for libgloss and newlibDimitar Dimitrov2019-10-3121-0/+5338
| | | | Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
* MSP430: Add missing build rule for unlink() to libgloss MakefileJozef Lawrynowicz2019-10-251-0/+1
|
* Adjust nios2 and m68k semihosting for sys/stat.h changes.Sandra Loosemore2019-09-044-12/+12
| | | | | | | | | | | Commit 72ff9acad2ab54e80a19ddaec0106065c817e3f6 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>
* Fix regression in visium caused by sys/stat.h changeJeff Law2019-08-202-6/+6
|
* Revert previous change to sys/stat.h and fix cris libglossJeff Johnston2019-08-191-6/+12
| | | | | | - 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
* Align libgloss/arm and libc/sys/arm sources: miscellaneous fixesAlexander Fedotov2019-08-052-61/+47
| | | | | 1. Trim trailing spaces 2. Align comments, function declarations and definitions
* Align libgloss/arm and libc/sys/arm sources: HeapInfo and __heap_limitAlexander Fedotov2019-08-051-6/+6
| | | | | | | | | | | 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
* Align _end symbol to at least 4 in all MIPS scriptsFaraz Shahbazker2019-07-3016-0/+16
| | | | | | | | | | | | Left-over part of commit 84b2a020daa17d8ee5c9ec979c3d56f95e69573b 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.
* MSP430: Remove .init/.fini sectionsJozef Lawrynowicz2019-07-245-157/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Stack Pointer and Stack Limit initialization refactored.Alexander Fedotov2019-07-232-89/+227
| | | | | | | | | 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.
* Arm: Use lrdimon-v2m_nano when semihosting v2 and nano selected respectivelyAlexander Fedotov2019-06-251-1/+1
|
* RISC-V: Add _LITE_EXIT in crt0.S.Jim Wilson2019-05-221-0/+13
| | | | | | 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.
* Make .data section placement coincide with _fdata symbolFaraz Shahbazker2019-05-1522-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix order of eh_frame sections in linker scriptsFaraz Shahbazker2019-04-2918-18/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* MSP430: Make the inclusion of run_*_array fns depend on defined assembler ↵Jozef Lawrynowicz2019-04-183-22/+74
| | | | | | | | | | | | | | | | | | | | | | 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.
* Fix incorrect assembly code in _msp430_run_arrayJozef Lawrynowicz2019-04-161-2/+2
|
* Fix definition of write() to use const char * for the type of the bufferJozef Lawrynowicz2019-04-151-4/+5
|
* Align comments and spaces in libgloss/arm/crt0.S and ↵Alexander Fedotov2019-04-121-67/+68
| | | | newlib/libc/sys/arm/crt0.S to ease further code alignment.
* Include code in trap.S for APCS only.Christophe Lyon2019-04-111-1/+1
| | | | | | | | | | 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__.
* Add a dummy interrupt handler to nios2 crt0.s.Sandra Loosemore2019-04-031-1/+13
| | | | | | 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).
* Add semihosting docs for nios2 and m68kcygwin-3_0_4-releaseJeff Johnston2019-03-142-0/+411
| | | | | | | | | | | 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.
* AArch32: Fix the build for M class semihostingTamar Christina2019-02-111-1/+3
| | | | | | | | | | | | | | The M class cores don't support Semihosting v2 mixed mode, but we were accidentally using the new immediates for it. My last patch changed the immediates which broke the build because doing a full multi-lib build including M architectures now results in an assembler error instead of silently doing the wrong thing. This fixes the issue by changing the defines around such that According to the specs any M class build uses the normal semihosting instructions. Regtested on arm-none-eabi and no issues, using a build with m class multilibs too.
* AArch32: Add support for HLT to Mixed Mode modelsTamar Christina2019-02-082-7/+13
| | | | | | | | | | | | | | | | | | | | | The Semihosting v2 protocol requires us to output the Armv8-a HLT instruction when in mixed mode (SEMIHOST_V2_MIXED_MODE), however it also requires this to be done for Armv7-a and earlier architectures. The HLT instruction is defined in the undefined encoding space for older architectures but simulators such as QEMU already trap on it [1] for all architectures and is a requirement for semihosting v2 [2]. Unfortunately the GAS restricts the use of HLT to Armv8-a which requires us to use the instruction encodings we want directly in crt0. This patch does this, I have not updated newlib/libc/* as that is quite out of date already. A proper sync is needed in order to get things back in sync. A different patch for this would be best. [1] https://github.com/qemu/qemu/commit/19a6e31c9d2701ef648b70ddcfc3bf64cec8c37e [2] https://developer.arm.com/docs/100863/latest/the-semihosting-interface
* Add libgloss install-pdf and install-html targets.Jim Wilson2018-11-202-1/+30
| | | | | | | | | | | | | | The toplevel makefile used by binutils/gcc/newlib/etc has install-pdf and install-html targets, but they fail because libgloss doesn't support them. Tested with an arm-eabi combined tree build and install, and verifying that the install-pdf and install-html targets now work, and that the pdf and html doc files are now in the install tree. libgloss/ * Makefile.in (install-html, install-pdf): New. * doc/Makefile.in (htmldir, pdfdir): New. (porting.ps): Delete white space on blank line. (install-pdf, install-html): New.
* Enable return code with semi-hosting SYS_EXIT_EXTENDEDMatthew Malcomson2018-11-192-22/+20
| | | | | | | | | | | | | | | | | | | | | | | The _exit function currently passes -1 as a "sig" to the _kill function as an invalid signal number so that _kill can distinguish between an abort and a standard exit. For boards using the SYS_EXIT_EXTENDED semi-hosting operation to return a status code, this means that the "status" paramter to _exit is ignored and the return code is always -1. https://developer.arm.com/docs/100863/latest/semihosting-operations/sys_exit_extended-0x20 This patch puts shared code between _kill and _exit into a new function _kill_shared that takes the semi-hosting "reason" to use (if semi-hosting is available) as an argument. For semi-hosting _kill_shared provides that "reason". Without the "sig" argument being used to distinguish between a normal and abnormal exit, the _exit function can provide the return code to be used if the SYS_EXIT_EXTENDED operation is available. Hence the exit code can be returned.
* Initialize SVE system registers.Tamar Christina2018-10-311-0/+27
| | | | | | | | | This patch initializes the SVE system registers if available and initializes the vector length to the maximum supported. This is done according to the SVE specification [1]. [1] https://developer.arm.com/docs/ddi0584/latest/arm-architecture-reference-manual-supplement-the-scalable-vector-extension-sve-for-armv8-a
* [Aarch64] Syscalls: fix prototypesChristophe Lyon2018-10-081-18/+19
| | | | | | | | | | This patch is similar the arm one committed recently. 2018-10-08 Christophe Lyon <christophe.lyon@linaro.org> * libgloss/aarch64/syscalls.c (_sbrk): Fix prototype. (_getpid, _write, _swiwrite, _lseek, _swilseek, _read, _wriread): Likewise.
* [ARM] Make _kill() a noreturn function.Christophe Lyon2018-10-082-4/+6
| | | | | | | | | | | | | | AngelSWI_Reason_ReportException does not return accoring to the ARM documentation, so it is valid to mark _kill() as noreturn. This way, the compiler does not warn about _exit() returning a value despite being noreturn. 2018-10-01 Christophe Lyon <christophe.lyon@linaro.org> * libgloss/arm/_exit.c (_exit): Declare _kill() as noreturn. * libgloss/arm/_exit.c (_kill): Likewise. Remove the return statements. * newlib/libc/sys/arm/syscalls.c (_kill): Likewise..
* [Aarch64] Fix warning in _sbrkChristophe Lyon2018-10-051-1/+1
| | | | | | | 2018-10-01 Christophe Lyon <christophe.lyon@linaro.org> * libgloss/aarch64/syscalls.c (_sbrk): Cast "__heap_limit" to "char *".
* Committed, CRIS port: fix fallout from time_t defaulting to 64 bits, part 1Hans-Peter Nilsson2018-09-132-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's been a while... I see the CRIS port broke with the time_t-default-to-64-bit change, observable by a few test-cases in the gcc fortran(!) tests failing, regressing when trying a recent newlib. This is a two-part belt-and-suspenders change: adjust the CRIS port gettimeofday syscall (the only one in newlib/CRIS passing a time_t or struct timeval) to handle a userspace 64-bit time_t and secondly default time_t to 32-bit long anyway. I considered making the local "kernel_timeval" copy in _gettimeofday conditional on (userspace) time_t being 64 bits, but thought it not worth bothering with the few move insns. The effect of a 64-bit time_t is however observable as longer simulation time when running the gcc testsuite and as bigger binaries without any actual upside from the larger time_t size, so I thought better make the default for this port go back to being a "long" again. Tested by running the gcc testsuite over the three combinations of two parts of the patch and observing the expected changes. Committed. libgloss: Adjust for syscall and userspace having different time_t or timeval. * cris/linunistd.h (kernel_time_t, kernel_suseconds_t, kernel_timeval): New types. (gettimeofday): Change the type of the first argument to be a pointer to a struct kernel_timeval. * cris/gensyscalls (_gettimeofday): Use an intermediate struct kernel_timeval for the syscall and initialize the result from that. Signed-off-by: Hans-Peter Nilsson <hp@axis.com>
* RISC-V: Fix _sbrk, it's failed only when return value is -1.Denis Ivanov2018-08-292-7/+12
| | | | Signed-off-by: Kito Cheng <kito.cheng@gmail.com>
* RISC-V: Fixed return code in _times syscall.Denis Ivanov2018-08-291-2/+2
| | | | | | | | Upon successful completion, times() shall return the elapsed real time, in clock ticks, since an arbitrary point in the past (for example, system start-up time). Signed-off-by: Kito Cheng <kito.cheng@gmail.com>
* Add BSP and semihosting library for nios2-generic-nommu QEMU emulation.Sandra Loosemore2018-08-0828-0/+5848
|