Option --android-oid for Android < 10

modified:   main.cpp
	modified:   options.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.h
This commit is contained in:
John Reiser 2024-11-18 16:06:45 -08:00
parent 3d9fc7ab53
commit 7ef018fed0
5 changed files with 14 additions and 3 deletions

View File

@ -739,6 +739,9 @@ static int do_option(int optc, const char *arg) {
case 677:
opt->o_unix.force_pie = true;
break;
case 678:
opt->o_unix.android_old = true;
break;
// ps1/exe
case 670:
opt->ps1_exe.boot_only = true;
@ -953,6 +956,7 @@ int main_get_options(int argc, char **argv) {
{"preserve-build-id", 0, N, 675},
{"android-shlib", 0, N, 676},
{"force-pie", 0x90, N, 677},
{"android-old", 0, N, 678},
// ps1/exe
{"boot-only", 0x90, N, 670},
{"no-align", 0x90, N, 671},

View File

@ -159,6 +159,7 @@ struct Options final {
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
bool preserve_build_id; // copy the build-id to the compressed binary
bool android_shlib; // keep some ElfXX_Shdr for dlopen()
bool android_old; // < Android_10 ==> no memfd_create, inconsistent __NR_ftruncate
bool force_pie; // choose DF_1_PIE instead of is_shlib
} o_unix;
struct {

View File

@ -5413,8 +5413,8 @@ int PackLinuxElf32::pack2_shlib(OutputFile *fo, Filter &ft, unsigned pre_xct_top
fi->seek(p_offset, SEEK_SET);
fi->read(ibuf, p_filesz); total_in += p_filesz;
MemBuffer buf2; buf2.allocForCompression(p_filesz);
c_len = pack2_shlib_overlay_compress(buf2, ibuf, u_len);
pack2_shlib_overlay_write(fo, buf2, u_len, c_len);
c_len = pack2_shlib_overlay_compress(buf2, ibuf, p_filesz);
pack2_shlib_overlay_write(fo, buf2, p_filesz, c_len);
Elf32_Phdr *lo_phdr = k + (Elf32_Phdr *)(1+ (Elf32_Ehdr *)&lowmem[0]);
set_te32(&lo_phdr->p_type, Elf32_Phdr::PT_NULL);
}

View File

@ -154,6 +154,12 @@ protected:
virtual void asl_pack2_Shdrs(OutputFile *, unsigned pre_xct_top); // AndroidSharedLibrary processes Shdrs
virtual void asl_slide_Shdrs(); // by so_slide if above xct_off
virtual int pack2(OutputFile *, Filter &) override; // append compressed data
virtual int pack2_shlib(OutputFile *fo, Filter &ft, unsigned pre_xct_top);
virtual unsigned pack2_shlib_overlay_init(OutputFile *fo);
virtual unsigned pack2_shlib_overlay_compress(MemBuffer &obuf,
MemBuffer &ibuf, unsigned u_len);
virtual unsigned pack2_shlib_overlay_write(OutputFile *fo, MemBuffer &obuf,
unsigned hdr_u_len, unsigned hdr_c_len);
virtual off_t pack3(OutputFile *, Filter &) override; // append loader
virtual void pack4(OutputFile *, Filter &) override; // append pack header
virtual unsigned forward_Shdrs(OutputFile *fo, Elf32_Ehdr *ehdro);

View File

@ -100,7 +100,7 @@ protected:
MemBuffer pt_dynamic;
int sz_dynamic;
unsigned b_len; // total length of b_info blocks
unsigned b_len; // total length of b_info blocks FIXME: unused
unsigned methods_used; // bitmask of compression methods
unsigned szb_info; // 3*4 (sizeof b_info); or 2*4 if ancient
unsigned saved_opt_android_shlib;