ida

Disable generation of ALIGN directives


I use IDA for disassembly and ALIGN directives often appear in disassembly code, such as here:

                ALIGN 0x10
off_8030680     DCD 0x200261D8
dword_8030680   DCD 0x20027D2A

Is it possible to disable the creation of these directives? There are non-zero bytes behind them, and I would like to see them, for example like this:

                DCW 0xBF00
off_8030680     DCD 0x200261D8
dword_8030680   DCD 0x20027D2A

Solution

  • I don't know of a way to just disable creation of alignment items, but script to remove them surely can be made. Something like this (IDC, Python version can be made same way):

    // unfortunately alignments cannot be found by find_data, so using this more broad one
    auto ea = find_defined(0, SEARCH_DOWN);
    while (ea != BADADDR) {
        if (is_align(get_flags(ea))) {
            // todo: maybe check for non-zero bytes and leave zeroes in?
            del_items(ea, DELIT_SIMPLE);
            // todo: convert it to data instead if you want it that way
        } else {
           ea = next_head(ea, BADADDR); // not an alignment, skip this item (so the script doesn't have to trudge through e.g. arrays byte by byte)
        }
        ea = find_defined(ea, SEARCH_DOWN);
    }