unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] configure: Fix check for INSERT in linker script
@ 2021-09-10  0:50 Fangrui Song via Libc-alpha
  2021-09-13 13:58 ` Siddhesh Poyarekar
  0 siblings, 1 reply; 2+ messages in thread
From: Fangrui Song via Libc-alpha @ 2021-09-10  0:50 UTC (permalink / raw
  To: libc-alpha, H.J. Lu

GCC/Clang use local access when referencing a const variable,
so the conftest.so may have no dynamic relocation.
LLD reports `error: unable to insert .foo after .rela.dyn` when the
destination section does not exist.

Use a non-const int to ensure that .rela.dyn exists.
---
 configure    | 2 +-
 configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 542802ad35..39d75eb4ed 100755
--- a/configure
+++ b/configure
@@ -5793,7 +5793,7 @@ if ${libc_cv_insert+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat > conftest.c <<EOF
-		const int __attribute__ ((section(".bar"))) bar = 0x12345678;
+		int __attribute__ ((section(".bar"))) bar = 0x12345678;
 		int test (void) { return bar; }
 EOF
 		cat > conftest.t <<EOF
diff --git a/configure.ac b/configure.ac
index d9232418de..00f49f09f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1217,7 +1217,7 @@ AC_SUBST(libc_cv_protected_data)
 AC_CACHE_CHECK(linker support for INSERT in linker script,
 	       libc_cv_insert,
 	       [cat > conftest.c <<EOF
-		const int __attribute__ ((section(".bar"))) bar = 0x12345678;
+		int __attribute__ ((section(".bar"))) bar = 0x12345678;
 		int test (void) { return bar; }
 EOF
 		cat > conftest.t <<EOF
-- 
2.33.0.309.g3052b89438-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] configure: Fix check for INSERT in linker script
  2021-09-10  0:50 [PATCH] configure: Fix check for INSERT in linker script Fangrui Song via Libc-alpha
@ 2021-09-13 13:58 ` Siddhesh Poyarekar
  0 siblings, 0 replies; 2+ messages in thread
From: Siddhesh Poyarekar @ 2021-09-13 13:58 UTC (permalink / raw
  To: Fangrui Song, libc-alpha, H.J. Lu

On 9/10/21 6:20 AM, Fangrui Song via Libc-alpha wrote:
> GCC/Clang use local access when referencing a const variable,
> so the conftest.so may have no dynamic relocation.
> LLD reports `error: unable to insert .foo after .rela.dyn` when the
> destination section does not exist.
> 
> Use a non-const int to ensure that .rela.dyn exists.
> ---
>   configure    | 2 +-
>   configure.ac | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index 542802ad35..39d75eb4ed 100755
> --- a/configure
> +++ b/configure
> @@ -5793,7 +5793,7 @@ if ${libc_cv_insert+:} false; then :
>     $as_echo_n "(cached) " >&6
>   else
>     cat > conftest.c <<EOF
> -		const int __attribute__ ((section(".bar"))) bar = 0x12345678;
> +		int __attribute__ ((section(".bar"))) bar = 0x12345678;
>   		int test (void) { return bar; }
>   EOF
>   		cat > conftest.t <<EOF
> diff --git a/configure.ac b/configure.ac
> index d9232418de..00f49f09f7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1217,7 +1217,7 @@ AC_SUBST(libc_cv_protected_data)
>   AC_CACHE_CHECK(linker support for INSERT in linker script,
>   	       libc_cv_insert,
>   	       [cat > conftest.c <<EOF
> -		const int __attribute__ ((section(".bar"))) bar = 0x12345678;
> +		int __attribute__ ((section(".bar"))) bar = 0x12345678;
>   		int test (void) { return bar; }
>   EOF
>   		cat > conftest.t <<EOF
> 

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-13 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-10  0:50 [PATCH] configure: Fix check for INSERT in linker script Fangrui Song via Libc-alpha
2021-09-13 13:58 ` Siddhesh Poyarekar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).