[0/7] kvx: New port.

Message ID 20230721074956.7188-1-piannetta@kalrayinc.com
Headers
Series kvx: New port. |

Message

Paul Iannetta July 21, 2023, 7:49 a.m. UTC
  On behalf of Kalray - a semiconductor company based in the south of France - I
would like to contribute the binutils port for the KVX ISA, with the following
sub-architectures:
  - kv3-v1: 3rd gen (Coolidge),  1st revision (stable);
  - kv3-v2: 3rd gen (Coolidge),  2nd revision (stable);
  - kv4-v1: 4th gen (Dolomites), 1st revision (experimental).

I will be the maintainer of the port.

I've split up the port into as many parts as subdirectories we have changes in,
the current set of patch covers the binutils without gdb (that we plan to upstream
in a second time.)

Kalray has completed the copyright assignment forms from FSF for the binutils.

Please let me know if I am missing anything.

Regards,
Paul Iannetta,
Kalray
  

Comments

Nick Clifton July 21, 2023, 8:29 a.m. UTC | #1
Hi Paul,

> On behalf of Kalray - a semiconductor company based in the south of France - I
> would like to contribute the binutils port for the KVX ISA,

Thanks very much for doing this.

> Please let me know if I am missing anything.

It may just be my mailer, but I am only seeing parts 1,2,4,5,7 of your patch
series.  IE parts 3 and 6 appear to be missing.  My guess would be that these
are for the opcodes and gas sub-directories.  Do I need to investigate on my
end, or did something go wrong when you sent them ?

Cheers
   Nick
  
YunQiang Su July 21, 2023, 8:57 a.m. UTC | #2
Paul Iannetta via Binutils <binutils@sourceware.org> 于2023年7月21日周五 15:51写道:
>
> On behalf of Kalray - a semiconductor company based in the south of France - I

Very interesting. Is it possible for us to read ISA and ABI documents?
A quick search didn't give me the path.

> would like to contribute the binutils port for the KVX ISA, with the following
> sub-architectures:
>   - kv3-v1: 3rd gen (Coolidge),  1st revision (stable);
>   - kv3-v2: 3rd gen (Coolidge),  2nd revision (stable);
>   - kv4-v1: 4th gen (Dolomites), 1st revision (experimental).
>
> I will be the maintainer of the port.
>
> I've split up the port into as many parts as subdirectories we have changes in,
> the current set of patch covers the binutils without gdb (that we plan to upstream
> in a second time.)
>
> Kalray has completed the copyright assignment forms from FSF for the binutils.
>
> Please let me know if I am missing anything.
>
> Regards,
> Paul Iannetta,
> Kalray
>
>
>
>
>
  
Paul Iannetta July 21, 2023, 4:51 p.m. UTC | #3
On Fri, Jul 21, 2023 at 04:57:50PM +0800, YunQiang Su wrote:
> Paul Iannetta via Binutils <binutils@sourceware.org> 于2023年7月21日周五 15:51写道:
> >
> > On behalf of Kalray - a semiconductor company based in the south of France - I
> 
> Very interesting. Is it possible for us to read ISA and ABI documents?
> A quick search didn't give me the path.
> 
Thank you for your interest.  I'll reach back to you as soon as I have the approval.

> > would like to contribute the binutils port for the KVX ISA, with the following
> > sub-architectures:
> >   - kv3-v1: 3rd gen (Coolidge),  1st revision (stable);
> >   - kv3-v2: 3rd gen (Coolidge),  2nd revision (stable);
> >   - kv4-v1: 4th gen (Dolomites), 1st revision (experimental).
> >
> > I will be the maintainer of the port.
> >
> > I've split up the port into as many parts as subdirectories we have changes in,
> > the current set of patch covers the binutils without gdb (that we plan to upstream
> > in a second time.)
> >
> > Kalray has completed the copyright assignment forms from FSF for the binutils.
> >
> > Please let me know if I am missing anything.
> >
> > Regards,
> > Paul Iannetta,
> > Kalray
> >
> >
> >
> >
> >
> 
> 
> -- 
> YunQiang Su
> 
> 
> 
>
  
Paul Iannetta July 21, 2023, 5 p.m. UTC | #4
Hi Nick,

On Fri, Jul 21, 2023 at 04:46:16PM +0100, Nick Clifton wrote:
> Hi Paul,
> 
> > Yes, part 3 (gas) and 6 (opcodes) are respectively 1.5M and 3.5M big,
> > so they are waiting for moderator approval.  Maybe I should have sent
> > them through a different medium?
> 
> Can you supply them in a compressed format attached to an email ?
> 

Thank you, it was indeed very effective :)
> Since the patch is presumably mostly text, a good compression algorithm
> ought to be very effective.
> 
> Cheers
>   Nick
> 
Thanks,
Paul
  
Nick Clifton July 24, 2023, 9:04 a.m. UTC | #5
Hi Paul,

> On behalf of Kalray - a semiconductor company based in the south of France - I
> would like to contribute the binutils port for the KVX ISA,

Fantastic - thank you for contributing this work.a

> Please let me know if I am missing anything.

Are you - or someone else at Kalray - offering to become a maintainer of the KVX port ?

Being a maintainer not only involves fixing bugs, but also monitoring the mailing
lists for bug reports, and, ideally, working to keep the port up to date and bit-rot
free.

Cheers
   Nick
  
Nick Clifton July 24, 2023, 9:28 a.m. UTC | #6
Hi Paul,

   I tried compiling the binutils for a kvx-elf target with your
   patches applied and I ran across a compile time warning/error:

gas/config/kvx-parse.c: In function 'parse_with_restarts':
gas/config/kvx-parse.c:766:3: error: using a dangling pointer to '__buf_tok' [-Werror=dangling-pointer=]
   766 |   printf_debug (1, "\nEntering rule: %d (Trying to match: %s (%s)[%d])\n", jump_target,
       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   767 |                 TOKEN_NAME (CLASS_ID (tok)), TOKEN_STR (tok), CLASS_ID (tok));
       |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gas/config/kvx-parse.c:391:6: note: '__buf_tok' declared here
   391 | char __buf_##token[256] = { 0 }; \
       |      ^~~~~~
gas/config/kvx-parse.c:767:46: note: in expansion of macro 'TOKEN_STR'
   767 |                 TOKEN_NAME (CLASS_ID (tok)), TOKEN_STR (tok), CLASS_ID (tok));
       |                                              ^~~~~~~~~
cc1: all warnings being treated as errors

   This is with gcc v13 on a Fedora 38 box...

   It looks like the TOKEN_STR macro is doing some funky things that are not fully
   supported by gcc 13...


   On a related note, building a toolchain configure as --enable-64-bit-bfd --enable-targets=all
   results in:

/bin/ld: ../bfd/.libs/libbfd.a(targets.o):(.rodata+0xbc8): undefined reference to `kvx_elf64_vec'
/bin/ld: ../bfd/.libs/libbfd.a(targets.o):(.rodata+0x1b98): undefined reference to `kvx_elf64_vec'
/bin/ld: ../bfd/.libs/libbfd.a(targets.o):(.rodata+0x1ba0): undefined reference to `kvx_elf64_linux_vec'
collect2: error: ld returned 1 exit status

   I believe that this is because you are missing an entry for elf64-kvx.lo
   from the BFD64_BACKENDS list defined in bfd/Makefile.am...

Cheers
   Nick
  
Paul Iannetta July 24, 2023, 9:38 a.m. UTC | #7
Hi Nick,

On Mon, Jul 24, 2023 at 10:04:54AM +0100, Nick Clifton wrote:
> Hi Paul,
> 
> > On behalf of Kalray - a semiconductor company based in the south of France - I
> > would like to contribute the binutils port for the KVX ISA,
> 
> Fantastic - thank you for contributing this work.a
> 
Thank you.
> > Please let me know if I am missing anything.
> 
> Are you - or someone else at Kalray - offering to become a maintainer of the KVX port ?
> 
Yes, I will be the maintainer of the port.

> Being a maintainer not only involves fixing bugs, but also monitoring the mailing
> lists for bug reports, and, ideally, working to keep the port up to date and bit-rot
> free.

Yes, that is what I intend to do.  I am already monitoring the mailing
list but did not have much occasions to participate yet.

Thanks,
Paul
> 
> Cheers
>   Nick
>
  
Nick Clifton July 24, 2023, 9:53 a.m. UTC | #8
Hi Paul,

   First a request: please could you add updates to the gas/NEWS and ld/NEWS
   files mentioning the fact that the KVX architecture is now supported.

   Next some code review.  I am going to skip over code formatting and comment
   structure issues for now, and also my favourite bugbear (calls to abort() in
   library code which stops the user of the library from handling error conditions),
   and instead focus on potential bugs and coding problems.  Except that I cannot
   find any!  Visual inspection may not be a perfect tool, but I have looked over
   your code and it all looks good to me.

   I will still need to check that the next set of patches compile and that the
   assembler and linker work, but I have to say that the contribution is looking
   very good so far.

Cheers
   Nick

PS.  It might me nice to have a few more KVX specific test files added to the
   assembler testsuite.  One at least that checks that each of the instructions
   assembles as expected...
  
Paul Iannetta July 24, 2023, 12:27 p.m. UTC | #9
Hi Nick,

The attached archive contains 3 more patches that could be squashed
into the previous patches adding the ld and gas files.

The first one adds new tests in gas checking that all instructions are
correctly assembled, and the other two are updates to gas/NEWS and
ld/NEWS. I'll improve test coverage in later patches.

Concerning the code, the disassembler (opcodes/kvx-dis.c) could be in
a better shape, there is still quite a bit of code duplication but
I'll be working on improving it.

I tried to pay attention to the GNU coding guidelines but I might have
overlooked some parts (especially the linker, and there may be quite a
few aborts there as well.)

Thanks,
Paul
  
Paul Iannetta July 24, 2023, 12:33 p.m. UTC | #10
Hi Nick,

On Mon, Jul 24, 2023 at 10:28:07AM +0100, Nick Clifton wrote:
> Hi Paul,
> 
>   I tried compiling the binutils for a kvx-elf target with your
>   patches applied and I ran across a compile time warning/error:
> 
> gas/config/kvx-parse.c: In function 'parse_with_restarts':
> gas/config/kvx-parse.c:766:3: error: using a dangling pointer to '__buf_tok' [-Werror=dangling-pointer=]
>   766 |   printf_debug (1, "\nEntering rule: %d (Trying to match: %s (%s)[%d])\n", jump_target,
>       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   767 |                 TOKEN_NAME (CLASS_ID (tok)), TOKEN_STR (tok), CLASS_ID (tok));
>       |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> gas/config/kvx-parse.c:391:6: note: '__buf_tok' declared here
>   391 | char __buf_##token[256] = { 0 }; \
>       |      ^~~~~~
> gas/config/kvx-parse.c:767:46: note: in expansion of macro 'TOKEN_STR'
>   767 |                 TOKEN_NAME (CLASS_ID (tok)), TOKEN_STR (tok), CLASS_ID (tok));
>       |                                              ^~~~~~~~~
> cc1: all warnings being treated as errors
> 
>   This is with gcc v13 on a Fedora 38 box...

Yes, indeed, it was more of a convenience macro but it is not well
supported by gcc13+, that's the only location it is used so you can
safely comment out those lines and I will remove them as well.

> 
>   It looks like the TOKEN_STR macro is doing some funky things that are not fully
>   supported by gcc 13...
> 
> 
>   On a related note, building a toolchain configure as --enable-64-bit-bfd --enable-targets=all
>   results in:
> 
> /bin/ld: ../bfd/.libs/libbfd.a(targets.o):(.rodata+0xbc8): undefined reference to `kvx_elf64_vec'
> /bin/ld: ../bfd/.libs/libbfd.a(targets.o):(.rodata+0x1b98): undefined reference to `kvx_elf64_vec'
> /bin/ld: ../bfd/.libs/libbfd.a(targets.o):(.rodata+0x1ba0): undefined reference to `kvx_elf64_linux_vec'
> collect2: error: ld returned 1 exit status
> 
>   I believe that this is because you are missing an entry for elf64-kvx.lo
>   from the BFD64_BACKENDS list defined in bfd/Makefile.am...

Thanks, I'll have a look.

> 
> Cheers
>   Nick
> 

Thanks,
Paul
  
Paul Iannetta July 24, 2023, 2:30 p.m. UTC | #11
Hi Nick,

> On Mon, Jul 24, 2023 at 10:28:07AM +0100, Nick Clifton wrote:
> >  [snip]
> >   On a related note, building a toolchain configure as --enable-64-bit-bfd --enable-targets=all
> >   results in:
> > 
> > /bin/ld: ../bfd/.libs/libbfd.a(targets.o):(.rodata+0xbc8): undefined reference to `kvx_elf64_vec'
> > /bin/ld: ../bfd/.libs/libbfd.a(targets.o):(.rodata+0x1b98): undefined reference to `kvx_elf64_vec'
> > /bin/ld: ../bfd/.libs/libbfd.a(targets.o):(.rodata+0x1ba0): undefined reference to `kvx_elf64_linux_vec'
> > collect2: error: ld returned 1 exit status
> > 
> >   I believe that this is because you are missing an entry for elf64-kvx.lo
> >   from the BFD64_BACKENDS list defined in bfd/Makefile.am...
> 
> Thanks, I'll have a look.

I have removed references to `kvx_elf64_linux_vec', and followed your
advice, it should now compile if you apply the attached patch and
remove the line using the TOKEN_STR macro.

Thanks,
Paul
commit f63739aeac93ae27d89b0d5987a6618195f18daf
Author: Paul Iannetta <piannetta@kalrayinc.com>
Date:   Mon Jul 24 16:01:58 2023 +0200

    kvx: bfd: Remove references to kvx_elf64_linux_vec
    
    bfd/ChangeLog:
    
    2023-07-24  Paul Iannetta  <piannetta@kalrayinc.com>
    
            * Makefile.am (BFD64_BACKENDS): Add elf64-kvx.lo.
            * Makefile.in: Regenerate.
            * targets.c: Remove references to kvx_elf64_linux_vec.

diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index 5fc2b822974..464d6dd692f 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -562,6 +562,7 @@ BFD64_BACKENDS = \
 	elf64-ia64-vms.lo \
 	elfxx-ia64.lo \
 	elfxx-kvx.lo \
+	elf64-kvx.lo \
 	elf32-loongarch.lo \
 	elf64-loongarch.lo \
 	elfxx-loongarch.lo \
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index c80fba86a0b..76c7e184dcd 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -1020,6 +1020,7 @@ BFD64_BACKENDS = \
 	elf64-ia64-vms.lo \
 	elfxx-ia64.lo \
 	elfxx-kvx.lo \
+	elf64-kvx.lo \
 	elf32-loongarch.lo \
 	elf64-loongarch.lo \
 	elfxx-loongarch.lo \
diff --git a/bfd/targets.c b/bfd/targets.c
index b966685c2f0..210beddaf11 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -771,7 +771,6 @@ extern const bfd_target ip2k_elf32_vec;
 extern const bfd_target iq2000_elf32_vec;
 extern const bfd_target kvx_elf32_vec;
 extern const bfd_target kvx_elf64_vec;
-extern const bfd_target kvx_elf64_linux_vec;
 extern const bfd_target lm32_elf32_vec;
 extern const bfd_target lm32_elf32_fdpic_vec;
 extern const bfd_target loongarch_elf64_vec;
@@ -1135,7 +1134,6 @@ static const bfd_target * const _bfd_target_vector[] =
 
 #ifdef BFD64
 	&kvx_elf64_vec,
-	&kvx_elf64_linux_vec,
 #endif
 
 	&lm32_elf32_vec,
  
Nick Clifton July 25, 2023, 2:13 p.m. UTC | #12
Hi Paul,

>>    I tried compiling the binutils for a kvx-elf target with your
>>    patches applied and I ran across a compile time warning/error:
> 
> Yes, indeed, it was more of a convenience macro but it is not well
> supported by gcc13+, that's the only location it is used so you can
> safely comment out those lines and I will remove them as well.

Ok, so with that down, the port compiles.  But then there are some unexpected
failures in the gas testsuite:

   FAIL: .set with IFUNC
   FAIL: elf type list
   FAIL: elf type-2 list

Which are all due to the fact that the kvx port does not support indirect
functions:

   gas/testsuite/gas/elf/ifunc-1.s: Assembler messages:
   gas/testsuite/gas/elf/ifunc-1.s:9: Error: unrecognized symbol type "gnu_indirect_function"

I suggest updating the list of targets-that-do-not-support-ifuncs starting
at line 237 of gas/testsuite/gas/elf/elf.exp to fix this.

There are similar problems with the binutils testsuite:

   FAIL: nm --ifunc-chars (assembly)
   FAIL: weaken STB_GNU_UNIQUE symbols
   FAIL: strip on STB_GNU_UNIQUE

Tweaks to proc supports_gnu_osabi in binutils/testsuite/lib/binutils-common.exp
and binutils/testsuite/binutils-all/nm.exp should fix these.

Finally there are quite a few failures in the linker testsuite:

   FAIL: --export-dynamic-symbol foo archive
   FAIL: -u --export-dynamic-symbol foo archive
   FAIL: -u --export-dynamic-symbol "f*" archive
   FAIL: --export-dynamic-symbol-list foo archive
   FAIL: -u --export-dynamic-symbol-list foo bar archive
   FAIL: -u --export-dynamic-symbol-list fstar archive
   FAIL: pr26580-2
   FAIL: Build pr22471
   FAIL: DT_TEXTREL map file warning
   FAIL: Build pr22150
   FAIL: Build pr25458
   FAIL: pr20995
   FAIL: --gc-sections with __gxx_personality
   FAIL: ld-scripts/fill

Six of these can be fixed by updating proc check_pie_support in binutils/testsuite/
lib/binutils-common.exp.  Interestingly patch 2/7 added a test to this proc, but
limited it to the kvx-*-cos target.  Which is odd since it appears to be a problem
for all kvx targets.

Most of the remaining failures appear to be due to this error:

  error: PHDR segment not covered by LOAD segment

Which I am guessing is due to some kind of issue with the built in linker script
for the KVX target.  Although I am not sure exactly what the issue might be.


All of which is to say - please could you submit a v2 patch series with these
issues resolved and your other updates integrated, and then I will have another
go at reviewing them.  Thanks.

Cheers
   Nick
  
Paul Iannetta July 26, 2023, 7:36 a.m. UTC | #13
Hi Nick,

Thank you for the review.
On Tue, Jul 25, 2023 at 03:13:29PM +0100, Nick Clifton wrote:
> Hi Paul,
> 
> > >    I tried compiling the binutils for a kvx-elf target with your
> > >    patches applied and I ran across a compile time warning/error:
> > 
> > Yes, indeed, it was more of a convenience macro but it is not well
> > supported by gcc13+, that's the only location it is used so you can
> > safely comment out those lines and I will remove them as well.
> 
> Ok, so with that down, the port compiles.  But then there are some unexpected
> failures in the gas testsuite:
> 
>   FAIL: .set with IFUNC
>   FAIL: elf type list
>   FAIL: elf type-2 list
> 
> Which are all due to the fact that the kvx port does not support indirect
> functions:
> 
>   gas/testsuite/gas/elf/ifunc-1.s: Assembler messages:
>   gas/testsuite/gas/elf/ifunc-1.s:9: Error: unrecognized symbol type "gnu_indirect_function"
> 
> I suggest updating the list of targets-that-do-not-support-ifuncs starting
> at line 237 of gas/testsuite/gas/elf/elf.exp to fix this.
> 
> There are similar problems with the binutils testsuite:
> 
>   FAIL: nm --ifunc-chars (assembly)
>   FAIL: weaken STB_GNU_UNIQUE symbols
>   FAIL: strip on STB_GNU_UNIQUE
> 
> Tweaks to proc supports_gnu_osabi in binutils/testsuite/lib/binutils-common.exp
> and binutils/testsuite/binutils-all/nm.exp should fix these.
> 
Indeed, we do not support indirect functions for now, I'll fix that.

> Finally there are quite a few failures in the linker testsuite:
> 
>   FAIL: --export-dynamic-symbol foo archive
>   FAIL: -u --export-dynamic-symbol foo archive
>   FAIL: -u --export-dynamic-symbol "f*" archive
>   FAIL: --export-dynamic-symbol-list foo archive
>   FAIL: -u --export-dynamic-symbol-list foo bar archive
>   FAIL: -u --export-dynamic-symbol-list fstar archive
>   FAIL: pr26580-2
>   FAIL: Build pr22471
>   FAIL: DT_TEXTREL map file warning
>   FAIL: Build pr22150
>   FAIL: Build pr25458
>   FAIL: pr20995
>   FAIL: --gc-sections with __gxx_personality
>   FAIL: ld-scripts/fill
> 
> Six of these can be fixed by updating proc check_pie_support in binutils/testsuite/
> lib/binutils-common.exp.  Interestingly patch 2/7 added a test to this proc, but
> limited it to the kvx-*-cos target.  Which is odd since it appears to be a problem
> for all kvx targets.
Thanks.
> 
> Most of the remaining failures appear to be due to this error:
> 
>  error: PHDR segment not covered by LOAD segment
> 
> Which I am guessing is due to some kind of issue with the built in linker script
> for the KVX target.  Although I am not sure exactly what the issue might be.
> 
This one is due to the fact that we do not generate a PHDR at all
since we only support a very primitive form of dynamic loading (only
through calls to dlopen/dlsym), we do not need a PHDR.  I'll could add
one if needed.

We have also been using the `--enable-warn-rwx-segments=no' switch.
But I don't think it will be a problem for the testsuite.

> 
> All of which is to say - please could you submit a v2 patch series with these
> issues resolved and your other updates integrated, and then I will have another
> go at reviewing them.  Thanks.
> 
I'll reach back to you as soon as I've fixed everything above.
> Cheers
>   Nick
> 

Thanks,
Paul
  
Michael Matz July 26, 2023, 1:32 p.m. UTC | #14
Hello,

On Wed, 26 Jul 2023, Paul Iannetta via Binutils wrote:

> > Most of the remaining failures appear to be due to this error:
> > 
> >  error: PHDR segment not covered by LOAD segment
> > 
> > Which I am guessing is due to some kind of issue with the built in linker script
> > for the KVX target.  Although I am not sure exactly what the issue might be.
> > 
> This one is due to the fact that we do not generate a PHDR at all
> since we only support a very primitive form of dynamic loading (only
> through calls to dlopen/dlsym), we do not need a PHDR.

You are using the ELF file format right?  In the gABI a program header 
table is actually non-optional for executables and shared libs.  
Obviously a psABI can do mostly whatever it likes, but not having PHDRs is 
_very_ unusual.  They aren't specific to dynamic linking: after all, even 
static executables need to be loaded somewhere, by kernel or boot loader 
or ROM or $othermagic, and the program headers describe what and where to 
load.  So, you really might want to reconsider.  At least one PT_LOAD 
segment covering the whole file would be good.


Ciao,
Michael.
  
Paul Iannetta July 26, 2023, 9:24 p.m. UTC | #15
Hi Nick,

I've taken into account the points you raised in your review,
everything should now compile fine when doing
 ../configure --enable-64-bit-bfd --enable-targets=all
and there should be no more unexpected failures both with
  ../configure --enable-32-bit-bfd --target=kvx-elf
and
 ../configure --enable-64-bit-bfd --target=kvx-elf

I've been using gcc (GCC) 13.1.1 20230724 (97d183a8ddb).

Please let me know if I am missing something.
Thanks,
Paul
  
Paul Iannetta July 26, 2023, 9:46 p.m. UTC | #16
Hi Michael,
On Wed, Jul 26, 2023 at 01:32:56PM +0000, Michael Matz wrote:
> Hello,
> 
> On Wed, 26 Jul 2023, Paul Iannetta via Binutils wrote:
> 
> > > Most of the remaining failures appear to be due to this error:
> > > 
> > >  error: PHDR segment not covered by LOAD segment
> > > 
> > > Which I am guessing is due to some kind of issue with the built in linker script
> > > for the KVX target.  Although I am not sure exactly what the issue might be.
> > > 
> > This one is due to the fact that we do not generate a PHDR at all
> > since we only support a very primitive form of dynamic loading (only
> > through calls to dlopen/dlsym), we do not need a PHDR.
> 
> You are using the ELF file format right?  In the gABI a program header 
> table is actually non-optional for executables and shared libs.  
> Obviously a psABI can do mostly whatever it likes, but not having PHDRs is 
> _very_ unusual.  They aren't specific to dynamic linking: after all, even 
> static executables need to be loaded somewhere, by kernel or boot loader 
> or ROM or $othermagic, and the program headers describe what and where to 
> load.  So, you really might want to reconsider.  At least one PT_LOAD 
> segment covering the whole file would be good.

I was not very clear sorry.  We have actually have 2 main usages of ELF
files:
  - one for bare-metal programs -- a program is linked with a bare-metal
OS into a final standalone free standing executable ELF file which
contains an OS, a libc and the userland program.  Those bare-metal
programs can use a dlopen/dlsym-like API to load ELF blobs which have
been deposed in the DDR by some other means. In that case, we don't
need a PHDR, even for the ELF blobs which are dynamically loaded, the
information in the ELF header are enough since we do not support PIE
in this mode and the information in the PHDR is mostly useful for the
dynamic loader.

 - one for linux programs.  In that case, all exec/shared libs have a
   PHDR, and iirc we follow the gABI.

When I was writing the previous mail, I had the first case in my head,
which is indeed a pretty unusual scenario.

Regards,
Paul
  
Nick Clifton July 31, 2023, 2:52 p.m. UTC | #17
Hi Paul,

> I've taken into account the points you raised in your review,

Thank you very much.

Just a couple more small issues:

   * The kvx-linux target does not appear to be supported by the
     assembler.  In particular when running the gas testsuite I
     found messages like this:

failed with: <Assembler messages:
Fatal error: selected target format 'elf32-kvx' unknown>, no expected output
FAIL: gas/kvx/kv3-1-insns-32

     The linker and binutils testsuites also have failures with
     similar messages.

     I am assuming that "kvx-linux" is a valid configuration target.
     If not, then it ought to be rejected by bfd/config.bfd.


   * The copyright dates on some of the new files are wrong/old.
      For example ld/emultempl/kvxelf.em has:

       # Copyright (C) 2009-2016 Free Software Foundation, Inc.

      This ought to be "...2009-2023...".  I have not checked all the
      other files in the patch, but if there any others will out of date
      copyright notices then I hope that you will fix them.

Cheers
   Nick
  
Paul Iannetta Aug. 2, 2023, 2:38 p.m. UTC | #18
Hi Nick,

Attached is the patch series revised.

On Mon, Jul 31, 2023 at 03:52:31PM +0100, Nick Clifton wrote:
> Hi Paul,
> 
> > I've taken into account the points you raised in your review,
> 
> Thank you very much.
> 
> Just a couple more small issues:
> 
>   * The kvx-linux target does not appear to be supported by the
>     assembler.  In particular when running the gas testsuite I
>     found messages like this:
> 
> failed with: <Assembler messages:
> Fatal error: selected target format 'elf32-kvx' unknown>, no expected output
> FAIL: gas/kvx/kv3-1-insns-32
> 
>     The linker and binutils testsuites also have failures with
>     similar messages.
> 
>     I am assuming that "kvx-linux" is a valid configuration target.
>     If not, then it ought to be rejected by bfd/config.bfd.
> 

Thanks!  Indeed, this is a valid configuration target but only for
64-bit elf and we were trying to run 32 bits tests on them.  This
point should be fixed now as well as the other failures on kvx-linux.

> 
>   * The copyright dates on some of the new files are wrong/old.
>      For example ld/emultempl/kvxelf.em has:
> 
>       # Copyright (C) 2009-2016 Free Software Foundation, Inc.
> 
>      This ought to be "...2009-2023...".  I have not checked all the
>      other files in the patch, but if there any others will out of date
>      copyright notices then I hope that you will fix them.

This point is now addressed as well.

> 
> Cheers
>   Nick
> 
Thanks,
Paul
  
Nick Clifton Aug. 16, 2023, 1:24 p.m. UTC | #19
Hi Paul,

> Attached is the patch series revised.

Sorry for the delay in responding - I was away on PTO.

Anyway, the patch series is now in very good shape, so I have
gone ahead and applied it.

Thanks very much for contributing to the binutils.

Cheers
   Nick
  
Luis Machado Aug. 17, 2023, 9:45 a.m. UTC | #20
On 8/16/23 14:24, Nick Clifton via Binutils wrote:
> Hi Paul,
> 
>> Attached is the patch series revised.
> 
> Sorry for the delay in responding - I was away on PTO.
> 
> Anyway, the patch series is now in very good shape, so I have
> gone ahead and applied it.
> 
> Thanks very much for contributing to the binutils.
> 
> Cheers
>   Nick
> 
> 

The builders have caught a few hiccups related to printf modifiers for 32-bit architectures.

Could you please take a look at those? A build with --enable-targets=all is recommended
to catch those.

See https://builder.sourceware.org/buildbot/#/builders/170/builds/3977.

--

In file included from ../../binutils-gdb/bfd/elfnn-kvx.c:22:
../../binutils-gdb/bfd/elfxx-kvx-relocs.h:74:3: error: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Werror=overflow]
   74 |   0xffffffffffffffff,   /* dst_mask */
      |   ^~~~~~~~~~~~~~~~~~
bfd.h:3204:15: note: in definition of macro ‘HOWTO’
 3204 |     src_mask, dst_mask, func, name }
      |               ^~~~~~~~
../../binutils-gdb/bfd/elfxx-kvx-relocs.h:243:3: error: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Werror=overflow]
  243 |   0xffffffffffffffff,   /* dst_mask */
      |   ^~~~~~~~~~~~~~~~~~
bfd.h:3204:15: note: in definition of macro ‘HOWTO’
 3204 |     src_mask, dst_mask, func, name }
      |               ^~~~~~~~
../../binutils-gdb/bfd/elfxx-kvx-relocs.h:399:3: error: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Werror=overflow]
  399 |   0xffffffffffffffff,   /* dst_mask */
      |   ^~~~~~~~~~~~~~~~~~
bfd.h:3204:15: note: in definition of macro ‘HOWTO’
 3204 |     src_mask, dst_mask, func, name }
      |               ^~~~~~~~
../../binutils-gdb/bfd/elfxx-kvx-relocs.h:490:3: error: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Werror=overflow]
  490 |   0xffffffffffffffff,   /* dst_mask */
      |   ^~~~~~~~~~~~~~~~~~
bfd.h:3204:15: note: in definition of macro ‘HOWTO’
 3204 |     src_mask, dst_mask, func, name }
      |               ^~~~~~~~
../../binutils-gdb/bfd/elfxx-kvx-relocs.h:737:3: error: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Werror=overflow]
  737 |   0xffffffffffffffff,   /* dst_mask */
      |   ^~~~~~~~~~~~~~~~~~
bfd.h:3204:15: note: in definition of macro ‘HOWTO’
 3204 |     src_mask, dst_mask, func, name }
      |               ^~~~~~~~
../../binutils-gdb/bfd/elfxx-kvx-relocs.h:750:3: error: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Werror=overflow]
  750 |   0xffffffffffffffff,   /* dst_mask */
      |   ^~~~~~~~~~~~~~~~~~
bfd.h:3204:15: note: in definition of macro ‘HOWTO’
 3204 |     src_mask, dst_mask, func, name }
      |               ^~~~~~~~
../../binutils-gdb/bfd/elfxx-kvx-relocs.h:958:3: error: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Werror=overflow]
  958 |   0xffffffffffffffff,   /* dst_mask */
      |   ^~~~~~~~~~~~~~~~~~
bfd.h:3204:15: note: in definition of macro ‘HOWTO’
 3204 |     src_mask, dst_mask, func, name }
      |               ^~~~~~~~
../../binutils-gdb/bfd/elfnn-kvx.c: In function ‘elf32_kvx_stub_name’:
../../binutils-gdb/bfd/elfnn-kvx.c:740:28: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 6 has type ‘bfd_vma’ {aka ‘const unsigned int’} [-Werror=format=]
  740 |  snprintf (stub_name, len, "%08x_%s+%" PRIx64 "x",
      |                            ^~~~~~~~~~~
......
  743 |     rel->r_addend);
      |     ~~~~~~~~~~~~~
      |        |
      |        bfd_vma {aka const unsigned int}
../../binutils-gdb/bfd/elfnn-kvx.c:750:28: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘bfd_vma’ {aka ‘const unsigned int’} [-Werror=format=]
  750 |  snprintf (stub_name, len, "%08x_%x:%x+%" PRIx64 "x",
      |                            ^~~~~~~~~~~~~~
......
  754 |     rel->r_addend);
      |     ~~~~~~~~~~~~~
      |        |
      |        bfd_vma {aka const unsigned int}
cc1: all warnings being treated as errors
make[3]: *** [Makefile:1758: elf32-kvx.lo] Error 1

--
  
Paul Iannetta Aug. 17, 2023, 12:46 p.m. UTC | #21
Hi Nick,

On Wed, Aug 16, 2023 at 02:24:16PM +0100, Nick Clifton wrote:
> Hi Paul,
> 
> > Attached is the patch series revised.
> 
> Sorry for the delay in responding - I was away on PTO.
> 
> Anyway, the patch series is now in very good shape, so I have
> gone ahead and applied it.
> 
> Thanks very much for contributing to the binutils.

Thanks,
Paul
  
Paul Iannetta Aug. 17, 2023, 3:09 p.m. UTC | #22
On Thu, Aug 17, 2023 at 10:45:09AM +0100, Luis Machado wrote:
> 
> The builders have caught a few hiccups related to printf modifiers for 32-bit architectures.
> 
> Could you please take a look at those? A build with --enable-targets=all is recommended
> to catch those.
> 
> See https://builder.sourceware.org/buildbot/#/builders/170/builds/3977.
> 
> --
> 
> In file included from ../../binutils-gdb/bfd/elfnn-kvx.c:22:
> ../../binutils-gdb/bfd/elfxx-kvx-relocs.h:74:3: error: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Werror=overflow]
>    74 |   0xffffffffffffffff,   /* dst_mask */
>       |   ^~~~~~~~~~~~~~~~~~
> bfd.h:3204:15: note: in definition of macro ‘HOWTO’
>  3204 |     src_mask, dst_mask, func, name }
>       |               ^~~~~~~~
> ../../binutils-gdb/bfd/elfnn-kvx.c: In function ‘elf32_kvx_stub_name’:
> ../../binutils-gdb/bfd/elfnn-kvx.c:740:28: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 6 has type ‘bfd_vma’ {aka ‘const unsigned int’} [-Werror=format=]
>   740 |  snprintf (stub_name, len, "%08x_%s+%" PRIx64 "x",
>       |                            ^~~~~~~~~~~
> ......
>   743 |     rel->r_addend);
>       |     ~~~~~~~~~~~~~
>       |        |
>       |        bfd_vma {aka const unsigned int}
> cc1: all warnings being treated as errors
> make[3]: *** [Makefile:1758: elf32-kvx.lo] Error 1
> 

Hi,

I was not able to fully reproduce but the attached patch should fix
the build errors.  However, we did not do any validation on 32 bits
hosts, so I think that even with this patch it will not be enough to
pass `mack check'.  I'll work on it so that everything pass by the end
of the week, so you may want to wait until I have also fixed the
validation before applying the patch.

Paul
commit fdbadf81bf5bdeda0a634ab362de75613011c1c4
Author: Paul Iannetta <piannetta@kalrayinc.com>
Date:   Thu Aug 17 16:08:29 2023 +0200

    kvx: fix warnings when compiling on 32-bits host
    
    bfd/ChangeLog:
    
    2023-08-17  Paul Iannetta  <piannetta@kalrayinc.com>
    
            * elfnn-kvx.c (elfNN_kvx_stub_name): Cast to uint64_t.
            (elfNN_kvx_relocate_section): Likewise.
            * elfxx-kvx-relocs.h: Add explicit casts.

diff --git a/bfd/elfnn-kvx.c b/bfd/elfnn-kvx.c
index 40f9087f3c4..a0a528ef9d2 100644
--- a/bfd/elfnn-kvx.c
+++ b/bfd/elfnn-kvx.c
@@ -740,7 +740,7 @@ elfNN_kvx_stub_name (const asection *input_section,
 	snprintf (stub_name, len, "%08x_%s+%" PRIx64 "x",
 		  (unsigned int) input_section->id,
 		  hash->root.root.root.string,
-		  rel->r_addend);
+		  (uint64_t) rel->r_addend);
     }
   else
     {
@@ -751,7 +751,7 @@ elfNN_kvx_stub_name (const asection *input_section,
 		  (unsigned int) input_section->id,
 		  (unsigned int) sym_sec->id,
 		  (unsigned int) ELFNN_R_SYM (rel->r_info),
-		  rel->r_addend);
+		  (uint64_t) rel->r_addend);
     }
 
   return stub_name;
@@ -2592,7 +2592,7 @@ elfNN_kvx_relocate_section (bfd *output_bfd,
               /* xgettext:c-format */
               : _("%pB(%pA+%#" PRIx64 "): %s used with non-TLS symbol %s")),
 	     input_bfd,
-	     input_section, (long) rel->r_offset, howto->name, name);
+	     input_section, (uint64_t) rel->r_offset, howto->name, name);
 	}
 
       /* Original aarch64 has relaxation handling for TLS here. */
diff --git a/bfd/elfxx-kvx-relocs.h b/bfd/elfxx-kvx-relocs.h
index 7cfd0ff952c..176cf54c63d 100644
--- a/bfd/elfxx-kvx-relocs.h
+++ b/bfd/elfxx-kvx-relocs.h
@@ -31,8 +31,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_NONE",			/* name */
 	 false,				/* partial_inplace */
-	 0,				/* src_mask */
-	 0,				/* dst_mask */
+	 (bfd_vma) 0,			/* src_mask */
+	 (bfd_vma) 0,			/* dst_mask */
 	 false),			/* pcrel_offset */
   HOWTO (R_KVX_16,			/* type */
 	 0,				/* rightshift */
@@ -44,8 +44,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_16",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_32,			/* type */
 	 0,				/* rightshift */
@@ -57,8 +57,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_32",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_64,			/* type */
 	 0,				/* rightshift */
@@ -70,8 +70,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_64",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffffffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffffffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S16_PCREL,			/* type */
 	 0,				/* rightshift */
@@ -83,8 +83,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S16_PCREL",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_PCREL17,			/* type */
 	 2,				/* rightshift */
@@ -96,8 +96,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_PCREL17",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7fffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7fffc0,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_PCREL27,			/* type */
 	 2,				/* rightshift */
@@ -109,8 +109,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_PCREL27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_32_PCREL,			/* type */
 	 0,				/* rightshift */
@@ -122,8 +122,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_32_PCREL",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S37_PCREL_LO10,			/* type */
 	 0,				/* rightshift */
@@ -135,8 +135,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_PCREL_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S37_PCREL_UP27,			/* type */
 	 10,				/* rightshift */
@@ -148,8 +148,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_PCREL_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S43_PCREL_LO10,			/* type */
 	 0,				/* rightshift */
@@ -161,8 +161,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_PCREL_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S43_PCREL_UP27,			/* type */
 	 10,				/* rightshift */
@@ -174,8 +174,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_PCREL_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S43_PCREL_EX6,			/* type */
 	 37,				/* rightshift */
@@ -187,8 +187,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_PCREL_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S64_PCREL_LO10,			/* type */
 	 0,				/* rightshift */
@@ -200,8 +200,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S64_PCREL_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S64_PCREL_UP27,			/* type */
 	 10,				/* rightshift */
@@ -213,8 +213,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S64_PCREL_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S64_PCREL_EX27,			/* type */
 	 37,				/* rightshift */
@@ -226,8 +226,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S64_PCREL_EX27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_64_PCREL,			/* type */
 	 0,				/* rightshift */
@@ -239,8 +239,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_64_PCREL",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffffffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffffffffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S16,			/* type */
 	 0,				/* rightshift */
@@ -252,8 +252,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S16",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S32_LO5,			/* type */
 	 0,				/* rightshift */
@@ -265,8 +265,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S32_LO5",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7c0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7c0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S32_UP27,			/* type */
 	 5,				/* rightshift */
@@ -278,8 +278,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S32_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_LO10,			/* type */
 	 0,				/* rightshift */
@@ -291,8 +291,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_UP27,			/* type */
 	 10,				/* rightshift */
@@ -304,8 +304,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_GOTOFF_LO10,			/* type */
 	 0,				/* rightshift */
@@ -317,8 +317,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_GOTOFF_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_GOTOFF_UP27,			/* type */
 	 10,				/* rightshift */
@@ -330,8 +330,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_GOTOFF_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_GOTOFF_LO10,			/* type */
 	 0,				/* rightshift */
@@ -343,8 +343,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_GOTOFF_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_GOTOFF_UP27,			/* type */
 	 10,				/* rightshift */
@@ -356,8 +356,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_GOTOFF_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_GOTOFF_EX6,			/* type */
 	 37,				/* rightshift */
@@ -369,8 +369,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_GOTOFF_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_32_GOTOFF,			/* type */
 	 0,				/* rightshift */
@@ -382,8 +382,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_32_GOTOFF",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_64_GOTOFF,			/* type */
 	 0,				/* rightshift */
@@ -395,8 +395,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_64_GOTOFF",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffffffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffffffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_32_GOT,			/* type */
 	 0,				/* rightshift */
@@ -408,8 +408,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_32_GOT",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_GOT_LO10,			/* type */
 	 0,				/* rightshift */
@@ -421,8 +421,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_GOT_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_GOT_UP27,			/* type */
 	 10,				/* rightshift */
@@ -434,8 +434,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_GOT_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_GOT_LO10,			/* type */
 	 0,				/* rightshift */
@@ -447,8 +447,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_GOT_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_GOT_UP27,			/* type */
 	 10,				/* rightshift */
@@ -460,8 +460,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_GOT_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_GOT_EX6,			/* type */
 	 37,				/* rightshift */
@@ -473,8 +473,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_GOT_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_64_GOT,			/* type */
 	 0,				/* rightshift */
@@ -486,8 +486,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_64_GOT",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffffffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffffffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_GLOB_DAT,			/* type */
 	 0,				/* rightshift */
@@ -499,8 +499,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_GLOB_DAT",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_COPY,			/* type */
 	 0,				/* rightshift */
@@ -512,8 +512,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_COPY",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_JMP_SLOT,			/* type */
 	 0,				/* rightshift */
@@ -525,8 +525,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_JMP_SLOT",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_RELATIVE,			/* type */
 	 0,				/* rightshift */
@@ -538,8 +538,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_RELATIVE",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_LO10,			/* type */
 	 0,				/* rightshift */
@@ -551,8 +551,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_UP27,			/* type */
 	 10,				/* rightshift */
@@ -564,8 +564,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_EX6,			/* type */
 	 37,				/* rightshift */
@@ -577,8 +577,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S64_LO10,			/* type */
 	 0,				/* rightshift */
@@ -590,8 +590,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S64_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S64_UP27,			/* type */
 	 10,				/* rightshift */
@@ -603,8 +603,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S64_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S64_EX27,			/* type */
 	 37,				/* rightshift */
@@ -616,8 +616,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S64_EX27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_GOTADDR_LO10,			/* type */
 	 0,				/* rightshift */
@@ -629,8 +629,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_GOTADDR_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S37_GOTADDR_UP27,			/* type */
 	 10,				/* rightshift */
@@ -642,8 +642,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_GOTADDR_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S43_GOTADDR_LO10,			/* type */
 	 0,				/* rightshift */
@@ -655,8 +655,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_GOTADDR_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S43_GOTADDR_UP27,			/* type */
 	 10,				/* rightshift */
@@ -668,8 +668,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_GOTADDR_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S43_GOTADDR_EX6,			/* type */
 	 37,				/* rightshift */
@@ -681,8 +681,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_GOTADDR_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S64_GOTADDR_LO10,			/* type */
 	 0,				/* rightshift */
@@ -694,8 +694,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S64_GOTADDR_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S64_GOTADDR_UP27,			/* type */
 	 10,				/* rightshift */
@@ -707,8 +707,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S64_GOTADDR_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_S64_GOTADDR_EX27,			/* type */
 	 37,				/* rightshift */
@@ -720,8 +720,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S64_GOTADDR_EX27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 true),			/* pc_offset */
   HOWTO (R_KVX_64_DTPMOD,			/* type */
 	 0,				/* rightshift */
@@ -733,8 +733,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_64_DTPMOD",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffffffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffffffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_64_DTPOFF,			/* type */
 	 0,				/* rightshift */
@@ -746,8 +746,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_64_DTPOFF",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffffffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffffffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_DTPOFF_LO10,			/* type */
 	 0,				/* rightshift */
@@ -759,8 +759,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_DTPOFF_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_DTPOFF_UP27,			/* type */
 	 10,				/* rightshift */
@@ -772,8 +772,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_DTPOFF_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_DTPOFF_LO10,			/* type */
 	 0,				/* rightshift */
@@ -785,8 +785,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_DTPOFF_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_DTPOFF_UP27,			/* type */
 	 10,				/* rightshift */
@@ -798,8 +798,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_DTPOFF_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_DTPOFF_EX6,			/* type */
 	 37,				/* rightshift */
@@ -811,8 +811,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_DTPOFF_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_GD_LO10,			/* type */
 	 0,				/* rightshift */
@@ -824,8 +824,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_GD_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_GD_UP27,			/* type */
 	 10,				/* rightshift */
@@ -837,8 +837,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_GD_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_GD_LO10,			/* type */
 	 0,				/* rightshift */
@@ -850,8 +850,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_GD_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_GD_UP27,			/* type */
 	 10,				/* rightshift */
@@ -863,8 +863,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_GD_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_GD_EX6,			/* type */
 	 37,				/* rightshift */
@@ -876,8 +876,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_GD_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_LD_LO10,			/* type */
 	 0,				/* rightshift */
@@ -889,8 +889,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_LD_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_LD_UP27,			/* type */
 	 10,				/* rightshift */
@@ -902,8 +902,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_LD_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_LD_LO10,			/* type */
 	 0,				/* rightshift */
@@ -915,8 +915,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_LD_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_LD_UP27,			/* type */
 	 10,				/* rightshift */
@@ -928,8 +928,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_LD_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_LD_EX6,			/* type */
 	 37,				/* rightshift */
@@ -941,8 +941,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_LD_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_64_TPOFF,			/* type */
 	 0,				/* rightshift */
@@ -954,8 +954,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_64_TPOFF",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffffffffffffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffffffffffffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_IE_LO10,			/* type */
 	 0,				/* rightshift */
@@ -967,8 +967,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_IE_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_IE_UP27,			/* type */
 	 10,				/* rightshift */
@@ -980,8 +980,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_IE_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_IE_LO10,			/* type */
 	 0,				/* rightshift */
@@ -993,8 +993,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_IE_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_IE_UP27,			/* type */
 	 10,				/* rightshift */
@@ -1006,8 +1006,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_IE_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_IE_EX6,			/* type */
 	 37,				/* rightshift */
@@ -1019,8 +1019,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_IE_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_LE_LO10,			/* type */
 	 0,				/* rightshift */
@@ -1032,8 +1032,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_LE_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S37_TLS_LE_UP27,			/* type */
 	 10,				/* rightshift */
@@ -1045,8 +1045,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S37_TLS_LE_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_LE_LO10,			/* type */
 	 0,				/* rightshift */
@@ -1058,8 +1058,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_LE_LO10",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xffc0,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xffc0,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_LE_UP27,			/* type */
 	 10,				/* rightshift */
@@ -1071,8 +1071,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_LE_UP27",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x7ffffff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x7ffffff,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_S43_TLS_LE_EX6,			/* type */
 	 37,				/* rightshift */
@@ -1084,8 +1084,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_S43_TLS_LE_EX6",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0x3f,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0x3f,		/* dst_mask */
 	 false),			/* pc_offset */
   HOWTO (R_KVX_8,			/* type */
 	 0,				/* rightshift */
@@ -1097,8 +1097,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
 	 bfd_elf_generic_reloc,		/* special_function */
 	 "R_KVX_8",			/* name */
 	 false,				/* partial_inplace */
-	 0x0,				/* src_mask */
-	 0xff,			/* dst_mask */
+	 (bfd_vma) 0x0,			/* src_mask */
+	 (bfd_vma) 0xff,		/* dst_mask */
 	 false),			/* pc_offset */
 };
  
Luis Machado Aug. 17, 2023, 4:28 p.m. UTC | #23
Hi Paul,

On 8/17/23 16:09, Paul Iannetta wrote:
> On Thu, Aug 17, 2023 at 10:45:09AM +0100, Luis Machado wrote:
>>
>> The builders have caught a few hiccups related to printf modifiers for 32-bit architectures.
>>
>> Could you please take a look at those? A build with --enable-targets=all is recommended
>> to catch those.
>>
>> See https://builder.sourceware.org/buildbot/#/builders/170/builds/3977.
>>
>> --
>>
>> In file included from ../../binutils-gdb/bfd/elfnn-kvx.c:22:
>> ../../binutils-gdb/bfd/elfxx-kvx-relocs.h:74:3: error: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Werror=overflow]
>>    74 |   0xffffffffffffffff,   /* dst_mask */
>>       |   ^~~~~~~~~~~~~~~~~~
>> bfd.h:3204:15: note: in definition of macro ‘HOWTO’
>>  3204 |     src_mask, dst_mask, func, name }
>>       |               ^~~~~~~~
>> ../../binutils-gdb/bfd/elfnn-kvx.c: In function ‘elf32_kvx_stub_name’:
>> ../../binutils-gdb/bfd/elfnn-kvx.c:740:28: error: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 6 has type ‘bfd_vma’ {aka ‘const unsigned int’} [-Werror=format=]
>>   740 |  snprintf (stub_name, len, "%08x_%s+%" PRIx64 "x",
>>       |                            ^~~~~~~~~~~
>> ......
>>   743 |     rel->r_addend);
>>       |     ~~~~~~~~~~~~~
>>       |        |
>>       |        bfd_vma {aka const unsigned int}
>> cc1: all warnings being treated as errors
>> make[3]: *** [Makefile:1758: elf32-kvx.lo] Error 1
>>
> 
> Hi,
> 
> I was not able to fully reproduce but the attached patch should fix
> the build errors.  However, we did not do any validation on 32 bits
> hosts, so I think that even with this patch it will not be enough to
> pass `mack check'.  I'll work on it so that everything pass by the end
> of the week, so you may want to wait until I have also fixed the
> validation before applying the patch.

Thanks! If 32-bit is supported for kvx, you might want to give the testsuite for that particular mode, just to make sure things are sane.

After pushing the changes, you may want to keep an eye out for the following:

https://builder.sourceware.org/buildbot/#/builders?tags=binutils
https://builder.sourceware.org/buildbot/#/builders?tags=gdb

You should see some going back to green.

> 
> Paul
> 
>
  
Alan Modra Aug. 17, 2023, 11:20 p.m. UTC | #24
On Thu, Aug 17, 2023 at 05:09:53PM +0200, Paul Iannetta via Binutils wrote:
> On Thu, Aug 17, 2023 at 10:45:09AM +0100, Luis Machado wrote:
> > 
> > The builders have caught a few hiccups related to printf modifiers for 32-bit architectures.

> I was not able to fully reproduce but the attached patch should fix
> the build errors.  However, we did not do any validation on 32 bits
> hosts, so I think that even with this patch it will not be enough to
> pass `mack check'.

On x86_64-linux, I check a 32-bit host binutils compile using
CC="gcc -m32" CXX="g++ -m32" \
CFLAGS="-g -O2" CXXFLAGS="-g -O2" \
~/src/binutils-gdb/configure --build=i686-linux --enable-targets=all \
--enable-gold --enable-threads --disable-gdb --disable-gdbserver \
--disable-sim --disable-readline --disable-libdecnumber \
--disable-libbacktrace --disable-gprofng --disable-nls

Specifying --build may not be necessary nowadays, this is from a very
old recipe.

>  I'll work on it so that everything pass by the end
> of the week, so you may want to wait until I have also fixed the
> validation before applying the patch.
> 
> Paul
> 
> 

> @@ -31,8 +31,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
>  	 bfd_elf_generic_reloc,		/* special_function */
>  	 "R_KVX_NONE",			/* name */
>  	 false,				/* partial_inplace */
> -	 0,				/* src_mask */
> -	 0,				/* dst_mask */
> +	 (bfd_vma) 0,			/* src_mask */
> +	 (bfd_vma) 0,			/* dst_mask */
>  	 false),			/* pcrel_offset */
>    HOWTO (R_KVX_16,			/* type */
>  	 0,				/* rightshift */

Please don't add unnecessary casts like the above.
  
Paul Iannetta Aug. 18, 2023, 7:13 a.m. UTC | #25
On Fri, Aug 18, 2023 at 08:50:14AM +0930, Alan Modra wrote:
> On Thu, Aug 17, 2023 at 05:09:53PM +0200, Paul Iannetta via Binutils wrote:
> > On Thu, Aug 17, 2023 at 10:45:09AM +0100, Luis Machado wrote:
> > > 
> > > The builders have caught a few hiccups related to printf modifiers for 32-bit architectures.
> 
> > I was not able to fully reproduce but the attached patch should fix
> > the build errors.  However, we did not do any validation on 32 bits
> > hosts, so I think that even with this patch it will not be enough to
> > pass `make check'.
> 

I've tested it against a 32-bit host in a virtual machine and I
think it is enough to pass the build and the validation phase since
the `make check' does not seem to actually validate all targets but the
host so it should be fine.  I still need to improve the validation
when the kvx targets are validated on 32 bits hosts but I can do that
in a second time.

What is the process to get the changes merged?

> On x86_64-linux, I check a 32-bit host binutils compile using
> CC="gcc -m32" CXX="g++ -m32" \
> CFLAGS="-g -O2" CXXFLAGS="-g -O2" \
> ~/src/binutils-gdb/configure --build=i686-linux --enable-targets=all \
> --enable-gold --enable-threads --disable-gdb --disable-gdbserver \
> --disable-sim --disable-readline --disable-libdecnumber \
> --disable-libbacktrace --disable-gprofng --disable-nls
> 
> Specifying --build may not be necessary nowadays, this is from a very
> old recipe.

I'll try that thanks, it will be faster than using a virtual machine.

> >  I'll work on it so that everything pass by the end
> > of the week, so you may want to wait until I have also fixed the
> > validation before applying the patch.
> > 
> > Paul
> > 
> > 
> 
> > @@ -31,8 +31,8 @@ static reloc_howto_type elf_kvx_howto_table[] =
> >  	 bfd_elf_generic_reloc,		/* special_function */
> >  	 "R_KVX_NONE",			/* name */
> >  	 false,				/* partial_inplace */
> > -	 0,				/* src_mask */
> > -	 0,				/* dst_mask */
> > +	 (bfd_vma) 0,			/* src_mask */
> > +	 (bfd_vma) 0,			/* dst_mask */
> >  	 false),			/* pcrel_offset */
> >    HOWTO (R_KVX_16,			/* type */
> >  	 0,				/* rightshift */
> 
> Please don't add unnecessary casts like the above.
> 

This is a generated file, that is why the casts are everywhere. I'll
get rid of them when unnecessary.

Thanks
Paul