]> granicus.if.org Git - yasm/commitdiff
Fix implementation of r1298 and fixup testcases.
authorPeter Johnson <peter@tortall.net>
Tue, 1 Nov 2005 03:57:42 +0000 (03:57 -0000)
committerPeter Johnson <peter@tortall.net>
Tue, 1 Nov 2005 03:57:42 +0000 (03:57 -0000)
* gas-bison.y (gas_get_section, gas_switch_section): Add parameter builtin
to indicate gas flags should not be generated.

svn path=/trunk/yasm/; revision=1299

modules/parsers/gas/gas-bison.y
modules/parsers/gas/tests/dataref-imm.hex
modules/parsers/gas/tests/datavis.hex
modules/parsers/gas/tests/datavis2.hex
modules/parsers/gas/tests/leb128.hex

index 815d569b793ad389de4a2272c3e0f203a66a4501..1b073ec6e8398697e7d8878ca94ee7a95547e33f 100644 (file)
@@ -45,10 +45,12 @@ RCSID("$Id$");
 static void define_label(yasm_parser_gas *parser_gas, char *name, int local);
 static yasm_section *gas_get_section
     (yasm_parser_gas *parser_gas, char *name, /*@null@*/ char *flags,
-     /*@null@*/ char *type, /*@null@*/ yasm_valparamhead *objext_valparams);
+     /*@null@*/ char *type, /*@null@*/ yasm_valparamhead *objext_valparams,
+     int builtin);
 static void gas_switch_section(yasm_parser_gas *parser_gas, char *name,
                               /*@null@*/ char *flags, /*@null@*/ char *type,
-                              /*@null@*/ yasm_valparamhead *objext_valparams);
+                              /*@null@*/ yasm_valparamhead *objext_valparams,
+                              int builtin);
 static yasm_bytecode *gas_parser_align(yasm_parser_gas *parser_gas,
                                       yasm_valparamhead *valparams,
                                       int power2);
@@ -234,7 +236,7 @@ lineexp: instr
        /* Put into .bss section. */
        /*@dependent@*/ yasm_section *bss =
            gas_get_section(parser_gas, yasm__xstrdup(".bss"), NULL, NULL,
-                           NULL);
+                           NULL, 1);
        /* TODO: default alignment */
        yasm_symtab_define_label(p_symtab, $2, yasm_section_bcs_last(bss), 1,
                                 cur_line);
@@ -246,7 +248,7 @@ lineexp: instr
        /* Put into .bss section. */
        /*@dependent@*/ yasm_section *bss =
            gas_get_section(parser_gas, yasm__xstrdup(".bss"), NULL, NULL,
-                           NULL);
+                           NULL, 1);
        /* TODO: force alignment */
        yasm_symtab_define_label(p_symtab, $2, yasm_section_bcs_last(bss), 1,
                                 cur_line);
@@ -334,32 +336,33 @@ lineexp: instr
     /* Section directives */
     | DIR_TEXT {
        gas_switch_section(parser_gas, yasm__xstrdup(".text"), NULL, NULL,
-                          NULL);
+                          NULL, 1);
        $$ = NULL;
     }
     | DIR_DATA {
        gas_switch_section(parser_gas, yasm__xstrdup(".data"), NULL, NULL,
-                          NULL);
+                          NULL, 1);
        $$ = NULL;
     }
     | DIR_BSS {
-       gas_switch_section(parser_gas, yasm__xstrdup(".bss"), NULL, NULL, NULL);
+       gas_switch_section(parser_gas, yasm__xstrdup(".bss"), NULL, NULL, NULL,
+                          1);
        $$ = NULL;
     }
     | DIR_SECTION label_id {
-       gas_switch_section(parser_gas, $2, NULL, NULL, NULL);
+       gas_switch_section(parser_gas, $2, NULL, NULL, NULL, 0);
        $$ = NULL;
     }
     | DIR_SECTION label_id ',' STRING {
-       gas_switch_section(parser_gas, $2, $4.contents, NULL, NULL);
+       gas_switch_section(parser_gas, $2, $4.contents, NULL, NULL, 0);
        $$ = NULL;
     }
     | DIR_SECTION label_id ',' STRING ',' '@' label_id {
-       gas_switch_section(parser_gas, $2, $4.contents, $7, NULL);
+       gas_switch_section(parser_gas, $2, $4.contents, $7, NULL, 0);
        $$ = NULL;
     }
     | DIR_SECTION label_id ',' STRING ',' '@' label_id ',' dirvals {
-       gas_switch_section(parser_gas, $2, $4.contents, $7, &$9);
+       gas_switch_section(parser_gas, $2, $4.contents, $7, &$9, 0);
        $$ = NULL;
     }
     /* Other directives */
@@ -367,7 +370,7 @@ lineexp: instr
        /* Put text into .comment section. */
        /*@dependent@*/ yasm_section *comment =
            gas_get_section(parser_gas, yasm__xstrdup(".comment"), NULL, NULL,
-                           NULL);
+                           NULL, 1);
        /* To match GAS output, if the comment section is empty, put an
         * initial 0 byte in the section.
         */
@@ -714,7 +717,8 @@ define_label(yasm_parser_gas *parser_gas, char *name, int local)
 static yasm_section *
 gas_get_section(yasm_parser_gas *parser_gas, char *name,
                /*@null@*/ char *flags, /*@null@*/ char *type,
-               /*@null@*/ yasm_valparamhead *objext_valparams)
+               /*@null@*/ yasm_valparamhead *objext_valparams,
+               int builtin)
 {
     yasm_valparamhead vps;
     yasm_valparam *vp;
@@ -725,18 +729,19 @@ gas_get_section(yasm_parser_gas *parser_gas, char *name,
     vp = yasm_vp_create(name, NULL);
     yasm_vps_append(&vps, vp);
 
-    if (flags) {
-       gasflags = yasm_xmalloc(5+strlen(flags));
-       strcpy(gasflags, "gas_");
-       strcat(gasflags, flags);
-       vp = yasm_vp_create(gasflags, NULL);
-       yasm_vps_append(&vps, vp);
-    } else if (type) {
-       gasflags = yasm__xstrdup("gas_");
+    if (!builtin) {
+       if (flags) {
+           gasflags = yasm_xmalloc(5+strlen(flags));
+           strcpy(gasflags, "gas_");
+           strcat(gasflags, flags);
+       } else
+           gasflags = yasm__xstrdup("gas_");
        vp = yasm_vp_create(gasflags, NULL);
        yasm_vps_append(&vps, vp);
-       vp = yasm_vp_create(type, NULL);
-       yasm_vps_append(&vps, vp);
+       if (type) {
+           vp = yasm_vp_create(type, NULL);
+           yasm_vps_append(&vps, vp);
+       }
     }
 
     new_section = yasm_objfmt_section_switch(parser_gas->objfmt, &vps,
@@ -749,12 +754,13 @@ gas_get_section(yasm_parser_gas *parser_gas, char *name,
 static void
 gas_switch_section(yasm_parser_gas *parser_gas, char *name,
                   /*@null@*/ char *flags, /*@null@*/ char *type,
-                  /*@null@*/ yasm_valparamhead *objext_valparams)
+                  /*@null@*/ yasm_valparamhead *objext_valparams,
+                  int builtin)
 {
     yasm_section *new_section;
 
     new_section = gas_get_section(parser_gas, name, flags, type,
-                                 objext_valparams);
+                                 objext_valparams, builtin);
     if (new_section) {
        parser_gas->cur_section = new_section;
        parser_gas->prev_bc = yasm_section_bcs_last(new_section);
index 9e4c6b1c79974f2a4a14c67b5e54f6a0d145f40e..84893dcada9360b95c314a6023dd3a80551ef648 100644 (file)
@@ -518,7 +518,7 @@ b8
 00 
 00 
 00 
-00 
+03 
 00 
 00 
 00 
index b5a76fb8e2fb3533e8ae0401ba35ea5b01a83f55..1d6f915fa041851523fd6a822cad9ccec8bd68ef 100644 (file)
@@ -726,7 +726,7 @@ c0
 00 
 00 
 00 
-00 
+03 
 00 
 00 
 00 
@@ -846,7 +846,7 @@ c0
 00 
 00 
 00 
-00 
+03 
 00 
 00 
 00 
index 3526b01c46b23142caf2c7f9c98f9d15a441868f..a0a71fd727ec2cc3800926a99ee191f1902abdb8 100644 (file)
@@ -93,6 +93,8 @@
 01 
 00 
 00 
+00 
+00 
 23 
 20 
 3a 
 00 
 00 
 00 
-00 
-00 
 2e 
 74 
 65 
@@ -686,7 +686,7 @@ d8
 00 
 00 
 00 
-5e 
+60 
 00 
 00 
 00 
@@ -702,7 +702,7 @@ d8
 00 
 00 
 00 
-01 
+04 
 00 
 00 
 00 
index 30e5b7ec31f598ac598955b7e16ac33ba02ab346..bc1363b63c0b10d503fbfcb747f5ac88d37eeacc 100644 (file)
@@ -414,7 +414,7 @@ ff
 00 
 00 
 00 
-00 
+03 
 00 
 00 
 00