aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2004-12-10 19:48:21 +0000
committerIan Lance Taylor <ian@airs.com>2004-12-10 19:48:21 +0000
commitaa6975fbb31187d739eeb94d715c0118e2425937 (patch)
treebc611f4894169fcba7fd058df1f24dd990d98333 /gas
parent01926a693560658e7293190549a9c2cee946811a (diff)
downloadbinutils-aa6975fbb31187d739eeb94d715c0118e2425937.zip
binutils-aa6975fbb31187d739eeb94d715c0118e2425937.tar.gz
binutils-aa6975fbb31187d739eeb94d715c0118e2425937.tar.bz2
* config/tc-mips.c (mips_in_shared): New static variable.
(macro_build_lui): Permit "_gp" if !mips_in_shared. (md_longopts): Add -mshared and -mno-shared. (md_parse_option): Handle OPTION_MSHARED and OPTION_MNO_SHARED. (s_cpload): Implement !mips_in_shared case. (s_cpsetup): Likewise. * doc/c-mips.texi (MIPS Opts): Document -mno-shared. * NEWS: Mention -mno-shared.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog11
-rw-r--r--gas/NEWS2
-rw-r--r--gas/config/tc-mips.c93
-rw-r--r--gas/doc/c-mips.texi10
4 files changed, 101 insertions, 15 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 8a1989f..2d5a186 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,14 @@
+2004-12-10 Ian Lance Taylor <ian@wasabisystems.com>
+
+ * config/tc-mips.c (mips_in_shared): New static variable.
+ (macro_build_lui): Permit "_gp" if !mips_in_shared.
+ (md_longopts): Add -mshared and -mno-shared.
+ (md_parse_option): Handle OPTION_MSHARED and OPTION_MNO_SHARED.
+ (s_cpload): Implement !mips_in_shared case.
+ (s_cpsetup): Likewise.
+ * doc/c-mips.texi (MIPS Opts): Document -mno-shared.
+ * NEWS: Mention -mno-shared.
+
2004-12-09 Paul Brook <paul@codesourcery.com>
* config/tc-arm.c (s_arm_unwind_fnend): Use R_ARM_PREL31 relocation
diff --git a/gas/NEWS b/gas/NEWS
index 28db422..92b42de 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -19,6 +19,8 @@
* Support for ColdFire EMAC instructions added and Motorola syntax for MAC/EMAC
instrucitons.
+* New command line option -mno-shared for MIPS ELF targets.
+
* New command line option --alternate and pseudo-ops .altmacro and .noaltmacro
added to enter (and leave) alternate macro syntax mode.
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index d03154a..157c541 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -136,6 +136,10 @@ static enum mips_abi_level mips_abi = NO_ABI;
/* Whether or not we have code that can call pic code. */
int mips_abicalls = FALSE;
+/* Whether or not we have code which can be put into a shared
+ library. */
+static bfd_boolean mips_in_shared = TRUE;
+
/* This is the set of options which may be modified by the .set
pseudo-op. We use a struct so that .set push and .set pop are more
reliable. */
@@ -3388,10 +3392,13 @@ macro_build_lui (expressionS *ep, int regnum)
else
{
assert (ep->X_op == O_symbol);
- /* _gp_disp is a special case, used from s_cpload. */
+ /* _gp_disp is a special case, used from s_cpload. _gp is used
+ if mips_no_shared. */
assert (mips_pic == NO_PIC
|| (! HAVE_NEWABI
- && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp_disp") == 0));
+ && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp_disp") == 0)
+ || (! mips_in_shared
+ && strcmp (S_GET_NAME (ep->X_add_symbol), "_gp") == 0));
*r = BFD_RELOC_HI16_S;
}
@@ -10120,10 +10127,14 @@ struct option md_longopts[] =
#define OPTION_NO_RELAX_BRANCH (OPTION_MISC_BASE + 11)
{"relax-branch", no_argument, NULL, OPTION_RELAX_BRANCH},
{"no-relax-branch", no_argument, NULL, OPTION_NO_RELAX_BRANCH},
+#define OPTION_MSHARED (OPTION_MISC_BASE + 12)
+#define OPTION_MNO_SHARED (OPTION_MISC_BASE + 13)
+ {"mshared", no_argument, NULL, OPTION_MSHARED},
+ {"mno-shared", no_argument, NULL, OPTION_MNO_SHARED},
/* ELF-specific options. */
#ifdef OBJ_ELF
-#define OPTION_ELF_BASE (OPTION_MISC_BASE + 12)
+#define OPTION_ELF_BASE (OPTION_MISC_BASE + 14)
#define OPTION_CALL_SHARED (OPTION_ELF_BASE + 0)
{"KPIC", no_argument, NULL, OPTION_CALL_SHARED},
{"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
@@ -10336,6 +10347,14 @@ md_parse_option (int c, char *arg)
mips_relax_branch = 0;
break;
+ case OPTION_MSHARED:
+ mips_in_shared = TRUE;
+ break;
+
+ case OPTION_MNO_SHARED:
+ mips_in_shared = FALSE;
+ break;
+
#ifdef OBJ_ELF
/* When generating ELF code, we permit -KPIC and -call_shared to
select SVR4_PIC, and -non_shared to select no PIC. This is
@@ -11794,12 +11813,22 @@ s_abicalls (int ignore ATTRIBUTE_UNUSED)
lui $gp,%hi(_gp_disp)
addiu $gp,$gp,%lo(_gp_disp)
addu $gp,$gp,.cpload argument
- The .cpload argument is normally $25 == $t9. */
+ The .cpload argument is normally $25 == $t9.
+
+ The -mno-shared option changes this to:
+ lui $gp,%hi(_gp)
+ addiu $gp,$gp,%lo(_gp)
+ and the argument is ignored. This saves an instruction, but the
+ resulting code is not position independent; it uses an absolute
+ address for _gp. Thus code assembled with -mno-shared can go into
+ an ordinary executable, but not into a shared library. */
static void
s_cpload (int ignore ATTRIBUTE_UNUSED)
{
expressionS ex;
+ int reg;
+ int in_shared;
/* If we are not generating SVR4 PIC code, or if this is NewABI code,
.cpload is ignored. */
@@ -11813,8 +11842,14 @@ s_cpload (int ignore ATTRIBUTE_UNUSED)
if (mips_opts.noreorder == 0)
as_warn (_(".cpload not in noreorder section"));
+ reg = tc_get_register (0);
+
+ /* If we need to produce a 64-bit address, we are better off using
+ the default instruction sequence. */
+ in_shared = mips_in_shared || HAVE_64BIT_ADDRESSES;
+
ex.X_op = O_symbol;
- ex.X_add_symbol = symbol_find_or_make ("_gp_disp");
+ ex.X_add_symbol = symbol_find_or_make (in_shared ? "_gp_disp" : "_gp");
ex.X_op_symbol = NULL;
ex.X_add_number = 0;
@@ -11825,8 +11860,9 @@ s_cpload (int ignore ATTRIBUTE_UNUSED)
macro_build_lui (&ex, mips_gp_register);
macro_build (&ex, "addiu", "t,r,j", mips_gp_register,
mips_gp_register, BFD_RELOC_LO16);
- macro_build (NULL, "addu", "d,v,t", mips_gp_register,
- mips_gp_register, tc_get_register (0));
+ if (in_shared)
+ macro_build (NULL, "addu", "d,v,t", mips_gp_register,
+ mips_gp_register, reg);
macro_end ();
demand_empty_rest_of_line ();
@@ -11846,7 +11882,13 @@ s_cpload (int ignore ATTRIBUTE_UNUSED)
lui $gp, %hi(%neg(%gp_rel(label)))
addiu $gp, $gp, %lo(%neg(%gp_rel(label)))
daddu $gp, $gp, $reg1
- $reg1 is normally $25 == $t9. */
+ $reg1 is normally $25 == $t9.
+
+ The -mno-shared option replaces the last three instructions with
+ lui $gp,%hi(_gp)
+ addiu $gp,$gp,%lo(_gp)
+ */
+
static void
s_cpsetup (int ignore ATTRIBUTE_UNUSED)
{
@@ -11908,15 +11950,36 @@ s_cpsetup (int ignore ATTRIBUTE_UNUSED)
macro_build (NULL, "daddu", "d,v,t", mips_cpreturn_register,
mips_gp_register, 0);
- macro_build (&ex_sym, "lui", "t,u", mips_gp_register,
- -1, BFD_RELOC_GPREL16, BFD_RELOC_MIPS_SUB, BFD_RELOC_HI16_S);
+ if (mips_in_shared || HAVE_64BIT_ADDRESSES)
+ {
+ macro_build (&ex_sym, "lui", "t,u", mips_gp_register,
+ -1, BFD_RELOC_GPREL16, BFD_RELOC_MIPS_SUB,
+ BFD_RELOC_HI16_S);
+
+ macro_build (&ex_sym, "addiu", "t,r,j", mips_gp_register,
+ mips_gp_register, -1, BFD_RELOC_GPREL16,
+ BFD_RELOC_MIPS_SUB, BFD_RELOC_LO16);
- macro_build (&ex_sym, "addiu", "t,r,j", mips_gp_register,
- mips_gp_register, -1, BFD_RELOC_GPREL16,
- BFD_RELOC_MIPS_SUB, BFD_RELOC_LO16);
+ macro_build (NULL, ADDRESS_ADD_INSN, "d,v,t", mips_gp_register,
+ mips_gp_register, reg1);
+ }
+ else
+ {
+ expressionS ex;
+
+ ex.X_op = O_symbol;
+ ex.X_add_symbol = symbol_find_or_make ("_gp");
+ ex.X_op_symbol = NULL;
+ ex.X_add_number = 0;
+
+ /* In ELF, this symbol is implicitly an STT_OBJECT symbol. */
+ symbol_get_bfdsym (ex.X_add_symbol)->flags |= BSF_OBJECT;
+
+ macro_build_lui (&ex, mips_gp_register);
+ macro_build (&ex, "addiu", "t,r,j", mips_gp_register,
+ mips_gp_register, BFD_RELOC_LO16);
+ }
- macro_build (NULL, ADDRESS_ADD_INSN, "d,v,t", mips_gp_register,
- mips_gp_register, reg1);
macro_end ();
demand_empty_rest_of_line ();
diff --git a/gas/doc/c-mips.texi b/gas/doc/c-mips.texi
index 1375230..6446c92 100644
--- a/gas/doc/c-mips.texi
+++ b/gas/doc/c-mips.texi
@@ -238,6 +238,16 @@ error is detected. This is the default.
@itemx -mno-pdr
Control generation of @code{.pdr} sections. Off by default on IRIX, on
elsewhere.
+
+@item -mshared
+@itemx -mno-shared
+When generating code using the Unix calling conventions (selected by
+@samp{-KPIC} or @samp{-mcall_shared}), gas will normally generate code
+which can go into a shared library. The @samp{-mno-shared} option
+tells gas to generate code which uses the calling convention, but can
+not go into a shared library. The resulting code is slightly more
+efficient. This option only affects the handling of the
+@samp{.cpload} and @samp{.cpsetup} pseudo-ops.
@end table
@node MIPS Object