Commit 1dd4da14 authored by Elias Naur's avatar Elias Naur Committed by Ian Lance Taylor

liblink, cmd/5a, cmd/5l: restore cgo on older ARM processors

CL 56120043 fixed TLS handling on ARM after the introduction of
liblink but left older ARM processors broken.

Before liblink, the MRC instruction was replaced with a fallback
on older ARMs. CL 56120043 removed that, because the rewrite matched
bit patterns on the AWORD pseudo-instruction and could therefore change
unrelated AWORDs that happened to match.

This CL adds an AMRC instruction to encode both MRC and MCR previously
encoded as AWORDs. Then, in liblink, the AMRC instructions are either
rewritten to AWORD, or, on goarm < 7, replaced with a branch to the
fallback.

./all.bash completes successfully on an ARMv7 with either GOARM=7 or
GOARM=5. I have verified that the fallback is indeed present in both
runtime.save_gm and runtime.load_gm when GOARM=5 but not when GOARM=7.

If all goes well, this should fix the armv5 builders.

LGTM=iant
R=iant, rsc
CC=golang-codereviews
https://golang.org/cl/55540044
parent e6d8bfe2
...@@ -294,7 +294,7 @@ inst: ...@@ -294,7 +294,7 @@ inst:
(($11 & 15) << 0) | /* Crm */ (($11 & 15) << 0) | /* Crm */
(($12 & 7) << 5) | /* coprocessor information */ (($12 & 7) << 5) | /* coprocessor information */
(1<<4); /* must be set */ (1<<4); /* must be set */
outcode(AWORD, Always, &nullgen, NREG, &g); outcode(AMRC, Always, &nullgen, NREG, &g);
} }
/* /*
* MULL r1,r2,(hi,lo) * MULL r1,r2,(hi,lo)
......
This diff is collapsed.
/* A Bison parser, made by GNU Bison 2.3. */ /* A Bison parser, made by GNU Bison 2.7.12-4996. */
/* Skeleton interface for Bison's Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation, either version 3 of the License, or
any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -16,9 +15,7 @@ ...@@ -16,9 +15,7 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program. If not, see <http://www.gnu.org/licenses/>. */
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains /* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work part or all of the Bison parser skeleton and distribute that work
...@@ -33,6 +30,16 @@ ...@@ -33,6 +30,16 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
#ifndef YY_YY_Y_TAB_H_INCLUDED
# define YY_YY_Y_TAB_H_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
...@@ -141,24 +148,41 @@ ...@@ -141,24 +148,41 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
#line 39 "a.y"
{ {
/* Line 2053 of yacc.c */
#line 39 "a.y"
Sym *sym; Sym *sym;
int32 lval; int32 lval;
double dval; double dval;
char sval[8]; char sval[8];
Addr addr; Addr addr;
}
/* Line 1529 of yacc.c. */
#line 157 "y.tab.h" /* Line 2053 of yacc.c */
YYSTYPE; #line 166 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif #endif
extern YYSTYPE yylval; extern YYSTYPE yylval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_Y_TAB_H_INCLUDED */
...@@ -200,6 +200,8 @@ enum as ...@@ -200,6 +200,8 @@ enum as
ACHECKNIL, ACHECKNIL,
AFATVARDEF, AFATVARDEF,
AMRC, // MRC/MCR
ALAST, ALAST,
}; };
......
...@@ -92,6 +92,7 @@ progedit(Link *ctxt, Prog *p) ...@@ -92,6 +92,7 @@ progedit(Link *ctxt, Prog *p)
{ {
char literal[64]; char literal[64];
LSym *s; LSym *s;
LSym *tlsfallback;
p->from.class = 0; p->from.class = 0;
p->to.class = 0; p->to.class = 0;
...@@ -105,6 +106,25 @@ progedit(Link *ctxt, Prog *p) ...@@ -105,6 +106,25 @@ progedit(Link *ctxt, Prog *p)
break; break;
} }
// Replace TLS register fetches on older ARM procesors.
switch(p->as) {
case AMRC:
// If the instruction matches MRC 15, 0, <reg>, C13, C0, 3, replace it.
if(ctxt->goarm < 7 && (p->to.offset & 0xffff0fff) == 0xee1d0f70) {
tlsfallback = linklookup(ctxt, "runtime.read_tls_fallback", 0);
// BL runtime.read_tls_fallback(SB)
p->as = ABL;
p->to.type = D_BRANCH;
p->to.sym = tlsfallback;
p->to.offset = 0;
} else {
// Otherwise, MRC/MCR instructions need no further treatment.
p->as = AWORD;
}
break;
}
// Rewrite float constants to values stored in memory. // Rewrite float constants to values stored in memory.
switch(p->as) { switch(p->as) {
case AMOVF: case AMOVF:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment