Differences between glibc and bsdlib (SoloXC only)
In order to provide CodeSafe developers the ability to write standard POSIX calls and be able to run in the SEE environments, gcc wrappers have been used to override certain standard functions. For example, both CodeSafe and Libc, have a definition for the function socket:
socket(int __domain, int __type, int __protocol)
At link time, the function call is overridden and resolved to the CodeSafe implementation. A linker options is used to accomplish that.
-Wl,-wrap=socket
The standard POSIX socket()
function can still be used calling real_socket()
. The applicability of the standard (real_*
) familiarity of functions is limited in the SEE environment due to embedded system constraints.
All the wrapped functions were replaced by equivalent ones with the underlying IPC support to communicate with nShield core and provide the same functionality as in legacy systems.
List functions that were wrapped and redefined:
-
socket()
-
bind()
-
listen()
-
accept()
-
connect()
-
read()
-
write()
-
send()
-
setsockopt()
-
poll()
-
select()
glibc Compatability exceptions
As a consequence of some function redefinitions and the underlying differences, some standard C functions may not work as expected in Codesafe.
FILE *fdopen( int fd, const char *mode)
: associates a stream with an existing file descriptor, fd
. In the case of a socket fd
(returned by Codesafe socket() implementation) the association result may fail or cause unexpected errors in subsequent calls.
Developers should avoid using fdopen
with non-standard Unix file descriptors.