Tool zobjcopy - z88dk/z88dk GitHub Wiki

Object and Library File Manipulator

Usage

zobjopy input [options] [output]

Description

zobjcopy reads the input library or object file generated by z80asm and produces an equivalent output file, where the input file can be in any of the current or older object file formats of z80asm and the output file is updated to the current format.

Each option denotes one action to be done on the input file, and multiple options can be specified to execute multiple actions in the sequence given in the command line.

Options

  • -l | --list
    Only reads an input file and displays the contents, does not write an output file.

  • --hide-local
    In option --list, do not show local symbols.

  • --hide-expr
    In option --list, do not show expressions.

  • --hide-code
    In option --list, do not show code dump of sections.

  • -v | --verbose
    Tells what is happening.

  • -s old-name-regex=new-name | --section old-name-regex=new-name
    Renames all sections that match the old name regex (standard POSIX) to the new name. Code sections are merged, if appropriate, fixing the patch addresses of expressions and label values accordingly.

  • -p name-regex,prefix | --add-prefix name-regex,prefix
    Renames all global symbols that match the given regex, adding the specified prefix. All expressions where the renamed symbols are used are corrected accordingly.

  • -y old-name=new-name | --symbol old-name=new-name
    Renames a global or external symbol. All expressions where the renamed symbols is used are corrected accordingly.

  • -L regex | --local regex
    Makes all global symbols that match the regex local.

  • -G regex | --global regex
    Makes all local symbols that match the regex global.

  • -F nn|0xhh |--filler nn|0xhh
    Change the filler byte to be used when merging sections to respect the ALIGN requirement. The default is 0xFF.
    The value can be supplied as decimal or hexadecimal with a '0x' prefix.

  • -O section,nn|0xhh |--org section,nn|0xhh
    Change the ORG of the given section.

  • -A section,nn|0xhh |--align section,nn|0xhh
    Change the ALIGN of the given section.

Examples

Dump the contents of a library file:

zobjcopy --list file.lib

Rename all sections starting with "text" to "rom" and all starting with "data" to "ram", writing the output in file2.lib:

zobjcopy file.lib --section ^text=rom --section ^data=ram file2.lib --verbose

Add a "lib_" prefix to all global symbols that start with "ff":

zobjcopy file.lib --add-prefix ^ff,lib_ file2.lib --verbose

Rename the global symbol "main" to "_main"

zobjcopy file.lib --symbol main=_main --verbose

Make the "main" symbol local:

zobjcopy file.lib --local '^main$' --verbose

Make the "main" symbol global:

zobjcopy file.lib --global '^main$' --verbose

Merge all sections, use 0x00 as the alignment byte:

zobjcopy file.lib --filler 0x00 --section .=text --verbose

Change section "text" to ORG 0x8000 and ALIGN 16:

zobjcopy file.lib --org text,0x8000 --align text,16 --verbose

TO-DO

  • factor code into z80asm
  • disassemble code sections