Skip to content

Fix Linux native installation support#644

Merged
bl-ue merged 2 commits intomainfrom
fix-linux-native-installation-support-032826
Mar 29, 2026
Merged

Fix Linux native installation support#644
bl-ue merged 2 commits intomainfrom
fix-linux-native-installation-support-032826

Conversation

@signadou
Copy link
Copy Markdown
Member

@signadou signadou commented Mar 29, 2026

Summary by CodeRabbit

  • New Features

    • Support for Bun's new ELF binary format in extraction and repacking.
  • Bug Fixes

    • Improved Linux native installation handling and fallback behavior for ELF binaries.
  • Chores

    • Updated node-lief dependency version.
  • Documentation

    • Added changelog entry for the Linux native installation fix.

@signadou signadou requested a review from bl-ue March 29, 2026 15:25
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 19f056e7-4e58-44b8-be0d-f98fa317fdd6

📥 Commits

Reviewing files that changed from the base of the PR and between 83c472a and dbde146.

📒 Files selected for processing (1)
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

Updated node-lief dependency and extended native installation logic to support extracting and repacking Bun data stored in a new .bun ELF section, while preserving fallback behavior for the legacy ELF overlay format.

Changes

Cohort / File(s) Summary
Dependency Update
package.json
Bumped node-lief from ^1.0.0 to ^1.1.1.
ELF Binary Format Support
src/nativeInstallation.ts
Added extractBunDataFromELFSection() returning `BunData
Changelog
CHANGELOG.md
Added Unreleased entry: “Fix Linux native installation support (#644)”.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant getBunData
    participant extractELFSection
    participant extractELFOverlay
    participant LIEF as LIEF Library

    Caller->>getBunData: getBunData(elfBinary)
    activate getBunData

    getBunData->>extractELFSection: extractBunDataFromELFSection(elfBinary)
    activate extractELFSection
    rect rgba(100,150,200,0.5)
        note over extractELFSection: Read `.bun` section [u64 len][payload]
        extractELFSection->>LIEF: read section contents
        LIEF-->>extractELFSection: section data or null
    end
    extractELFSection-->>getBunData: BunData | null
    deactivate extractELFSection

    alt section present
        getBunData-->>Caller: BunData
    else section missing/invalid
        rect rgba(200,150,100,0.5)
            note over getBunData: Fall back to overlay extraction
            getBunData->>extractELFOverlay: extractBunDataFromELFOverlay(elfBinary)
            activate extractELFOverlay
            extractELFOverlay->>LIEF: read ELF overlay
            LIEF-->>extractELFOverlay: BunData
            extractELFOverlay-->>getBunData: BunData
            deactivate extractELFOverlay
        end
        getBunData-->>Caller: BunData
    end

    deactivate getBunData

    Caller->>Caller: repackNativeInstallation()
    alt sectionHeaderSize provided
        rect rgba(150,200,100,0.5)
            note over Caller: Use repackELFSection() — rebuild `.bun` section, find PT_LOAD, align sizes, patch vaddr/size
        end
    else
        rect rgba(200,150,100,0.5)
            note over Caller: Use repackELFOverlay() — legacy overlay repack
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • bl-ue

Poem

🐰 I dug a little .bun tonight,
tucked bytes in sections snug and tight,
if old overlays come to play,
I hop back to keep them safe—hooray! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix Linux native installation support' directly aligns with the main changes in the pull request, which introduce support for extracting and repacking Bun ELF format on Linux systems.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-linux-native-installation-support-032826

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/nativeInstallation.ts`:
- Around line 1313-1318: Guard against a zero or falsy segment alignment before
computing pageSize/alignedSize: check bunSegment.alignment (used to set
pageSize) and if it's 0 or not a positive number, substitute a safe fallback
(for example 1 or a default page size) or compute alignedSize directly from
newSectionData.length; then compute alignedSize using that non-zero pageSize and
assign bunSegment.fileSize and bunSegment.virtualSize. Reference:
bunSegment.alignment, pageSize, alignedSize, newSectionData.length,
bunSegment.fileSize, bunSegment.virtualSize.
- Around line 1325-1330: The call to elfBinary.patchAddress currently passes a
Buffer (vaddrPatch) but node-lief's patchAddress expects a number[]; change the
second argument to an array by converting the buffer (vaddrPatch) to a number
array (e.g. use Array.from(vaddrPatch)) when calling patchAddress with
bunCompiledVaddr so the types match; update the code that creates vaddrPatch
(Buffer.alloc and writeBigUInt64LE with bunSectionVaddr) to keep the buffer but
pass Array.from(vaddrPatch) into elfBinary.patchAddress.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35b537a3-22fa-467e-8633-33d5f9261698

📥 Commits

Reviewing files that changed from the base of the PR and between fc227b4 and 83c472a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json
  • src/nativeInstallation.ts

@bl-ue bl-ue merged commit 04e8e3b into main Mar 29, 2026
2 checks passed
@bl-ue bl-ue deleted the fix-linux-native-installation-support-032826 branch March 29, 2026 16:35
basekevin pushed a commit that referenced this pull request Apr 2, 2026
@coderabbitai coderabbitai bot mentioned this pull request Apr 2, 2026
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