Skip to content

Support dt needed in linker#49

Merged
katsyoshi merged 10 commits intomainfrom
support-dt-needed-in-linker
Apr 15, 2026
Merged

Support dt needed in linker#49
katsyoshi merged 10 commits intomainfrom
support-dt-needed-in-linker

Conversation

@katsyoshi
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@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

Here are some automated review suggestions for this pull request.

Reviewed commit: 75d81c16ca

ℹ️ 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".

Comment on lines +251 to +255
if _start.nil?
main_offset = entry_sym.nil? ? 0 : entry_sym.value + start_len
start_bytes[1, 4] = num2bytes((main_offset - 5), 4) if @executable
text_section.body.prepend(start_bytes.pack("C*"))
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Set entrypoint to resolved _start address

When _start exists, this branch skips inserting the generated startup stub, but no replacement entry address is propagated; the writer still defaults e_entry to the start of .text. If _start is not at offset 0 in merged .text (for example, when its object is not first in inputs), the process starts at the wrong instructions and can crash immediately.

Useful? React with 👍 / 👎.

sym_by_elf = Hash.new { |h, k| h[k] = [] }
dynstr, dynsym = build_shared_dynamic_sections if dynamic?

start_len = 0 if @elf_objs.any? { |elf| elf.find_by_name(".symtab").body.find { |sym| sym.name_string == "_start" } }
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require defined _start before enabling custom entry mode

This _start probe matches by name only, so an undefined _start reference (shndx == 0) in any input object will disable the normal main startup path. That can produce an executable without a valid startup routine even though no _start definition was provided; restrict the detection to symbols that are actually defined.

Useful? React with 👍 / 👎.

@katsyoshi katsyoshi merged commit 501c016 into main Apr 15, 2026
2 checks passed
@katsyoshi katsyoshi deleted the support-dt-needed-in-linker branch April 15, 2026 14:37
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