[PATCH 2/2] coff-go32: support extended relocations

J.W. Jagersma jwjagersma@gmail.com
Thu Apr 9 16:39:15 GMT 2020


On 2020-04-09 11:49, Nick Clifton wrote:
> Hi Jan,
> 
>> 	coffswap.h: (coff_swap_scnhdr_in, coff_swap_scnhdr_out): Allow
>> 	overriding these functions with macros of the same name.
> 
> [...]
> 
>> +#ifndef coff_swap_scnhdr_in
>>  static void
>>  coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in)
> 
> This breaks build any other COFF based target.  They all define coff_swap_scnhdr_in
> and coff_swap_scnhdr_out to be target specific names, but they use the generic code.
> Eg bfd/alpha-coff.c (lines 86 and 87):
> 
>   #define coff_swap_scnhdr_in alpha_ecoff_swap_scnhdr_in
>   #define coff_swap_scnhdr_out alpha_ecoff_swap_scnhdr_out
> 
> I believe that this is done so that if the binutils are configured to support multiple
> coff targets they will each have their own versions of the coff_swap_scnhdr_[in|out]
> functions.  (Which makes sense given that the functions use macros which can be target
> specific).
> 
> I think that what you need to do is to change these defines (in coff-go32.c and coff-stgo32.c):
> 
>  #define coff_swap_scnhdr_in _bfd_go32_swap_scnhdr_in
>  #define coff_swap_scnhdr_out _bfd_go32_swap_scnhdr_out
> 
> to:
> 
>  #define coff_SWAP_scnhdr_in _bfd_go32_swap_scnhdr_in
>  #define coff_SWAP_scnhdr_out _bfd_go32_swap_scnhdr_out
> 
> which will then ensure that the correct routines are referenced in the bfd_coff_std_swap_table
> defined in coffcode.h.
> 
> Please could you check this and make sure that it does work ?
> 
> Secondly, once that is done, please could you check that a toolchain configured as:
> 
>   --enable-targets=all
> 
> will build ?  That way you can be sure that the alpha and mips coff targets also work.
> 
> Cheers
>   Nick

Thanks, I see how the swap tables and these macros are used now.

However when I define coff_SWAP_scnhdr_{in,out}, I get an unused
function warning for coff_swap_scnhdr_in:

In file included from ../../binutils-gdb/bfd/coffcode.h:356,
                 from ../../binutils-gdb/bfd/coff-i386.c:618,
                 from ../../binutils-gdb/bfd/coff-stgo32.c:73:
../../binutils-gdb/bfd/coffswap.h:729:1: warning: 'coff_swap_scnhdr_in' defined but not used [-Wunused-function]
  729 | coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in)
      | ^~~~~~~~~~~~~~~~~~~

This can be suppressed with ATTRIBUTE_UNUSED.  But note that the
warning doesn't appear for _out.  It seems this function is used
directly in coff_write_object_contents (coffcode.h:3618,3744).  I
suppose this should be bfd_coff_swap_scnhdr_out instead?


More information about the Binutils mailing list