I'm writing a 6502 emulator in x86 assembly language. The heart of the emulated machine is a 256-entry table of code pointers for each 6502 opcode :
fns_asm:
.word opasm_brk // 0x00 BRK
.word opasm_ora_indzx // 0x01 ORA (,x)
.word opasm_undef
.word opasm_slo_indzx // 0x03: SLO (,x)
.word opasm_nop_zp // 0x04: NOP zp
...
opasm_brk:
< implementation of BRK instruction >
opasm_ora_indzx
< implmentation of ORA instruction >
... etc ...
The problem is that the compiled shared library (.so) fails to load at runtime. The error reported on x86 Android is:
dlopen("/data/app/com.myapk/lib/x86/lib6502.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "" referenced by "lib6502.so"
Note the empty symbol name, very unhelpful!
I've worked out that my function table is to blame... if I change fns_asm to be a zero-entry table, or to have a single entry with a constant rather than a label (i.e. ".word 0") then the .so loads fine. It's the referencing of labels with .word directives that causes things to go wrong.
What am I doing wrong?
.longinstead.