Skip to contentSkip to conversation

xtensa: add -mtext-section-literals to xtensa ABI

PATCH Superseded Max Filippov 2 participants 5 messages Mar 30, 2014

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover xtensa: add -mtext-section-literals to xtensa ABI

Hi Thomas,

these two patches are the second part of fixes for building huge sources, like wireshark or mplayer: adding trampolines support to binutils allows assembling of such files, but with literals placed into separate section build fails at the linking step.

First patch allows building uclibc with -mtext-section-literals, it is posted to the uclibc list, but not reviewed/checked in yet. Second patch adds -mtext-section-literals flag to xtensa ABI.

Max Filippov (2):
uclibc: add missing .literal_position directives Makefile.in: add -mtext-section-literals to xtensa ABI

 package/Makefile.in                                |  2 +-
 ...-add-missing-.literal_position-directives.patch | 62 ++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 package/uclibc/7bf35c8b7d4a1f97174eb49f47f33946b282114c/uclibc-0001-xtensa-add-missing-.literal_position-directives.patch
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/2 uclibc: add missing .literal_position directives

This allows building uclibc with -mtext-section-literals flag.

---
 ...-add-missing-.literal_position-directives.patch | 62 ++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 package/uclibc/7bf35c8b7d4a1f97174eb49f47f33946b282114c/uclibc-0001-xtensa-add-missing-.literal_position-directives.patch
package/uclibc/7bf35c8b7d4a1f97174eb49f47f33946b282114c/uclibc-0001-xtensa-add-missing-.literal_position-directives.patch new file +62 -0
new file mode 100644
index 0000000..f5577c6
@@ -0,0 +1,62 @@
+From 04d7bd868b300c8150231d7a37e62150eaf810d0 Mon Sep 17 00:00:00 2001
+From: Max Filippov <[email protected]>
+Date: Mon, 24 Mar 2014 01:06:35 +0400
+Subject: [PATCH] xtensa: add missing .literal_position directives
+
+This addition allows building uClibc with -mtext-section-literals
+
+Signed-off-by: Max Filippov <[email protected]>
+---
+ ldso/ldso/xtensa/dl-startup.h | 1 +
+ ldso/ldso/xtensa/resolve.S    | 1 +
+ libc/string/xtensa/strcmp.S   | 5 +++--
+ 3 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/ldso/ldso/xtensa/dl-startup.h b/ldso/ldso/xtensa/dl-startup.h
+index 45af82d..b135a4c 100644
+--- a/ldso/ldso/xtensa/dl-startup.h
++++ b/ldso/ldso/xtensa/dl-startup.h
+@@ -11,6 +11,7 @@
+ __asm__ (
+     "	.text\n"
+     "	.align  4\n"
++    "	.literal_position\n"
+     "	.global _start\n"
+     "	.type   _start, @function\n"
+     "	.hidden _start\n"
+diff --git a/ldso/ldso/xtensa/resolve.S b/ldso/ldso/xtensa/resolve.S
+index 61c2c5d..d1ae8aa 100644
+--- a/ldso/ldso/xtensa/resolve.S
++++ b/ldso/ldso/xtensa/resolve.S
+@@ -27,6 +27,7 @@
+ 
+ 	.text
+ 	.align	4
++	.literal_position
+ 	.global	_dl_linux_resolve
+ 	.type	_dl_linux_resolve, @function
+ _dl_linux_resolve:
+diff --git a/libc/string/xtensa/strcmp.S b/libc/string/xtensa/strcmp.S
+index d3d72e0..8ed1ed0 100644
+--- a/libc/string/xtensa/strcmp.S
++++ b/libc/string/xtensa/strcmp.S
+@@ -34,13 +34,14 @@
+ 
+ #define MASK4 0x40404040
+ 
++	.text
++	.align 4
++	.literal_position
+ 	.literal .Lmask0, MASK0
+ 	.literal .Lmask1, MASK1
+ 	.literal .Lmask2, MASK2
+ 	.literal .Lmask3, MASK3
+ 	.literal .Lmask4, MASK4
+-
+-	.text
+ ENTRY (strcmp)
+ 	/* a2 = s1, a3 = s2 */
+ 
+-- 
+1.8.1.4
+
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH 2/2 Makefile.in: add -mtext-section-literals to xtensa ABI

In reply to Max Filippov

Collecting literals into separate section can be advantageous if that section is placed into DTCM at link time. This is applicable for code running on bare metal, but makes no sense under linux, where userspace is isolated from the physical memory details. OTOH placing literals into separate section breaks build of huge source files, because l32r instruction can only access literals in 256 KBytes range.

Add -mtext-section-literals into xtensa ABI to fix build issues of packages with huge sources.

---
 package/Makefile.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/Makefile.in +1 -1
index eea7043..31c72a0 100644
@@ -73,7 +73,7 @@ endif
 # code size and performance, the linker can usually optimize away the
 # overhead when a call ends up within a certain range.
 ifeq ($(BR2_xtensa),y)
-TARGET_ABI += -mlongcalls
+TARGET_ABI += -mlongcalls -mtext-section-literals
 endif
 
 STAGING_SUBDIR = usr/$(GNU_TARGET_NAME)/sysroot
Signature · 1 line
1.8.1.4
#3 lore raw

PATCH 2/2 Makefile.in: add -mtext-section-literals to xtensa ABI

Hi Max,

Quoted 20 lines · Max Filippov

Collecting literals into separate section can be advantageous if that section is placed into DTCM at link time. This is applicable for code running on bare metal, but makes no sense under linux, where userspace is isolated from the physical memory details. OTOH placing literals into separate section breaks build of huge source files, because l32r instruction can only access literals in 256 KBytes range.

Add -mtext-section-literals into xtensa ABI to fix build issues of packages with huge sources.

---
 package/Makefile.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/Makefile.in +0 -0
index eea7043..31c72a0 100644

package/Makefile.in endif · line 74

Quoted 2 lines
package/Makefile.in +0 -0
@@ -73,7 +73,7 @@ endif
 # code size and performance, the linker can usually optimize away the
 # overhead when a call ends up within a certain range.

Please add the commit log explanation to the comment here.

package/Makefile.in endif · line 76

Quoted 3 lines
package/Makefile.in +1 -1
 ifeq ($(BR2_xtensa),y)
-TARGET_ABI += -mlongcalls
+TARGET_ABI += -mlongcalls -mtext-section-literals

With this in place a follow-up patch should remove local -mtext-section-literals that I sprinkled on various packages to fix xtensa build failures.

Thanks,
baruch

Quoted 3 lines
package/Makefile.in +0 -0
 endif
 
 STAGING_SUBDIR = usr/$(GNU_TARGET_NAME)/sysroot
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#4 lore raw

PATCH 2/2 Makefile.in: add -mtext-section-literals to xtensa ABI

Quoted 18 lines · Baruch Siach

Hi Max,

Quoted 15 lines · Max Filippov

Collecting literals into separate section can be advantageous if that section is placed into DTCM at link time. This is applicable for code running on bare metal, but makes no sense under linux, where userspace is isolated from the physical memory details. OTOH placing literals into separate section breaks build of huge source files, because l32r instruction can only access literals in 256 KBytes range.

Add -mtext-section-literals into xtensa ABI to fix build issues of packages with huge sources.

---
 package/Makefile.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 9 lines

package/Makefile.in endif · line 74

Quoted 7 lines
package/Makefile.in +0 -0
index eea7043..31c72a0 100644
@@ -73,7 +73,7 @@ endif
 # code size and performance, the linker can usually optimize away the
 # overhead when a call ends up within a certain range.

Please add the commit log explanation to the comment here.

Ok.

Quoted 7 lines

package/Makefile.in endif · line 76

Quoted 3 lines
package/Makefile.in +1 -1
 ifeq ($(BR2_xtensa),y)
-TARGET_ABI += -mlongcalls
+TARGET_ABI += -mlongcalls -mtext-section-literals

With this in place a follow-up patch should remove local -mtext-section-literals that I sprinkled on various packages to fix xtensa build failures.

Ok, will add it.

Signature · 2 lines
Thanks.
-- Max