From b0e1bd239fd09b7376d02b3b135a55222490ee77 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 26 Sep 2006 16:21:28 -0700 Subject: [PATCH] Pack shell scripts for Linux only (and not *BSD, for example [no stub!]) --- src/p_lx_exc.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/p_lx_exc.cpp b/src/p_lx_exc.cpp index 34f0b59e..2c544b23 100644 --- a/src/p_lx_exc.cpp +++ b/src/p_lx_exc.cpp @@ -55,12 +55,13 @@ **************************************************************************/ PackLinuxI386::PackLinuxI386(InputFile *f) : super(f), - ei_osabi(0), osabi_note(NULL) + ei_osabi(Elf32_Ehdr::ELFOSABI_LINUX), osabi_note(NULL) { } PackBSDI386::PackBSDI386(InputFile *f) : super(f) { + ei_osabi = 0; // not ELFOSABI_LINUX } static const @@ -560,15 +561,17 @@ bool PackLinuxI386::canPack() // FIXME: N_TRSIZE, N_DRSIZE // FIXME: check for aout shared libraries } -#if defined(__linux__) - // only compress scripts when running under Linux - else if (!memcmp(buf, "#!/", 3)) // #!/bin/sh - exetype = -1; - else if (!memcmp(buf, "#! /", 4)) // #! /bin/sh - exetype = -1; - else if (!memcmp(buf, "\xca\xfe\xba\xbe", 4)) // Java bytecode - exetype = -2; -#endif + else { // shell scripts and other interpreters + if (Elf32_Ehdr::ELFOSABI_LINUX!=ei_osabi) { + return false; // so far, only Linux has runtime stub for shell + } + else if (!memcmp(buf, "#!/", 3)) // #!/bin/sh + exetype = -1; + else if (!memcmp(buf, "#! /", 4)) // #! /bin/sh + exetype = -1; + else if (!memcmp(buf, "\xca\xfe\xba\xbe", 4)) // Java bytecode + exetype = -2; + } return super::canPack(); }