Add --pcrel option to m68k port

This commit is contained in:
Nick Clifton 2000-07-31 22:08:14 +00:00
parent 9aa1e687a2
commit 28e7409f62
10 changed files with 835 additions and 763 deletions

View File

@ -1,3 +1,12 @@
2000-07-31 Michael Sokolov <msokolov@ivan.Harhan.ORG>
* config/tc-m68k.c (flag_keep_pcrel, OPTION_PCREL): Add --pcrel option.
(md_convert_frag_1, md_estimate_size_before_relax): When making DBcc
long emit a long branch if available instead of an absolute jump, never
emit absolute jumps for anything with --pcrel.
* doc/c-m68k.texi: Document new command line option.
2000-07-28 Jason Eckhardt <jle@cygnus.com> 2000-07-28 Jason Eckhardt <jle@cygnus.com>
* configure.in: Add bits for i860-stardent-{sysv4, elf}*. * configure.in: Add bits for i860-stardent-{sysv4, elf}*.

View File

@ -1889,7 +1889,7 @@ configure configure.in gdbinit.in itbl-lex.c itbl-parse.c
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar TAR = gtar
GZIP_ENV = --best GZIP_ENV = --best
SOURCES = $(itbl_test_SOURCES) $(as_new_SOURCES) $(EXTRA_as_new_SOURCES) $(gasp_new_SOURCES) SOURCES = $(itbl_test_SOURCES) $(as_new_SOURCES) $(EXTRA_as_new_SOURCES) $(gasp_new_SOURCES)
OBJECTS = $(itbl_test_OBJECTS) $(as_new_OBJECTS) $(gasp_new_OBJECTS) OBJECTS = $(itbl_test_OBJECTS) $(as_new_OBJECTS) $(gasp_new_OBJECTS)

11
gas/aclocal.m4 vendored
View File

@ -173,7 +173,7 @@ LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
|| AC_MSG_ERROR([libtool configure failed]) || AC_MSG_ERROR([libtool configure failed])
# Reload cache, that may have been modified by ltconfig # Reload cache, that may have been modified by ltconfig
@ -205,11 +205,6 @@ AC_REQUIRE([AC_PROG_NM])dnl
AC_REQUIRE([AC_PROG_LN_S])dnl AC_REQUIRE([AC_PROG_LN_S])dnl
dnl dnl
case "$target" in
NONE) lt_target="$host" ;;
*) lt_target="$target" ;;
esac
# Check for any special flags to pass to ltconfig. # Check for any special flags to pass to ltconfig.
libtool_flags="--cache-file=$cache_file" libtool_flags="--cache-file=$cache_file"
test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
@ -228,7 +223,7 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
# Some flags need to be propagated to the compiler or linker for good # Some flags need to be propagated to the compiler or linker for good
# libtool support. # libtool support.
case "$lt_target" in case "$host" in
*-*-irix6*) *-*-irix6*)
# Find out which ABI we are using. # Find out which ABI we are using.
echo '[#]line __oline__ "configure"' > conftest.$ac_ext echo '[#]line __oline__ "configure"' > conftest.$ac_ext
@ -495,7 +490,7 @@ AC_MSG_RESULT([$NM])
AC_DEFUN(AC_CHECK_LIBM, AC_DEFUN(AC_CHECK_LIBM,
[AC_REQUIRE([AC_CANONICAL_HOST])dnl [AC_REQUIRE([AC_CANONICAL_HOST])dnl
LIBM= LIBM=
case "$lt_target" in case "$host" in
*-*-beos* | *-*-cygwin*) *-*-beos* | *-*-cygwin*)
# These system don't have libm # These system don't have libm
;; ;;

View File

@ -1,5 +1,5 @@
/* GAS interface for targets using CGEN: Cpu tools GENerator. /* GAS interface for targets using CGEN: Cpu tools GENerator.
Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.

View File

@ -1,5 +1,5 @@
/* GAS cgen support. /* GAS cgen support.
Copyright (C) 1998, 1999 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler. This file is part of GAS, the GNU Assembler.

View File

@ -74,6 +74,7 @@ int flag_want_pic;
static int flag_short_refs; /* -l option */ static int flag_short_refs; /* -l option */
static int flag_long_jumps; /* -S option */ static int flag_long_jumps; /* -S option */
static int flag_keep_pcrel; /* --pcrel option. */
#ifdef REGISTER_PREFIX_OPTIONAL #ifdef REGISTER_PREFIX_OPTIONAL
int flag_reg_prefix_optional = REGISTER_PREFIX_OPTIONAL; int flag_reg_prefix_optional = REGISTER_PREFIX_OPTIONAL;
@ -4317,8 +4318,11 @@ md_convert_frag_1 (fragP)
ext = 2; ext = 2;
break; break;
case TAB (ABRANCH, LONG): case TAB (ABRANCH, LONG):
if (!HAVE_LONG_BRANCH(current_architecture)) if (!HAVE_LONG_BRANCH (current_architecture))
{ {
if (flag_keep_pcrel)
as_bad (_("long branch not supported"));
if (fragP->fr_opcode[0] == 0x61) if (fragP->fr_opcode[0] == 0x61)
/* BSR */ /* BSR */
{ {
@ -4363,6 +4367,9 @@ md_convert_frag_1 (fragP)
case TAB (BCC68000, LONG): case TAB (BCC68000, LONG):
/* only Bcc 68000 instructions can come here */ /* only Bcc 68000 instructions can come here */
/* change bcc into b!cc/jmp absl long */ /* change bcc into b!cc/jmp absl long */
if (flag_keep_pcrel)
as_bad (_("long branch not supported"));
fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ fragP->fr_opcode[0] ^= 0x01; /* invert bcc */
fragP->fr_opcode[1] = 0x6;/* branch offset = 6 */ fragP->fr_opcode[1] = 0x6;/* branch offset = 6 */
@ -4379,18 +4386,30 @@ md_convert_frag_1 (fragP)
break; break;
case TAB (DBCC, LONG): case TAB (DBCC, LONG):
/* only DBcc 68000 instructions can come here */ /* only DBcc 68000 instructions can come here */
/* change dbcc into dbcc/jmp absl long */ /* Change dbcc into dbcc/bral. */
if (! HAVE_LONG_BRANCH (current_architecture) && flag_keep_pcrel)
as_bad (_("long branch not supported"));
/* JF: these used to be fr_opcode[2-7], but that's wrong */ /* JF: these used to be fr_opcode[2-7], but that's wrong */
*buffer_address++ = 0x00; /* branch offset = 4 */ *buffer_address++ = 0x00; /* branch offset = 4 */
*buffer_address++ = 0x04; *buffer_address++ = 0x04;
*buffer_address++ = 0x60; /* put in bra pc+6 */ *buffer_address++ = 0x60; /* put in bra pc+6 */
*buffer_address++ = 0x06; *buffer_address++ = 0x06;
*buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */ if (HAVE_LONG_BRANCH (current_architecture))
{
*buffer_address++ = 0x60; /* Put in bral (0x60ff). */
*buffer_address++ = (char) 0xff;
}
else
{
*buffer_address++ = 0x4e; /* Put in jmp long (0x4ef9). */
*buffer_address++ = (char) 0xf9; *buffer_address++ = (char) 0xf9;
}
fragP->fr_fix += 6; /* account for bra/jmp instructions */ fragP->fr_fix += 6; /* account for bra/jmp instructions */
fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
fragP->fr_offset, 0, NO_RELOC); fragP->fr_offset, HAVE_LONG_BRANCH (current_architecture),
NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
ext = 0; ext = 0;
break; break;
@ -4532,7 +4551,8 @@ md_estimate_size_before_relax (fragP, segment)
fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), BYTE); fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), BYTE);
break; break;
} }
else if ((fragP->fr_symbol != NULL) && flag_short_refs) else if ((fragP->fr_symbol != NULL)
&& (flag_short_refs || flag_keep_pcrel))
{ /* Symbol is undefined and we want short ref */ { /* Symbol is undefined and we want short ref */
fix_new (fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol, fix_new (fragP, (int) (fragP->fr_fix), 2, fragP->fr_symbol,
fragP->fr_offset, 1, NO_RELOC); fragP->fr_offset, 1, NO_RELOC);
@ -4630,7 +4650,7 @@ md_estimate_size_before_relax (fragP, segment)
break; break;
} }
/* only Bcc 68000 instructions can come here */ /* only Bcc 68000 instructions can come here */
if ((fragP->fr_symbol != NULL) && flag_short_refs) if ((fragP->fr_symbol != NULL) && (flag_short_refs || flag_keep_pcrel))
{ {
/* the user wants short refs, so emit one */ /* the user wants short refs, so emit one */
fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol,
@ -4666,7 +4686,10 @@ md_estimate_size_before_relax (fragP, segment)
} }
/* only DBcc 68000 instructions can come here */ /* only DBcc 68000 instructions can come here */
if (fragP->fr_symbol != NULL && flag_short_refs) if (fragP->fr_symbol != NULL
&& (flag_short_refs
|| (! HAVE_LONG_BRANCH (current_architecture)
&& flag_keep_pcrel)))
{ {
/* the user wants short refs, so emit one */ /* the user wants short refs, so emit one */
fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol, fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol,
@ -4675,18 +4698,27 @@ md_estimate_size_before_relax (fragP, segment)
} }
else else
{ {
/* change dbcc into dbcc/jmp absl long */ /* Change dbcc into dbcc/bral. */
/* JF: these used to be fr_opcode[2-4], which is wrong. */ /* JF: these used to be fr_opcode[2-4], which is wrong. */
buffer_address[0] = 0x00; /* branch offset = 4 */ buffer_address[0] = 0x00; /* branch offset = 4 */
buffer_address[1] = 0x04; buffer_address[1] = 0x04;
buffer_address[2] = 0x60; /* put in bra pc + ... */ buffer_address[2] = 0x60; /* put in bra pc + ... */
/* JF: these were fr_opcode[5-7] */ /* JF: these were fr_opcode[5-7] */
buffer_address[3] = 0x06; /* Plus 6 */ buffer_address[3] = 0x06; /* Plus 6 */
buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */ if (HAVE_LONG_BRANCH (current_architecture))
{
buffer_address[4] = 0x60; /* Put in bral (0x60ff). */
buffer_address[5] = (char) 0xff;
}
else
{
buffer_address[4] = 0x4e; /* Put in jmp long (0x4ef9). */
buffer_address[5] = (char) 0xf9; buffer_address[5] = (char) 0xf9;
}
fragP->fr_fix += 6; /* account for bra/jmp instruction */ fragP->fr_fix += 6; /* account for bra/jmp instruction */
fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol, fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
fragP->fr_offset, 0, NO_RELOC); fragP->fr_offset, HAVE_LONG_BRANCH (current_architecture),
NO_RELOC);
fragP->fr_fix += 4; fragP->fr_fix += 4;
} }
@ -6745,6 +6777,7 @@ s_mri_endw (ignore)
* *
* -pic Indicates PIC. * -pic Indicates PIC.
* -k Indicates PIC. (Sun 3 only.) * -k Indicates PIC. (Sun 3 only.)
* --pcrel Never turn PC-relative branches into absolute jumps.
* *
* --bitwise-or * --bitwise-or
* Permit `|' to be used in expressions. * Permit `|' to be used in expressions.
@ -6773,6 +6806,8 @@ struct option md_longopts[] = {
{"disp-size-default-16", no_argument, NULL, OPTION_DISP_SIZE_DEFAULT_16}, {"disp-size-default-16", no_argument, NULL, OPTION_DISP_SIZE_DEFAULT_16},
#define OPTION_DISP_SIZE_DEFAULT_32 (OPTION_MD_BASE + 6) #define OPTION_DISP_SIZE_DEFAULT_32 (OPTION_MD_BASE + 6)
{"disp-size-default-32", no_argument, NULL, OPTION_DISP_SIZE_DEFAULT_32}, {"disp-size-default-32", no_argument, NULL, OPTION_DISP_SIZE_DEFAULT_32},
#define OPTION_PCREL (OPTION_MD_BASE + 7)
{"pcrel", no_argument, NULL, OPTION_PCREL},
{NULL, no_argument, NULL, 0} {NULL, no_argument, NULL, 0}
}; };
size_t md_longopts_size = sizeof(md_longopts); size_t md_longopts_size = sizeof(md_longopts);
@ -6794,6 +6829,11 @@ md_parse_option (c, arg)
flag_long_jumps = 1; flag_long_jumps = 1;
break; break;
case OPTION_PCREL: /* --pcrel means never turn PC-relative
branches into absolute jumps. */
flag_keep_pcrel = 1;
break;
case 'A': case 'A':
if (*arg == 'm') if (*arg == 'm')
arg++; arg++;
@ -6950,6 +6990,7 @@ md_show_usage (stream)
[default yes for 68020 and up]\n\ [default yes for 68020 and up]\n\
-pic, -k generate position independent code\n\ -pic, -k generate position independent code\n\
-S turn jbsr into jsr\n\ -S turn jbsr into jsr\n\
--pcrel never turn PC-relative branches into absolute jumps\n\
--register-prefix-optional\n\ --register-prefix-optional\n\
recognize register names without prefix character\n\ recognize register names without prefix character\n\
--bitwise-or do not treat `|' as a comment character\n")); --bitwise-or do not treat `|' as a comment character\n"));

442
gas/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -84,6 +84,13 @@ to instead assume that the displacement is 16 bits. In this case,
@samp{disp} is a 16 bit value. You may use the @samp{disp} is a 16 bit value. You may use the
@samp{--disp-size-default-32} option to restore the default behaviour. @samp{--disp-size-default-32} option to restore the default behaviour.
@cindex @samp{--pcrel}
Always generate PC relative branches. Actually what this option really
does is to prevent PC relative branches from being turned into absolute
jumps. If this cannot be done (because the specific architecture does
not have a suitable PC relative branch instruction), the assembler will
generate an error message.
@cindex @samp{-m68000} and related options @cindex @samp{-m68000} and related options
@cindex architecture options, M680x0 @cindex architecture options, M680x0
@cindex M680x0 architecture options @cindex M680x0 architecture options

View File

@ -126,18 +126,18 @@ ecoff.c
ecoff.h ecoff.h
ehopt.c ehopt.c
ehopt.c ehopt.c
emul-target.h
emul.h emul.h
emul-target.h
expr.c expr.c
expr.c expr.c
expr.h expr.h
flonum-copy.c flonum-copy.c
flonum-copy.c flonum-copy.c
flonum-konst.c
flonum-konst.c
flonum-mult.c
flonum-mult.c
flonum.h flonum.h
flonum-konst.c
flonum-konst.c
flonum-mult.c
flonum-mult.c
frags.c frags.c
frags.c frags.c
frags.h frags.h

File diff suppressed because it is too large Load Diff