oven-sh/bun · error · ElfError

BunSectionNotFound

BunSectionNotFound

Error message

BunSectionNotFound

What it means

ElfError variant: the `__bun` section that Bun uses to store appended module bytecode was not found while scanning the executable's section headers. It fires when stamping an ELF that was not produced by Bun's linker (or whose section table was stripped), so there is no anchor point to write the bundle into.

Solutions

  1. Use a Bun-produced target executable that contains the __bun section
  2. If the section was stripped, rebuild the target or re-add the section with the expected name/type before stamping
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/exe_format/elf.rs:29 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/31fd8f7504bf1877. Report an issue: GitHub.

Appendix: source

Thrown at src/exe_format/elf.rs:29

use core::sync::atomic::{AtomicU8, Ordering};

#[cfg(any(target_os = "linux", target_os = "android"))]
use bun_core::env_var;
use bun_core::{slice_to_nul, strings};

use crate::{align_up, read_struct, write_struct};

bun_core::declare_scope!(elf, visible);

#[derive(Debug, thiserror::Error, strum::IntoStaticStr)]
pub enum ElfError {
    #[error("InvalidElfFile")]
    InvalidElfFile,
    #[error("Not64Bit")]
    Not64Bit,
    #[error("NotLittleEndian")]
    NotLittleEndian,
    #[error("BunSectionNotFound")]
    BunSectionNotFound,
    #[error("NoWritableLoadSegment")]
    NoWritableLoadSegment,
    #[error("NewVaddrCollides")]
    NewVaddrCollides,
}

pub struct ElfFile {
    pub data: Vec<u8>,
}

impl ElfFile {
    pub fn init(data: Vec<u8>) -> Result<Box<ElfFile>, ElfError> {
        validate_elf64_le(&data)?;
        Ok(Box::new(ElfFile { data }))
    }

    /// If PT_INTERP points into a Nix/Guix store path, rewrite it to the

View on GitHub (pinned to 8c5296ac45)