mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
fix(compile): use 8-byte header for embedded section to ensure bytecode alignment (#25377)
## Summary - Change the size header in embedded Mach-O and PE sections from `u32` (4 bytes) to `u64` (8 bytes) - Ensures the data payload starts at an 8-byte aligned offset, which is required for the bytecode cache ## Test plan - [x] Test standalone compilation on macOS - [ ] Test standalone compilation on Windows 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -119,7 +119,7 @@ pub const StandaloneModuleGraph = struct {
|
||||
};
|
||||
|
||||
const Macho = struct {
|
||||
pub extern "C" fn Bun__getStandaloneModuleGraphMachoLength() ?*align(1) u32;
|
||||
pub extern "C" fn Bun__getStandaloneModuleGraphMachoLength() ?*align(1) u64;
|
||||
|
||||
pub fn getData() ?[]const u8 {
|
||||
if (Bun__getStandaloneModuleGraphMachoLength()) |length| {
|
||||
@@ -127,8 +127,10 @@ pub const StandaloneModuleGraph = struct {
|
||||
return null;
|
||||
}
|
||||
|
||||
// BlobHeader has 8 bytes size (u64), so data starts at offset 8.
|
||||
const data_offset = @sizeOf(u64);
|
||||
const slice_ptr: [*]const u8 = @ptrCast(length);
|
||||
return slice_ptr[4..][0..length.*];
|
||||
return slice_ptr[data_offset..][0..length.*];
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -136,7 +138,7 @@ pub const StandaloneModuleGraph = struct {
|
||||
};
|
||||
|
||||
const PE = struct {
|
||||
pub extern "C" fn Bun__getStandaloneModuleGraphPELength() u32;
|
||||
pub extern "C" fn Bun__getStandaloneModuleGraphPELength() u64;
|
||||
pub extern "C" fn Bun__getStandaloneModuleGraphPEData() ?[*]u8;
|
||||
|
||||
pub fn getData() ?[]const u8 {
|
||||
|
||||
Reference in New Issue
Block a user