Skip to content

Commit 604edc8

Browse files
authored
fix(autopack): ensure shared library with interpret section is detected as AutopackKind::SharedLibrary (#125)
Signed-off-by: Jérémy Audiger <jeremy.audiger@icloud.com>
1 parent b38c728 commit 604edc8

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • crates/brioche-autopack/src

crates/brioche-autopack/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,16 @@ fn autopack_kind(path: &Path) -> eyre::Result<Option<AutopackKind>> {
439439
return Ok(None);
440440
};
441441

442-
// Only ET_EXEC and ET_DYN can potentially be packed
442+
// Only ET_EXEC and ET_DYN can potentially be packed.
443+
// Check if it's a library first. A shared library can
444+
// have an interpreter section and it should be packed
445+
// as SharedLibrary, not DynamicBinary.
443446
match elf_object.header.e_type {
444447
goblin::elf::header::ET_EXEC | goblin::elf::header::ET_DYN => {
445-
if elf_object.interpreter.is_some() {
446-
Ok(Some(AutopackKind::DynamicBinary))
447-
} else if elf_object.is_lib {
448+
if elf_object.is_lib {
448449
Ok(Some(AutopackKind::SharedLibrary))
450+
} else if elf_object.interpreter.is_some() {
451+
Ok(Some(AutopackKind::DynamicBinary))
449452
} else {
450453
Ok(None)
451454
}

0 commit comments

Comments
 (0)