diff mc-code-powerpc.c @ 516:bfa4c834a3b8

data/text/rodata segment fix (incomplete)
author kono
date Mon, 26 Dec 2005 10:55:15 +0900
parents 4c2607e72ab5
children d686497e8fd2
line wrap: on
line diff
--- a/mc-code-powerpc.c	Mon Dec 26 09:18:36 2005 +0900
+++ b/mc-code-powerpc.c	Mon Dec 26 10:55:15 2005 +0900
@@ -30,8 +30,6 @@
 #define DATA_EMIT_MODE 1
 #define RODATA_EMIT_MODE 2
 
-static void data_mode(char *name);
-static void text_mode();
 static void ld_indexx(int byte, int n, int xreg,int reg,int sign);
 static void local_table(void);
 static void shift(char *op, int creg,int reg);
@@ -975,7 +973,7 @@
 	free_register(lreg_stack[--lreg_sp]);
     }
     use_int0();
-    text_mode();
+    text_mode(0);
     gexpr_code_init();
     register_usage("gexpr_init");
 }
@@ -1481,7 +1479,7 @@
     if (output_mode==TEXT_EMIT_MODE) {
 	printf(".text\n");
     } else {
-	text_mode();
+	text_mode(0);
     }
     printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",crn,lb,code_base);
     printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",crn,lb,code_base,crn);
@@ -2699,7 +2697,7 @@
 code_enter(char *name)
 {
     if (output_mode!=TEXT_EMIT_MODE) 
-	text_mode();
+	text_mode(0);
     else
 	printf("\t.align 2\n");
     if (stmode!=STATIC)
@@ -2751,7 +2749,7 @@
 enter(char *name)
 {
     if (output_mode!=TEXT_EMIT_MODE) 
-	text_mode();
+	text_mode(0);
     else
 	printf("\t.align 2\n");
     if (stmode!=STATIC)
@@ -2785,7 +2783,7 @@
 void
 enter1()
 {
-    text_mode();
+    text_mode(0);
     // set_lreg(LREG_LREGISTER,0);
     set_ireg(CREG_REGISTER,0);
     set_freg(FREG_FREGISTER,0);
@@ -2948,10 +2946,9 @@
 emit_string_label() {
     int lb;
 
-    printf(".data\t\n.cstring\n\t.align 2\n");
     lb=fwdlabel();
+    cstring_mode();
     printf("L_%d:\n",lb);
-    output_mode = RODATA_EMIT_MODE;
     return lb;
 }
 
@@ -2970,13 +2967,17 @@
     }
 }
 
-extern void
-emit_global(char *name,int t)
+void
+emit_global(NMTBL *n,int t,int e)
 {
-    // data_mode(name);
-    printf(".globl\t_%s\n",name);
-    align(t);
-    printf("_%s:\n",name); 
+    if (e && car(e)==STRING) {
+        cstring_mode();
+    } else {
+        data_mode(n->nm);
+        align(t);
+    }
+    printf("\t.globl\t_%s\n",n->nm);
+    printf("_%s:\n",n->nm);
 }
 
 extern void
@@ -3125,7 +3126,7 @@
 printf("\t.indirect_symbol _%s\n",extrn);
 printf("\t.long dyld_stub_binding_helper\n");
 	    } else if (n->sc==FUNCTION||n->sc==CODE) {
-		text_mode();
+		text_mode(0);
 printf("\t.set L_%s$stub,_%s\n",extrn,extrn);
 		data_mode(0);
 printf("L_%s$non_lazy_ptr:\n\t.long\t_%s\n",extrn,extrn);
@@ -3181,7 +3182,16 @@
 }
 
 void
-text_mode(void)
+cstring_mode(int align)
+{
+    if (output_mode!=RODATA_EMIT_MODE) {
+        printf(".cstring\n\t.align 2\n");
+        output_mode = RODATA_EMIT_MODE;
+    }
+}
+
+void
+text_mode(int align)
 {
     if (output_mode!=TEXT_EMIT_MODE) {
 	printf(".text\n");
@@ -3369,7 +3379,7 @@
     if (output_mode==TEXT_EMIT_MODE) {
 	printf(".text\n");
     } else {
-	text_mode();
+	text_mode(0);
     }
     printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",rrn,lb,code_base);
     printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",rrn,lb,code_base,rrn);
@@ -5201,7 +5211,7 @@
     char *p;
     int reg[MAX_ASM_REG];
 
-    text_mode();
+    text_mode(0);
     c = *asm_str;
     if (c!='\t'&&c!=' ') printf("\t");
     for(i=0;repl && i<MAX_ASM_REG;i++) {