• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisión8dcea93252a9ea7dff57e85220a719e2a5e8ab41 (tree)
Tiempo2015-05-15 19:30:53
AutorH.J. Lu <hjl.tools@gmai...>
CommiterH.J. Lu

Log Message

Add -mshared option to x86 ELF assembler

This patch adds -mshared option to x86 ELF assembler. By default,
assembler will optimize out non-PLT relocations against defined non-weak
global branch targets with default visibility. The -mshared option tells
the assembler to generate code which may go into a shared library
where all non-weak global branch targets with default visibility can
be preempted. The resulting code is slightly bigger. This option
only affects the handling of branch instructions.

This Linux kernel patch is needed to create a working x86 Linux kernel if
it hasn't been applied:

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index ae6588b..b91a00c 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -339,8 +339,8 @@ early_idt_handlers:

i = i + 1
.endr

-/* This is global to keep gas from relaxing the jumps */
-ENTRY(early_idt_handler)
+/* This is weak to keep gas from relaxing the jumps */
+WEAK(early_idt_handler)

cld
cmpl $2,(%rsp) # X86_TRAP_NMI

--

gas/

* config/tc-i386.c (shared): New.
(OPTION_MSHARED): Likewise.
(elf_symbol_resolved_in_segment_p): Add relocation argument.
Check PLT relocations and shared.
(md_estimate_size_before_relax): Pass fragP->fr_var to
elf_symbol_resolved_in_segment_p.
(md_longopts): Add -mshared.
(md_show_usage): Likewise.
(md_parse_option): Handle OPTION_MSHARED.
* doc/c-i386.texi: Document -mshared.

gas/testsuite/

* gas/i386/i386.exp: Don't run pcrel for ELF targets. Run
pcrel-elf, relax-4 and x86-64-relax-3 for ELF targets.
* gas/i386/pcrel-elf.d: New file.
* gas/i386/relax-4.d: Likewise.
* gas/i386/x86-64-relax-3.d: Likewise.
* gas/i386/relax-3.d: Pass -mshared to assembler. Updated.
* gas/i386/x86-64-relax-2.d: Likewise.
* gas/i386/relax-3.s: Add test for PLT relocation.

Cambiar Resumen

Diferencia incremental

--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,16 @@
1+2015-05-15 H.J. Lu <hongjiu.lu@intel.com>
2+
3+ * config/tc-i386.c (shared): New.
4+ (OPTION_MSHARED): Likewise.
5+ (elf_symbol_resolved_in_segment_p): Add relocation argument.
6+ Check PLT relocations and shared.
7+ (md_estimate_size_before_relax): Pass fragP->fr_var to
8+ elf_symbol_resolved_in_segment_p.
9+ (md_longopts): Add -mshared.
10+ (md_show_usage): Likewise.
11+ (md_parse_option): Handle OPTION_MSHARED.
12+ * doc/c-i386.texi: Document -mshared.
13+
114 2015-05-14 H.J. Lu <hongjiu.lu@intel.com>
215
316 * write.c (compress_debug): Don't write the zlib header, which
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -524,6 +524,11 @@ static enum x86_elf_abi x86_elf_abi = I386_ABI;
524524 static int use_big_obj = 0;
525525 #endif
526526
527+#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
528+/* 1 if generating code for a shared library. */
529+static int shared = 0;
530+#endif
531+
527532 /* 1 for intel syntax,
528533 0 if att syntax. */
529534 static int intel_syntax = 0;
@@ -8818,7 +8823,7 @@ i386_frag_max_var (fragS *frag)
88188823
88198824 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
88208825 static int
8821-elf_symbol_resolved_in_segment_p (symbolS *fr_symbol)
8826+elf_symbol_resolved_in_segment_p (symbolS *fr_symbol, offsetT fr_var)
88228827 {
88238828 /* STT_GNU_IFUNC symbol must go through PLT. */
88248829 if ((symbol_get_bfdsym (fr_symbol)->flags
@@ -8829,9 +8834,24 @@ elf_symbol_resolved_in_segment_p (symbolS *fr_symbol)
88298834 /* Symbol may be weak or local. */
88308835 return !S_IS_WEAK (fr_symbol);
88318836
8837+ /* Global symbols with non-default visibility can't be preempted. */
8838+ if (ELF_ST_VISIBILITY (S_GET_OTHER (fr_symbol)) != STV_DEFAULT)
8839+ return 1;
8840+
8841+ if (fr_var != NO_RELOC)
8842+ switch ((enum bfd_reloc_code_real) fr_var)
8843+ {
8844+ case BFD_RELOC_386_PLT32:
8845+ case BFD_RELOC_X86_64_PLT32:
8846+ /* Symbol with PLT relocatin may be preempted. */
8847+ return 0;
8848+ default:
8849+ abort ();
8850+ }
8851+
88328852 /* Global symbols with default visibility in a shared library may be
88338853 preempted by another definition. */
8834- return ELF_ST_VISIBILITY (S_GET_OTHER (fr_symbol)) != STV_DEFAULT;
8854+ return !shared;
88358855 }
88368856 #endif
88378857
@@ -8858,7 +8878,8 @@ md_estimate_size_before_relax (fragS *fragP, segT segment)
88588878 if (S_GET_SEGMENT (fragP->fr_symbol) != segment
88598879 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
88608880 || (IS_ELF
8861- && !elf_symbol_resolved_in_segment_p (fragP->fr_symbol))
8881+ && !elf_symbol_resolved_in_segment_p (fragP->fr_symbol,
8882+ fragP->fr_var))
88628883 #endif
88638884 #if defined (OBJ_COFF) && defined (TE_PE)
88648885 || (OUTPUT_FLAVOR == bfd_target_coff_flavour
@@ -9528,6 +9549,7 @@ const char *md_shortopts = "qn";
95289549 #define OPTION_MBIG_OBJ (OPTION_MD_BASE + 18)
95299550 #define OPTION_OMIT_LOCK_PREFIX (OPTION_MD_BASE + 19)
95309551 #define OPTION_MEVEXRCIG (OPTION_MD_BASE + 20)
9552+#define OPTION_MSHARED (OPTION_MD_BASE + 21)
95319553
95329554 struct option md_longopts[] =
95339555 {
@@ -9538,6 +9560,7 @@ struct option md_longopts[] =
95389560 #endif
95399561 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
95409562 {"x32", no_argument, NULL, OPTION_X32},
9563+ {"mshared", no_argument, NULL, OPTION_MSHARED},
95419564 #endif
95429565 {"divide", no_argument, NULL, OPTION_DIVIDE},
95439566 {"march", required_argument, NULL, OPTION_MARCH},
@@ -9598,6 +9621,10 @@ md_parse_option (int c, char *arg)
95989621 /* -s: On i386 Solaris, this tells the native assembler to use
95999622 .stab instead of .stab.excl. We always use .stab anyhow. */
96009623 break;
9624+
9625+ case OPTION_MSHARED:
9626+ shared = 1;
9627+ break;
96019628 #endif
96029629 #if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
96039630 || defined (TE_PE) || defined (TE_PEP) || defined (OBJ_MACH_O))
@@ -10027,6 +10054,8 @@ md_show_usage (FILE *stream)
1002710054 -mold-gcc support old (<= 2.8.1) versions of gcc\n"));
1002810055 fprintf (stream, _("\
1002910056 -madd-bnd-prefix add BND prefix for all valid branches\n"));
10057+ fprintf (stream, _("\
10058+ -mshared disable branch optimization for shared code\n"));
1003010059 # if defined (TE_PE) || defined (TE_PEP)
1003110060 fprintf (stream, _("\
1003210061 -mbig-obj generate big object files\n"));
--- a/gas/doc/c-i386.texi
+++ b/gas/doc/c-i386.texi
@@ -298,6 +298,17 @@ The @code{.att_syntax} and @code{.intel_syntax} directives will take precedent.
298298 This option forces the assembler to add BND prefix to all branches, even
299299 if such prefix was not explicitly specified in the source code.
300300
301+@cindex @samp{-mshared} option, i386
302+@cindex @samp{-mshared} option, x86-64
303+@item -mno-shared
304+On ELF target, the assembler normally optimizes out non-PLT relocations
305+against defined non-weak global branch targets with default visibility.
306+The @samp{-mshared} option tells the assembler to generate code which
307+may go into a shared library where all non-weak global branch targets
308+with default visibility can be preempted. The resulting code is
309+slightly bigger. This option only affects the handling of branch
310+instructions.
311+
301312 @cindex @samp{-mbig-obj} option, x86-64
302313 @item -mbig-obj
303314 On x86-64 PE/COFF target this option forces the use of big object file
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,14 @@
1+2015-05-15 H.J. Lu <hongjiu.lu@intel.com>
2+
3+ * gas/i386/i386.exp: Don't run pcrel for ELF targets. Run
4+ pcrel-elf, relax-4 and x86-64-relax-3 for ELF targets.
5+ * gas/i386/pcrel-elf.d: New file.
6+ * gas/i386/relax-4.d: Likewise.
7+ * gas/i386/x86-64-relax-3.d: Likewise.
8+ * gas/i386/relax-3.d: Pass -mshared to assembler. Updated.
9+ * gas/i386/x86-64-relax-2.d: Likewise.
10+ * gas/i386/relax-3.s: Add test for PLT relocation.
11+
112 2015-05-14 Peter Bergner <bergner@vnet.ibm.com>
213
314 * gas/ppc/power4.d: Add a slbia test.
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -352,8 +352,10 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
352352 # but the relocs we currently produce are slightly different
353353 # from those produced for ELF/COFF based toolchains.
354354 # So for now we ignore PE targets.
355- run_dump_test "pcrel"
356355 run_dump_test "absrel"
356+ if {[istarget "*-*-coff*"]} then {
357+ run_dump_test "pcrel"
358+ }
357359 }
358360
359361 # ELF specific tests
@@ -361,6 +363,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
361363 # PIC is only supported on ELF targets.
362364 run_dump_test "intelpic"
363365
366+ run_dump_test "pcrel-elf"
364367 run_dump_test "relax"
365368 run_dump_test "gotpc"
366369 run_dump_test "tlsd"
@@ -396,6 +399,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
396399 run_dump_test "note"
397400
398401 run_dump_test "relax-3"
402+ run_dump_test "relax-4"
399403
400404 if {![istarget "*-*-nacl*"]} then {
401405 run_dump_test "iamcu-1"
@@ -763,6 +767,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
763767 run_list_test "x86-64-size-inval-1" "-al"
764768
765769 run_dump_test "x86-64-relax-2"
770+ run_dump_test "x86-64-relax-3"
766771
767772 run_dump_test "x86-64-jump"
768773 }
--- /dev/null
+++ b/gas/testsuite/gas/i386/pcrel-elf.d
@@ -0,0 +1,52 @@
1+#source: pcrel.s
2+#as: -mshared
3+#objdump: -drw
4+#name: i386 pcrel ELF reloc
5+
6+.*: +file format .*i386.*
7+
8+Disassembly of section \.text:
9+
10+0+ <loc>:
11+[ ]*[a-f0-9]+: e9 30 12 00 00 jmp 1235 <abs\+0x1> 1: R_386_PC32 \*ABS\*
12+
13+0+5 <glob>:
14+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 6 <glob\+0x1> 6: R_386_PC32 ext
15+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp b <glob\+0x6> b: R_386_PC32 weak
16+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 10 <glob\+0xb> 10: R_386_PC32 comm
17+[ ]*[a-f0-9]+: eb ea jmp 0 <loc>
18+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 17 <glob\+0x12> 17: R_386_PC32 glob
19+[ ]*[a-f0-9]+: e9 72 98 00 00 jmp 9892 <abs2\+0x1c> 1c: R_386_PC32 \*ABS\*
20+[ ]*[a-f0-9]+: e9 db 00 00 00 jmp 100 <loc2>
21+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 26 <glob\+0x21> 26: R_386_PC32 glob2
22+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 2b <glob\+0x26> 2b: R_386_PC32 .data
23+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 34 <glob\+0x2f> 30: R_386_PC32 .data
24+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 35 <glob\+0x30> 35: R_386_PC32 \*ABS\*
25+[ ]*[a-f0-9]+: e9 c8 ed ff ff jmp ffffee06 <abs2\+0xffff5590> 3a: R_386_PC32 ext
26+[ ]*[a-f0-9]+: e9 c8 ed ff ff jmp ffffee0b <abs2\+0xffff5595> 3f: R_386_PC32 weak
27+[ ]*[a-f0-9]+: e9 c8 ed ff ff jmp ffffee10 <abs2\+0xffff559a> 44: R_386_PC32 comm
28+[ ]*[a-f0-9]+: e9 7f ed ff ff jmp ffffedcc <abs2\+0xffff5556>
29+[ ]*[a-f0-9]+: e9 c8 ed ff ff jmp ffffee1a <abs2\+0xffff55a4> 4e: R_386_PC32 glob
30+[ ]*[a-f0-9]+: e9 3e 86 00 00 jmp 8695 <abs\+0x7461> 53: R_386_PC32 \*ABS\*
31+[ ]*[a-f0-9]+: e9 70 ee ff ff jmp ffffeecc <abs2\+0xffff5656>
32+[ ]*[a-f0-9]+: e9 c8 ed ff ff jmp ffffee29 <abs2\+0xffff55b3> 5d: R_386_PC32 glob2
33+[ ]*[a-f0-9]+: e9 c8 ed ff ff jmp ffffee2e <abs2\+0xffff55b8> 62: R_386_PC32 .data
34+[ ]*[a-f0-9]+: e9 cc ed ff ff jmp ffffee37 <abs2\+0xffff55c1> 67: R_386_PC32 .data
35+[ ]*[a-f0-9]+: e9 ba 79 ff ff jmp ffff7a2a <abs2\+0xfffee1b4> 6c: R_386_PC32 \*ABS\*
36+[ ]*[a-f0-9]+: e9 86 67 ff ff jmp ffff67fb <abs2\+0xfffecf85> 71: R_386_PC32 ext
37+[ ]*[a-f0-9]+: e9 86 67 ff ff jmp ffff6800 <abs2\+0xfffecf8a> 76: R_386_PC32 weak
38+[ ]*[a-f0-9]+: e9 86 67 ff ff jmp ffff6805 <abs2\+0xfffecf8f> 7b: R_386_PC32 comm
39+[ ]*[a-f0-9]+: e9 06 67 ff ff jmp ffff678a <abs2\+0xfffecf14>
40+[ ]*[a-f0-9]+: e9 06 67 ff ff jmp ffff678f <abs2\+0xfffecf19>
41+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 8a <glob\+0x85> 8a: R_386_PC32 \*ABS\*
42+[ ]*[a-f0-9]+: e9 f7 67 ff ff jmp ffff688a <abs2\+0xfffed014>
43+[ ]*[a-f0-9]+: e9 f7 67 ff ff jmp ffff688f <abs2\+0xfffed019>
44+[ ]*[a-f0-9]+: e9 86 67 ff ff jmp ffff6823 <abs2\+0xfffecfad> 99: R_386_PC32 .data
45+[ ]*[a-f0-9]+: e9 8a 67 ff ff jmp ffff682c <abs2\+0xfffecfb6> 9e: R_386_PC32 .data
46+[ ]*[a-f0-9]+: e9 fc 00 00 00 jmp 1a3 <glob2\+0x9e> a3: R_386_PC32 \*ABS\*
47+[ ]*[a-f0-9]+: e9 01 00 00 00 jmp ad <glob\+0xa8> a8: R_386_PC32 \*ABS\*
48+[ ]*[a-f0-9]+: e9 01 ff ff ff jmp ffffffb2 <abs2\+0xffff673c> ad: R_386_PC32 \*ABS\*
49+[ ]*[a-f0-9]+: e9 01 01 00 00 jmp 1b7 <glob2\+0xb2> b2: R_386_PC32 \*ABS\*
50+[ ]*[a-f0-9]+: e9 01 00 00 00 jmp bc <glob\+0xb7> b7: R_386_PC32 \*ABS\*
51+ ...
52+#pass
--- a/gas/testsuite/gas/i386/relax-3.d
+++ b/gas/testsuite/gas/i386/relax-3.d
@@ -1,3 +1,4 @@
1+#as: -mshared
12 #objdump: -dwr
23
34 .*: +file format .*
@@ -5,26 +6,27 @@
56 Disassembly of section .text:
67
78 0+ <foo>:
8-[ ]*[a-f0-9]+: eb 1f jmp 21 <local>
9-[ ]*[a-f0-9]+: eb 19 jmp 1d <hidden_def>
10-[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 5 <foo\+0x5> 5: (R_386_PC)?(DISP)?32 global_def
11-[ ]*[a-f0-9]+: e9 fc ff ff ff jmp a <foo\+0xa> a: (R_386_PC)?(DISP)?32 weak_def
12-[ ]*[a-f0-9]+: e9 fc ff ff ff jmp f <foo\+0xf> f: (R_386_PC)?(DISP)?32 weak_hidden_undef
13-[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 14 <foo\+0x14> 14: (R_386_PC)?(DISP)?32 weak_hidden_def
14-[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 19 <foo\+0x19> 19: (R_386_PC)?(DISP)?32 hidden_undef
15-
16-0+1d <hidden_def>:
9+[ ]*[a-f0-9]+: eb 24 jmp 26 <local>
10+[ ]*[a-f0-9]+: eb 1e jmp 22 <hidden_def>
11+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 5 <foo\+0x5> 5: R_386_PC32 global_def
12+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp a <foo\+0xa> a: R_386_PLT32 global_def
13+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp f <foo\+0xf> f: R_386_PC32 weak_def
14+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 14 <foo\+0x14> 14: R_386_PC32 weak_hidden_undef
15+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 19 <foo\+0x19> 19: R_386_PC32 weak_hidden_def
16+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 1e <foo\+0x1e> 1e: R_386_PC32 hidden_undef
17+
18+0+22 <hidden_def>:
1719 [ ]*[a-f0-9]+: c3 ret
1820
19-0+1e <weak_hidden_def>:
21+0+23 <weak_hidden_def>:
2022 [ ]*[a-f0-9]+: c3 ret
2123
22-0+1f <global_def>:
24+0+24 <global_def>:
2325 [ ]*[a-f0-9]+: c3 ret
2426
25-0+20 <weak_def>:
27+0+25 <weak_def>:
2628 [ ]*[a-f0-9]+: c3 ret
2729
28-0+21 <local>:
30+0+26 <local>:
2931 [ ]*[a-f0-9]+: c3 ret
3032 #pass
--- a/gas/testsuite/gas/i386/relax-3.s
+++ b/gas/testsuite/gas/i386/relax-3.s
@@ -4,6 +4,7 @@ foo:
44 jmp local
55 jmp hidden_def
66 jmp global_def
7+ jmp global_def@PLT
78 jmp weak_def
89 jmp weak_hidden_undef
910 jmp weak_hidden_def
--- /dev/null
+++ b/gas/testsuite/gas/i386/relax-4.d
@@ -0,0 +1,32 @@
1+#source: relax-3.s
2+#objdump: -dwr
3+
4+.*: +file format .*
5+
6+Disassembly of section .text:
7+
8+0+ <foo>:
9+[ ]*[a-f0-9]+: eb 21 jmp 23 <local>
10+[ ]*[a-f0-9]+: eb 1b jmp 1f <hidden_def>
11+[ ]*[a-f0-9]+: eb 1b jmp 21 <global_def>
12+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 7 <foo\+0x7> 7: R_386_PLT32 global_def
13+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp c <foo\+0xc> c: R_386_PC32 weak_def
14+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 11 <foo\+0x11> 11: R_386_PC32 weak_hidden_undef
15+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 16 <foo\+0x16> 16: R_386_PC32 weak_hidden_def
16+[ ]*[a-f0-9]+: e9 fc ff ff ff jmp 1b <foo\+0x1b> 1b: R_386_PC32 hidden_undef
17+
18+0+1f <hidden_def>:
19+[ ]*[a-f0-9]+: c3 ret
20+
21+0+20 <weak_hidden_def>:
22+[ ]*[a-f0-9]+: c3 ret
23+
24+0+21 <global_def>:
25+[ ]*[a-f0-9]+: c3 ret
26+
27+0+22 <weak_def>:
28+[ ]*[a-f0-9]+: c3 ret
29+
30+0+23 <local>:
31+[ ]*[a-f0-9]+: c3 ret
32+#pass
--- a/gas/testsuite/gas/i386/x86-64-relax-2.d
+++ b/gas/testsuite/gas/i386/x86-64-relax-2.d
@@ -1,4 +1,5 @@
11 #source: relax-3.s
2+#as: -mshared
23 #objdump: -dwr
34
45 .*: +file format .*
@@ -7,26 +8,27 @@
78 Disassembly of section .text:
89
910 0+ <foo>:
10-[ ]*[a-f0-9]+: eb 1f jmp 21 <local>
11-[ ]*[a-f0-9]+: eb 19 jmp 1d <hidden_def>
11+[ ]*[a-f0-9]+: eb 24 jmp 26 <local>
12+[ ]*[a-f0-9]+: eb 1e jmp 22 <hidden_def>
1213 [ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 9 <foo\+0x9> 5: R_X86_64_PC32 global_def-0x4
13-[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq e <foo\+0xe> a: R_X86_64_PC32 weak_def-0x4
14-[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 13 <foo\+0x13> f: R_X86_64_PC32 weak_hidden_undef-0x4
15-[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 18 <foo\+0x18> 14: R_X86_64_PC32 weak_hidden_def-0x4
16-[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 1d <hidden_def> 19: R_X86_64_PC32 hidden_undef-0x4
14+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq e <foo\+0xe> a: R_X86_64_PLT32 global_def-0x4
15+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 13 <foo\+0x13> f: R_X86_64_PC32 weak_def-0x4
16+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 18 <foo\+0x18> 14: R_X86_64_PC32 weak_hidden_undef-0x4
17+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 1d <foo\+0x1d> 19: R_X86_64_PC32 weak_hidden_def-0x4
18+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 22 <hidden_def> 1e: R_X86_64_PC32 hidden_undef-0x4
1719
18-0+1d <hidden_def>:
20+0+22 <hidden_def>:
1921 [ ]*[a-f0-9]+: c3 retq
2022
21-0+1e <weak_hidden_def>:
23+0+23 <weak_hidden_def>:
2224 [ ]*[a-f0-9]+: c3 retq
2325
24-0+1f <global_def>:
26+0+24 <global_def>:
2527 [ ]*[a-f0-9]+: c3 retq
2628
27-0+20 <weak_def>:
29+0+25 <weak_def>:
2830 [ ]*[a-f0-9]+: c3 retq
2931
30-0+21 <local>:
32+0+26 <local>:
3133 [ ]*[a-f0-9]+: c3 retq
3234 #pass
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-relax-3.d
@@ -0,0 +1,33 @@
1+#source: relax-3.s
2+#objdump: -dwr
3+
4+.*: +file format .*
5+
6+
7+Disassembly of section .text:
8+
9+0+ <foo>:
10+[ ]*[a-f0-9]+: eb 21 jmp 23 <local>
11+[ ]*[a-f0-9]+: eb 1b jmp 1f <hidden_def>
12+[ ]*[a-f0-9]+: eb 1b jmp 21 <global_def>
13+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq b <foo\+0xb> 7: R_X86_64_PLT32 global_def-0x4
14+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 10 <foo\+0x10> c: R_X86_64_PC32 weak_def-0x4
15+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 15 <foo\+0x15> 11: R_X86_64_PC32 weak_hidden_undef-0x4
16+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 1a <foo\+0x1a> 16: R_X86_64_PC32 weak_hidden_def-0x4
17+[ ]*[a-f0-9]+: e9 00 00 00 00 jmpq 1f <hidden_def> 1b: R_X86_64_PC32 hidden_undef-0x4
18+
19+0+1f <hidden_def>:
20+[ ]*[a-f0-9]+: c3 retq
21+
22+0+20 <weak_hidden_def>:
23+[ ]*[a-f0-9]+: c3 retq
24+
25+0+21 <global_def>:
26+[ ]*[a-f0-9]+: c3 retq
27+
28+0+22 <weak_def>:
29+[ ]*[a-f0-9]+: c3 retq
30+
31+0+23 <local>:
32+[ ]*[a-f0-9]+: c3 retq
33+#pass