Skip to content

n64sym: run objdump without a shell - #2

Closed
soft-circles wants to merge 1 commit into
n64brew:previewfrom
soft-circles:n64sym-objdump-argv
Closed

soft-circles wants to merge 1 commit into
n64brew:previewfrom
soft-circles:n64sym-objdump-argv

Conversation

@soft-circles

Copy link
Copy Markdown

n64sym runs objdump through popen(), with $N64_INST and the ELF path pasted unquoted into the command line. A
space (or any other shell metacharacter) in either one breaks symbol generation:

$ N64_INST="/path/spaced dir/n64 sdk" n64sym game.elf game.sym
sh: /path/spaced: No such file or directory
sh: /path/spaced: No such file or directory
Error: objdump failed

$ n64sym "spaced dir/game.elf" game.sym
.../mips64-elf-objdump: 'spaced': No such file
.../mips64-elf-objdump: 'dir/game.elf': No such file
...
Error: objdump failed

addr2line was already run through subprocess_create() with an argument vector, so only the two objdump calls
(-t and -d) were affected.

This PR runs objdump the same way, through two small helpers: objdump_start() and objdump_finish().

  • objdump still inherits the environment, as it did under popen().
  • objdump's stderr is forwarded to n64sym's stderr after its output has been read, so errors such as
    file format not recognized still reach the user.
  • The exit status check is now the same on every host, which removes the __MINGW32__ branch around pclose().
  • With -v, the Running: lines are unchanged.

Testing was done on macOS with Apple clang. The tools build with -Werror. Each check ran on this branch and on
c79a52b42.

  • The .sym output is byte-identical to the unfixed tool on three ROM ELFs. Each ELF was checked with the default
    options, --all, --no-inlines and --all --no-inlines.
  • Each of those runs was repeated with a spaced N64_INST and a relative or absolute spaced ELF path. The output
    matches and stderr is empty.
  • A relative N64_INST works, for example N64_INST=sdk.
  • A path containing $(...) and quotes works.
  • A missing objdump reports Error: cannot run: .../mips64-elf-objdump.
  • A non-ELF input still prints objdump's error, followed by Error: objdump failed.

Windows (MinGW) was not built or tested. subprocess.h already handles argument quoting there for addr2line.

🤖 Generated with Claude Code

n64sym ran objdump through popen() with the N64_INST prefix and the ELF
path pasted unquoted into a shell command line, so a space (or any shell
metacharacter) in either one broke symbol generation, eg:

  sh: /path/with/spaced: No such file or directory
  Error: objdump failed

Run objdump through subprocess_create() with an argument vector, as the
addr2line workers already are. objdump's error output is still forwarded
to stderr, and the generated .sym files are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@soft-circles

Copy link
Copy Markdown
Author

Closing: this was opened prematurely on our side. Apologies for the noise.

@soft-circles
soft-circles deleted the n64sym-objdump-argv branch October 8, 2026 03:07
@soft-circles
soft-circles restored the n64sym-objdump-argv branch October 8, 2026 03:09
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.

1 participant