[PATCH] configury : Fix LEB128 support for non-GNU assemblers.

Iain Sandoe iain@sandoe.co.uk
Wed Nov 25 09:49:58 GMT 2020


Hi,

I’ve had this patch in my Darwin trees for (literally) years, it is  
relevant to
the GCC ports that use a non-binutils assembler.

At present, even if such an assembler supports LEB128,  the GCC config
is setting HAVE_LEB128 = 0.

The ports I know of that can benefit from a change here are:

AIX (unaffected by this change, since the assembler [at least on gcc119] does
         not support leb128 directives)

Darwin (checked the various different assemblers)

GCN (I can’t test this, so Andrew, please could you say if the change
           is OK for that)

Solaris (bootstrapped and tests running on GCC211, but maybe Rainer would
             want wider checks).

I guess we could exclude specific ports that don’t want to use leb128 with
a target elif in the configuration.

OK for master?

thanks
Iain

===== commit message

Some assemblers that either do not respond to --version, or are non-GNU,
do support leb128 directives.  The current configuration test omits these
cases and only supports GNU assemblers with a version > 2.11.

The patch extends the asm test to cover one failure case present in
assemblers based off an older version of GAS (where a 64 bit value with
the MSB set presented to a .uleb128 directive causes a fail).

This change then assumes that a non-GNU assembler that passes the asm test
correctly supports the directives.

gcc/ChangeLog:

	* configure.ac (check leb128 support): Support non-GNU assemblers
	that pass the leb128 confgure test.  Add a test for uleb128 with
	the MSB set for a 64 bit value.
	* configure: Regenerated.
---
  gcc/configure    | 6 ++++++
  gcc/configure.ac | 6 ++++++
  2 files changed, 12 insertions(+)

diff --git a/gcc/configure.ac b/gcc/configure.ac
index b410428b4fc..8a1aa95f01b 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3072,6 +3072,8 @@ AC_MSG_RESULT($gcc_cv_ld_ro_rw_mix)
  gcc_AC_INITFINI_ARRAY
 
  # Check if we have .[us]leb128, and support symbol arithmetic with it.
+# Some assemblers based on older GAS have a bug when the MSB is set for
+# a 64b value and used in a uleb128.
  gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,
    [elf,2,11,0],,
  [	.data
@@ -3079,6 +3081,7 @@ gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128],  
gcc_cv_as_leb128,
  L1:
  	.uleb128 1280
  	.sleb128 -1010
+	.uleb128 0x8000000000000000
  L2:],
  [[# GAS versions before 2.11 do not support uleb128,
    # despite appearing to.
@@ -3095,6 +3098,9 @@ L2:],
      then :
      else gcc_cv_as_leb128=yes
      fi
+  else
+    # This is a non-GNU assembler, which passes the feature check.
+    gcc_cv_as_leb128=yes
    fi]],
    [AC_DEFINE(HAVE_AS_LEB128, 1,
      [Define if your assembler supports .sleb128 and .uleb128.])],
-- 
2.24.1



More information about the Gcc-patches mailing list