aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cachegrind/tests/x86/fpu-28-108.S6
-rw-r--r--coregrind/m_cpuid.S2
-rw-r--r--coregrind/pub_core_basics.h1
-rw-r--r--coregrind/pub_core_basics_asm.h8
-rw-r--r--include/pub_tool_basics.h24
-rw-r--r--include/pub_tool_basics_asm.h28
-rw-r--r--massif/tests/ignored.c2
-rw-r--r--tests/asm.h2
8 files changed, 47 insertions, 26 deletions
diff --git a/cachegrind/tests/x86/fpu-28-108.S b/cachegrind/tests/x86/fpu-28-108.S
index f655c00f7..54b2da650 100644
--- a/cachegrind/tests/x86/fpu-28-108.S
+++ b/cachegrind/tests/x86/fpu-28-108.S
@@ -4,6 +4,8 @@
/* Useful listing:
gcc -o tests/fpu_28_108 tests/fpu_28_108.S -Wa,-a */
+#include "tests/asm.h"
+
.data
fooble:
.long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
@@ -12,8 +14,8 @@ fooble:
bar:
.text
-.globl main
-main:
+.globl VG_SYM_ASM(main)
+VG_SYM_ASM(main):
fstsw fooble
fsave fooble
frstor fooble
diff --git a/coregrind/m_cpuid.S b/coregrind/m_cpuid.S
index 37e609f01..d7dcff325 100644
--- a/coregrind/m_cpuid.S
+++ b/coregrind/m_cpuid.S
@@ -143,7 +143,7 @@
ret
#endif
-#if defined(VGA_x86) || defined(VGA_amd64)
+#if defined(VGO_linux)
/* Let the linker know we don't need an executable stack */
.section .note.GNU-stack,"",@progbits
#endif
diff --git a/coregrind/pub_core_basics.h b/coregrind/pub_core_basics.h
index 99053f589..eb38f6b8f 100644
--- a/coregrind/pub_core_basics.h
+++ b/coregrind/pub_core_basics.h
@@ -37,7 +37,6 @@
// everywhere.
//--------------------------------------------------------------------
-#include "pub_core_basics_asm.h"
#include "pub_tool_basics.h"
/* ---------------------------------------------------------------------
diff --git a/coregrind/pub_core_basics_asm.h b/coregrind/pub_core_basics_asm.h
index d413f4524..a71e8ffec 100644
--- a/coregrind/pub_core_basics_asm.h
+++ b/coregrind/pub_core_basics_asm.h
@@ -1,7 +1,6 @@
/*--------------------------------------------------------------------*/
-/*--- Header imported directly by every core asm file, and ---*/
-/*--- (via pub_core_basics.h) by every core C file. ---*/
+/*--- Header imported directly by every core asm file. ---*/
/*--- pub_core_basics_asm.h ---*/
/*--------------------------------------------------------------------*/
@@ -34,9 +33,8 @@
#define __PUB_CORE_BASICS_ASM_H
//--------------------------------------------------------------------
-// PURPOSE: This header should be imported by every single asm and
-// (indirectly) by every C file in the core. It contains really basic
-// things needed everywhere.
+// PURPOSE: This header should be imported by every single asm file
+// in the core. It contains really basic things needed everywhere.
//--------------------------------------------------------------------
#include "pub_tool_basics_asm.h"
diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h
index a21b0b604..9bff837fc 100644
--- a/include/pub_tool_basics.h
+++ b/include/pub_tool_basics.h
@@ -46,9 +46,6 @@
// Addr32, Addr64, HWord, HChar, Bool, False and True.
#include "libvex_basictypes.h"
-// For the VG_() macro
-#include "pub_tool_basics_asm.h"
-
// For varargs types
#include <stdarg.h>
@@ -57,6 +54,27 @@
/* ---------------------------------------------------------------------
+ symbol prefixing
+ ------------------------------------------------------------------ */
+
+// All symbols externally visible from Valgrind are prefixed
+// as specified here to avoid namespace conflict problems.
+//
+// VG_ is for symbols exported from modules. ML_ (module-local) is
+// for symbols which are not intended to be visible outside modules,
+// but which cannot be declared as C 'static's since they need to be
+// visible across C files within a given module. It is a mistake for
+// a ML_ name to appear in a pub_core_*.h or pub_tool_*.h file.
+// Likewise it is a mistake for a VG_ name to appear in a priv_*.h
+// file.
+
+#define VGAPPEND(str1,str2) str1##str2
+
+#define VG_(str) VGAPPEND(vgPlain_, str)
+#define ML_(str) VGAPPEND(vgModuleLocal_, str)
+
+
+/* ---------------------------------------------------------------------
builtin types
------------------------------------------------------------------ */
diff --git a/include/pub_tool_basics_asm.h b/include/pub_tool_basics_asm.h
index 426ce82b3..201c1b5af 100644
--- a/include/pub_tool_basics_asm.h
+++ b/include/pub_tool_basics_asm.h
@@ -1,7 +1,6 @@
/*--------------------------------------------------------------------*/
-/*--- Header imported directly by every tool asm file, and ---*/
-/*--- (via pub_tool_basics.h) by every tool C file. ---*/
+/*--- Header imported directly by every tool asm file. ---*/
/*--- pub_tool_basics_asm.h ---*/
/*--------------------------------------------------------------------*/
@@ -33,19 +32,22 @@
#ifndef __PUB_TOOL_BASICS_ASM_H
#define __PUB_TOOL_BASICS_ASM_H
-/* All symbols externally visible from Valgrind are prefixed
- as specified here to avoid namespace conflict problems. */
+// See pub_tool_basics.h for the purpose of these macros.
+//
+// Note that although the macros here (which are used in asm files) have the
+// same name as those in pub_tool_basics.h (which are used in C files), they
+// have different definitions. Actually, on Linux the definitions are the
+// same, but on Darwin they are different. The reason is that C names on
+// Darwin always get a '_' prepended to them by the compiler. But in order to
+// refer to them from asm code, we have to add the '_' ourselves. Having two
+// versions of these macros makes that difference transparent, so we can use
+// VG_/ML_ in both asm and C files.
+//
+// Note also that the exact prefixes used have to match those used in
+// pub_tool_basics.h.
#define VGAPPEND(str1,str2) str1##str2
-
-/* VG_ is for symbols exported from modules. ML_ (module-local) is
- for symbols which are not intended to be visible outside modules,
- but which cannot be declared as C 'static's since they need to be
- visible across C files within a given module. It is a mistake for
- a ML_ name to appear in a pub_core_*.h or pub_tool_*.h file.
- Likewise it is a mistake for a VG_ name to appear in a priv_*.h
- file.
-*/
+
#define VG_(str) VGAPPEND(vgPlain_, str)
#define ML_(str) VGAPPEND(vgModuleLocal_, str)
diff --git a/massif/tests/ignored.c b/massif/tests/ignored.c
index be16f69c5..8b1bf08ca 100644
--- a/massif/tests/ignored.c
+++ b/massif/tests/ignored.c
@@ -45,5 +45,7 @@ int main(void)
ignore2(x, ignored_x);
x = realloc(ignored_x, 0); // equivalent to 'free(ignored_x)'.
+
+ return 0;
}
diff --git a/tests/asm.h b/tests/asm.h
index 0fd5cb3ba..99f9cc5a5 100644
--- a/tests/asm.h
+++ b/tests/asm.h
@@ -8,4 +8,4 @@
#define VG_SYM(x) #x
// This one is for use in asm files.
-#define VG_SYM_ASM(x) _#x
+#define VG_SYM_ASM(x) x