public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2] gcc: Use ld -r when checking for HAVE_LD_RO_RW_SECTION_MIXING
@ 2022-12-05 13:43 Joakim Nohlgård
  2023-04-30 16:35 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Joakim Nohlgård @ 2022-12-05 13:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joakim Nohlgård

Fall back to ld -r if ld -shared fails during configure. The check for
HAVE_LD_RO_RW_SECTION_MIXING can fail on targets where ld does not
support shared objects, even though the answer to the test should be
'read-write'. One such target is riscv64-unknown-elf. Failing this test
results in a libgcc crtbegin.o which has a writable .eh_frame section
leading to the default linker scripts placing the .eh_frame section in a
writable memory segment, or a linker warning when using ld scripts that
place .eh_frame unconditionally in ROM.

gcc/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Use ld -r in the check for HAVE_LD_RO_RW_SECTION_MIXING

Signed-off-by: Joakim Nohlgård <joakim@nohlgard.se>
---
 gcc/configure.ac | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/gcc/configure.ac b/gcc/configure.ac
index 7c55bff6cb0..500829ceb1d 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3152,16 +3152,19 @@ elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
   echo '.byte 0' >> conftest3.s
   if $gcc_cv_as -o conftest1.o conftest1.s > /dev/null 2>&1 \
      && $gcc_cv_as -o conftest2.o conftest2.s > /dev/null 2>&1 \
-     && $gcc_cv_as -o conftest3.o conftest3.s > /dev/null 2>&1 \
-     && $gcc_cv_ld -shared -o conftest1.so conftest1.o \
-	conftest2.o conftest3.o > /dev/null 2>&1; then
-    gcc_cv_ld_ro_rw_mix=`$gcc_cv_objdump -h conftest1.so \
-			 | sed -e '/myfoosect/!d' -e N`
-    if echo "$gcc_cv_ld_ro_rw_mix" | grep CONTENTS > /dev/null; then
-      if echo "$gcc_cv_ld_ro_rw_mix" | grep READONLY > /dev/null; then
-	gcc_cv_ld_ro_rw_mix=read-only
-      else
-	gcc_cv_ld_ro_rw_mix=read-write
+     && $gcc_cv_as -o conftest3.o conftest3.s > /dev/null 2>&1; then
+    if $gcc_cv_ld -shared -o conftest1.so conftest1.o \
+       conftest2.o conftest3.o > /dev/null 2>&1 \
+       || $gcc_cv_ld -r -o conftest1.so conftest1.o \
+	  conftest2.o conftest3.o > /dev/null 2>&1; then
+      gcc_cv_ld_ro_rw_mix=`$gcc_cv_objdump -h conftest1.so \
+			   | sed -e '/myfoosect/!d' -e N`
+      if echo "$gcc_cv_ld_ro_rw_mix" | grep CONTENTS > /dev/null; then
+	if echo "$gcc_cv_ld_ro_rw_mix" | grep READONLY > /dev/null; then
+	  gcc_cv_ld_ro_rw_mix=read-only
+	else
+	  gcc_cv_ld_ro_rw_mix=read-write
+	fi
       fi
     fi
   fi
-- 
2.38.1


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

* Re: [PATCH v2] gcc: Use ld -r when checking for HAVE_LD_RO_RW_SECTION_MIXING
  2022-12-05 13:43 [PATCH v2] gcc: Use ld -r when checking for HAVE_LD_RO_RW_SECTION_MIXING Joakim Nohlgård
@ 2023-04-30 16:35 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2023-04-30 16:35 UTC (permalink / raw)
  To: Joakim Nohlgård, gcc-patches



On 12/5/22 06:43, Joakim Nohlgård wrote:
> Fall back to ld -r if ld -shared fails during configure. The check for
> HAVE_LD_RO_RW_SECTION_MIXING can fail on targets where ld does not
> support shared objects, even though the answer to the test should be
> 'read-write'. One such target is riscv64-unknown-elf. Failing this test
> results in a libgcc crtbegin.o which has a writable .eh_frame section
> leading to the default linker scripts placing the .eh_frame section in a
> writable memory segment, or a linker warning when using ld scripts that
> place .eh_frame unconditionally in ROM.
> 
> gcc/ChangeLog:
> 
> 	* configure: Regenerate.
> 	* configure.ac: Use ld -r in the check for HAVE_LD_RO_RW_SECTION_MIXING
Thanks.  I've pushed this to the trunk.
jeff

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

end of thread, other threads:[~2023-04-30 16:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 13:43 [PATCH v2] gcc: Use ld -r when checking for HAVE_LD_RO_RW_SECTION_MIXING Joakim Nohlgård
2023-04-30 16:35 ` Jeff Law

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).