Topic: Undefined reference to _abort, _getpid and _sbrk

Hi,
I'm building with custom Makefile wolfssl library for STM32F2xx with FreeRTOS.
Library build passed OK but linking the final project with a libraty produce undefined references to _abort, _getpid and _sbrk.
I'm quite sure something is missing in configuration of the library. Please help...

Here is my user_settings.h

/*
*-------------------------------------------------------------------
* wolf SSL user_settings.h
*-------------------------------------------------------------------
*/
#ifndef USER_SETTINGS_H_INCLUDED
#define USER_SETTINGS_H_INCLUDED

/*
*-----------------------------------------------------------------------------
* wolfSSL options
*-----------------------------------------------------------------------------
*/
#define FREERTOS
#define WOLFSSL_STM32F2
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT

#define WOLFSSL_USER_IO
#define USER_TIME
#define USER_TICKS

#define STM32F2_RNG_COOLAUTOMATION
#define STM32F2_CRYPTO_COOLAUTOMATION

#define BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
#define HAVE_DH
#define HAVE_AESGCM

//#define NO_AES
#define NO_FILESYSTEM
//#define NO_RABBIT (defined by WOLFSSL_STM32F2)
//#define NO_RSA
//#define NO_DSA (defined by FREERTOS)
//#define NO_DH
//#define NO_CERTS
#define NO_PWDBASED
#define NO_DES3
#define NO_MD4
#define NO_MD5
#define NO_ERROR_STRINGS
#define NO_OLD_TLS
#define NO_RC4
//#define NO_WRITEV (defined by FREERTOS)
//#define NO_SESSION_CACHE
//#define NO_DEV_RANDOM (defined by WOLFSSL_STM32F2)
//#define NO_WOLFSSL_SERVER ???
#define NO_PSK
#define NO_SHA
//#define NO_WOLFSSL_MEMORY ???
//#define NO_ASN
//#define NO_BIG_INT
//#define NO_CODING
//#define NO_HC128 (defined by FREERTOS)
//#define NO_INLINE ???
//#define NO_ASN_TIME

And this is an invocation of GCC:

Compiling file: ../wolfssl-3.9.10/src/ssl.c
C:/ARM_GCC/current/bin/arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb -Os -Wall -Wstrict-prototypes -Wextra -Wformat=0 -std=gnu89 -fverbose-asm -nostdlib -funwind-tables -Wa,-ahlms=_output/ssl.lst -DWOLFSSL_USER_SETTINGS -I. -I../wolfssl-3.9.10/ -I../../STM32/lib/Core -I../../STM32/lib -I../../STM32/FreeRTOSv8.0.1/Source/include -I../../STM32/FreeRTOSv8.0.1/Source/portable/GCC/ARM_CM3 ../wolfssl-3.9.10/src/ssl.c -o _output/ssl.o

Share

Re: Undefined reference to _abort, _getpid and _sbrk

Hi dimax.main,

These undefined references can typically be resolved by adding semi-hosting support to your libraries. I see in the configuration you have

-nostdlib

. Ideally you could replace this by adding lib rdimon and setting the specs to rdimon.specs IE:

 -lrdimon -specs=rdimon.specs

here is a very simple example of a cross-compile script I recently used where we added semi-hosting to the project.

#!/bin/sh                                                                       

#export these items to the local environment (duration of the script)                                                                             
export CCBIN="/opt/gcc-arm-none-eabi-5_2-2015q4/bin"                            
export LIBS="-Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group"          
export CCT="${CCBIN}/arm-none-eabi-"                                            
                                                                                
CFLAGS="-mcpu=cortex-m4 -mthumb -ffunction-sections -fdata-sections -MD -std=c99 -Wall -Os"
CFLAGS="${CFLAGS} -specs=rdimon.specs"                                                                                                
CFLAGS="${CFLAGS} -DUSE_SLOW_SHA -DNO_HMAC -DRSA_LOW_MEM"
CFLAGS="${CFLAGS} -DTFM_TIMING_RESISTANT -DBENCH_EMBEDDED"

#export these items to the local environment (duration of the script)
export CFLAGS="${CFLAGS}"                                                       
                                                                                
./configure --host=arm-none-eabi CC=${CCT}gcc AR=${CCT}ar --disable-shared --enable-static --disable-sha512 --enable-smallstack --disable-sha --disable-errorstrings --enable-rsa --disable-oldtls --disable-chacha --disable-poly1305 --disable-des3 --disable-md5 --enable-asn --enable-sha256 --enable-fastmath
                                              
make src/libwolfssl.la 

Feel free to use that script and modify it to your needs.


Kind Regards,

Kaleb