aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog33
-rw-r--r--gas/NEWS7
-rw-r--r--gas/config.in3
-rw-r--r--gas/config/tc-i386.c30
-rwxr-xr-xgas/configure38
-rw-r--r--gas/configure.ac29
-rw-r--r--gas/doc/c-i386.texi12
-rw-r--r--gas/testsuite/gas/i386/got-no-relax.d31
-rw-r--r--gas/testsuite/gas/i386/got.d1
-rw-r--r--gas/testsuite/gas/i386/i386.exp2
-rw-r--r--gas/testsuite/gas/i386/ilp32/x86-64-gotpcrel.d1
-rw-r--r--gas/testsuite/gas/i386/ilp32/x86-64-localpic.d1
-rw-r--r--gas/testsuite/gas/i386/localpic.d1
-rw-r--r--gas/testsuite/gas/i386/mixed-mode-reloc32.d1
-rw-r--r--gas/testsuite/gas/i386/reloc32.d1
-rw-r--r--gas/testsuite/gas/i386/x86-64-gotpcrel-no-relax.d27
-rw-r--r--gas/testsuite/gas/i386/x86-64-gotpcrel.d1
-rw-r--r--gas/testsuite/gas/i386/x86-64-localpic.d1
18 files changed, 215 insertions, 5 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 56146c7..da426fc 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -4,6 +4,39 @@
2016-02-03 H.J. Lu <hongjiu.lu@intel.com>
+ PR gas/19520
+ * NEWS: Mention new command line option -mrelax-relocations and
+ new configure option --enable-x86-relax-relocations for x86
+ target.
+ * config.in: Regenerated.
+ * configure.ac: Add --enable-x86-relax-relocations.
+ (ac_default_x86_relax_relocations): New. Default to 1 except
+ for x86 Solaris targets older than Solaris 12.
+ (DEFAULT_GENERATE_X86_RELAX_RELOCATIONS): Define.
+ * configure: Likewise.
+ * config/tc-i386.c (generate_relax_relocations): New.
+ (OPTION_MRELAX_RELOCATIONS): Likewise.
+ (output_disp): Don't generate relax relocations if
+ generate_relax_relocations is 0.
+ (md_longopts): Add -mrelax-relocations.
+ (md_show_usage): Likewise.
+ (md_parse_option): Handle OPTION_MRELAX_RELOCATIONS.
+ * doc/c-i386.texi: Document -mrelax-relocations=.
+ * testsuite/gas/i386/got-no-relax.d: New file.
+ * testsuite/gas/i386/x86-64-gotpcrel-no-relax.d: Likewise.
+ * testsuite/gas/i386/got.d: Pass -mrelax-relocations=yes to as.
+ * testsuite/gas/i386/localpic.d: Likewise.
+ * testsuite/gas/i386/mixed-mode-reloc32.d: Likewise.
+ * testsuite/gas/i386/reloc32.d: Likewise.
+ * testsuite/gas/i386/x86-64-gotpcrel.d: Likewise.
+ * testsuite/gas/i386/x86-64-localpic.d: Likewise.
+ * testsuite/gas/i386/ilp32/x86-64-gotpcrel.d: Likewise.
+ * testsuite/gas/i386/ilp32/x86-64-localpic.d: Likewise.
+ * testsuite/gas/i386/i386.exp: Run got-no-relax and
+ x86-64-gotpcrel-no-relax.
+
+2016-02-03 H.J. Lu <hongjiu.lu@intel.com>
+
* NEWS: Mention new command line option -mfence-as-lock-add=yes
for x86 target.
diff --git a/gas/NEWS b/gas/NEWS
index fdcbac4..7175ef0 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -1,5 +1,12 @@
-*- text -*-
+* Add a configure option --enable-x86-relax-relocations to decide whether
+ x86 assembler should generate relax relocations by default. Default to
+ yes, except for x86 Solaris targets older than Solaris 12.
+
+* New command line option -mrelax-relocations= for x86 target to control
+ whether to generate relax relocations.
+
* New command line option -mfence-as-lock-add=yes for x86 target to encode
lfence, mfence and sfence as "lock addl $0x0, (%[re]sp)".
diff --git a/gas/config.in b/gas/config.in
index 35c8202..8b040fc 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -39,6 +39,9 @@
/* Define if you want compressed debug sections by default. */
#undef DEFAULT_FLAG_COMPRESS_DEBUG
+/* Define to 1 if you want to generate x86 relax relocations by default. */
+#undef DEFAULT_GENERATE_X86_RELAX_RELOCATIONS
+
/* Supported emulations. */
#undef EMULATIONS
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 3a98b21..2bc7616 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -556,6 +556,11 @@ static int omit_lock_prefix = 0;
"lock addl $0, (%{re}sp)". */
static int avoid_fence = 0;
+/* 1 if the assembler should generate relax relocations. */
+
+static int generate_relax_relocations
+ = DEFAULT_GENERATE_X86_RELAX_RELOCATIONS;
+
static enum check_kind
{
check_none = 0,
@@ -7267,9 +7272,14 @@ output_disp (fragS *insn_start_frag, offsetT insn_start_off)
/* Check for "call/jmp *mem", "mov mem, %reg",
"test %reg, mem" and "binop mem, %reg" where binop
is one of adc, add, and, cmp, or, sbb, sub, xor
- instructions. */
- if ((i.rm.mode == 2
- || (i.rm.mode == 0 && i.rm.regmem == 5))
+ instructions. Always generate R_386_GOT32X for
+ "sym*GOT" operand in 32-bit mode. */
+ if ((generate_relax_relocations
+ || (!object_64bit
+ && i.rm.mode == 0
+ && i.rm.regmem == 5))
+ && (i.rm.mode == 2
+ || (i.rm.mode == 0 && i.rm.regmem == 5))
&& ((i.operands == 1
&& i.tm.base_opcode == 0xff
&& (i.rm.reg == 2 || i.rm.reg == 4))
@@ -9643,6 +9653,7 @@ const char *md_shortopts = "qn";
#define OPTION_MAMD64 (OPTION_MD_BASE + 22)
#define OPTION_MINTEL64 (OPTION_MD_BASE + 23)
#define OPTION_MFENCE_AS_LOCK_ADD (OPTION_MD_BASE + 24)
+#define OPTION_MRELAX_RELOCATIONS (OPTION_MD_BASE + 25)
struct option md_longopts[] =
{
@@ -9675,6 +9686,7 @@ struct option md_longopts[] =
#endif
{"momit-lock-prefix", required_argument, NULL, OPTION_MOMIT_LOCK_PREFIX},
{"mfence-as-lock-add", required_argument, NULL, OPTION_MFENCE_AS_LOCK_ADD},
+ {"mrelax-relocations", required_argument, NULL, OPTION_MRELAX_RELOCATIONS},
{"mevexrcig", required_argument, NULL, OPTION_MEVEXRCIG},
{"mamd64", no_argument, NULL, OPTION_MAMD64},
{"mintel64", no_argument, NULL, OPTION_MINTEL64},
@@ -10003,6 +10015,15 @@ md_parse_option (int c, char *arg)
as_fatal (_("invalid -mfence-as-lock-add= option: `%s'"), arg);
break;
+ case OPTION_MRELAX_RELOCATIONS:
+ if (strcasecmp (arg, "yes") == 0)
+ generate_relax_relocations = 1;
+ else if (strcasecmp (arg, "no") == 0)
+ generate_relax_relocations = 0;
+ else
+ as_fatal (_("invalid -mrelax-relocations= option: `%s'"), arg);
+ break;
+
case OPTION_MAMD64:
cpu_arch_flags.bitfield.cpuamd64 = 1;
cpu_arch_flags.bitfield.cpuintel64 = 0;
@@ -10187,6 +10208,9 @@ md_show_usage (FILE *stream)
encode lfence, mfence and sfence as\n\
lock addl $0x0, (%%{re}sp)\n"));
fprintf (stream, _("\
+ -mrelax-relocations=[no|yes]\n\
+ generate relax relocations\n"));
+ fprintf (stream, _("\
-mamd64 accept only AMD64 ISA\n"));
fprintf (stream, _("\
-mintel64 accept only Intel64 ISA\n"));
diff --git a/gas/configure b/gas/configure
index b1731f0..cd7182f 100755
--- a/gas/configure
+++ b/gas/configure
@@ -765,6 +765,7 @@ enable_largefile
enable_targets
enable_checking
enable_compressed_debug_sections
+enable_x86_relax_relocations
enable_werror
enable_build_warnings
enable_nls
@@ -1415,6 +1416,8 @@ Optional Features:
--enable-checking enable run-time checks
--enable-compressed-debug-sections={all,gas,none}
compress debug sections by default
+ --enable-x86-relax-relocations
+ generate x86 relax relocations by default
--enable-werror treat compile warnings as errors
--enable-build-warnings enable build-time compiler warnings
--disable-nls do not use Native Language Support
@@ -10972,7 +10975,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10975 "configure"
+#line 10978 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11078,7 +11081,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11081 "configure"
+#line 11084 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11680,6 +11683,17 @@ if test "${enable_compressed_debug_sections+set}" = set; then :
esac
fi
+# PR gas/19520
+# Decide if x86 assembler should generate relax relocations.
+ac_default_x86_relax_relocations=unset
+# Provide a configure time option to override our default.
+# Check whether --enable-x86_relax_relocations was given.
+if test "${enable_x86_relax_relocations+set}" = set; then :
+ enableval=$enable_x86_relax_relocations; case "${enableval}" in
+ no) ac_default_x86_relax_relocations=0 ;;
+esac
+fi
+
using_cgen=no
@@ -12085,6 +12099,17 @@ $as_echo "#define STRICTCOFF 1" >>confdefs.h
;;
+ i386-*-solaris2 \
+ | x86_64-*-solaris2 \
+ | i386-*-solaris2.[0-9] \
+ | i386-*-solaris2.1[01] \
+ | x86_64-*-solaris2.1[01])
+ if test ${this_target} = $target \
+ && test ${ac_default_x86_relax_relocations} = unset; then
+ ac_default_x86_relax_relocations=0
+ fi
+ ;;
+
i860-*-*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: GAS support for ${generic_target} is preliminary and a work in progress" >&5
$as_echo "$as_me: WARNING: GAS support for ${generic_target} is preliminary and a work in progress" >&2;}
@@ -12505,6 +12530,15 @@ _ACEOF
done
+if test ${ac_default_x86_relax_relocations} = unset; then
+ ac_default_x86_relax_relocations=1
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_GENERATE_X86_RELAX_RELOCATIONS $ac_default_x86_relax_relocations
+_ACEOF
+
+
if test x$ac_default_compressed_debug_sections = xyes ; then
$as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h
diff --git a/gas/configure.ac b/gas/configure.ac
index 9af5121..377526e 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -77,6 +77,17 @@ AC_ARG_ENABLE(compressed_debug_sections,
*) ac_default_compressed_debug_sections=unset ;;
esac])dnl
+# PR gas/19520
+# Decide if x86 assembler should generate relax relocations.
+ac_default_x86_relax_relocations=unset
+# Provide a configure time option to override our default.
+AC_ARG_ENABLE(x86_relax_relocations,
+ AS_HELP_STRING([--enable-x86-relax-relocations],
+ [generate x86 relax relocations by default]),
+[case "${enableval}" in
+ no) ac_default_x86_relax_relocations=0 ;;
+esac])dnl
+
using_cgen=no
AM_BINUTILS_WARNINGS
@@ -168,6 +179,17 @@ for this_target in $target $canon_targets ; do
AC_DEFINE(STRICTCOFF, 1, [Using strict COFF?])
;;
+ i386-*-solaris2 \
+ | x86_64-*-solaris2 \
+ | i386-*-solaris2.[[0-9]] \
+ | i386-*-solaris2.1[[01]] \
+ | x86_64-*-solaris2.1[[01]])
+ if test ${this_target} = $target \
+ && test ${ac_default_x86_relax_relocations} = unset; then
+ ac_default_x86_relax_relocations=0
+ fi
+ ;;
+
i860-*-*)
AC_MSG_WARN(GAS support for ${generic_target} is preliminary and a work in progress)
;;
@@ -549,6 +571,13 @@ changequote([,])dnl
done
+if test ${ac_default_x86_relax_relocations} = unset; then
+ ac_default_x86_relax_relocations=1
+fi
+AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_X86_RELAX_RELOCATIONS,
+ $ac_default_x86_relax_relocations,
+ [Define to 1 if you want to generate x86 relax relocations by default.])
+
if test x$ac_default_compressed_debug_sections = xyes ; then
AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.])
fi
diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi
index 357851a..7d50349 100644
--- a/gas/doc/c-i386.texi
+++ b/gas/doc/c-i386.texi
@@ -339,6 +339,18 @@ sfence as @samp{lock addl $0x0, (%rsp)} in 64-bit mode and
@option{-mfence-as-lock-add=@var{no}} will encode lfence, mfence and
sfence as usual, which is the default.
+@cindex @samp{-mrelax-relocations=} option, i386
+@cindex @samp{-mrelax-relocations=} option, x86-64
+@item -mrelax-relocations=@var{no}
+@itemx -mrelax-relocations=@var{yes}
+These options control whether the assembler should generate relax
+relocations, R_386_GOT32X, in 32-bit mode, or R_X86_64_GOTPCRELX and
+R_X86_64_REX_GOTPCRELX, in 64-bit mode.
+@option{-mrelax-relocations=@var{yes}} will generate relax relocations.
+@option{-mrelax-relocations=@var{no}} will not generate relax
+relocations. The default can be controlled by a configure option
+@option{--enable-x86-relax-relocations}.
+
@cindex @samp{-mevexrcig=} option, i386
@cindex @samp{-mevexrcig=} option, x86-64
@item -mevexrcig=@var{rne}
diff --git a/gas/testsuite/gas/i386/got-no-relax.d b/gas/testsuite/gas/i386/got-no-relax.d
new file mode 100644
index 0000000..6bf138a
--- /dev/null
+++ b/gas/testsuite/gas/i386/got-no-relax.d
@@ -0,0 +1,31 @@
+#source: got.s
+#as: -mrelax-relocations=no
+#objdump: -dwr
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <_start>:
+[ ]*[a-f0-9]+: b8 00 00 00 00 mov \$0x0,%eax 1: R_386_GOT32 foo
+[ ]*[a-f0-9]+: 8b 05 00 00 00 00 mov 0x0,%eax 7: R_386_GOT32X foo
+[ ]*[a-f0-9]+: 8b 80 00 00 00 00 mov 0x0\(%eax\),%eax d: R_386_GOT32 foo
+[ ]*[a-f0-9]+: 05 00 00 00 00 add \$0x0,%eax 12: R_386_GOT32 foo
+[ ]*[a-f0-9]+: 03 05 00 00 00 00 add 0x0,%eax 18: R_386_GOT32X foo
+[ ]*[a-f0-9]+: 03 80 00 00 00 00 add 0x0\(%eax\),%eax 1e: R_386_GOT32 foo
+[ ]*[a-f0-9]+: ff 15 00 00 00 00 call \*0x0 24: R_386_GOT32X foo
+[ ]*[a-f0-9]+: ff 90 00 00 00 00 call \*0x0\(%eax\) 2a: R_386_GOT32 foo
+[ ]*[a-f0-9]+: ff 25 00 00 00 00 jmp \*0x0 30: R_386_GOT32X foo
+[ ]*[a-f0-9]+: ff a0 00 00 00 00 jmp \*0x0\(%eax\) 36: R_386_GOT32 foo
+[ ]*[a-f0-9]+: b8 00 00 00 00 mov \$0x0,%eax 3b: R_386_GOT32 foo
+[ ]*[a-f0-9]+: 8b 05 00 00 00 00 mov 0x0,%eax 41: R_386_GOT32X foo
+[ ]*[a-f0-9]+: 8b 80 00 00 00 00 mov 0x0\(%eax\),%eax 47: R_386_GOT32 foo
+[ ]*[a-f0-9]+: 05 00 00 00 00 add \$0x0,%eax 4c: R_386_GOT32 foo
+[ ]*[a-f0-9]+: 03 05 00 00 00 00 add 0x0,%eax 52: R_386_GOT32X foo
+[ ]*[a-f0-9]+: 03 80 00 00 00 00 add 0x0\(%eax\),%eax 58: R_386_GOT32 foo
+[ ]*[a-f0-9]+: ff 90 00 00 00 00 call \*0x0\(%eax\) 5e: R_386_GOT32 foo
+[ ]*[a-f0-9]+: ff 15 00 00 00 00 call \*0x0 64: R_386_GOT32X foo
+[ ]*[a-f0-9]+: ff a0 00 00 00 00 jmp \*0x0\(%eax\) 6a: R_386_GOT32 foo
+[ ]*[a-f0-9]+: ff 25 00 00 00 00 jmp \*0x0 70: R_386_GOT32X foo
+#pass
diff --git a/gas/testsuite/gas/i386/got.d b/gas/testsuite/gas/i386/got.d
index f76ca47..7621cdf 100644
--- a/gas/testsuite/gas/i386/got.d
+++ b/gas/testsuite/gas/i386/got.d
@@ -1,3 +1,4 @@
+#as: -mrelax-relocations=yes
#objdump: -dwr
.*: +file format .*
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index b9144c4..22aca23 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -408,6 +408,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
run_dump_test "relax-4"
run_dump_test "got"
+ run_dump_test "got-no-relax"
if {![istarget "*-*-nacl*"]} then {
run_dump_test "iamcu-1"
@@ -788,6 +789,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
run_list_test "x86-64-branch-3" "-al -mintel64"
run_dump_test "x86-64-gotpcrel"
+ run_dump_test "x86-64-gotpcrel-no-relax"
}
set ASFLAGS "$old_ASFLAGS"
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-gotpcrel.d b/gas/testsuite/gas/i386/ilp32/x86-64-gotpcrel.d
index e5a3b1c..1314e5b 100644
--- a/gas/testsuite/gas/i386/ilp32/x86-64-gotpcrel.d
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-gotpcrel.d
@@ -1,4 +1,5 @@
#source: ../x86-64-gotpcrel.s
+#as: --x32 -mrelax-relocations=yes
#objdump: -dwr
#name: x86-64 (ILP32) gotpcrel
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-localpic.d b/gas/testsuite/gas/i386/ilp32/x86-64-localpic.d
index 0ca69c7..a9528a2 100644
--- a/gas/testsuite/gas/i386/ilp32/x86-64-localpic.d
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-localpic.d
@@ -1,4 +1,5 @@
#source: ../x86-64-localpic.s
+#as: --x32 -mrelax-relocations=yes
#readelf: -rsW
#name: x86-64 (ILP32) local PIC
diff --git a/gas/testsuite/gas/i386/localpic.d b/gas/testsuite/gas/i386/localpic.d
index 04fb5ce..0a5eec5 100644
--- a/gas/testsuite/gas/i386/localpic.d
+++ b/gas/testsuite/gas/i386/localpic.d
@@ -1,3 +1,4 @@
+#as: -mrelax-relocations=yes
#readelf: -rs
#name: i386 local PIC
diff --git a/gas/testsuite/gas/i386/mixed-mode-reloc32.d b/gas/testsuite/gas/i386/mixed-mode-reloc32.d
index 9affc36..a2ef6a0 100644
--- a/gas/testsuite/gas/i386/mixed-mode-reloc32.d
+++ b/gas/testsuite/gas/i386/mixed-mode-reloc32.d
@@ -1,3 +1,4 @@
+#as: -mrelax-relocations=yes
#objdump: -r
#source: mixed-mode-reloc.s
#name: x86 mixed mode relocs (32-bit object)
diff --git a/gas/testsuite/gas/i386/reloc32.d b/gas/testsuite/gas/i386/reloc32.d
index 45c9cd2..b6e1bbd 100644
--- a/gas/testsuite/gas/i386/reloc32.d
+++ b/gas/testsuite/gas/i386/reloc32.d
@@ -1,3 +1,4 @@
+#as: -mrelax-relocations=yes
#objdump: -Drw
#name: i386 relocs
diff --git a/gas/testsuite/gas/i386/x86-64-gotpcrel-no-relax.d b/gas/testsuite/gas/i386/x86-64-gotpcrel-no-relax.d
new file mode 100644
index 0000000..a3f8943
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-gotpcrel-no-relax.d
@@ -0,0 +1,27 @@
+#source: x86-64-gotpcrel.s
+#as: -mrelax-relocations=no
+#objdump: -dwr
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <_start>:
+[ ]*[a-f0-9]+: 48 c7 c0 00 00 00 00 mov \$0x0,%rax 3: R_X86_64_GOTPCREL foo
+[ ]*[a-f0-9]+: 48 8b 04 25 00 00 00 00 mov 0x0,%rax b: R_X86_64_GOTPCREL foo
+[ ]*[a-f0-9]+: 48 8b 05 00 00 00 00 mov 0x0\(%rip\),%rax # 16 <_start\+0x16> 12: R_X86_64_GOTPCREL foo-0x4
+[ ]*[a-f0-9]+: 48 8b 81 00 00 00 00 mov 0x0\(%rcx\),%rax 19: R_X86_64_GOTPCREL foo
+[ ]*[a-f0-9]+: ff 15 00 00 00 00 callq \*0x0\(%rip\) # 23 <_start\+0x23> 1f: R_X86_64_GOTPCREL foo-0x4
+[ ]*[a-f0-9]+: ff 90 00 00 00 00 callq \*0x0\(%rax\) 25: R_X86_64_GOTPCREL foo
+[ ]*[a-f0-9]+: ff 25 00 00 00 00 jmpq \*0x0\(%rip\) # 2f <_start\+0x2f> 2b: R_X86_64_GOTPCREL foo-0x4
+[ ]*[a-f0-9]+: ff a1 00 00 00 00 jmpq \*0x0\(%rcx\) 31: R_X86_64_GOTPCREL foo
+[ ]*[a-f0-9]+: 48 c7 c0 00 00 00 00 mov \$0x0,%rax 38: R_X86_64_GOTPCREL foo
+[ ]*[a-f0-9]+: 48 8b 04 25 00 00 00 00 mov 0x0,%rax 40: R_X86_64_GOTPCREL foo
+[ ]*[a-f0-9]+: 48 8b 05 00 00 00 00 mov 0x0\(%rip\),%rax # 4b <_start\+0x4b> 47: R_X86_64_GOTPCREL foo-0x4
+[ ]*[a-f0-9]+: 48 8b 81 00 00 00 00 mov 0x0\(%rcx\),%rax 4e: R_X86_64_GOTPCREL foo
+[ ]*[a-f0-9]+: ff 15 00 00 00 00 callq \*0x0\(%rip\) # 58 <_start\+0x58> 54: R_X86_64_GOTPCREL foo-0x4
+[ ]*[a-f0-9]+: ff 90 00 00 00 00 callq \*0x0\(%rax\) 5a: R_X86_64_GOTPCREL foo
+[ ]*[a-f0-9]+: ff 25 00 00 00 00 jmpq \*0x0\(%rip\) # 64 <_start\+0x64> 60: R_X86_64_GOTPCREL foo-0x4
+[ ]*[a-f0-9]+: ff a1 00 00 00 00 jmpq \*0x0\(%rcx\) 66: R_X86_64_GOTPCREL foo
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-gotpcrel.d b/gas/testsuite/gas/i386/x86-64-gotpcrel.d
index 6ca3fc7..fbe5e47 100644
--- a/gas/testsuite/gas/i386/x86-64-gotpcrel.d
+++ b/gas/testsuite/gas/i386/x86-64-gotpcrel.d
@@ -1,3 +1,4 @@
+#as: -mrelax-relocations=yes
#objdump: -dwr
.*: +file format .*
diff --git a/gas/testsuite/gas/i386/x86-64-localpic.d b/gas/testsuite/gas/i386/x86-64-localpic.d
index 0a07149..bafaa9c 100644
--- a/gas/testsuite/gas/i386/x86-64-localpic.d
+++ b/gas/testsuite/gas/i386/x86-64-localpic.d
@@ -1,3 +1,4 @@
+#as: -mrelax-relocations=yes
#readelf: -rsW
#name: x86-64 local PIC