shithub: mc

Download patch

ref: 7ff626d1c51afb52e48183e39d6086103ea1ea2f
parent: ec403cbfcb3bf3c814469fb9f686c2ece04b3258
author: Ori Bernstein <[email protected]>
date: Tue Jan 22 05:55:40 EST 2013

Rename things in the platform configuration header.

--- a/6/isel.c
+++ b/6/isel.c
@@ -784,7 +784,7 @@
 {
     size_t i, j;
 
-    if (fn->isexport || !strcmp(fn->name, Fprefix "main"))
+    if (fn->isexport || !strcmp(fn->name, Symprefix "main"))
         fprintf(fd, ".globl %s\n", fn->name);
     fprintf(fd, "%s:\n", fn->name);
     for (j = 0; j < s->cfg->nbb; j++) {
--- a/6/platform.h
+++ b/6/platform.h
@@ -1,9 +1,9 @@
 #if defined(__APPLE__) && defined(__MACH__)
 /* for OSX */
 #   define Asmcmd "as -g -o %s %s"
-#   define Fprefix "_"
+#   define Symprefix "_"
 #else
 /* Default to linux */
 #   define Asmcmd "as -g -o %s %s"
-#   define Fprefix ""
+#   define Symprefix ""
 #endif
--- a/6/simp.c
+++ b/6/simp.c
@@ -111,6 +111,8 @@
     return n;
 }
 
+/* takes the address of a node, possibly converting it to
+ * a pointer to the base type 'bt' */
 static Node *addr(Node *a, Type *bt)
 {
     Node *n;
@@ -187,12 +189,17 @@
     return s->decl.isconst && decltype(s)->type == Tyfunc;
 }
 
+/* For x86, the assembly names are generated as follows:
+ *      local symbols: .name
+ *      un-namespaced symbols: <symprefix>name
+ *      namespaced symbols: <symprefix>namespace$name
+ */
 static char *asmname(Node *n)
 {
     char *s;
     int len;
 
-    len = strlen(Fprefix);
+    len = strlen(Symprefix);
     if (n->name.ns)
         len += strlen(n->name.ns) + 1; /* +1 for separator */
     len += strlen(n->name.name) + 1;
@@ -200,9 +207,11 @@
     s = xalloc(len + 1);
     s[0] = '\0';
     if (n->name.ns)
-        snprintf(s, len, "%s%s$%s", Fprefix, n->name.ns, n->name.name);
+        snprintf(s, len, "%s%s$%s", Symprefix, n->name.ns, n->name.name);
+    else if (n->name.name[0] == '.')
+        snprintf(s, len, "%s", n->name.name);
     else
-        snprintf(s, len, "%s%s", Fprefix, n->name.name);
+        snprintf(s, len, "%s%s", Symprefix, n->name.name);
     return s;
 }