public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv
@ 2023-07-23  1:06 Andrew Pinski
  2023-07-23  1:06 ` [PATCH 2/2] AARCH64: Turn off unwind tables for crtbeginT.o Andrew Pinski
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andrew Pinski @ 2023-07-23  1:06 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

The problem -fasynchronous-unwind-tables is on by default for riscv linux
We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
to .eh_frame data from crtbeginT.o instead of the user-defined object
during static linking.

This turns it off.

OK?

libgcc/ChangeLog:

	* config.host (riscv*-*-linux*): Add t-crtstuff to tmake_file.
	(riscv*-*-freebsd*): Likewise.
	* config/riscv/t-crtstuff: New file.
---
 libgcc/config.host             | 4 ++--
 libgcc/config/riscv/t-crtstuff | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 libgcc/config/riscv/t-crtstuff

diff --git a/libgcc/config.host b/libgcc/config.host
index 9d7212028d0..c94d69d84b7 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1304,12 +1304,12 @@ pru-*-*)
 	tm_file="$tm_file pru/pru-abi.h"
 	;;
 riscv*-*-linux*)
-	tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
+	tmake_file="${tmake_file} riscv/t-crtstuff riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
 	extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
 	md_unwind_header=riscv/linux-unwind.h
 	;;
 riscv*-*-freebsd*)
-	tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
+	tmake_file="${tmake_file} riscv/t-crtstuff riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
 	extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
 	;;
 riscv*-*-*)
diff --git a/libgcc/config/riscv/t-crtstuff b/libgcc/config/riscv/t-crtstuff
new file mode 100644
index 00000000000..685d11b3e66
--- /dev/null
+++ b/libgcc/config/riscv/t-crtstuff
@@ -0,0 +1,5 @@
+# -fasynchronous-unwind-tables -funwind-tables is on by default for riscv linux
+# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
+# to .eh_frame data from crtbeginT.o instead of the user-defined object
+# during static linking.
+CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
-- 
2.39.1


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

* [PATCH 2/2] AARCH64: Turn off unwind tables for crtbeginT.o
  2023-07-23  1:06 [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv Andrew Pinski
@ 2023-07-23  1:06 ` Andrew Pinski
  2023-07-24 15:55   ` Richard Sandiford
  2023-07-23  3:35 ` [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv Kito Cheng
  2023-07-23  6:46 ` Andreas Schwab
  2 siblings, 1 reply; 7+ messages in thread
From: Andrew Pinski @ 2023-07-23  1:06 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

The problem -fasynchronous-unwind-tables is on by default for aarch64
We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
to .eh_frame data from crtbeginT.o instead of the user-defined object
during static linking.

This turns it off.

OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions.

libgcc/ChangeLog:

	* config.host (aarch64*-*-*): Add t-crtstuff to tmake_file.
	* config/aarch64/t-crtstuff: New file.
---
 libgcc/config.host               | 6 ++++++
 libgcc/config/aarch64/t-crtstuff | 5 +++++
 2 files changed, 11 insertions(+)
 create mode 100644 libgcc/config/aarch64/t-crtstuff

diff --git a/libgcc/config.host b/libgcc/config.host
index c94d69d84b7..b2d82041a69 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -390,6 +390,7 @@ aarch64*-*-elf | aarch64*-*-rtems*)
 	extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o"
 	extra_parts="$extra_parts crtfastmath.o"
 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+	tmake_file="${tmake_file} ${cpu_type}/t-crtstuff"
 	tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
 	tmake_file="${tmake_file} t-dfprules"
@@ -398,6 +399,7 @@ aarch64*-*-elf | aarch64*-*-rtems*)
 aarch64*-*-freebsd*)
 	extra_parts="$extra_parts crtfastmath.o"
 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+	tmake_file="${tmake_file} ${cpu_type}/t-crtstuff"
 	tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
 	tmake_file="${tmake_file} t-dfprules"
@@ -406,12 +408,14 @@ aarch64*-*-freebsd*)
 aarch64*-*-netbsd*)
 	extra_parts="$extra_parts crtfastmath.o"
 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+	tmake_file="${tmake_file} ${cpu_type}/t-crtstuff"
 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
 	tmake_file="${tmake_file} t-dfprules"
 	md_unwind_header=aarch64/aarch64-unwind.h
 	;;
 aarch64*-*-fuchsia*)
 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+	tmake_file="${tmake_file} ${cpu_type}/t-crtstuff"
 	tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
 	tmake_file="${tmake_file} t-dfprules"
@@ -420,6 +424,7 @@ aarch64*-*-linux*)
 	extra_parts="$extra_parts crtfastmath.o"
 	md_unwind_header=aarch64/linux-unwind.h
 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+	tmake_file="${tmake_file} ${cpu_type}/t-crtstuff"
 	tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
 	tmake_file="${tmake_file} t-dfprules"
@@ -428,6 +433,7 @@ aarch64*-*-vxworks7*)
 	extra_parts="$extra_parts crtfastmath.o"
 	md_unwind_header=aarch64/aarch64-unwind.h
 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+	tmake_file="${tmake_file} ${cpu_type}/t-crtstuff"
 	tmake_file="${tmake_file} ${cpu_type}/t-lse"
 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
 	tmake_file="${tmake_file} t-dfprules"
diff --git a/libgcc/config/aarch64/t-crtstuff b/libgcc/config/aarch64/t-crtstuff
new file mode 100644
index 00000000000..2e2814e6c67
--- /dev/null
+++ b/libgcc/config/aarch64/t-crtstuff
@@ -0,0 +1,5 @@
+# -fasynchronous-unwind-tables -funwind-tables is on by default for aarch64
+# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
+# to .eh_frame data from crtbeginT.o instead of the user-defined object
+# during static linking.
+CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
-- 
2.39.1


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

* Re: [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv
  2023-07-23  1:06 [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv Andrew Pinski
  2023-07-23  1:06 ` [PATCH 2/2] AARCH64: Turn off unwind tables for crtbeginT.o Andrew Pinski
@ 2023-07-23  3:35 ` Kito Cheng
  2024-05-08 16:07   ` Andrew Pinski
  2023-07-23  6:46 ` Andreas Schwab
  2 siblings, 1 reply; 7+ messages in thread
From: Kito Cheng @ 2023-07-23  3:35 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 2570 bytes --]

OK for trunk, thanks:)

Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> 於 2023年7月23日 週日
09:07 寫道:

> The problem -fasynchronous-unwind-tables is on by default for riscv linux
> We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__
> point
> to .eh_frame data from crtbeginT.o instead of the user-defined object
> during static linking.
>
> This turns it off.
>
> OK?
>
> libgcc/ChangeLog:
>
>         * config.host (riscv*-*-linux*): Add t-crtstuff to tmake_file.
>         (riscv*-*-freebsd*): Likewise.
>         * config/riscv/t-crtstuff: New file.
> ---
>  libgcc/config.host             | 4 ++--
>  libgcc/config/riscv/t-crtstuff | 5 +++++
>  2 files changed, 7 insertions(+), 2 deletions(-)
>  create mode 100644 libgcc/config/riscv/t-crtstuff
>
> diff --git a/libgcc/config.host b/libgcc/config.host
> index 9d7212028d0..c94d69d84b7 100644
> --- a/libgcc/config.host
> +++ b/libgcc/config.host
> @@ -1304,12 +1304,12 @@ pru-*-*)
>         tm_file="$tm_file pru/pru-abi.h"
>         ;;
>  riscv*-*-linux*)
> -       tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp
> riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
> +       tmake_file="${tmake_file} riscv/t-crtstuff
> riscv/t-softfp${host_address} t-softfp riscv/t-elf
> riscv/t-elf${host_address} t-slibgcc-libgcc"
>         extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o
> crtendS.o crtbeginT.o"
>         md_unwind_header=riscv/linux-unwind.h
>         ;;
>  riscv*-*-freebsd*)
> -       tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp
> riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
> +       tmake_file="${tmake_file} riscv/t-crtstuff
> riscv/t-softfp${host_address} t-softfp riscv/t-elf
> riscv/t-elf${host_address} t-slibgcc-libgcc"
>         extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o
> crtendS.o crtbeginT.o"
>         ;;
>  riscv*-*-*)
> diff --git a/libgcc/config/riscv/t-crtstuff
> b/libgcc/config/riscv/t-crtstuff
> new file mode 100644
> index 00000000000..685d11b3e66
> --- /dev/null
> +++ b/libgcc/config/riscv/t-crtstuff
> @@ -0,0 +1,5 @@
> +# -fasynchronous-unwind-tables -funwind-tables is on by default for riscv
> linux
> +# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> +# to .eh_frame data from crtbeginT.o instead of the user-defined object
> +# during static linking.
> +CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
> --
> 2.39.1
>
>

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

* Re: [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv
  2023-07-23  1:06 [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv Andrew Pinski
  2023-07-23  1:06 ` [PATCH 2/2] AARCH64: Turn off unwind tables for crtbeginT.o Andrew Pinski
  2023-07-23  3:35 ` [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv Kito Cheng
@ 2023-07-23  6:46 ` Andreas Schwab
  2 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2023-07-23  6:46 UTC (permalink / raw)
  To: Andrew Pinski via Gcc-patches; +Cc: Andrew Pinski

On Jul 22 2023, Andrew Pinski via Gcc-patches wrote:

> The problem -fasynchronous-unwind-tables is on by default for riscv linux
> We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> to .eh_frame data from crtbeginT.o instead of the user-defined object
> during static linking.
>
> This turns it off.

Since this is a recurring problem, and difficult to notice (see how long
the aarch64 case went unnoticed), it should be fixed generically,
instead of having to patch every case separately.

> diff --git a/libgcc/config/riscv/t-crtstuff b/libgcc/config/riscv/t-crtstuff
> new file mode 100644
> index 00000000000..685d11b3e66
> --- /dev/null
> +++ b/libgcc/config/riscv/t-crtstuff
> @@ -0,0 +1,5 @@
> +# -fasynchronous-unwind-tables -funwind-tables is on by default for riscv linux
> +# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> +# to .eh_frame data from crtbeginT.o instead of the user-defined object
> +# during static linking.
> +CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables

What about CRTSTUFF_T_CFLAGS_S?

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: [PATCH 2/2] AARCH64: Turn off unwind tables for crtbeginT.o
  2023-07-23  1:06 ` [PATCH 2/2] AARCH64: Turn off unwind tables for crtbeginT.o Andrew Pinski
@ 2023-07-24 15:55   ` Richard Sandiford
  2023-07-25  7:06     ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Sandiford @ 2023-07-24 15:55 UTC (permalink / raw)
  To: Andrew Pinski via Gcc-patches; +Cc: Andrew Pinski

Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> The problem -fasynchronous-unwind-tables is on by default for aarch64
> We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> to .eh_frame data from crtbeginT.o instead of the user-defined object
> during static linking.

Could you go into more details?  Which user-defined object do you mean?

I notice alpha has:

    # When GAS-generated unwind tables are created, they get created
    # after the __FRAME_END__ terminator, which causes an ld error.
    CRTSTUFF_T_CFLAGS = -fno-unwind-tables

which I guess was a separate problem.

Thanks,
Richard

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

* Re: [PATCH 2/2] AARCH64: Turn off unwind tables for crtbeginT.o
  2023-07-24 15:55   ` Richard Sandiford
@ 2023-07-25  7:06     ` Richard Biener
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Biener @ 2023-07-25  7:06 UTC (permalink / raw)
  To: Richard Sandiford, Andrew Pinski via Gcc-patches, Andrew Pinski

On Mon, Jul 24, 2023 at 5:56 PM Richard Sandiford via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> > The problem -fasynchronous-unwind-tables is on by default for aarch64
> > We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> > to .eh_frame data from crtbeginT.o instead of the user-defined object
> > during static linking.
>
> Could you go into more details?  Which user-defined object do you mean?
>
> I notice alpha has:
>
>     # When GAS-generated unwind tables are created, they get created
>     # after the __FRAME_END__ terminator, which causes an ld error.
>     CRTSTUFF_T_CFLAGS = -fno-unwind-tables
>
> which I guess was a separate problem.

x86 has

# crtend*.o cannot be compiled without -fno-asynchronous-unwind-tables,
# because then __FRAME_END__ might not be the last thing in .eh_frame
# section.

>
> Thanks,
> Richard

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

* Re: [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv
  2023-07-23  3:35 ` [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv Kito Cheng
@ 2024-05-08 16:07   ` Andrew Pinski
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Pinski @ 2024-05-08 16:07 UTC (permalink / raw)
  To: Kito Cheng; +Cc: Andrew Pinski, GCC Patches

On Sat, Jul 22, 2023 at 8:36 PM Kito Cheng via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> OK for trunk, thanks:)

I have now backported it to 13 branch.

Thanks,
Andrew


>
> Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> 於 2023年7月23日 週日
> 09:07 寫道:
>
> > The problem -fasynchronous-unwind-tables is on by default for riscv linux
> > We need turn it off for crt*.o because it would make __EH_FRAME_BEGIN__
> > point
> > to .eh_frame data from crtbeginT.o instead of the user-defined object
> > during static linking.
> >
> > This turns it off.
> >
> > OK?
> >
> > libgcc/ChangeLog:
> >
> >         * config.host (riscv*-*-linux*): Add t-crtstuff to tmake_file.
> >         (riscv*-*-freebsd*): Likewise.
> >         * config/riscv/t-crtstuff: New file.
> > ---
> >  libgcc/config.host             | 4 ++--
> >  libgcc/config/riscv/t-crtstuff | 5 +++++
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> >  create mode 100644 libgcc/config/riscv/t-crtstuff
> >
> > diff --git a/libgcc/config.host b/libgcc/config.host
> > index 9d7212028d0..c94d69d84b7 100644
> > --- a/libgcc/config.host
> > +++ b/libgcc/config.host
> > @@ -1304,12 +1304,12 @@ pru-*-*)
> >         tm_file="$tm_file pru/pru-abi.h"
> >         ;;
> >  riscv*-*-linux*)
> > -       tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp
> > riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
> > +       tmake_file="${tmake_file} riscv/t-crtstuff
> > riscv/t-softfp${host_address} t-softfp riscv/t-elf
> > riscv/t-elf${host_address} t-slibgcc-libgcc"
> >         extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o
> > crtendS.o crtbeginT.o"
> >         md_unwind_header=riscv/linux-unwind.h
> >         ;;
> >  riscv*-*-freebsd*)
> > -       tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp
> > riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc"
> > +       tmake_file="${tmake_file} riscv/t-crtstuff
> > riscv/t-softfp${host_address} t-softfp riscv/t-elf
> > riscv/t-elf${host_address} t-slibgcc-libgcc"
> >         extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o
> > crtendS.o crtbeginT.o"
> >         ;;
> >  riscv*-*-*)
> > diff --git a/libgcc/config/riscv/t-crtstuff
> > b/libgcc/config/riscv/t-crtstuff
> > new file mode 100644
> > index 00000000000..685d11b3e66
> > --- /dev/null
> > +++ b/libgcc/config/riscv/t-crtstuff
> > @@ -0,0 +1,5 @@
> > +# -fasynchronous-unwind-tables -funwind-tables is on by default for riscv
> > linux
> > +# We turn it off for crt*.o because it would make __EH_FRAME_BEGIN__ point
> > +# to .eh_frame data from crtbeginT.o instead of the user-defined object
> > +# during static linking.
> > +CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
> > --
> > 2.39.1
> >
> >

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

end of thread, other threads:[~2024-05-08 16:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-23  1:06 [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv Andrew Pinski
2023-07-23  1:06 ` [PATCH 2/2] AARCH64: Turn off unwind tables for crtbeginT.o Andrew Pinski
2023-07-24 15:55   ` Richard Sandiford
2023-07-25  7:06     ` Richard Biener
2023-07-23  3:35 ` [PATCH 1/2] Fix PR 110066: crash with -pg -static on riscv Kito Cheng
2024-05-08 16:07   ` Andrew Pinski
2023-07-23  6:46 ` Andreas Schwab

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