Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPX fails to compress native Rust library for Armv7 Android #835

Open
marsrcm opened this issue Jul 1, 2024 · 1 comment
Open

UPX fails to compress native Rust library for Armv7 Android #835

marsrcm opened this issue Jul 1, 2024 · 1 comment

Comments

@marsrcm
Copy link

marsrcm commented Jul 1, 2024

This issue tracker is ONLY used for reporting bugs.
Please use stackoverflow for supporting issues.

What's the problem (or question)?

UPX fails to compress a shared Rust library built for the Armv7 architecture (linked with Android Studio's NDK linker for Arm).
Instead, it terminates with the following output

                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2024
UPX git-17cf73  Markus Oberhumer, Laszlo Molnar & John Reiser   Jun 19th 2024

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
upx: librust_native.so: CantPackException: bad DT_GNU_HASH n_bucket{0x1} <= buckets[0]{0x1c}


Packed 0 files.

WARNING: this is an unstable beta version - use for testing only! Really.

Interestingly, this problem does not occur when the library is built for Armv8. In that case, UPX compresses it successfully and it runs without problems.

What should have happened?

UPX should have successfully packed the library.

Do you have an idea for a solution?

Unfortunately not.

How can we reproduce the issue?

  1. Download and unpack librust_native.so.gz

  2. Try to compress librust_native.so with upx --android-shlib (though packing without the android-shlib parameter has the same effect)

  3. UPX should be unable to pack the library

The librust_native.so binary is a simple library, built to evaluate UPX for our usecase, with the following source code:

#[macro_use] extern crate log;
extern crate android_logger;

use std::os::raw::c_void;
use jni::JavaVM;
use jni::sys::{jint, JNI_VERSION_1_6};
use log::LevelFilter;
use android_logger::{Config};

#[no_mangle]
pub fn _init() { }

#[allow(non_snake_case)]
#[no_mangle]
pub extern "system" fn JNI_OnLoad(_: JavaVM, _: *mut c_void) -> jint {

    android_logger::init_once(
        Config::default().with_max_level(LevelFilter::Trace)
    );
    info!("Hello from Rust!");

    return JNI_VERSION_1_6;
}

We used rustc version 1.78.0 to compile it.

Please tell us details about your environment.

  • UPX version used (upx --version):

upx 4.2.4-devel.42+git-17cf7300

The same error occurs with the regular 4.2.4 release

  • Host Operating System and version:

EndeavourOS 6.9.6-arch1-1

  • Host CPU architecture:

x86_64

  • Target Operating System and version:

Android 14.0, API version 34

  • Target CPU architecture:

Armv7

Copy link

github-actions bot commented Oct 7, 2024

This issue is stale because it has been open for 90 days with no activity. Please remove the stale label or add a comment or this issue will be closed in 30 days.

@github-actions github-actions bot added the stale label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants