cmd/9a: fix GLOBL instruction

Because it was lumped in with the TEXT instruction,
the high 32 bits of the 64-bit constant holding the size
were always set to 0x80000000 (ArgsSizeUnknown).
This only worked because cmd/9l was reading the 64-bit
value into an int32.

While we're here, fix 5a.
It wasn't as much of a problem there because
the two values were being stored in two different fields.
But it was still wrong.

Change-Id: I69a2214c7be939530d499e29cfdc3b26720ac05a
Reviewed-on: https://go-review.googlesource.com/3570
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
Russ Cox 2015-01-29 13:50:19 -05:00
parent eaa872009d
commit a293c7e68f
8 changed files with 1518 additions and 1435 deletions

View File

@ -51,7 +51,7 @@
%left '*' '/' '%'
%token <lval> LTYPE1 LTYPE2 LTYPE3 LTYPE4 LTYPE5
%token <lval> LTYPE6 LTYPE7 LTYPE8 LTYPE9 LTYPEA
%token <lval> LTYPEB LTYPEC LTYPED LTYPEE
%token <lval> LTYPEB LGLOBL LTYPEC LTYPED LTYPEE
%token <lval> LTYPEG LTYPEH LTYPEI LTYPEJ LTYPEK
%token <lval> LTYPEL LTYPEM LTYPEN LTYPEBX LTYPEPLD
%token <lval> LCONST LSP LSB LFP LPC
@ -210,7 +210,7 @@ inst:
outcode($1, $2, &nullgen, 0, &nullgen);
}
/*
* TEXT/GLOBL
* TEXT
*/
| LTYPEB name ',' imm
{
@ -233,6 +233,19 @@ inst:
$6.u.argsize = $8;
outcode($1, Always, &$2, $4, &$6);
}
/*
* GLOBL
*/
| LGLOBL name ',' imm
{
settext($2.sym);
outcode($1, Always, &$2, 0, &$4);
}
| LGLOBL name ',' con ',' imm
{
settext($2.sym);
outcode($1, Always, &$2, $4, &$6);
}
/*
* DATA
*/

View File

@ -406,7 +406,7 @@ struct
"RFE", LTYPEA, ARFE,
"TEXT", LTYPEB, ATEXT,
"GLOBL", LTYPEB, AGLOBL,
"GLOBL", LGLOBL, AGLOBL,
"DATA", LTYPEC, ADATA,
"CASE", LTYPED, ACASE,
"END", LTYPEE, AEND,

File diff suppressed because it is too large Load Diff

View File

@ -50,43 +50,44 @@
LTYPE9 = 266,
LTYPEA = 267,
LTYPEB = 268,
LTYPEC = 269,
LTYPED = 270,
LTYPEE = 271,
LTYPEG = 272,
LTYPEH = 273,
LTYPEI = 274,
LTYPEJ = 275,
LTYPEK = 276,
LTYPEL = 277,
LTYPEM = 278,
LTYPEN = 279,
LTYPEBX = 280,
LTYPEPLD = 281,
LCONST = 282,
LSP = 283,
LSB = 284,
LFP = 285,
LPC = 286,
LTYPEX = 287,
LTYPEPC = 288,
LTYPEF = 289,
LR = 290,
LREG = 291,
LF = 292,
LFREG = 293,
LC = 294,
LCREG = 295,
LPSR = 296,
LFCR = 297,
LCOND = 298,
LS = 299,
LAT = 300,
LFCONST = 301,
LSCONST = 302,
LNAME = 303,
LLAB = 304,
LVAR = 305
LGLOBL = 269,
LTYPEC = 270,
LTYPED = 271,
LTYPEE = 272,
LTYPEG = 273,
LTYPEH = 274,
LTYPEI = 275,
LTYPEJ = 276,
LTYPEK = 277,
LTYPEL = 278,
LTYPEM = 279,
LTYPEN = 280,
LTYPEBX = 281,
LTYPEPLD = 282,
LCONST = 283,
LSP = 284,
LSB = 285,
LFP = 286,
LPC = 287,
LTYPEX = 288,
LTYPEPC = 289,
LTYPEF = 290,
LR = 291,
LREG = 292,
LF = 293,
LFREG = 294,
LC = 295,
LCREG = 296,
LPSR = 297,
LFCR = 298,
LCOND = 299,
LS = 300,
LAT = 301,
LFCONST = 302,
LSCONST = 303,
LNAME = 304,
LLAB = 305,
LVAR = 306
};
#endif
/* Tokens. */
@ -101,43 +102,44 @@
#define LTYPE9 266
#define LTYPEA 267
#define LTYPEB 268
#define LTYPEC 269
#define LTYPED 270
#define LTYPEE 271
#define LTYPEG 272
#define LTYPEH 273
#define LTYPEI 274
#define LTYPEJ 275
#define LTYPEK 276
#define LTYPEL 277
#define LTYPEM 278
#define LTYPEN 279
#define LTYPEBX 280
#define LTYPEPLD 281
#define LCONST 282
#define LSP 283
#define LSB 284
#define LFP 285
#define LPC 286
#define LTYPEX 287
#define LTYPEPC 288
#define LTYPEF 289
#define LR 290
#define LREG 291
#define LF 292
#define LFREG 293
#define LC 294
#define LCREG 295
#define LPSR 296
#define LFCR 297
#define LCOND 298
#define LS 299
#define LAT 300
#define LFCONST 301
#define LSCONST 302
#define LNAME 303
#define LLAB 304
#define LVAR 305
#define LGLOBL 269
#define LTYPEC 270
#define LTYPED 271
#define LTYPEE 272
#define LTYPEG 273
#define LTYPEH 274
#define LTYPEI 275
#define LTYPEJ 276
#define LTYPEK 277
#define LTYPEL 278
#define LTYPEM 279
#define LTYPEN 280
#define LTYPEBX 281
#define LTYPEPLD 282
#define LCONST 283
#define LSP 284
#define LSB 285
#define LFP 286
#define LPC 287
#define LTYPEX 288
#define LTYPEPC 289
#define LTYPEF 290
#define LR 291
#define LREG 292
#define LF 293
#define LFREG 294
#define LC 295
#define LCREG 296
#define LPSR 297
#define LFCR 298
#define LCOND 299
#define LS 300
#define LAT 301
#define LFCONST 302
#define LSCONST 303
#define LNAME 304
#define LLAB 305
#define LVAR 306
@ -153,7 +155,7 @@ typedef union YYSTYPE
Addr addr;
}
/* Line 1529 of yacc.c. */
#line 157 "y.tab.h"
#line 159 "y.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1

View File

@ -50,7 +50,7 @@
%left '*' '/' '%'
%token <lval> LMOVW LMOVB LABS LLOGW LSHW LADDW LCMP LCROP
%token <lval> LBRA LFMOV LFCONV LFCMP LFADD LFMA LTRAP LXORW
%token <lval> LNOP LEND LRETT LWORD LTEXT LDATA LRETRN
%token <lval> LNOP LEND LRETT LWORD LTEXT LGLOBL LDATA LRETRN
%token <lval> LCONST LSP LSB LFP LPC LCREG LFLUSH
%token <lval> LREG LFREG LR LCR LF LFPSCR
%token <lval> LLR LCTR LSPR LSPREG LSEG LMSR
@ -611,7 +611,7 @@ inst:
outcode($1, &nullgen, 0, &nullgen);
}
/*
* TEXT/GLOBL
* TEXT
*/
| LTEXT name ',' imm
{
@ -632,6 +632,20 @@ inst:
$6.offset |= ($8 & 0xffffffffull) << 32;
outcode($1, &$2, $4, &$6);
}
/*
* GLOBL
*/
| LGLOBL name ',' imm
{
settext($2.sym);
outcode($1, &$2, 0, &$4);
}
| LGLOBL name ',' con ',' imm
{
settext($2.sym);
outcode($1, &$2, $4, &$6);
}
/*
* DATA
*/

View File

@ -454,7 +454,7 @@ struct
"FMOVS", LFMOV, AFMOVS,
"FMOVDCC", LFCONV, AFMOVDCC, /* fmr. */
"GLOBL", LTEXT, AGLOBL,
"GLOBL", LGLOBL, AGLOBL,
"MOVB", LMOVB, AMOVB,
"MOVBZ", LMOVB, AMOVBZ,

File diff suppressed because it is too large Load Diff

View File

@ -60,45 +60,46 @@
LRETT = 276,
LWORD = 277,
LTEXT = 278,
LDATA = 279,
LRETRN = 280,
LCONST = 281,
LSP = 282,
LSB = 283,
LFP = 284,
LPC = 285,
LCREG = 286,
LFLUSH = 287,
LREG = 288,
LFREG = 289,
LR = 290,
LCR = 291,
LF = 292,
LFPSCR = 293,
LLR = 294,
LCTR = 295,
LSPR = 296,
LSPREG = 297,
LSEG = 298,
LMSR = 299,
LPCDAT = 300,
LFUNCDAT = 301,
LSCHED = 302,
LXLD = 303,
LXST = 304,
LXOP = 305,
LXMV = 306,
LRLWM = 307,
LMOVMW = 308,
LMOVEM = 309,
LMOVFL = 310,
LMTFSB = 311,
LMA = 312,
LFCONST = 313,
LSCONST = 314,
LNAME = 315,
LLAB = 316,
LVAR = 317
LGLOBL = 279,
LDATA = 280,
LRETRN = 281,
LCONST = 282,
LSP = 283,
LSB = 284,
LFP = 285,
LPC = 286,
LCREG = 287,
LFLUSH = 288,
LREG = 289,
LFREG = 290,
LR = 291,
LCR = 292,
LF = 293,
LFPSCR = 294,
LLR = 295,
LCTR = 296,
LSPR = 297,
LSPREG = 298,
LSEG = 299,
LMSR = 300,
LPCDAT = 301,
LFUNCDAT = 302,
LSCHED = 303,
LXLD = 304,
LXST = 305,
LXOP = 306,
LXMV = 307,
LRLWM = 308,
LMOVMW = 309,
LMOVEM = 310,
LMOVFL = 311,
LMTFSB = 312,
LMA = 313,
LFCONST = 314,
LSCONST = 315,
LNAME = 316,
LLAB = 317,
LVAR = 318
};
#endif
/* Tokens. */
@ -123,45 +124,46 @@
#define LRETT 276
#define LWORD 277
#define LTEXT 278
#define LDATA 279
#define LRETRN 280
#define LCONST 281
#define LSP 282
#define LSB 283
#define LFP 284
#define LPC 285
#define LCREG 286
#define LFLUSH 287
#define LREG 288
#define LFREG 289
#define LR 290
#define LCR 291
#define LF 292
#define LFPSCR 293
#define LLR 294
#define LCTR 295
#define LSPR 296
#define LSPREG 297
#define LSEG 298
#define LMSR 299
#define LPCDAT 300
#define LFUNCDAT 301
#define LSCHED 302
#define LXLD 303
#define LXST 304
#define LXOP 305
#define LXMV 306
#define LRLWM 307
#define LMOVMW 308
#define LMOVEM 309
#define LMOVFL 310
#define LMTFSB 311
#define LMA 312
#define LFCONST 313
#define LSCONST 314
#define LNAME 315
#define LLAB 316
#define LVAR 317
#define LGLOBL 279
#define LDATA 280
#define LRETRN 281
#define LCONST 282
#define LSP 283
#define LSB 284
#define LFP 285
#define LPC 286
#define LCREG 287
#define LFLUSH 288
#define LREG 289
#define LFREG 290
#define LR 291
#define LCR 292
#define LF 293
#define LFPSCR 294
#define LLR 295
#define LCTR 296
#define LSPR 297
#define LSPREG 298
#define LSEG 299
#define LMSR 300
#define LPCDAT 301
#define LFUNCDAT 302
#define LSCHED 303
#define LXLD 304
#define LXST 305
#define LXOP 306
#define LXMV 307
#define LRLWM 308
#define LMOVMW 309
#define LMOVEM 310
#define LMOVFL 311
#define LMTFSB 312
#define LMA 313
#define LFCONST 314
#define LSCONST 315
#define LNAME 316
#define LLAB 317
#define LVAR 318
@ -177,7 +179,7 @@ typedef union YYSTYPE
Addr addr;
}
/* Line 1529 of yacc.c. */
#line 181 "y.tab.h"
#line 183 "y.tab.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1