oven-sh/bun · error · MachoError

MissingLinkeditSegment

Error message

MissingLinkeditSegment

What it means

MachoError variant: the __LINKEDIT segment is absent from the Mach-O's segment list. Bun's code-signing/section manipulation must grow or rewrite data inside __LINKEDIT, so an executable without it (fully stripped or unusual layout) cannot be processed.

Solutions

  1. Link the target with a __LINKEDIT segment (standard on macOS executables)
  2. Teach macho.rs to synthesize a __LINKEDIT segment when missing
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/exe_format/macho.rs:18 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/63a2a9af9e4fa74e. Report an issue: GitHub.

Appendix: source

Thrown at src/exe_format/macho.rs:18

use core::mem::size_of;

// `std.macho` types ported locally (see macho_types.rs).
use crate::align_up as align_size;
use crate::macho_types as macho;
use crate::macho_types::{BlobIndex, CodeDirectory, SuperBlob};
use crate::{read_struct, write_struct};

use bun_core::env_var::feature_flag;

const SEGNAME_BUN: [u8; 16] = *b"__BUN\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
const SECTNAME: [u8; 16] = *b"__bun\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";

#[derive(Debug, Copy, Clone, PartialEq, Eq, thiserror::Error, strum::IntoStaticStr)]
pub enum MachoError {
    #[error("InvalidObject")]
    InvalidObject,
    #[error("MissingLinkeditSegment")]
    MissingLinkeditSegment,
    #[error("OffsetOutOfRange")]
    OffsetOutOfRange,
    #[error("OffsetOverflow")]
    OffsetOverflow,
    #[error("InvalidLinkeditOffset")]
    InvalidLinkeditOffset,
    #[error("OverlappingSegments")]
    OverlappingSegments,
    #[error("MissingRequiredSegment")]
    MissingRequiredSegment,
    #[error("OutOfMemory")]
    OutOfMemory,
}
bun_core::oom_from_alloc!(MachoError);

pub struct MachoFile {
    pub(crate) header: macho::mach_header_64,

View on GitHub (pinned to 8c5296ac45)