03 Sf
# cc -m32 -shared -fPIC -Wall -Wextra \
-o /usr/local/lib/libc3_shim.so /root/libc3_shim_02.c
# run_applix /usr/local/lib/libc3_shim.so
Bad system call
return code=140, signal=12
From the Stage-02 Command to the __sF Experiment
The output above does not identify __sF. A faithful investigation first
explains the fatal signal, crosses that boundary, and only then inspects symbols
used by later-loaded Applix libraries. These are separate debugging stages.
1. Identify what the command actually built
There are two similarly named files in the jail:
ls -l /root/libc3_shim_02.c /root/libc3-shim-02.c
1057 ... /root/libc3_shim_02.c
2851 ... /root/libc3-shim-02.c
The command in the failure uses the underscore file,
libc3_shim_02.c. Inspect the resulting preload without guessing what it
contains:
nm -D /usr/local/lib/libc3_shim.so |
egrep ' (sysconf|sigaction|sigprocmask|getpwuid|__sF)$'
T sysconf
That source is an earlier sysconf() experiment. It does not export
sigaction, getpwuid, or __sF, so its filename must not be treated as proof
that it contains the staged libc3-shim-02.c behavior.
2. Explain Bad system call before looking for __sF
Rebuild the same underscore source to a temporary path and trace it:
cc -m32 -shared -fPIC -Wall -Wextra \
-o /tmp/03-libc3-shim-02.so /root/libc3_shim_02.c
env \
LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/applixware1999cdrom/axdata/axshlib \
LD_32_PRELOAD=/tmp/03-libc3-shim-02.so \
AXHOME=/applixware1999cdrom \
AXGFSDIR=/applixware1999cdrom/axdata/fontmetrics/gallium \
AXLANG=english_us AX_TEMP_DIR=/tmp DISPLAY=:1 \
truss -f -o /tmp/03-stage02.truss \
/applixware1999cdrom/applix -wp
egrep 'sigaction|SIGSYS|killed' /tmp/03-stage02.truss
Measured result:
compat.freebsd32_sigaction() ERR#78 'Function not implemented'
SIGNAL 12 (SIGSYS) code=SI_KERNEL
process killed, signal = 12
The process dies in the legacy signal syscall before reaching the later Applix
libraries that reference __sF. Adding a data symbol cannot repair this
system-call failure. The signal boundary must be crossed first, as derived in
01-sigaction.md.
This establishes an important rule for stage 03:
Bad system call -> investigate signal ABI
undefined __sF -> investigate dynamic data-symbol providers
They are not two descriptions of the same problem.
3. Discover __sF without assuming its name
After a working earlier-stage preload keeps the launcher and helpers alive,
scan undefined symbols in all Applix shared libraries. Count every name first;
do not begin with grep __sF:
nm -D /applixware1999cdrom/axdata/axshlib/*.so 2>/dev/null |
awk '$1 == "U" { count[$2]++ }
END { for (name in count) print count[name], name }' |
sort -nr |
head -25
The measured list includes:
17 sprintf
16 strlen
15 strcpy
15 strcmp
14 strncpy
14 stat
14 memset
14 memcpy
13 fwrite
13 fopen
13 fclose
13 __error
12 strchr
12 strcat
12 fseek
12 fflush
12 __sF
This is where __sF comes from: it emerges as an undefined name used by twelve
later Applix libraries. Only after that discovery should a targeted search
identify the consumers:
for f in /applixware1999cdrom/axdata/axshlib/*.so
do
nm -D "$f" 2>/dev/null | grep -q ' U __sF$' && echo "$f"
done
The consumers include libaxwp.so, libfontfs.so, libshelf.so, and nine
other Applix libraries. In nm output, U __sF means only "undefined in this
object." It does not mean that the complete process lacks a provider.
4. Search for an existing provider before creating one
Confirm that the launcher loads old libc3, then inspect that library's dynamic symbol table:
env \
LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/applixware1999cdrom/axdata/axshlib \
ldd /applixware1999cdrom/applix | grep 'libc.so.3'
nm -D /usr/local/lib32/compat/applix/libc.so.3 |
grep ' __sF$'
libc.so.3 => /usr/local/lib32/compat/applix/libc.so.3 (...)
0007116c D __sF
D means libc3 already defines __sF as initialized global data. Because
libc3 is in the process, it can satisfy the Applix libraries' U __sF
references. The complete symbol investigation therefore does not prove
that __sF is missing.
This corrects the tempting but incomplete inference:
U __sF in a consumer -> another object must provide it
U __sF plus no provider anywhere -> create or stage a provider
U __sF plus D __sF in libc.so.3 -> the dependency is already satisfied
5. Reproduce the stage-03 interposition experiment
The existing libc3-shim-03.c deliberately exports another __sF before
including all of stage 02:
/* Stage 03: stage 02 plus the old exported stdio object. */
#include <stdio.h>
FILE __sF[3];
#include "libc3-shim-02.c"
Build and inspect it:
cc -m32 -shared -fPIC -Wall -Wextra \
-o /usr/local/lib/libc3-shim-03.so \
/root/libc3-shim-03.c
nm -D /usr/local/lib/libc3-shim-03.so |
egrep ' (__sF|sigaction|getpwuid)$'
A fresh build produced the following symbol types (addresses are omitted because they change when earlier stages change size):
B __sF
T getpwuid
T sigaction
B means the new preload contains zero-initialized global storage for
__sF. Since a preload is searched before normal dependencies, this strong
definition can interpose on libc3's authentic D __sF object.
That explains how libc3-shim-03.c is constructed, but not why it is required.
The available evidence shows:
- the supplied
Bad system callis a signal-ABI failure and is unaffected byFILE __sF[3]; - Applix libraries reference
__sF; - loaded libc3 already provides
__sF; - exporting another object is therefore an experiment, not a demonstrated fix.
A valid necessity test would compare otherwise identical stage-02 and stage-03 runs after all earlier boundaries are crossed and show a failure that occurs only without the preload definition. Without that before/after result, stage 03 should be described as compatibility-symbol coverage rather than as the fix for the SIGSYS output at the top of this document.