Bug 19520 - [2.26 regression] R_386_GOT32X relocation breaks gcc bootstrap with non-gld/gold linker
Summary: [2.26 regression] R_386_GOT32X relocation breaks gcc bootstrap with non-gld/g...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.27
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-26 14:09 UTC by Rainer Orth
Modified: 2016-02-03 16:40 UTC (History)
2 users (show)

See Also:
Host: i386-pc-solaris2.*
Target: i386-pc-solaris2.*
Build: i386-pc-solaris2.*
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2016-01-26 14:09:40 UTC
The new R_386_GOT32X reloc introduced in binutils 2.26 break gcc mainline bootstrap
with gas 2.26 and Solaris ld, which doesn't handle it:

ld: fatal: relocation error: file cpuinfo_s.o: section [5].rel.text.startup: invalid relocation type: 0x2b

Even if support were introduced, there's guaranteed a large number of older linkers in the field that continue not to support it, so there needs to be a way
to disable its generation.

  Rainer
Comment 1 H.J. Lu 2016-01-26 14:31:01 UTC
Please open a Solaris linker request to support R_386_GOT32X,
R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX.  Then we discuss
how to address it, depending on the response.
Comment 2 Rainer Orth 2016-01-26 14:37:15 UTC
> --- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
> Please open a Solaris linker request to support R_386_GOT32X,
> R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX.  Then we discuss
> how to address it, depending on the response.

I've started just that (at least for R_386_GOT32X for now), but even if
this were implemented for Solaris 12, this won't help older
installations in the field.  This also needs to be addressed on the
binutils side.

	Rainer
Comment 3 H.J. Lu 2016-01-26 14:39:24 UTC
(In reply to Rainer Orth from comment #2)
> > --- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
> > Please open a Solaris linker request to support R_386_GOT32X,
> > R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX.  Then we discuss
> > how to address it, depending on the response.
> 
> I've started just that (at least for R_386_GOT32X for now), but even if
> this were implemented for Solaris 12, this won't help older
> installations in the field.  This also needs to be addressed on the
> binutils side.

Understood.  I still need a response from Solaris.
Comment 4 H.J. Lu 2016-01-26 23:09:43 UTC
Please checkout users/hjl/pr19520/master branch.  I added a
configure-time option, --enable-new-x86-relocations, and a
run-time option, -mnew-relocations=.
Comment 5 Andreas Schwab 2016-01-27 08:27:53 UTC
They won't be new for long.
Comment 6 H.J. Lu 2016-01-27 13:55:56 UTC
(In reply to Andreas Schwab from comment #5)
> They won't be new for long.

Yes, I will rename them to --enable-x86-relax-relocations and
-mrelax-relocations=.
Comment 7 Rainer Orth 2016-01-27 14:00:29 UTC
> --- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
> Please checkout users/hjl/pr19520/master branch.  I added a
> configure-time option, --enable-new-x86-relocations, and a
> run-time option, -mnew-relocations=.

I've successfully bootstrapped gcc mainline with gas 2.26 with your
patch applied and /bin/ld.

A couple of comments, though:

* As Andreas noted, today's new is tomorrow's old.  The option needs a
  more descriptive name.

* It needs documentation in gas/doc/c-i386.texi, perhaps together with
  the new configure option.

* I wonder if the gas option should be called -mnew-relocations=(yes|no)
  or -m(no-)new-relocations.  There seems to be precedent for both
  versions.

* There's a superfluous trailing ] in gas/configure, both for the new
  option and --enable-compressed-debug-sections (copy-and-paste error,
  no doubt):

@@ -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-new-x86-relocations
+                          generate new x86 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

* Typo in gas/configure.ac:

diff --git a/gas/configure.ac b/gas/configure.ac
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -77,6 +77,20 @@ AC_ARG_ENABLE(compressed_debug_sections,
[...]
+AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_X86_NEW_RELOCATIONS,
+  $ac_default_new_x86_relocations,
+  [Define to 1 if you want generate new x86 relocations by default.])

                            ^ to generate

* I believe --enable-new-x86-relocations should default to 0 on
  i?86-*-solaris2.[0-9], i?86-*-solaris2.1[01], x86_64-*-solaris2.1[01]
  and to 1 on i?86-solaris2.1[2-9], x86_64-*-solaris2.1[2-9] so this
  works out of the box.

	Rainer
Comment 8 H.J. Lu 2016-01-27 18:47:57 UTC
(In reply to Rainer Orth from comment #7)
> > --- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
> > Please checkout users/hjl/pr19520/master branch.  I added a
> > configure-time option, --enable-new-x86-relocations, and a
> > run-time option, -mnew-relocations=.
> 
> I've successfully bootstrapped gcc mainline with gas 2.26 with your
> patch applied and /bin/ld.

Please try the updated users/hjl/pr19520/master branch.

> A couple of comments, though:
> 
> * As Andreas noted, today's new is tomorrow's old.  The option needs a
>   more descriptive name.

Fixed.

> * It needs documentation in gas/doc/c-i386.texi, perhaps together with
>   the new configure option.

Fixed.

> * I wonder if the gas option should be called -mnew-relocations=(yes|no)
>   or -m(no-)new-relocations.  There seems to be precedent for both
>   versions.

I prefer -mrelax-relocations=.

> * There's a superfluous trailing ] in gas/configure, both for the new
>   option and --enable-compressed-debug-sections (copy-and-paste error,
>   no doubt):
> 
> @@ -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-new-x86-relocations
> +                          generate new x86 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

Fixed.

> * Typo in gas/configure.ac:
> 
> diff --git a/gas/configure.ac b/gas/configure.ac
> --- a/gas/configure.ac
> +++ b/gas/configure.ac
> @@ -77,6 +77,20 @@ AC_ARG_ENABLE(compressed_debug_sections,
> [...]
> +AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_X86_NEW_RELOCATIONS,
> +  $ac_default_new_x86_relocations,
> +  [Define to 1 if you want generate new x86 relocations by default.])
> 
>                             ^ to generate

Fixed.

> * I believe --enable-new-x86-relocations should default to 0 on
>   i?86-*-solaris2.[0-9], i?86-*-solaris2.1[01], x86_64-*-solaris2.1[01]
>   and to 1 on i?86-solaris2.1[2-9], x86_64-*-solaris2.1[2-9] so this
>   works out of the box.

Fixed.
Comment 9 Richard PALO 2016-01-31 16:19:51 UTC
Unfortunately this patch branch is not based upon 2.26.0 (as in the source tarball) so a format-patch output does not patch cleanly for distributions.

Will/can 2.26.1 be quickly released?
Comment 10 H.J. Lu 2016-01-31 16:50:17 UTC
I am waiting for confirmation before applying it to master and
backporting to 2.26 branch.
Comment 11 Mike Frysinger 2016-02-01 23:19:16 UTC
a 2.26.1 most likely will be released, but i think we might want to let the list of regressions settle first :x
Comment 12 Rainer Orth 2016-02-03 12:14:19 UTC
> --- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
> (In reply to Rainer Orth from comment #7)
>> > --- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
>> > Please checkout users/hjl/pr19520/master branch.  I added a
>> > configure-time option, --enable-new-x86-relocations, and a
>> > run-time option, -mnew-relocations=.
>> 
>> I've successfully bootstrapped gcc mainline with gas 2.26 with your
>> patch applied and /bin/ld.
>
> Please try the updated users/hjl/pr19520/master branch.

Thanks for all the fixes.  I found no problems in the updated branch,
and applied the patch (with minimal changes) to 2.26.

Tested as follows:

* configure and build on i386-pc-solaris2.9,
  DEFAULT_GENERATE_X86_RELAX_RELOCATIONS is 0

* configure and build on i386-pc-solaris2.12 => 1, successfully
  bootstrapped gcc mainline with /bin/ld modified to handle relax relocs

* configure and build on i386-pc-solaris2.12 with
  --disable-x86-relax-relocations => 0, successfully bootstrapped gcc
  mainline with unmodified /bin/ld which doesn't support relax relocs yet

So from my POV the patch is good to go.

Thanks alot.

	Rainer
Comment 13 cvs-commit@gcc.gnu.org 2016-02-03 16:26:55 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0cb4071ef9e10f703220f5e731141bf438aca16e

commit 0cb4071ef9e10f703220f5e731141bf438aca16e
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Feb 3 08:25:15 2016 -0800

    Add -mrelax-relocations= to x86 assembler
    
    The x86 relax relocations introduced in binutils 2.26 aren't supported
    by linker on Solaris older than Solaris 12.  To use x86 assembler with
    older Solaris linker, this patch adds
    
    1. A command line option -mrelax-relocations= to x86 assembler to
    control whether to generate relax relocations.
    2. A configure option --enable-x86-relax-relocations to decide whether
    x86 assembler should generate relax relocations by default.  It is
    defaulted to yes, except for x86 Solaris targets older than Solaris 12.
    
    gas/
    
    	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.
    
    ld/
    
    	PR gas/19520
    	* testsuite/ld-i386/branch1.d: Pass -mrelax-relocations=yes to as.
    	* testsuite/ld-i386/call1.d: Likewise.
    	* testsuite/ld-i386/call2.d: Likewise.
    	* testsuite/ld-i386/call3a.d: Likewise.
    	* testsuite/ld-i386/call3b.d: Likewise.
    	* testsuite/ld-i386/call3c.d: Likewise.
    	* testsuite/ld-i386/call3d.d: Likewise.
    	* testsuite/ld-i386/call3e.d: Likewise.
    	* testsuite/ld-i386/call3f.d: Likewise.
    	* testsuite/ld-i386/call3g.d: Likewise.
    	* testsuite/ld-i386/call3h.d: Likewise.
    	* testsuite/ld-i386/jmp1.d: Likewise.
    	* testsuite/ld-i386/jmp2.d: Likewise.
    	* testsuite/ld-i386/lea1c.d: Likewise.
    	* testsuite/ld-i386/load1.d: Likewise.
    	* testsuite/ld-i386/load2.d: Likewise.
    	* testsuite/ld-i386/load3.d: Likewise.
    	* testsuite/ld-i386/load4a.d: Likewise.
    	* testsuite/ld-i386/load5a.d: Likewise.
    	* testsuite/ld-i386/mov2b.d: Likewise.
    	* testsuite/ld-i386/mov3.d: Likewise.
    	* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
    	* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
    	* testsuite/ld-ifunc/ifunc-5r-local-x86-64.d: Likewise.
    	* testsuite/ld-x86-64/call1a.d: Likewise.
    	* testsuite/ld-x86-64/call1b.d: Likewise.
    	* testsuite/ld-x86-64/call1c.d: Likewise.
    	* testsuite/ld-x86-64/call1d.d: Likewise.
    	* testsuite/ld-x86-64/call1e.d: Likewise.
    	* testsuite/ld-x86-64/call1f.d: Likewise.
    	* testsuite/ld-x86-64/call1h.d: Likewise.
    	* testsuite/ld-x86-64/call1i.d: Likewise.
    	* testsuite/ld-x86-64/load1a.d: Likewise.
    	* testsuite/ld-x86-64/load1b.d: Likewise.
    	* testsuite/ld-i386/got1a.S: Load GOT into %ecx and use it.
    	* testsuite/ld-i386/got1.dd: Updated.
    	* testsuite/ld-i386/got1d.S (1): Removed.
    	* testsuite/ld-i386/i386.exp: Add -Wa,-mrelax-relocations=yes.
    	* testsuite/ld-x86-64/x86-64.exp: Likewise.
Comment 14 cvs-commit@gcc.gnu.org 2016-02-03 16:39:35 UTC
The binutils-2_26-branch branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bab518b383819aea3a8d1725f7dfd906b7f34216

commit bab518b383819aea3a8d1725f7dfd906b7f34216
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Feb 3 08:25:15 2016 -0800

    Add -mrelax-relocations= to x86 assembler
    
    The x86 relax relocations introduced in binutils 2.26 aren't supported
    by linker on Solaris older than Solaris 12.  To use x86 assembler with
    older Solaris linker, this patch adds
    
    1. A command line option -mrelax-relocations= to x86 assembler to
    control whether to generate relax relocations.
    2. A configure option --enable-x86-relax-relocations to decide whether
    x86 assembler should generate relax relocations by default.  It is
    defaulted to yes, except for x86 Solaris targets older than Solaris 12.
    
    Backport from master
    
    gas/
    
    	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.
    
    ld/
    
    	PR gas/19520
    	* testsuite/ld-i386/branch1.d: Pass -mrelax-relocations=yes to as.
    	* testsuite/ld-i386/call1.d: Likewise.
    	* testsuite/ld-i386/call2.d: Likewise.
    	* testsuite/ld-i386/call3a.d: Likewise.
    	* testsuite/ld-i386/call3b.d: Likewise.
    	* testsuite/ld-i386/call3c.d: Likewise.
    	* testsuite/ld-i386/call3d.d: Likewise.
    	* testsuite/ld-i386/call3e.d: Likewise.
    	* testsuite/ld-i386/call3f.d: Likewise.
    	* testsuite/ld-i386/call3g.d: Likewise.
    	* testsuite/ld-i386/call3h.d: Likewise.
    	* testsuite/ld-i386/jmp1.d: Likewise.
    	* testsuite/ld-i386/jmp2.d: Likewise.
    	* testsuite/ld-i386/lea1c.d: Likewise.
    	* testsuite/ld-i386/load1.d: Likewise.
    	* testsuite/ld-i386/load2.d: Likewise.
    	* testsuite/ld-i386/load3.d: Likewise.
    	* testsuite/ld-i386/load4a.d: Likewise.
    	* testsuite/ld-i386/load5a.d: Likewise.
    	* testsuite/ld-i386/mov2b.d: Likewise.
    	* testsuite/ld-i386/mov3.d: Likewise.
    	* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
    	* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
    	* testsuite/ld-ifunc/ifunc-5r-local-x86-64.d: Likewise.
    	* testsuite/ld-x86-64/call1a.d: Likewise.
    	* testsuite/ld-x86-64/call1b.d: Likewise.
    	* testsuite/ld-x86-64/call1c.d: Likewise.
    	* testsuite/ld-x86-64/call1d.d: Likewise.
    	* testsuite/ld-x86-64/call1e.d: Likewise.
    	* testsuite/ld-x86-64/call1f.d: Likewise.
    	* testsuite/ld-x86-64/call1h.d: Likewise.
    	* testsuite/ld-x86-64/call1i.d: Likewise.
    	* testsuite/ld-x86-64/load1a.d: Likewise.
    	* testsuite/ld-x86-64/load1b.d: Likewise.
    	* testsuite/ld-i386/got1a.S: Load GOT into %ecx and use it.
    	* testsuite/ld-i386/got1.dd: Updated.
    	* testsuite/ld-i386/got1d.S (1): Removed.
    	* testsuite/ld-i386/i386.exp: Add -Wa,-mrelax-relocations=yes.
    	* testsuite/ld-x86-64/x86-64.exp: Likewise.
Comment 15 H.J. Lu 2016-02-03 16:40:31 UTC
Fixed for 2.27 and 2.26.1.