Skip to contentSkip to conversation

package/gcc: backport xtensa trap pattern for 5.x

PATCH New Max Filippov 2 participants 5 messages Nov 14, 2016 – Nov 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/gcc: backport xtensa trap pattern for 5.x

gcc 5.x uses trap pattern extensively to mark locations where program execution should never get. Default pattern implementation emits a call to 'abort' function. This function however is not always available, e.g. it's not available for the libc dynamic linker. Backport implementation of the trap pattern for xtensa that does not result in a call to 'abort'.

Fixes:
http://autobuild.buildroot.net/results/0fbcc4475545904bf88f25a3bdf3ee552bf4960e
http://autobuild.buildroot.net/results/cb7f5bdfac615d774f3bcd1b802f8d74460bc557
http://autobuild.buildroot.net/results/cf3dc9ae4f74ff28b285f1a862b71d96384d7651

---
 .../5.4.0/875-xtensa-implement-trap-pattern.patch  | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 package/gcc/5.4.0/875-xtensa-implement-trap-pattern.patch
package/gcc/5.4.0/875-xtensa-implement-trap-pattern.patch new file +67 -0
new file mode 100644
index 0000000..870b079
@@ -0,0 +1,67 @@
+From 2b4b5775554c91a63ccae4ee566db696b633652e Mon Sep 17 00:00:00 2001
+From: jcmvbkbc <jcmvbkbc@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 10 Jun 2015 15:07:40 +0000
+Subject: [PATCH] xtensa: implement trap pattern
+
+2015-06-10  Max Filippov  <[email protected]>
+gcc/
+	* config/xtensa/xtensa.h (TARGET_DEBUG): New definition.
+	* config/xtensa/xtensa.md (define_attr "type"): New type "trap".
+	(define_insn "trap"): New definition.
+
+Signed-off-by: Max Filippov <[email protected]>
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk at 224330 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+ gcc/config/xtensa/xtensa.h  |  1 +
+ gcc/config/xtensa/xtensa.md | 15 ++++++++++++++-
+ 2 files changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
+index 615f741..fb8702c 100644
+--- a/gcc/config/xtensa/xtensa.h
++++ b/gcc/config/xtensa/xtensa.h
+@@ -67,6 +67,7 @@ extern unsigned xtensa_current_frame_size;
+ #define TARGET_THREADPTR	XCHAL_HAVE_THREADPTR
+ #define TARGET_LOOPS	        XCHAL_HAVE_LOOPS
+ #define TARGET_WINDOWED_ABI	(XSHAL_ABI == XTHAL_ABI_WINDOWED)
++#define TARGET_DEBUG		XCHAL_HAVE_DEBUG
+ 
+ #define TARGET_DEFAULT \
+   ((XCHAL_HAVE_L32R	? 0 : MASK_CONST16) |				\
+diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
+index 6d84384..a577aa3 100644
+--- a/gcc/config/xtensa/xtensa.md
++++ b/gcc/config/xtensa/xtensa.md
+@@ -86,7 +86,7 @@
+ ;; Attributes.
+ 
+ (define_attr "type"
+-  "unknown,jump,call,load,store,move,arith,multi,nop,farith,fmadd,fconv,fload,fstore,mul16,mul32,div32,mac16,rsr,wsr,entry"
++  "unknown,jump,call,load,store,move,arith,multi,nop,farith,fmadd,fconv,fload,fstore,mul16,mul32,div32,mac16,rsr,wsr,entry,trap"
+   (const_string "unknown"))
+ 
+ (define_attr "mode"
+@@ -1764,6 +1764,19 @@
+   [(set_attr "length" "0")
+    (set_attr "type" "nop")])
+ 
++(define_insn "trap"
++  [(trap_if (const_int 1) (const_int 0))]
++  ""
++{
++  if (TARGET_DEBUG)
++    return "break\t1, 15";
++  else
++    return (TARGET_DENSITY ? "ill.n" : "ill");
++}
++  [(set_attr "type"	"trap")
++   (set_attr "mode"	"none")
++   (set_attr "length"	"3")])
++
+ ;; Setting up a frame pointer is tricky for Xtensa because GCC doesn't
+ ;; know if a frame pointer is required until the reload pass, and
+ ;; because there may be an incoming argument value in the hard frame
+-- 
+2.1.4
+
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 package/gcc: backport xtensa trap pattern for 5.x

Hello,

Quoted 12 lines · Max Filippov

gcc 5.x uses trap pattern extensively to mark locations where program execution should never get. Default pattern implementation emits a call to 'abort' function. This function however is not always available, e.g. it's not available for the libc dynamic linker. Backport implementation of the trap pattern for xtensa that does not result in a call to 'abort'.

Fixes:
http://autobuild.buildroot.net/results/0fbcc4475545904bf88f25a3bdf3ee552bf4960e
http://autobuild.buildroot.net/results/cb7f5bdfac615d774f3bcd1b802f8d74460bc557
http://autobuild.buildroot.net/results/cf3dc9ae4f74ff28b285f1a862b71d96384d7651

Quoted 5 lines
---
 .../5.4.0/875-xtensa-implement-trap-pattern.patch  | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 package/gcc/5.4.0/875-xtensa-implement-trap-pattern.patch

Applied to master, thanks. However, I'm wondering if this backport should also be done on gcc versions earlier than 5.x. Could you clarify this point?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 package/gcc: backport xtensa trap pattern for 5.x

Hello,

Quoted 21 lines · Thomas Petazzoni

Hello,

Quoted 12 lines · Max Filippov

gcc 5.x uses trap pattern extensively to mark locations where program execution should never get. Default pattern implementation emits a call to 'abort' function. This function however is not always available, e.g. it's not available for the libc dynamic linker. Backport implementation of the trap pattern for xtensa that does not result in a call to 'abort'.

Fixes:
http://autobuild.buildroot.net/results/0fbcc4475545904bf88f25a3bdf3ee552bf4960e
http://autobuild.buildroot.net/results/cb7f5bdfac615d774f3bcd1b802f8d74460bc557
http://autobuild.buildroot.net/results/cf3dc9ae4f74ff28b285f1a862b71d96384d7651

Quoted 5 lines
---
 .../5.4.0/875-xtensa-implement-trap-pattern.patch  | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 package/gcc/5.4.0/875-xtensa-implement-trap-pattern.patch  
Quoted 3 lines

Applied to master, thanks. However, I'm wondering if this backport should also be done on gcc versions earlier than 5.x. Could you clarify this point?

FYI, I've rebuilt the Xtensa pre-built toolchain and deployed it to autobuild.b.o for our autobuilders to use.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH 1/1 package/gcc: backport xtensa trap pattern for 5.x

In reply to Thomas Petazzoni

Hi Thomas,

Quoted 3 lines · Thomas Petazzoni

Applied to master, thanks. However, I'm wondering if this backport should also be done on gcc versions earlier than 5.x. Could you clarify this point?

I haven't seen that issue with earlier gcc versions, it only started showing up with gcc-5.x.

Signature · 2 lines
Thanks.
-- Max
#4 lore raw

PATCH 1/1 package/gcc: backport xtensa trap pattern for 5.x

Hello,

Quoted 2 lines · Max Filippov

I haven't seen that issue with earlier gcc versions, it only started showing up with gcc-5.x.

OK, thanks for the confirmation!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com