This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [AArch64] nosys.specs and printf
- From: Tamar Christina <Tamar dot Christina at arm dot com>
- To: Alexander Fedotov <alfedotov at gmail dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>
- Cc: nd <nd at arm dot com>
- Date: Tue, 19 Sep 2017 14:43:01 +0000
- Subject: Re: [AArch64] nosys.specs and printf
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Tamar dot Christina at arm dot com;
- Nodisclaimer: True
- References: <CAN8C2Cptf5v8+KrEsd7ppfjhbM88wYOianMcPVUJ19bm9SOBzA@mail.gmail.com> <DB6PR0802MB230915D25ABD3E6534040138FF600@DB6PR0802MB2309.eurprd08.prod.outlook.com>,<CAN8C2Crygk-MsBz-=x5qa0pJ-2SvOQoOwdqcJztxppdTskEkdg@mail.gmail.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Hi Alex,
It's not that ARM is working, in the sense it does anything useful,
It's just that the warnings don't seem to be emitted because the conftests in libgloss/libnosys/configure.in are too simplistic,
for instance it tests for elf platforms by seeing if the target triple ends with "-elf".
However, just like aarch64, using nosys gives you stubs and not actual code.
/d/t/g/s/gcc (master ↩☡=) ../../build-arm-none-eabi/install/bin/arm-none-eabi-gcc test.c --specs=nosys.specs
/d/t/g/s/gcc (master ↩☡=) ../../build-arm-none-eabi/install/bin/arm-none-eabi-objdump -d a.out
...
0000b0b4 <_lseek>:
b0b4: e3a02058 mov r2, #88 ; 0x58
b0b8: e59f3008 ldr r3, [pc, #8] ; b0c8 <_lseek+0x14>
b0bc: e3e00000 mvn r0, #0
b0c0: e5832000 str r2, [r3]
b0c4: e12fff1e bx lr
b0c8: 0001b9fc .word 0x0001b9fc
0000b0cc <_read>:
b0cc: e3a02058 mov r2, #88 ; 0x58
b0d0: e59f3008 ldr r3, [pc, #8] ; b0e0 <_read+0x14>
b0d4: e3e00000 mvn r0, #0
b0d8: e5832000 str r2, [r3]
b0dc: e12fff1e bx lr
b0e0: 0001b9fc .word 0x0001b9fc
...
They all just return -1 and set ERRNO just as expected. https://github.com/eblot/newlib/blob/master/libgloss/libnosys/read.c
So Aarch64 is actually working as intended, it's ARM that's missing the warnings. And yeah, in order to suppress the warnings
you need to provide an alternate implementation.
Tamar.
________________________________________
From: Alexander Fedotov <alfedotov@gmail.com>
Sent: Tuesday, September 19, 2017 2:15 PM
To: Tamar Christina
Subject: Re: [AArch64] nosys.specs and printf
Hello Tamar
Well that's sounds to me like newlib completely useless for aarch64 in
current state.
So if I want to use nosys in my way I need to implement empty stubs to
suppress these warnings ? Right ?
How nosys ARM port is working in such case ?
BR,
Alex
On Tue, Sep 19, 2017 at 2:08 PM, Tamar Christina
<Tamar.Christina@arm.com> wrote:
> Hi Alexander,
>
> I believe your changes to libnosys are correct. We don't actually support nosys on AArch64, enough stuff has been committed for particular use cases but that's about it.
>
> The warnings you get with your libnosys changes are correct in that libnosys doesn't provide any IO functionality, so you don't have open, close, read and write. Which means your printf example won't work and it's just warning you ahead of time.
>
> Kind regards,
> Tamar
> ________________________________________
> From: newlib-owner@sourceware.org <newlib-owner@sourceware.org> on behalf of Alexander Fedotov <alfedotov@gmail.com>
> Sent: Friday, September 15, 2017 11:43:23 AM
> To: newlib@sourceware.org
> Subject: [AArch64] nosys.specs and printf
>
> Hello all
>
> I'm trying to compile following simple program for aarch64 with nosys specs
>
> #include <stdio.h>
> int main(void) {
> printf("hello");
> return 0;
> }
>
> But I've got:
> d:\gcc-6.3-arm64-eabi\bin>aarch64-none-elf-gcc --specs=nosys.specs test.c
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-sbrkr.o):
> In function `_sbrk_r':
> sbrkr.c:(.text._sbrk_r+0x1c): undefined reference to `_sbrk'
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-writer.o):
> In function `_write_r':
> writer.c:(.text._write_r+0x24): undefined reference to `_write'
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-closer.o):
> In function `_close_r':
> closer.c:(.text._close_r+0x1c): undefined reference to `_close'
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-fstatr.o):
> In function `_fstat_r':
> fstatr.c:(.text._fstat_r+0x20): undefined reference to `_fstat'
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-isattyr.o):
> In function `_isatty_r':
> isattyr.c:(.text._isatty_r+0x1c): undefined reference to `_isatty'
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-lseekr.o):
> In function `_lseek_r':
> lseekr.c:(.text._lseek_r+0x24): undefined reference to `_lseek'
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-readr.o):
> In function `_read_r':
> readr.c:(.text._read_r+0x24): undefined reference to `_read'
> collect2.exe: error: ld returned 1 exit status
>
> d:\gcc-6.3-arm64-eabi\bin>aarch64-none-elf-gcc --specs=rdimon.specs test.c
>
> d:\gcc-6.3-arm64-eabi\bin>
>
>
> I tried to reconfigure libnosys in the same way as ARM port:
>
> diff -ruN newlib-2.5.0/libgloss/libnosys/configure
> newlib-2.5.0/libgloss/libnosys/configure
> --- newlib-2.5.0/libgloss/libnosys/configure 2016-12-23
> 05:33:54.000000000 +0300
> +++ newlib-2.5.0/libgloss/libnosys/configure 2017-09-15
> 13:14:56.412457618 +0300
> @@ -2009,6 +2009,8 @@
> ;;
> a29k-amd-udi)
> ;;
> + aarch64*-*-*)
> + ;;
> arc-*-*)
> ;;
> arm*-*-*)
> diff -ruN newlib-2.5.0/libgloss/libnosys/configure.in
> newlib-2.5.0/libgloss/libnosys/configure.in
> --- newlib-2.5.0/libgloss/libnosys/configure.in 2016-12-23
> 05:33:54.000000000 +0300
> +++ newlib-2.5.0/libgloss/libnosys/configure.in 2017-09-14
> 18:32:27.330466884 +0300
> @@ -43,6 +43,8 @@
> ;;
> a29k-amd-udi)
> ;;
> + aarch64*-*-*)
> + ;;
> arc-*-*)
> ;;
> arm*-*-*)
>
> It now compiles so I get final elf, but with warnings:
> d:\gcc-6.3-arm64-eabi\bin>aarch64-none-elf-gcc --specs=nosys.specs test.c
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-closer.o):
> In function `_close_r':
> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/closer.c:53:
> warning: _close is not impl
> emented and will always fail
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-fstatr.o):
> In function `_fstat_r':
> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/fstatr.c:62:
> warning: _fstat is not impl
> emented and will always fail
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-isattyr.o):
> In function `_isatty_r':
> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/isattyr.c:58:
> warning: _isatty is not im
> plemented and will always fail
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-lseekr.o):
> In function `_lseek_r':
> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/lseekr.c:58:
> warning: _lseek is not impl
> emented and will always fail
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-readr.o):
> In function `_read_r':
> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/readr.c:58:
> warning: _read is not implem
> ented and will always fail
> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-writer.o):
> In function `_write_r':
> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/writer.c:58:
> warning: _write is not impl
> emented and will always fail
>
>
> Hi do I correctly to configure AArch64 nosys ?
--
Best regards,
AF