Skip to contentSkip to conversation

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

PATCH New Max Filippov 3 participants 13 messages Mar 30, 2014 – Apr 3, 2014

lore
Share & tools
lore
#0 lore raw

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

Hi Thomas,

this series is 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. Remaining patches revert -mtext-section-literals additions to individual packages.

Changes v2 -> v3:
- drop patch 3 and revert individual commits that added -mtext-section-literals flag instead

Changes v1 -> v2:
- add comment to XTENSA_ABI variable explaining -mtext-section-literals usage
- remove -mtext-section-literals from individual package *.mk's

Max Filippov (10):
uclibc: add missing .literal_position directives Makefile.in: add -mtext-section-literals to xtensa ABI Revert "civetweb: fix build for xtensa"
Revert "ffmpeg: fix build for xtensa"
Revert "gst-ffmpeg: fix build for xtensa" Revert "gst1-libav: fix build for xtensa" Revert "lmbench: fix build for xtensa"
Revert "php: fix build for xtensa"
Revert "sqlcipher: fix build for xtensa"
Revert "xtensa: sqlite requires special compiler option"

 package/Makefile.in                                | 11 +++-
 package/civetweb/civetweb.mk                       |  3 --
 package/ffmpeg/ffmpeg.mk                           |  8 ---
 package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk         |  8 ---
 package/gstreamer1/gst1-libav/gst1-libav.mk        |  8 ---
 package/lmbench/lmbench.mk                         |  4 --
 package/php/php.mk                                 |  4 --
 package/sqlcipher/sqlcipher.mk                     |  4 --
 package/sqlite/sqlite.mk                           |  4 --
 ...-add-missing-.literal_position-directives.patch | 62 ++++++++++++++++++++++
 10 files changed, 72 insertions(+), 44 deletions(-)
 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 v3 1/10 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 v3 2/10 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.

---
Changes v1 -> v2:
- add comment to XTENSA_ABI variable explaining -mtext-section-literals usage

 package/Makefile.in | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
package/Makefile.in +10 -1
index eea7043..a70e538 100644
@@ -72,8 +72,17 @@ endif
 # and is required for some packages. While this option can degrade both
 # code size and performance, the linker can usually optimize away the
 # overhead when a call ends up within a certain range.
+#
+# Use text-section-literals for Xtensa globally.
+# 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.
+#
 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 v3 3/10 Revert "civetweb: fix build for xtensa"

In reply to Max Filippov

This reverts commit 37084ead509fa42db39637fcb837e7a99197c6c9. Now that -mtext-section-literals is specified in the xtensa ABI this fix is no longer needed.

---
Changes v2 -> v3:
- new patch

 package/civetweb/civetweb.mk | 3 ---
 1 file changed, 3 deletions(-)
package/civetweb/civetweb.mk +0 -3
index be7620a..4b73a5e 100644
@@ -25,9 +25,6 @@ endif
 
 ifeq ($(BR2_CIVETWEB_WITH_LUA),y)
 	CIVETWEB_CONF_OPT += WITH_LUA=1
-ifeq ($(BR2_xtensa),y)
-	CIVETWEB_COPT += -mtext-section-literals
-endif
 endif
 
 ifeq ($(BR2_PACKAGE_OPENSSL),y)
Signature · 1 line
1.8.1.4
#4 lore raw

PATCH v3 4/10 Revert "ffmpeg: fix build for xtensa"

In reply to Max Filippov

This reverts commit 4ec35e76b8a31810a0b8955a6dee787cefa013bc. Now that -mtext-section-literals is specified in the xtensa ABI this fix is no longer needed.

---
Changes v2 -> v3:
- new patch

 package/ffmpeg/ffmpeg.mk | 8 --------
 1 file changed, 8 deletions(-)
package/ffmpeg/ffmpeg.mk +0 -8
index a067fe6..fae558a 100644
@@ -73,14 +73,6 @@ FFMPEG_CONF_OPT = \
 
 FFMPEG_DEPENDENCIES += $(if $(BR2_PACKAGE_LIBICONV),libiconv)
 
-FFMPEG_CFLAGS = $(TARGET_CFLAGS)
-
-ifeq ($(BR2_xtensa),y)
-FFMPEG_CFLAGS += -mtext-section-literals
-endif
-
-FFMPEG_CONF_ENV = CFLAGS="$(FFMPEG_CFLAGS)"
-
 ifeq ($(BR2_PACKAGE_FFMPEG_GPL),y)
 FFMPEG_CONF_OPT += --enable-gpl
 else
Signature · 1 line
1.8.1.4
#5 lore raw

PATCH v3 5/10 Revert "gst-ffmpeg: fix build for xtensa"

In reply to Max Filippov

This reverts commit 7e558aa0d87d86be1bbc91b284acd0d11378ee4e. Now that -mtext-section-literals is specified in the xtensa ABI this fix is no longer needed.

---
Changes v2 -> v3:
- new patch

 package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk | 8 --------
 1 file changed, 8 deletions(-)
package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk +0 -8
index eb7389f..6534f93 100644
@@ -14,14 +14,6 @@ GST_FFMPEG_CONF_EXTRA_OPT = \
 		--cross-prefix=$(TARGET_CROSS) \
 		--target-os=linux
 
-GST_FFMPEG_CFLAGS = $(TARGET_CFLAGS)
-
-ifeq ($(BR2_xtensa),y)
-GST_FFMPEG_CFLAGS += -mtext-section-literals
-endif
-
-GST_FFMPEG_CONF_ENV = CFLAGS="$(GST_FFMPEG_CFLAGS)"
-
 ifeq ($(BR2_PACKAGE_ZLIB),y)
 GST_FFMPEG_CONF_EXTRA_OPT += --enable-zlib
 GST_FFMPEG_DEPENDENCIES += zlib
Signature · 1 line
1.8.1.4
#6 lore raw

PATCH v3 6/10 Revert "gst1-libav: fix build for xtensa"

In reply to Max Filippov

This reverts commit ae3298d7d489f5ee465ff4ce83494de527d0ac73. Now that -mtext-section-literals is specified in the xtensa ABI this fix is no longer needed.

---
Changes v2 -> v3:
- new patch

 package/gstreamer1/gst1-libav/gst1-libav.mk | 8 --------
 1 file changed, 8 deletions(-)
package/gstreamer1/gst1-libav/gst1-libav.mk +0 -8
index a0a536e..1c45acc 100644
@@ -83,12 +83,4 @@ endif
 GST1_LIBAV_CONF_OPT = \
 	--with-libav-extra-configure="$(GST1_LIBAV_CONF_EXTRA_OPT)"
 
-GST1_LIBAV_CFLAGS = $(TARGET_CFLAGS)
-
-ifeq ($(BR2_xtensa),y)
-GST1_LIBAV_CFLAGS += -mtext-section-literals
-endif
-
-GST1_LIBAV_CONF_ENV += CFLAGS="$(GST1_LIBAV_CFLAGS)"
-
 $(eval $(autotools-package))
Signature · 1 line
1.8.1.4
#7 lore raw

PATCH v3 7/10 Revert "lmbench: fix build for xtensa"

In reply to Max Filippov

This reverts commit 7c04932603476f3adf474f3bc47c35bdb59d947a. Now that -mtext-section-literals is specified in the xtensa ABI this fix is no longer needed.

---
Changes v2 -> v3:
- new patch

 package/lmbench/lmbench.mk | 4 ----
 1 file changed, 4 deletions(-)
package/lmbench/lmbench.mk +0 -4
index 529026f..c3a6c09 100644
@@ -19,10 +19,6 @@ LMBENCH_CFLAGS += -I$(STAGING_DIR)/usr/include/tirpc/
 LMBENCH_LDFLAGS += -ltirpc
 endif
 
-ifeq ($(BR2_xtensa),y)
-LMBENCH_CFLAGS += -mtext-section-literals
-endif
-
 define LMBENCH_CONFIGURE_CMDS
 	$(call CONFIG_UPDATE,$(@D))
 	sed -i 's/CFLAGS=/CFLAGS+=/g' $(@D)/src/Makefile
Signature · 1 line
1.8.1.4
#8 lore raw

PATCH v3 8/10 Revert "php: fix build for xtensa"

In reply to Max Filippov

This reverts commit 410c3cf7ebe69016e73bbe63d1ba4b0a251b5c9a. Now that -mtext-section-literals is specified in the xtensa ABI this fix is no longer needed.

---
Changes v2 -> v3:
- new patch

 package/php/php.mk | 4 ----
 1 file changed, 4 deletions(-)
package/php/php.mk +0 -4
index de02f4b..5797758 100644
@@ -35,10 +35,6 @@ ifneq ($(BR2_INET_IPV6),y)
 endif
 endif
 
-ifeq ($(BR2_xtensa),y)
-PHP_CFLAGS += -mtext-section-literals
-endif
-
 PHP_CONF_OPT += $(if $(BR2_PACKAGE_PHP_CLI),,--disable-cli)
 PHP_CONF_OPT += $(if $(BR2_PACKAGE_PHP_CGI),,--disable-cgi)
 
Signature · 1 line
1.8.1.4
#9 lore raw

PATCH v3 9/10 Revert "sqlcipher: fix build for xtensa"

In reply to Max Filippov

This reverts commit 43d8dc3a392dcb769075cf1b076376a280c15c99. Now that -mtext-section-literals is specified in the xtensa ABI this fix is no longer needed.

---
Changes v2 -> v3:
- new patch

 package/sqlcipher/sqlcipher.mk | 4 ----
 1 file changed, 4 deletions(-)
package/sqlcipher/sqlcipher.mk +0 -4
index ace5ce8..6130870 100644
@@ -32,10 +32,6 @@ ifeq ($(BR2_PACKAGE_SQLCIPHER_STAT3),y)
 SQLCIPHER_CFLAGS += -DSQLITE_ENABLE_STAT3
 endif
 
-ifeq ($(BR2_xtensa),y)
-SQLCIPHER_CFLAGS += -mtext-section-literals
-endif
-
 ifeq ($(BR2_PACKAGE_SQLCIPHER_READLINE),y)
 SQLCIPHER_DEPENDENCIES += ncurses readline
 SQLCIPHER_CONF_OPT += --with-readline-inc="-I$(STAGING_DIR)/usr/include"
Signature · 1 line
1.8.1.4
#10 lore raw

PATCH v3 10/10 Revert "xtensa: sqlite requires special compiler option"

In reply to Max Filippov

This reverts commit 6a30cd3fb30b8057ddde2c72a88c0bb6ad7d1761. Now that -mtext-section-literals is specified in the xtensa ABI this fix is no longer needed.

---
Changes v2 -> v3:
- new patch

 package/sqlite/sqlite.mk | 4 ----
 1 file changed, 4 deletions(-)
package/sqlite/sqlite.mk +0 -4
index b27eb58..6493a29 100644
@@ -33,10 +33,6 @@ ifeq ($(BR2_PACKAGE_SQLITE_SECURE_DELETE),y)
 SQLITE_CFLAGS += -DSQLITE_SECURE_DELETE
 endif
 
-ifeq ($(BR2_xtensa),y)
-SQLITE_CFLAGS += -mtext-section-literals
-endif
-
 SQLITE_CONF_ENV = CFLAGS="$(TARGET_CFLAGS) $(SQLITE_CFLAGS)"
 
 SQLITE_CONF_OPT = \
Signature · 1 line
1.8.1.4
#11 lore raw

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

In reply to Max Filippov

Hi Max,

Quoted 7 lines · Max Filippov

Hi Thomas,

this series is 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.

Quoted 5 lines

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. Remaining patches revert -mtext-section-literals additions to individual packages.

For patches 2-10:

baruch

Quoted 32 lines

Changes v2 -> v3:
- drop patch 3 and revert individual commits that added -mtext-section-literals flag instead

Changes v1 -> v2:
- add comment to XTENSA_ABI variable explaining -mtext-section-literals usage
- remove -mtext-section-literals from individual package *.mk's

Max Filippov (10):
uclibc: add missing .literal_position directives Makefile.in: add -mtext-section-literals to xtensa ABI Revert "civetweb: fix build for xtensa"
Revert "ffmpeg: fix build for xtensa"
Revert "gst-ffmpeg: fix build for xtensa" Revert "gst1-libav: fix build for xtensa" Revert "lmbench: fix build for xtensa"
Revert "php: fix build for xtensa"
Revert "sqlcipher: fix build for xtensa"
Revert "xtensa: sqlite requires special compiler option"

 package/Makefile.in                                | 11 +++-
 package/civetweb/civetweb.mk                       |  3 --
 package/ffmpeg/ffmpeg.mk                           |  8 ---
 package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk         |  8 ---
 package/gstreamer1/gst1-libav/gst1-libav.mk        |  8 ---
 package/lmbench/lmbench.mk                         |  4 --
 package/php/php.mk                                 |  4 --
 package/sqlcipher/sqlcipher.mk                     |  4 --
 package/sqlite/sqlite.mk                           |  4 --
 ...-add-missing-.literal_position-directives.patch | 62 ++++++++++++++++++++++
 10 files changed, 72 insertions(+), 44 deletions(-)
 create mode 100644 package/uclibc/7bf35c8b7d4a1f97174eb49f47f33946b282114c/uclibc-0001-xtensa-add-missing-.literal_position-directives.patch
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 -
#12 lore raw

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

In reply to Max Filippov

Dear Max Filippov,

Quoted 10 lines · Max Filippov

this series is 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. Remaining patches revert -mtext-section-literals additions to individual packages.

Series applied, thanks.

Thomas

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