[PATCH] gas: Fix -mrelax-relocations detection on Solaris/x86 [PR19520]

Jan Beulich jbeulich@suse.com
Mon Oct 13 06:18:53 GMT 2025


On 12.10.2025 14:29, Rainer Orth wrote:
> Hi Jan,
> 
>> On 28.09.2025 16:16, Rainer Orth wrote:
>>> I recently noticed a complex case statement in gas/configure.ac controlling
>>> the setting of ac_default_x86_relax_relocations on Solaris/x86.  Since it
>>> included all versions of Solaris, it could be massively simplified.
>>>
>>> Looking closer however, I found that it was introduced in
>>>
>>> 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
>>>
>>> based on PR gas/19520.  This PR reported that the new R_386_GOT32X
>>> etc. relocations weren't supported on older versions of Solaris,
>>> breaking gcc bootstrap.  In response, they were disabled on all Solaris
>>> versions except Solaris 12, where they had been implemented in the
>>> native toolchain based on my findings.
>>>
>>> However, Solaris 12 has been rechristened to 11.4 before release,
>>> effectively disabling DEFAULT_GENERATE_X86_RELAX_RELOCATIONS on all
>>> versions of Solaris/x86.
>>>
>>> This patch fixes this by correcting the detection of Solaris 11.4.  Since
>>> the minor version is not included in the configure triplet, this can only
>>> be done natively with uname -v.
>>>
>>> Tested on i386-pc-solaris2.11 and amd64-pc-solaris2.11 (Solaris 11.4)
>>> and with gcc trunk bootstraps with the patched gas and native ld.  Also
>>> tested on Solaris 11.3/x86 (build only to check that the macro is set to
>>> 0 as expected).
>>>
>>> Ok for trunk?
>>
>> Hmm, no, not really. What target an assembler is built for shouldn't
>> really depend on host properties imo. There's no other similar use
>> of uname anywhere in the script.
> 
> what else could I do?  Natively, I see three options:
> 
> * Try to link an object containing one of the gotx relocs with /bin/ld.
>   However, that might be difficult to create since there's no guarantee
>   that gas is even available when building binutils.
> 
> * Check the native <sys/elf_i386.h> and <sys/elf_amd64.h> if the gotx
>   relocs are defined there.
> 
> * Check if the exact OS version is 11.4.
> 
> None of this works for crosses:
> 
> * The first is obviously impossible.
> 
> * The second would work, but the natively headers are most likely not
>   available for a cross build.
> 
> * The third won't work either since the info about the minor OS versions
>   isn't included in the target triplet.
> 
> That's why I used the uname route in the native case while erring on the
> side of caution for crosses by disabling gotx reloc support.
> 
> If you have other suggestions, I'm all ears.

I don't; perhaps the only viable route is the option discussed on the other
sub-thread (with H.J.).

Jan


More information about the Binutils mailing list