Skip to content

Conversation

@katsyoshi
Copy link
Owner

No description provided.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

main_sym = symtab_section.body.find { |sym| sym.name_string == "main" }
raise Caotral::Binary::ELF::Error, "main function not found" if executable && main_sym.nil?
main_offset = main_sym.nil? ? 0 : main_sym.value + start_len
start_bytes[1, 4] = num2bytes((main_offset - 5), 4)
text_section.body.prepend(start_bytes.pack("C*"))

P2 Badge Skip _start stub when executable is false

With the new executable: false option, main_sym can be nil, but the builder still patches and prepends the _start stub. When main_sym is nil, main_offset becomes 0 and start_bytes gets a rel32 of -5, producing a call-to-self stub that is meaningless for non-executable output and shifts all .text symbols. This means linking a shared library or non-executable with linker: "self", executable: false will still embed an invalid entry stub rather than leaving the code intact, which is likely unintended and can corrupt the resulting artifact. Consider skipping the stub and symbol offset adjustment entirely when executable is false.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@katsyoshi katsyoshi merged commit 7916aa5 into main Jan 18, 2026
2 checks passed
@katsyoshi katsyoshi deleted the chmod-755-in-linker branch January 18, 2026 09:29
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