public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gas: amend X_unsigned uses
@ 2023-07-28  9:52 Jan Beulich
  2023-07-28 10:16 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2023-07-28  9:52 UTC (permalink / raw)
  To: Binutils; +Cc: Nick Clifton, Khem Raj

PR gas/30688

X_unsigned being clear does not indicate a negative number; it merely
indicates a signed one (whose sign may still be clear). Amend two uses
by an actual value check.
---
There's a similar pattern in config/obj-macho.c:obj_mach_o_zerofill(),
but I'm unsure whether that also wants adjusting.

Nick - Cc-ing you for approval on the branch. From your other reply I
understand there's not much time left, so I'd need to commit later
today.

--- a/gas/read.c
+++ b/gas/read.c
@@ -1751,7 +1751,7 @@ s_comm_internal (int param,
       ignore_rest_of_line ();
       goto out;
     }
-  else if (temp != size || !exp.X_unsigned)
+  else if (temp != size || (!exp.X_unsigned && exp.X_add_number < 0))
     {
       as_warn (_("size (%ld) out of range, ignored"), (long) temp);
       ignore_rest_of_line ();
@@ -2541,7 +2541,7 @@ parse_align (int align_bytes)
   if (exp.X_op == O_absent)
     goto no_align;
 
-  if (!exp.X_unsigned)
+  if (!exp.X_unsigned && exp.X_add_number < 0)
     {
       as_warn (_("alignment negative; 0 assumed"));
       align = 0;
--- a/gas/testsuite/gas/elf/common3.s
+++ b/gas/testsuite/gas/elf/common3.s
@@ -1 +1,8 @@
 	.comm foobar,30,4
+	.comm buf1, 5-1, 8
+	.comm buf2, 4, 9-1
+	.ifndef lcomm_align
+	.lcomm lbuf, 9-1
+	.else
+	.lcomm lbuf, 9-1, 8
+	.endif
--- a/gas/testsuite/gas/elf/common3a.d
+++ b/gas/testsuite/gas/elf/common3a.d
@@ -1,7 +1,16 @@
 #source: common3.s
 #as: --elf-stt-common=yes
 #readelf: -s -W
+# MIPS'es IRIX emulation puts lbuf (STB_LOCAL) after the globals in the
+# symbol table, and that mode is hard to check for (see irixemul in
+# binutils/testsuite/binutils-all/mips/mips.exp)
+#notarget: mips*-*-*
 
 #...
+ +[0-9]+: +0+ +8 +(OBJECT|NOTYPE) +LOCAL +DEFAULT +[1-9] +lbuf
+#...
  +[0-9]+: +0+4 +30 +COMMON +GLOBAL +DEFAULT +COM +foobar
+#...
+ +[0-9]+: +0+8 +4 +COMMON +GLOBAL +DEFAULT +COM +buf1
+ +[0-9]+: +0+8 +4 +COMMON +GLOBAL +DEFAULT +COM +buf2
 #pass
--- a/gas/testsuite/gas/elf/common3b.d
+++ b/gas/testsuite/gas/elf/common3b.d
@@ -1,7 +1,16 @@
 #source: common3.s
 #as: --elf-stt-common=no
 #readelf: -s -W
+# MIPS'es IRIX emulation puts lbuf (STB_LOCAL) after the globals in the
+# symbol table, and that mode is hard to check for (see irixemul in
+# binutils/testsuite/binutils-all/mips/mips.exp)
+#notarget: mips*-*-*
 
 #...
+ +[0-9]+: +0+ +8 +(OBJECT|NOTYPE) +LOCAL +DEFAULT +[1-9] +lbuf
+#...
  +[0-9]+: +0+4 +30 +OBJECT +GLOBAL +DEFAULT +COM +foobar
+#...
+ +[0-9]+: +0+8 +4 +OBJECT +GLOBAL +DEFAULT +COM +buf1
+ +[0-9]+: +0+8 +4 +OBJECT +GLOBAL +DEFAULT +COM +buf2
 #pass
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -345,8 +345,16 @@ if { [is_elf_format] } then {
 
     # hpux has a non-standard common directive.
     if { ![istarget "*-*-hpux*"] } then {
-	run_dump_test "common3a"
-	run_dump_test "common3b"
+	switch -glob $target_triplet {
+	    ia64-*-* {
+		run_dump_test "common3a" { { as "--defsym lcomm_align=1" } }
+		run_dump_test "common3b" { { as "--defsym lcomm_align=1" } }
+	    }
+	    default {
+		run_dump_test "common3a"
+		run_dump_test "common3b"
+	    }
+	}
 	run_dump_test "common4a"
 	run_dump_test "common4b"
 	run_dump_test "common5a"

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gas: amend X_unsigned uses
  2023-07-28  9:52 [PATCH] gas: amend X_unsigned uses Jan Beulich
@ 2023-07-28 10:16 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2023-07-28 10:16 UTC (permalink / raw)
  To: Jan Beulich, Binutils; +Cc: Khem Raj

Hi Jan,

> Nick - Cc-ing you for approval on the branch. From your other reply I
> understand there's not much time left, so I'd need to commit later
> today.

Please go ahead and apply to the branch.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-28 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28  9:52 [PATCH] gas: amend X_unsigned uses Jan Beulich
2023-07-28 10:16 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).