Skip to contentSkip to conversation

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

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

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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

Hi Thomas,

these three 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. Third patch removes -mtext-section-literals flag from individual packages that used to need them.

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 (3):
uclibc: add missing .literal_position directives Makefile.in: add -mtext-section-literals to xtensa ABI
xtensa: remove -mtext-section-literals from individual package *.mk's

 package/Makefile.in                                | 11 +++-
 package/civetweb/civetweb.mk                       |  3 --
 package/ffmpeg/ffmpeg.mk                           |  4 --
 package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk         |  4 --
 package/gstreamer1/gst1-libav/gst1-libav.mk        |  4 --
 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(+), 32 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 v2 1/3 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 v2 2/3 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 v2 3/3 xtensa: remove -mtext-section-literals from individual package *.mk's

In reply to Max Filippov

Now that -mtext-section-literals is specified in xtensa ABI remove it from individual packages that needed it.

---
Changes v1 -> v2:
- new patch

 package/civetweb/civetweb.mk                | 3 ---
 package/ffmpeg/ffmpeg.mk                    | 4 ----
 package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk  | 4 ----
 package/gstreamer1/gst1-libav/gst1-libav.mk | 4 ----
 package/lmbench/lmbench.mk                  | 4 ----
 package/php/php.mk                          | 4 ----
 package/sqlcipher/sqlcipher.mk              | 4 ----
 package/sqlite/sqlite.mk                    | 4 ----
 8 files changed, 31 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)
package/ffmpeg/ffmpeg.mk +0 -4
index a067fe6..a5d5de1 100644
@@ -75,10 +75,6 @@ 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)
package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk +0 -4
index eb7389f..1975682 100644
@@ -16,10 +16,6 @@ GST_FFMPEG_CONF_EXTRA_OPT = \
 
 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)
package/gstreamer1/gst1-libav/gst1-libav.mk +0 -4
index a0a536e..6e6ff51 100644
@@ -85,10 +85,6 @@ GST1_LIBAV_CONF_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))
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
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)
 
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"
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
#4 lore raw

PATCH v2 3/3 xtensa: remove -mtext-section-literals from individual package *.mk's

Hi Max,

Quoted 17 lines · Max Filippov

Now that -mtext-section-literals is specified in xtensa ABI remove it from individual packages that needed it.

---
Changes v1 -> v2:
- new patch

 package/civetweb/civetweb.mk                | 3 ---
 package/ffmpeg/ffmpeg.mk                    | 4 ----
 package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk  | 4 ----
 package/gstreamer1/gst1-libav/gst1-libav.mk | 4 ----
 package/lmbench/lmbench.mk                  | 4 ----
 package/php/php.mk                          | 4 ----
 package/sqlcipher/sqlcipher.mk              | 4 ----
 package/sqlite/sqlite.mk                    | 4 ----
 8 files changed, 31 deletions(-)

[snip]

package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk GST_FFMPEG_CONF_EXTRA_OPT = \ · line 19

Quoted 13 lines
package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk +0 -4
index eb7389f..1975682 100644
@@ -16,10 +16,6 @@ GST_FFMPEG_CONF_EXTRA_OPT = \
 
 GST_FFMPEG_CFLAGS = $(TARGET_CFLAGS)
 
-ifeq ($(BR2_xtensa),y)
-GST_FFMPEG_CFLAGS += -mtext-section-literals
-endif
-
 GST_FFMPEG_CONF_ENV = CFLAGS="$(GST_FFMPEG_CFLAGS)"

Both GST_FFMPEG_CONF_ENV and GST_FFMPEG_CFLAGS are not used anywhere else.

Quoted 6 lines
package/gstreamer/gst-ffmpeg/gst-ffmpeg.mk +0 -0
 ifeq ($(BR2_PACKAGE_ZLIB),y)
package/gstreamer1/gst1-libav/gst1-libav.mk +0 -0
index a0a536e..6e6ff51 100644

package/gstreamer1/gst1-libav/gst1-libav.mk GST1_LIBAV_CONF_OPT = \ · line 88

Quoted 8 lines
package/gstreamer1/gst1-libav/gst1-libav.mk +0 -4
@@ -85,10 +85,6 @@ GST1_LIBAV_CONF_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)"

Ditto.

baruch

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 -