Fix undefined references to hardware_poll()

Ultimately, mbedtls_hardware_poll() is going to be provided by the
OS/environment when running on target. But for on-host programs and tests, we
need to define (a fake version) in each program that we want to be able to
link.

A previous commit took care of ssl_client2 and ssl_server2. But if we want to
be able to compile all programs, we need to modify each of them. This doesn't
seem useful, so instead let's just build the programs we need for testing -
this means only udp_proxy needs fixing in addition to what's already done.

This issue went unnoticed in the PR that introduced the new all.sh component,
because at that time the platform_memxxx() functions were not actually used in
the library (nor in programs), so the linker could live with
mbedtls_hardware_poll() not being defined, as it wasn't called anywhere. This
changed when we started using the new platform_memxxx() functions in the
library.
This commit is contained in:
Manuel Pégourié-Gonnard 2019-10-22 12:50:13 +02:00
parent 3d01f2313b
commit 66491e1840
2 changed files with 18 additions and 2 deletions

View file

@ -79,6 +79,19 @@ int main( void )
#include <unistd.h>
#endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
#define MAX_MSG_SIZE 16384 + 2048 /* max record/datagram size */
#define DFL_SERVER_ADDR "localhost"

View file

@ -426,7 +426,9 @@ $text"
;;
*)
record_status command make "$@"
build_status=$last_status
if [ $build_status -eq 0 ]; then
build_status=$last_status
fi
;;
esac
}
@ -1564,7 +1566,8 @@ component_test_baremetal () {
component_test_hardware_entropy () {
msg "build: default config + MBEDTLS_ENTROPY_HARDWARE_ALT"
scripts/config.pl set MBEDTLS_ENTROPY_HARDWARE_ALT
make CFLAGS='-Werror -O1'
make CFLAGS='-Werror -O1' lib tests
make CFLAGS='-Werror -O1' -C programs ssl/ssl_server2 ssl/ssl_client2 test/udp_proxy
msg "test: default config + MBEDTLS_ENTROPY_HARDWARE_ALT"
if_build_succeeded make test