xtensa: gas: don't keep relocations for constants

Message ID 20190128092137.22150-1-jcmvbkbc@gmail.com
State New
Headers show
Series
  • xtensa: gas: don't keep relocations for constants
Related show

Commit Message

Max Filippov Jan. 28, 2019, 9:21 a.m.
xtensa gas chokes on 8/16 bit data entries representing constant symbols
because it leaves BFD_RELOC_8/BFD_RELOC_16 fixups for which xtensa BFD
cannot emit relocations. Resolve fixups for constant symbols in
md_apply_fix.

gas/
2019-01-28  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (md_apply_fix): Mark fixups for constant
	symbols as done in md_apply_fix.
	* testsuite/gas/all/forward.d: Don't XFAIL for xtensa.
---
 gas/config/tc-xtensa.c          | 6 ++++++
 gas/testsuite/gas/all/forward.d | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.11.0

Comments

Nick Clifton Jan. 28, 2019, 12:28 p.m. | #1
Hi Max,

> gas/

> 2019-01-28  Max Filippov  <jcmvbkbc@gmail.com>

> 

> 	* config/tc-xtensa.c (md_apply_fix): Mark fixups for constant

> 	symbols as done in md_apply_fix.

> 	* testsuite/gas/all/forward.d: Don't XFAIL for xtensa.


Approved - please apply.

Cheers
  Nick
Max Filippov Jan. 28, 2019, 6:57 p.m. | #2
Hi Nick,

On Mon, Jan 28, 2019 at 4:28 AM Nick Clifton <nickc@redhat.com> wrote:
> > gas/

> > 2019-01-28  Max Filippov  <jcmvbkbc@gmail.com>

> >

> >       * config/tc-xtensa.c (md_apply_fix): Mark fixups for constant

> >       symbols as done in md_apply_fix.

> >       * testsuite/gas/all/forward.d: Don't XFAIL for xtensa.

>

> Approved - please apply.


Thanks, applied to master.
This is a fix for regression in 2.32 candidate, is it OK for
binutils-2_32-branch?

-- 
Thanks.
-- Max
Nick Clifton Jan. 29, 2019, 12:56 p.m. | #3
Hi Max,

>>>       * config/tc-xtensa.c (md_apply_fix): Mark fixups for constant

>>>       symbols as done in md_apply_fix.

>>>       * testsuite/gas/all/forward.d: Don't XFAIL for xtensa.

>>

>> Approved - please apply.

> 

> Thanks, applied to master.

> This is a fix for regression in 2.32 candidate, is it OK for

> binutils-2_32-branch?


Yes - please apply there as well.

Cheers
  Nick
Max Filippov Jan. 29, 2019, 7:25 p.m. | #4
On Tue, Jan 29, 2019 at 4:56 AM Nick Clifton <nickc@redhat.com> wrote:
> >>>       * config/tc-xtensa.c (md_apply_fix): Mark fixups for constant

> >>>       symbols as done in md_apply_fix.

> >>>       * testsuite/gas/all/forward.d: Don't XFAIL for xtensa.

> >>

> >> Approved - please apply.

> >

> > Thanks, applied to master.

> > This is a fix for regression in 2.32 candidate, is it OK for

> > binutils-2_32-branch?

>

> Yes - please apply there as well.


Thanks, applied.

-- Max
Romain Naour Feb. 2, 2019, 5:59 p.m. | #5
Hi Max,

Le 29/01/2019 à 20:25, Max Filippov a écrit :
> On Tue, Jan 29, 2019 at 4:56 AM Nick Clifton <nickc@redhat.com> wrote:

>>>>>       * config/tc-xtensa.c (md_apply_fix): Mark fixups for constant

>>>>>       symbols as done in md_apply_fix.

>>>>>       * testsuite/gas/all/forward.d: Don't XFAIL for xtensa.

>>>>

>>>> Approved - please apply.

>>>

>>> Thanks, applied to master.

>>> This is a fix for regression in 2.32 candidate, is it OK for

>>> binutils-2_32-branch?

>>

>> Yes - please apply there as well.

> 

> Thanks, applied.


Thanks for the patch.

Best regards,
Romain

> 

> -- Max

>
Romain Naour Feb. 3, 2019, 11:20 a.m. | #6
Hi Max,

Le 02/02/2019 à 18:59, Romain Naour a écrit :
> Hi Max,

> 

> Le 29/01/2019 à 20:25, Max Filippov a écrit :

>> On Tue, Jan 29, 2019 at 4:56 AM Nick Clifton <nickc@redhat.com> wrote:

>>>>>>       * config/tc-xtensa.c (md_apply_fix): Mark fixups for constant

>>>>>>       symbols as done in md_apply_fix.

>>>>>>       * testsuite/gas/all/forward.d: Don't XFAIL for xtensa.

>>>>>

>>>>> Approved - please apply.

>>>>

>>>> Thanks, applied to master.

>>>> This is a fix for regression in 2.32 candidate, is it OK for

>>>> binutils-2_32-branch?

>>>

>>> Yes - please apply there as well.

>>

>> Thanks, applied.

> 


I tested the patch using Binutils 2.32, the toolchain build is ok but the kernel
doesn't boot.

https://gitlab.com/kubu93/toolchains-builder/-/jobs/155355484

I tested the with the same config but using Binutils 2.31.1 and the kernel boot.

Can you have a look?

Best regards,
Romain

> 

>>

>> -- Max

>>

>
Max Filippov Feb. 3, 2019, 1:36 p.m. | #7
Hi Romain,

On Sun, Feb 3, 2019 at 3:20 AM Romain Naour <romain.naour@gmail.com> wrote:
> I tested the patch using Binutils 2.32, the toolchain build is ok but the kernel

> doesn't boot.


This is because the section .note.gnu.build-id that is inserted at the
beginning of the kernel. This was fixed by the commit 4119ba211bc4
(xtensa: add NOTES section to the linker script) in the linux mainline
which was backported to a number of stable kernels, but not into the
4.16.y
I've changed kernel version to 4.19 in the buildroot, it builds and boots
successfully.

--
Thanks.
-- Max
Romain Naour Feb. 3, 2019, 1:50 p.m. | #8
Hi Max,

Le dim. 3 févr. 2019 à 14:36, Max Filippov <jcmvbkbc@gmail.com> a écrit :

> Hi Romain,

>

> On Sun, Feb 3, 2019 at 3:20 AM Romain Naour <romain.naour@gmail.com>

> wrote:

> > I tested the patch using Binutils 2.32, the toolchain build is ok but

> the kernel

> > doesn't boot.

>

> This is because the section .note.gnu.build-id that is inserted at the

> beginning of the kernel. This was fixed by the commit 4119ba211bc4

> (xtensa: add NOTES section to the linker script) in the linux mainline

> which was backported to a number of stable kernels, but not into the

> 4.16.y

> I've changed kernel version to 4.19 in the buildroot, it builds and boots

> successfully.

>


Thanks, I'll add a comment about this while adding Binutils 2.32 into
Buildroot.

Also, all Buildroot's Qemu configs will be updated soon with kernel 4.19.

Best regards,
Romain


> --

> Thanks.

> -- Max

>

Patch

diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 23bb2d291fc8..3bdbbc931cfc 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -6019,6 +6019,12 @@  md_apply_fix (fixS *fixP, valueT *valP, segT seg)
 	  val = *valP;
 	  fixP->fx_done = 1;
 	}
+      else if (S_GET_SEGMENT (fixP->fx_addsy) == absolute_section)
+	{
+	  val = S_GET_VALUE (fixP->fx_addsy) + fixP->fx_offset;
+	  *valP = val;
+	  fixP->fx_done = 1;
+	}
       /* fall through */
 
     case BFD_RELOC_XTENSA_PLT:
diff --git a/gas/testsuite/gas/all/forward.d b/gas/testsuite/gas/all/forward.d
index 9750133e9efe..5a7f370a17e2 100644
--- a/gas/testsuite/gas/all/forward.d
+++ b/gas/testsuite/gas/all/forward.d
@@ -1,7 +1,7 @@ 
 #objdump: -s -j .data
 #name: forward references
 # Some targets don't manage to resolve BFD_RELOC_8 for constants.
-#xfail: *c30-*-* *c4x-*-* d10v-*-* d30v-*-* pdp11-*-* xtensa*-*-*
+#xfail: *c30-*-* *c4x-*-* d10v-*-* d30v-*-* pdp11-*-*
 
 .*: .*