Cc65 integration

From llvm-mos

LLD has the ability to use od65 and ld65 to link against xo65 object files (the native output format of ca65). LLD searches the system path for these utilities; failing this, their locations are provided by the linker arguments --od65-path and --ld65-path. Using these utilities allows symbol values to pass freely between xo65 object files and ELF object files. xo65 segments are placed as if they were ELF sections. Since ld65's configuration script does not provide the ability to place segments from different xo65 input files differently, all sections derived from xo65 segments are considered in LLD linker scripts to come from a fictitious input file named xo65-enclave. The LLVM-MOS SDK already places the default cc65 segments into the corresponding modern output section.

This feature cannot be used during a relocatable link (-r), since the output is a relocatable ELF file, and ca65's relocations are much richer than LLVM-MOS ELF allows.

ELF sections have richer names, types, and flags than xo65 segments. Accordingly, the linker uses an underscore-based escaping scheme to decode this information from the xo65 segment names. The default cc65 segments are automatically assigned the correct type and flags.

Escape Sequences
Sequence Result
__ _
_d $
_h -
_p .
_xXX The byte given by hex string XX (case insensitive)
_tn Section type SHT_NOBITS (last wins)
_tp Section type SHT_PROGBITS (last wins)
_fw Section flag SHF_WRITE
_fx Section flag SHF_EXECINSTR