Do not warn of missing PT_GNU_RELRO segment when custom DSO filter used
authorKjetil Matheussen <k.s.matheussen@notam02.no>
Fri, 15 Jul 2016 12:00:26 +0000 (14:00 +0200)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 22 Jul 2016 17:27:02 +0000 (20:27 +0300)
It is most likely that it is not found just because the segment had
been excluded.

Alternatively, we could have registered all segments, and checked the
callback afterwards, but then we could break programs that rely on
GC_has_static_roots_func to avoid overflowing the maximum number of
roots.  In addition, it would make the logic slightly more
complicated, probably without a very good reason since the chance of
this warning to show without the segment being excluded is likely to
be none.

* dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynlib_callback):
Do not call WARN() if GC_has_static_roots callback is set.

dyn_load.c

index b6880ab..c0f9c5b 100644 (file)
@@ -506,8 +506,11 @@ STATIC int GC_register_dynlib_callback(struct dl_phdr_info * info,
                 }
                 break;
               }
-              if (j == 0) WARN("Failed to find PT_GNU_RELRO segment"
-                               " inside PT_LOAD region\n", 0);
+              if (0 == j && 0 == GC_has_static_roots)
+                WARN("Failed to find PT_GNU_RELRO segment"
+                     " inside PT_LOAD region\n", 0);
+              /* No warning reported in case of the callback is present */
+              /* because most likely the segment has been excluded.     */
             }
         }