Skip to content

fix: ELF note section parsing alignment and name length comparison - #109

Open
KoHaRxnP wants to merge 2 commits into
nodejs:mainfrom
KoHaRxnP:main
Open

fix: ELF note section parsing alignment and name length comparison#109
KoHaRxnP wants to merge 2 commits into
nodejs:mainfrom
KoHaRxnP:main

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).

@KoHaRxnP KoHaRxnP changed the title Fix ELF note section parsing alignment and name length comparison fix: ELF note section parsing alignment and name length comparison Aug 5, 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.

1 participant