[gimp] libgimpbase: fix _gimp_reloc_init_lib().



commit 8586f16f3161d5f4a8e5957e2a881165f9037008
Author: Jehan <jehan girinstud io>
Date:   Sat Mar 20 20:36:59 2021 +0100

    libgimpbase: fix _gimp_reloc_init_lib().
    
    While testing the relocatable code paths, I realized that
    _br_find_exe_for_symbol() was always returning NULL. The reason is that
    our code looking at /proc/self/maps was expecting that the searched
    pointer would be in a "r-xp" memory region. On my machine though, it was
    in a "r--p" region.
    Maybe in some cases or some older kernel, the "r-xp" permission is/was
    right, I have no idea, so now let's just not make any assumption on the
    region's permission, where we expect to find our static string, i.e.
    let's not do any test on the region permission anymore.

 libgimpbase/gimpreloc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/libgimpbase/gimpreloc.c b/libgimpbase/gimpreloc.c
index 48f3b5048d..bee9d062a3 100644
--- a/libgimpbase/gimpreloc.c
+++ b/libgimpbase/gimpreloc.c
@@ -201,7 +201,14 @@ _br_find_exe_for_symbol (const void *symbol, GimpBinrelocInitError *error)
         break;
 
       /* Sanity check. */
-      if (strstr (line, " r-xp ") == NULL || strchr (line, '/') == NULL)
+      /* XXX Early versions of this code would check that the mapped
+       * region was with r-xp permission. It might have been true at
+       * some point in time, but last I tested, the searched pointer was
+       * in a r--p region for libgimpbase. Thus _br_find_exe_for_symbol()
+       * would fail to find the executable's path.
+       * So now we don't test the region's permission anymore.
+       */
+      if (strchr (line, '/') == NULL)
         continue;
 
       /* Parse line. */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]