Skip to content

deps: fix ELF note section parsing alignment in postject - #65029

Closed
KoHaRxnP wants to merge 1 commit into
nodejs:mainfrom
KoHaRxnP:fix-postject-elf-alignment
Closed

deps: fix ELF note section parsing alignment in postject#65029
KoHaRxnP wants to merge 1 commit into
nodejs:mainfrom
KoHaRxnP:fix-postject-elf-alignment

Conversation

@KoHaRxnP

@KoHaRxnP KoHaRxnP commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Fixes an issue where Single Executable Application (SEA) tests fail when Node.js is compiled using LLD (zig cc / clang with lld).

Details

  1. Dynamic Alignment Calculation: postject_find_resource in deps/postject/postject-api.h previously hardcoded note section padding to 4 bytes (roundup(..., 4)). On 64-bit ELF binaries produced by LLD, notes use 8-byte alignment (phdr->p_align), which led to offset misalignment and segment errors. This PR updates the logic to dynamically calculate padding using phdr->p_align.
  2. Corrected Name Comparison Length: Replaced sizeof(name) in strncmp (which evaluated to pointer size) with name_len (strlen(name) / n_namesz check).

Testing

  • Ran python3 tools/test.py --mode=release sea on an ARM64/x86_64 build using zig cc.
  • Result: All 36 tests passed (100%).

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/security-wg
  • @nodejs/single-executable

@nodejs-github-bot nodejs-github-bot added dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. labels Aug 5, 2026

@avivkeller avivkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes to postject belong in it's dedicated repo

@KoHaRxnP

KoHaRxnP commented Aug 5, 2026

Copy link
Copy Markdown
Author

Changes to postject belong in it's dedicated repo

Thank you for the feedback! I have submitted the fix to the upstream repository as requested: nodejs/postject#109

I will close this PR for now and open a dependency update PR once it's merged upstream.

@KoHaRxnP KoHaRxnP closed this Aug 5, 2026
@KoHaRxnP
KoHaRxnP deleted the fix-postject-elf-alignment branch August 8, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants