Skip to content

Add option to disable BSS pad symbols#205

Merged
AngheloAlf merged 2 commits into
Decompollaborate:1.xfrom
andresj-sanchez:add-bss-pad-option
Jun 2, 2026
Merged

Add option to disable BSS pad symbols#205
AngheloAlf merged 2 commits into
Decompollaborate:1.xfrom
andresj-sanchez:add-bss-pad-option

Conversation

@andresj-sanchez
Copy link
Copy Markdown
Contributor

@andresj-sanchez andresj-sanchez commented Jun 1, 2026

Summary

  • Add a --create-bss-pads / --no-create-bss-pads option to control autogenerated BSS/SBSS pad symbols.
  • Keep the default enabled to preserve existing output.
  • Avoid BSS range-check warnings when pad symbols are disabled and a declared symbol intentionally absorbs following padding.

Thanks to @dreamingmoths and @Mc-muffin for the help.

Context

Spimdisasm already has options for controlling autogenerated data and rodata pad symbols:

--create-data-pads / --no-create-data-pads
--create-rodata-pads / --no-create-rodata-pads

BSS currently always creates pad symbols after user-sized symbols. For example, a BSS symbol with declared size 0x4 followed by another symbol at +0x8 emits an autogenerated pad label for the gap:

dlabel some_bss_symbol
 .space 0x04

/* Automatically generated and unreferenced pad */
dlabel D_XXXXXXXX
 .space 0x04

This creates extra generated labels in BSS/SBSS output and can make objdiff views noisier.

Before:

image

After:

image

When those gap labels are not useful, disabling BSS pad creation folds the gap into the preceding BSS symbol instead:

dlabel some_bss_symbol
 .space 0x08

This PR adds the same style of control for BSS/SBSS via CREATE_BSS_PADS, exposed through the CLI as:

--create-bss-pads
--no-create-bss-pads

When enabled, behavior stays unchanged. When disabled, Spimdisasm stops creating those autogenerated BSS/SBSS pad symbols.

Notes

Testing

  • Verified --no-create-bss-pads disables autogenerated BSS pad symbols.
  • Verified --create-bss-pads preserves the existing autogenerated pad behavior.
  • Verified zero-sized declared BSS symbols do not create pad symbols, matching data/rodata pad behavior.

Co-authored-by: dreamingmoths <252494949+dreamingmoths@users.noreply.github.com>
Co-authored-by: Mc-muffin <8714476+Mc-muffin@users.noreply.github.com>
@andresj-sanchez
Copy link
Copy Markdown
Contributor Author

Wait @Mc-muffin found a possible bug with this approach related to the padding folding. I'll take a look at it.

Co-authored-by: dreamingmoths <252494949+dreamingmoths@users.noreply.github.com>
Co-authored-by: Mc-muffin <8714476+Mc-muffin@users.noreply.github.com>
@andresj-sanchez
Copy link
Copy Markdown
Contributor Author

Fix pushed. @Mc-muffin was right: dropping the pad label also dropped the size boundary, so objdiff showed the previous BSS symbol absorbing the padding.

Now it follows the data/rodata-style end marker approach: emit the declared BSS size, close it with enddlabel, then leave the padding as unlabeled .space.

image

@AngheloAlf
Copy link
Copy Markdown
Member

Funnily I was a bit worried something like this could happen, but you figured out on your own. I was planning on fixing it after the merge.

Either way, how does the generated assembly looks like? Hopefully you could show the before and after.

@andresj-sanchez
Copy link
Copy Markdown
Contributor Author

Sure.

Before, with autogenerated pad label:

dlabel "m_tpcSingleton__27clsSingleton<11clsPfSystem>", weak
    /* 006E69B8 */ .space 0x04

/* Automatically generated and unreferenced pad */
dlabel D_006E69BC
    /* 006E69BC */ .space 0x04

Bad intermediate version:

dlabel "m_tpcSingleton__27clsSingleton<11clsPfSystem>", weak
    /* 006E69B8 */ .space 0x08

Current version:

dlabel "m_tpcSingleton__27clsSingleton<11clsPfSystem>", weak
    /* 006E69B8 */ .space 0x04
enddlabel "m_tpcSingleton__27clsSingleton<11clsPfSystem>"
    /* 006E69BC */ .space 0x04

So the dummy D_006E69BC label is gone, but the real BSS symbol still keeps its declared 0x04 size.

@AngheloAlf
Copy link
Copy Markdown
Member

Awesome, that's exactly what I had in mind
thank you very much

@andresj-sanchez
Copy link
Copy Markdown
Contributor Author

Thanks to you! and @Mc-muffin lol

@AngheloAlf AngheloAlf merged commit e82c538 into Decompollaborate:1.x Jun 2, 2026
5 checks passed
@AngheloAlf
Copy link
Copy Markdown
Member

fyi I can't make the new release today but I'll merge the pr either way.

I'll probably make the release tomorrow morning

@AngheloAlf
Copy link
Copy Markdown
Member

hey @andresj-sanchez i got some time and made the release

@andresj-sanchez andresj-sanchez deleted the add-bss-pad-option branch June 2, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants