[PATCH] configure: Extend SHF_GNU_RETAIN conftest to check for unsupported gold

Jeff Law law@redhat.com
Mon Jan 4 21:50:55 GMT 2021



On 12/16/20 11:39 AM, Jozef Lawrynowicz wrote:
> Since "6fbec038f7a Use SHF_GNU_RETAIN to preserve symbol definitions",
> GCC could create sections with the 'R' flag, which GAS would map to
> SHF_GNU_RETAIN.
>
> SHF_GNU_RETAIN support was not available in gold until Binutils commit
> ff4bc37d77, on 2020-12-14. Until the support was added, invalid binaries
> could be created if some special sections, such as .init_array, had
> SHF_GNU_RETAIN set.
>
> HAVE_GAS_SHF_GNU_RETAIN is now disabled if a version of gold without
> SHF_GNU_RETAIN support is detected.
>
> I tested that HAVE_GAS_SHF_GNU_RETAIN was enabled/disabled as
> appropriate in a number of configurations, using both in-tree and
> out-of-tree Binutils:
> - Before the Binutils gold patch:
>   * gold disabled == SHF_GNU_RETAIN enabled
>   * gold enabled == SHF_GNU_RETAIN disabled
> - After the Binutils gold patch:
>   * gold disabled == SHF_GNU_RETAIN enabled
>   * gold enabled == SHF_GNU_RETAIN enabled 
>
> Successfully bootstrapped for x86_64-pc-linux-gnu.
>
> Ok to apply?
>
> 0001-configure-Extend-SHF_GNU_RETAIN-conftest-to-check-fo.patch
>
> From af3000bbacc6d8ca57581c11790032b73ea944ac Mon Sep 17 00:00:00 2001
> From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
> Date: Wed, 16 Dec 2020 18:33:54 +0000
> Subject: [PATCH] configure: Extend SHF_GNU_RETAIN conftest to check for
>  unsupported gold
>
> Since "6fbec038f7a Use SHF_GNU_RETAIN to preserve symbol definitions",
> GCC could create sections with the 'R' flag, which GAS would map to
> SHF_GNU_RETAIN.
>
> SHF_GNU_RETAIN support was not available in gold until Binutils commit
> ff4bc37d77, on 2020-12-14. Until the support was added, invalid binaries
> could be created if some special sections, such as .init_array, had
> SHF_GNU_RETAIN set.
>
> HAVE_GAS_SHF_GNU_RETAIN is now disabled if a version of gold without
> SHF_GNU_RETAIN support is detected.
>
> gcc/ChangeLog:
>
> 	PR target/98210
> 	* configure: Regenerate.
> 	* configure.ac (gcc_cv_as_shf_gnu_retain): Disable
> 	HAVE_GAS_SHF_GNU_RETAIN for gold versions that do not support it.
Sorry.  I would strongly recommend against testing like this using
version numbers.  Test the feature, not the version #, date, etc.

jeff



More information about the Gcc-patches mailing list