Skip to content

Latest commit

 

History

History
138 lines (99 loc) · 4.01 KB

File metadata and controls

138 lines (99 loc) · 4.01 KB

nm45 — Symbol Lister for .o45 / .o65 Object Files

nm45 lists the symbols (imports and exports) in .o45 and .o65 relocatable object files. It follows the conventions of the standard Unix nm tool.

Both 32-bit .o45 files (produced by ca45 -c or cc45 -c) and standard 16-bit .o65 files (from other 6502 toolchains) are supported.

Usage

nm45 [options] <file.o45|file.o65> [...]

Output Format

Each line displays one symbol:

OFFSET TYPE NAME
  • OFFSET: 8-digit hex address (segment-relative offset for exports, blank for imports).
  • TYPE: Single letter indicating the symbol's segment and linkage.
  • NAME: The symbol name as stored in the object file.

Type Letters

Letter Meaning
U Undefined — imported symbol (.extern)
T Text segment — code (.global in .code/.text)
D Data segment — initialized data (.global in .data)
B BSS segment — uninitialized data (.global in .bss)
Z Zero Page / Direct Page segment (.global in .zp)
A Absolute — not relative to any segment

Options

Flag Description
-u Display only undefined (imported) symbols
-g Display only global (exported) symbols
-n Sort by address instead of name (defined symbols first)
-r Reverse the sort order
-p No sorting — display in file order
-A, -o Prepend filename to each line (file.o45:offset T name)
-? Display help message

Examples

List all symbols

$ nm45 main.o45
         U _printf
00000000 T _main
00000000 D _counter

Show only undefined (imported) symbols

$ nm45 -u main.o45
         U _printf

Sort by address

$ nm45 -n program.o45
00000000 T _init
00000000 D _buffer
0000002c T _main
00000050 T _cleanup

Reverse alphabetical order

$ nm45 -r main.o45
00000000 D _result
00000000 T _main
         U _add

Search across multiple object files

Use -A to prepend filenames, making the output grep-friendly:

$ nm45 -A *.o45 | grep _main
main.o45:00000000 T _main
math.o45:         U _main

This shows that main.o45 defines _main and math.o45 references it.

Multi-file listing (without -A)

Without -A, multiple files get headers:

$ nm45 main.o45 math.o45

main.o45:
         U _add
00000000 T _main
00000000 D _result

math.o45:
00000000 T _add

Supported Formats

Format Extension Width Description
.o45 .o45 32-bit MEGA65 relocatable objects (produced by ca45 -c or cc45 -c)
.o65 .o65 16-bit Standard Andre Fachat 6502 relocatable objects (from xa65, cc65, etc.)

Both formats share the same magic bytes ($01 $00 "o65"), option structure, relocation encoding, and symbol table layout. The reader auto-detects the width from the SIZE32 mode bit. 16-bit values are widened to 32-bit internally.

The CPU_EXT mode bit is also handled: when set, an extended CPU ID byte is read after the segment fields (e.g., $45 for 45GS02, $03 for 65CE02).

Relation to the Toolchain

nm45 reads object files produced by:

  • ca45 -c input.s -o output.o45 — assembler in relocatable mode
  • cc45 -c input.c -o output.o45 — C compiler in relocatable mode
  • Any .o65-compatible toolchain (xa65, cc65, etc.)

It is the primary diagnostic tool for inspecting symbol tables before linking with ln45.

See Also

  • ca45 — Assembler (produces .o45 with -c)
  • cc45 — C Compiler (produces .o45 with -c)
  • lib.md.o45 format specification
  • ln45 — Linker design (future)