diff options
author | Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> | 2023-08-08 18:09:50 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2023-08-09 11:38:03 +0200 |
commit | b9e867d088935d9f0bf312e6dbf3e4976850dfd3 (patch) | |
tree | c1e533435a9fe52fe6c3aa435d5029c3eb913174 /libgloss | |
parent | cbe7543cdfdb7f3d270214877d4a4c3e78710bd3 (diff) | |
download | newlib-b9e867d088935d9f0bf312e6dbf3e4976850dfd3.zip newlib-b9e867d088935d9f0bf312e6dbf3e4976850dfd3.tar.gz newlib-b9e867d088935d9f0bf312e6dbf3e4976850dfd3.tar.bz2 |
Add stub for getentropy
Example test case that fails with undefined reference to getentropy:
Testing g++.robertl/eb77.C, -std=c++20
doing compile
Executing on host: /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -fmessage-length=0 -std=c++20 -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe (timeout = 800)
spawn -ignore SIGHUP /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -fmessage-length=0 -std=c++20 -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe
pid is 28414 -28414
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
pid is -1
close result is 28414 exp6 0 1
output is /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
status 1
compiler exited with status 1
FAIL: g++.old-deja/g++.robertl/eb77.C -std=c++20 (test for excess errors)
Excess errors:
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
(.text._rs_stir+0x8): undefined reference to `getentropy'
UNRESOLVED: g++.old-deja/g++.robertl/eb77.C -std=c++20 compilation failed to produce executable
Contributed by STMicroelectronics
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Diffstat (limited to 'libgloss')
-rw-r--r-- | libgloss/Makefile.in | 5 | ||||
-rw-r--r-- | libgloss/libnosys/Makefile.inc | 1 | ||||
-rw-r--r-- | libgloss/libnosys/getentropy.c | 21 |
3 files changed, 27 insertions, 0 deletions
diff --git a/libgloss/Makefile.in b/libgloss/Makefile.in index 187d0ed..7f46375 100644 --- a/libgloss/Makefile.in +++ b/libgloss/Makefile.in @@ -409,6 +409,7 @@ libnosys_libnosys_a_LIBADD = @CONFIG_LIBNOSYS_TRUE@ libnosys/unlink.$(OBJEXT) \ @CONFIG_LIBNOSYS_TRUE@ libnosys/wait.$(OBJEXT) \ @CONFIG_LIBNOSYS_TRUE@ libnosys/write.$(OBJEXT) \ +@CONFIG_LIBNOSYS_TRUE@ libnosys/getentropy.$(OBJEXT) \ @CONFIG_LIBNOSYS_TRUE@ libnosys/_exit.$(OBJEXT) libnosys_libnosys_a_OBJECTS = $(am_libnosys_libnosys_a_OBJECTS) libobjs_a_AR = $(AR) $(ARFLAGS) @@ -991,6 +992,7 @@ TEXINFO_TEX = ../texinfo/texinfo.tex @CONFIG_LIBNOSYS_TRUE@ libnosys/unlink.c \ @CONFIG_LIBNOSYS_TRUE@ libnosys/wait.c \ @CONFIG_LIBNOSYS_TRUE@ libnosys/write.c \ +@CONFIG_LIBNOSYS_TRUE@ libnosys/getentropy.c \ @CONFIG_LIBNOSYS_TRUE@ libnosys/_exit.c @CONFIG_LM32_TRUE@lm32_libgloss_a_SOURCES = \ @@ -1558,6 +1560,8 @@ libnosys/wait.$(OBJEXT): libnosys/$(am__dirstamp) \ libnosys/$(DEPDIR)/$(am__dirstamp) libnosys/write.$(OBJEXT): libnosys/$(am__dirstamp) \ libnosys/$(DEPDIR)/$(am__dirstamp) +libnosys/getentropy.$(OBJEXT): libnosys/$(am__dirstamp) \ + libnosys/$(DEPDIR)/$(am__dirstamp) libnosys/_exit.$(OBJEXT): libnosys/$(am__dirstamp) \ libnosys/$(DEPDIR)/$(am__dirstamp) @@ -1958,6 +1962,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/execve.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/fork.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/fstat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/getentropy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/getpid.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/gettod.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@libnosys/$(DEPDIR)/isatty.Po@am__quote@ diff --git a/libgloss/libnosys/Makefile.inc b/libgloss/libnosys/Makefile.inc index 5e69072..334f694 100644 --- a/libgloss/libnosys/Makefile.inc +++ b/libgloss/libnosys/Makefile.inc @@ -24,4 +24,5 @@ multilibtool_LIBRARIES += %D%/libnosys.a %D%/unlink.c \ %D%/wait.c \ %D%/write.c \ + %D%/getentropy.c \ %D%/_exit.c diff --git a/libgloss/libnosys/getentropy.c b/libgloss/libnosys/getentropy.c new file mode 100644 index 0000000..5c4d3a8 --- /dev/null +++ b/libgloss/libnosys/getentropy.c @@ -0,0 +1,21 @@ +/* + * Stub version of getentropy. + */ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include <errno.h> +#undef errno +extern int errno; +#include "warning.h" + +int +_getentropy (void *buf, + size_t buflen) +{ + errno = ENOSYS; + return -1; +} + +stub_warning(_getentropy) |