x86: Always define TC_PARSE_CONS_EXPRESSION

Message ID CAMe9rOr1tt7Rx+zJvhxHF3=OxmCLr4f79OzAk3=1yq_uiCZbyA@mail.gmail.com
State New
Headers show
Series
  • x86: Always define TC_PARSE_CONS_EXPRESSION
Related show

Commit Message

Alan Modra via Binutils June 11, 2021, 1:23 p.m.
On Thu, Jun 10, 2021 at 7:20 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>

> On Thu, Jun 10, 2021 at 7:09 AM Jan Beulich <jbeulich@suse.com> wrote:

> >

> > On 10.06.2021 15:34, H.J. Lu wrote:

> > > Please try this patch to see if gas_bfd64_check works for you.

> >

> > Without having tried it yet, two questions: For one, is the

> > AS_CLASS use in there rather meant to be AS_BFD64? And then, how

>

> It should be AS_BFD64.

>

> > is it going to help to check the as-new binary for a target (like

> > a.out) which doesn't have said --help output line, when this can

> > still be a 64-bit binary defaulting to BFD64 or a 32-bit one where

> > ./configure simply was passed --enable-64-bit-bfd?

>

> It isn't covered.

>

> > Wouldn't it be more direct to check for a working .code64

> > directive? Its availability directly depends on BFD64. Of course

>

> Sure if it works.

>

> > then a next question is whether gas_64_check really needs to be

> > different from gas_bfd64_check (albeit the two then still wouldn't

> > do the same checking).

>

> They are different things. BFD64 can be used without --64.

>


I am checking in this.

-- 
H.J.

Comments

Alan Modra via Binutils June 11, 2021, 1:31 p.m. | #1
On Fri, Jun 11, 2021 at 6:23 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>

> On Thu, Jun 10, 2021 at 7:20 AM H.J. Lu <hjl.tools@gmail.com> wrote:

> >

> > On Thu, Jun 10, 2021 at 7:09 AM Jan Beulich <jbeulich@suse.com> wrote:

> > >

> > > On 10.06.2021 15:34, H.J. Lu wrote:

> > > > Please try this patch to see if gas_bfd64_check works for you.

> > >

> > > Without having tried it yet, two questions: For one, is the

> > > AS_CLASS use in there rather meant to be AS_BFD64? And then, how

> >

> > It should be AS_BFD64.

> >

> > > is it going to help to check the as-new binary for a target (like

> > > a.out) which doesn't have said --help output line, when this can

> > > still be a 64-bit binary defaulting to BFD64 or a 32-bit one where

> > > ./configure simply was passed --enable-64-bit-bfd?

> >

> > It isn't covered.

> >

> > > Wouldn't it be more direct to check for a working .code64

> > > directive? Its availability directly depends on BFD64. Of course

> >

> > Sure if it works.

> >

> > > then a next question is whether gas_64_check really needs to be

> > > different from gas_bfd64_check (albeit the two then still wouldn't

> > > do the same checking).

> >

> > They are different things. BFD64 can be used without --64.

> >

>

> I am checking in this.

>


This is the patch I am checking in.

-- 
H.J.
From aaf364ccb09ec9bda8c375fcde890e09e59e01a4 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 11 Jun 2021 06:19:16 -0700
Subject: [PATCH] x86: Always define TC_PARSE_CONS_EXPRESSION

Always define TC_PARSE_CONS_EXPRESSION to properly wrap constants for
all x86 targets.

	* config/tc-i386.c (x86_cons): Handle GOT/PLT relocations only
	if needed.
	* config/tc-i386.h (TC_PARSE_CONS_EXPRESSION): Always define.
---
 gas/ChangeLog        | 6 ++++++
 gas/config/tc-i386.c | 6 ++++++
 gas/config/tc-i386.h | 3 ---
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 11693d33182..6bcb035621e 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2021-06-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* config/tc-i386.c (x86_cons): Handle GOT/PLT relocations only
+	if needed.
+	* config/tc-i386.h (TC_PARSE_CONS_EXPRESSION): Always define.
+
 2021-06-11  Nelson Chu  <nelson.chu@sifive.com>
 
 	* config/tc-riscv.c (riscv_set_arch): Call riscv_set_rvc
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 47c12b97651..b3f9f31db76 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -10413,6 +10413,9 @@ x86_cons (expressionS *exp, int size)
 {
   bfd_reloc_code_real_type got_reloc = NO_RELOC;
 
+#if ((defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) \
+      && !defined (LEX_AT)) \
+    || defined (TE_PE)
   intel_syntax = -intel_syntax;
 
   exp->X_md = 0;
@@ -10468,6 +10471,9 @@ x86_cons (expressionS *exp, int size)
 
   if (intel_syntax)
     i386_intel_simplify (exp);
+#else
+  expression (exp);
+#endif
 
   /* If not 64bit, massage value, to account for wraparound when !BFD64.  */
   if (size == 4 && exp->X_op == O_constant && !object_64bit)
diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h
index 9ca9727d4ca..90d23da7d91 100644
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -126,10 +126,7 @@ extern const char *i386_comment_chars;
 #define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_"
 #endif
 
-#if ((defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) \
-     && !defined (LEX_AT)) || defined (TE_PE)
 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) x86_cons (EXP, NBYTES)
-#endif
 extern bfd_reloc_code_real_type x86_cons (expressionS *, int);
 
 #define TC_CONS_FIX_NEW(FRAG, OFF, LEN, EXP, RELOC)	\
Alan Modra via Binutils June 11, 2021, 1:39 p.m. | #2
On 11.06.2021 15:31, H.J. Lu wrote:
> On Fri, Jun 11, 2021 at 6:23 AM H.J. Lu <hjl.tools@gmail.com> wrote:

>>

>> On Thu, Jun 10, 2021 at 7:20 AM H.J. Lu <hjl.tools@gmail.com> wrote:

>>>

>>> On Thu, Jun 10, 2021 at 7:09 AM Jan Beulich <jbeulich@suse.com> wrote:

>>>>

>>>> On 10.06.2021 15:34, H.J. Lu wrote:

>>>>> Please try this patch to see if gas_bfd64_check works for you.

>>>>

>>>> Without having tried it yet, two questions: For one, is the

>>>> AS_CLASS use in there rather meant to be AS_BFD64? And then, how

>>>

>>> It should be AS_BFD64.

>>>

>>>> is it going to help to check the as-new binary for a target (like

>>>> a.out) which doesn't have said --help output line, when this can

>>>> still be a 64-bit binary defaulting to BFD64 or a 32-bit one where

>>>> ./configure simply was passed --enable-64-bit-bfd?

>>>

>>> It isn't covered.

>>>

>>>> Wouldn't it be more direct to check for a working .code64

>>>> directive? Its availability directly depends on BFD64. Of course

>>>

>>> Sure if it works.

>>>

>>>> then a next question is whether gas_64_check really needs to be

>>>> different from gas_bfd64_check (albeit the two then still wouldn't

>>>> do the same checking).

>>>

>>> They are different things. BFD64 can be used without --64.

>>>

>>

>> I am checking in this.

>>

> 

> This is the patch I am checking in.


Ah yes, thanks, this should remove all concerns about bogus overflow
warnings for data definition.

Jan

Patch

From 19df92444311d0cb4a68c09804d23a13f2cf430e Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 11 Jun 2021 06:19:16 -0700
Subject: [PATCH] x86: Always define TC_PARSE_CONS_EXPRESSION

Always define TC_PARSE_CONS_EXPRESSION to properly wrap constants for
all x86 targets.

	* config/tc-i386.h (TC_PARSE_CONS_EXPRESSION): Always define.
---
 gas/ChangeLog        | 4 ++++
 gas/config/tc-i386.h | 3 ---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 11693d33182..e78ab3c2983 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,7 @@ 
+2021-06-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* config/tc-i386.h (TC_PARSE_CONS_EXPRESSION): Always define.
+
 2021-06-11  Nelson Chu  <nelson.chu@sifive.com>
 
 	* config/tc-riscv.c (riscv_set_arch): Call riscv_set_rvc
diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h
index 9ca9727d4ca..90d23da7d91 100644
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -126,10 +126,7 @@  extern const char *i386_comment_chars;
 #define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_"
 #endif
 
-#if ((defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) \
-     && !defined (LEX_AT)) || defined (TE_PE)
 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) x86_cons (EXP, NBYTES)
-#endif
 extern bfd_reloc_code_real_type x86_cons (expressionS *, int);
 
 #define TC_CONS_FIX_NEW(FRAG, OFF, LEN, EXP, RELOC)	\
-- 
2.31.1