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

Revive support for old libc versions #780

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ jobs:
./configure --build=linux-x86 --host=linux-x86 ${{ env.GUM_OPTIONS }}
make
- name: Upload Gum devkit
if: ${{ !startsWith(matrix.id, 'linux-') }}
uses: actions/upload-artifact@v4
with:
name: gum-devkit-${{ matrix.id }}
path: build/gum/devkit/
- name: Upload GumJS devkit
if: ${{ !startsWith(matrix.id, 'linux-') }}
uses: actions/upload-artifact@v4
with:
name: gumjs-devkit-${{ matrix.id }}
Expand Down Expand Up @@ -121,16 +123,48 @@ jobs:
./configure ${{ matrix.opts }} ${{ env.GUM_OPTIONS }}
make
- name: Upload Gum devkit
if: ${{ !startsWith(matrix.id, 'linux-') }}
uses: actions/upload-artifact@v4
with:
name: gum-devkit-${{ matrix.id }}
path: build/gum/devkit/
- name: Upload GumJS devkit
if: ${{ !startsWith(matrix.id, 'linux-') }}
uses: actions/upload-artifact@v4
with:
name: gumjs-devkit-${{ matrix.id }}
path: build/bindings/gumjs/devkit/

manylinux:
strategy:
matrix:
arch: [x86, x86_64, x86_64-musl, armhf, arm64, arm64-musl, mips, mipsel, mips64, mips64el]
fail-fast: false
runs-on: ubuntu-latest
container: ghcr.io/frida/x-tools-linux-${{ matrix.arch }}:latest
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build
run: |
./configure --host=$XTOOLS_HOST ${{ env.GUM_OPTIONS }}
make
- name: Upload Gum devkit
uses: actions/upload-artifact@v4
with:
name: gum-devkit-linux-${{ matrix.arch }}
path: build/gum/devkit/
- name: Upload GumJS devkit
uses: actions/upload-artifact@v4
with:
name: gumjs-devkit-linux-${{ matrix.arch }}
path: build/bindings/gumjs/devkit/
- name: Test
if: matrix.arch == 'x86' || matrix.arch == 'x86_64'
run: make test

mobile:
strategy:
matrix:
Expand Down
18 changes: 12 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,18 @@ if ffi_dep.found() and (ffi_dep.type_name() == 'internal' or cc.has_function('ff
cdata.set('HAVE_FRIDA_LIBFFI', 1)
endif

if cc.has_function('pthread_attr_getstack',
args: ['-D_GNU_SOURCE'],
dependencies: [threads_dep],
prefix: '#include <pthread.h>')
cdata.set('HAVE_PTHREAD_ATTR_GETSTACK', 1)
endif
pthread_functions = [
'pthread_attr_getstack',
'pthread_setname_np',
]
foreach f : pthread_functions
if cc.has_function(f,
args: ['-D_GNU_SOURCE'],
dependencies: [threads_dep],
prefix: '#include <pthread.h>')
cdata.set('HAVE_' + f.to_upper(), 1)
endif
endforeach

if host_os_family == 'windows'
extra_deps += cc.find_library('psapi')
Expand Down
2 changes: 1 addition & 1 deletion releng
Submodule releng updated 2 files
+13 −13 devkit.py
+2 −0 machine_spec.py
12 changes: 8 additions & 4 deletions tests/core/process.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008-2023 Ole André Vadla Ravnås <[email protected]>
* Copyright (C) 2008-2024 Ole André Vadla Ravnås <[email protected]>
* Copyright (C) 2008 Christian Berentsen <[email protected]>
* Copyright (C) 2015 Asger Hautop Drewsen <[email protected]>
* Copyright (C) 2023 Grant Douglas <[email protected]>
Expand Down Expand Up @@ -154,8 +154,8 @@ static gboolean thread_found_cb (const GumThreadDetails * details,
gpointer user_data);
static gboolean thread_check_cb (const GumThreadDetails * details,
gpointer user_data);
static gboolean thread_collect_if_matching_id (const GumThreadDetails * details,
gpointer user_data);
G_GNUC_UNUSED static gboolean thread_collect_if_matching_id (
const GumThreadDetails * details, gpointer user_data);
static gboolean module_found_cb (const GumModuleDetails * details,
gpointer user_data);
static gboolean import_found_cb (const GumImportDetails * details,
Expand Down Expand Up @@ -240,6 +240,9 @@ TESTCASE (process_threads_exclude_cloaked)

TESTCASE (process_threads_should_include_name)
{
#if defined (HAVE_LINUX) && !defined (HAVE_PTHREAD_SETNAME_NP)
g_print ("<skipping, libc is too old> ");
#else
volatile gboolean done = FALSE;
GThread * thread;
GumThreadDetails d = { 0, };
Expand All @@ -256,6 +259,7 @@ TESTCASE (process_threads_should_include_name)
g_thread_join (thread);

g_free ((gpointer) d.name);
#endif
}

static gboolean
Expand Down Expand Up @@ -1146,7 +1150,7 @@ sleeping_dummy (gpointer data)
* to GLib potentially having been prebuilt against an old libc. Therefore we
* set the name manually using pthreads.
*/
#ifdef HAVE_LINUX
#if defined (HAVE_LINUX) && defined (HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np (pthread_self (), sync_data->name);
#endif

Expand Down
16 changes: 10 additions & 6 deletions tests/gumjs/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ static gpointer run_stalked_through_target_function (gpointer data);
#endif

static gpointer sleeping_dummy (gpointer data);
static gpointer named_sleeper (gpointer data);
G_GNUC_UNUSED static gpointer named_sleeper (gpointer data);

static gpointer invoke_target_function_int_worker (gpointer data);
static gpointer invoke_target_function_trigger (gpointer data);
Expand Down Expand Up @@ -5052,21 +5052,24 @@ sleeping_dummy (gpointer data)

TESTCASE (process_threads_have_names)
{
#if defined (HAVE_LINUX) && !defined (HAVE_PTHREAD_SETNAME_NP)
g_print ("<skipping, libc is too old> ");
#else
GumNamedSleeperContext ctx;
GThread * thread;

#ifdef HAVE_LINUX
# ifdef HAVE_LINUX
if (!check_exception_handling_testable ())
return;
#endif
# endif

#ifdef HAVE_MIPS
# ifdef HAVE_MIPS
if (!g_test_slow ())
{
g_print ("<skipping, run in slow mode> ");
return;
}
#endif
# endif

ctx.controller_messages = g_async_queue_new ();
ctx.sleeper_messages = g_async_queue_new ();
Expand All @@ -5085,6 +5088,7 @@ TESTCASE (process_threads_have_names)

g_async_queue_unref (ctx.sleeper_messages);
g_async_queue_unref (ctx.controller_messages);
#endif
}

static gpointer
Expand All @@ -5097,7 +5101,7 @@ named_sleeper (gpointer data)
* to GLib potentially having been prebuilt against an old libc. Therefore we
* set the name manually using pthreads.
*/
#ifdef HAVE_LINUX
#if defined (HAVE_LINUX) && defined (HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np (pthread_self (), "named-sleeper");
#endif

Expand Down