]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD: changes for building with GCC
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 23 Feb 2024 08:33:24 +0000 (09:33 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 23 Feb 2024 08:33:24 +0000 (09:33 +0100)
Use MARK_STACK_NO_EXEC (it's a null macro on non-linux platforms).
GCC complains if it's not used.

parse_procselfmaps yet again.

The hack that I added in 6fdd59afb5e473b30e7ad1fbadcf9a397253fed4
only works for clang/ld.lld. This change makes it also work with
GCC/ld.bfd. Still a hack though.

coregrind/m_aspacemgr/aspacemgr-linux.c
include/pub_tool_basics_asm.h

index 22eefd30d4a9353712be7c01eda16393ecc858e5..da3db87fcdc088a056879821c9a2f18464c66409 100644 (file)
@@ -3981,6 +3981,17 @@ static void parse_procselfmaps (
    Int    oid[4];
    SysRes sres;
    Int map_count = 0;
+   // this assumes that compiling with clang uses ld.lld which produces 3 LOAD segements
+   // and that compiling with GCC uses ld.bfd which produces 2 LOAD segments
+#if defined(__clang__)
+   Int const rx_map = 1;
+   Int const rw_map = 2;
+#elif defined(__GNUC__)
+   Int const rx_map = 0;
+   Int const rw_map = 1;
+#else
+#error("unsupported compiler")
+#endif
    // could copy the whole kinfo_vmentry but it is 1160 bytes
    char   *rx_filename = NULL;
    ULong  rx_dev = 0U;
@@ -4024,7 +4035,7 @@ static void parse_procselfmaps (
 
       map_count = (p - (char *)procmap_buf)/kve->kve_structsize;
 
-      if (tool_read_maps && map_count == 2) {
+      if (tool_read_maps && map_count == rw_map) {
          aspacem_assert((prot & (VKI_PROT_READ | VKI_PROT_WRITE)) == (VKI_PROT_READ | VKI_PROT_WRITE));
          filename = rx_filename;
          dev = rx_dev;
@@ -4041,7 +4052,7 @@ static void parse_procselfmaps (
                            foffset, filename, tool_read_maps && map_count == 2 );
       }
 
-      if (tool_read_maps && map_count == 1) {
+      if (tool_read_maps && map_count == rx_map) {
          aspacem_assert((prot & (VKI_PROT_READ | VKI_PROT_EXEC)) == (VKI_PROT_READ | VKI_PROT_EXEC));
          rx_filename = filename;
          rx_dev = dev;
index 894fd1f5f02be5933907675f68186090cd5a02d5..99f2ab18e7571278fa0706a9c605eca90c208c41 100644 (file)
@@ -60,7 +60,7 @@
    The call to MARK_STACK_NO_EXEC should be put unconditionally
    at the end of all asm source files.
 */
-#if defined(VGO_linux)
+#if defined(VGO_linux) || defined(VGO_freebsd)
 #  if defined(VGA_arm)
 #    define MARK_STACK_NO_EXEC .section .note.GNU-stack,"",%progbits
 #  else