File 2009-Fix-too-many-arguments-for-function.patch of Package qemu.29142

From: Liang Yan <lyan@suse.com>
Date: Sun, 19 Dec 2021 08:33:55 -0500
Subject: Fix too many arguments for function bfd_section_size after binutils
 updae

Git-commit: 00000000000000000000000000000000000000000000
References: bsc#1192463

After update binutils, it broke qemu broke. One of the issue is affected ipxe before 2016 which still have FTBFS support.
Destail in https://github.com/ipxe/ipxe/commit/efd5cf9aadcaf36f45db5d1c3059197a8479567c

Consideing the deprecation situation, this patch won't get in upstream.

[  417s]   [VERSION] bin-i386-efi/version.1af41000.efidrv.o
[  417s] util/elf2efi.c: In function 'process_section':
[  417s] util/elf2efi.c:337:2: error: implicit declaration of function 'bfd_get_section_flags' [-Werror=implicit-function-declaration]
[  417s]   unsigned long flags = bfd_get_section_flags ( bfd, section );
[  417s]   ^
[  417s] util/elf2efi.c:362:2: error: passing argument 1 of 'bfd_section_size' from incompatible pointer type [-Werror]
[  417s]   section_memsz = bfd_section_size ( bfd, section );
[  417s]   ^
[  417s] In file included from util/elf2efi.c:32:0:
[  417s] /usr/include/bfd.h:1191:1: note: expected 'const struct asection *' but argument is of type 'struct bfd *'
[  417s]  bfd_section_size (const asection *sec)
[  417s]  ^
[  417s] util/elf2efi.c:362:2: error: too many arguments to function 'bfd_section_size'
[  417s]   section_memsz = bfd_section_size ( bfd, section );
[  417s]   ^
[  417s] In file included from util/elf2efi.c:32:0:
[  417s] /usr/include/bfd.h:1191:1: note: declared here
[  417s]  bfd_section_size (const asection *sec)
[  417s]  ^
[  417s] util/elf2efi.c:372:2: error: implicit declaration of function 'bfd_get_section_vma' [-Werror=implicit-function-declaration]
[  417s]   new->hdr.VirtualAddress = bfd_get_section_vma ( bfd, section );
[  417s]   ^
[  417s] cc1: all warnings being treated as errors
[  417s] Makefile.housekeeping:1307: recipe for target 'util/elf2efi32' failed
[  417s] make[2]: *** [util/elf2efi32] Error 1
[  417s] make[2]: *** Waiting for unfinished jobs....
[  419s] rm bin-i386-efi/version.1af41000.efidrv.o bin-i386-efi/version.10222000.efidrv.o bin-i386-efi/version.8086100e.efidrv.o bin-i386-efi/version.80861209.efidrv.o bin-i386-efi/version.10ec8139.efidrv.o bin-i386-efi/version.10500940.efidrv.o
[  419s] Makefile.housekeeping:259: recipe for target 'bin-i386-efi/8086100e.efidrv' failed
[  419s] make[1]: *** [bin-i386-efi/8086100e.efidrv] Error 2

Patch is based on:
https://wiki.gentoo.org/wiki/Binutils_2.34_porting_notes/undefined_reference_to_bfd_get_section_*

Signed-off-by: Liang Yan <lyan@suse.com>
---
 src/util/elf2efi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/roms/ipxe/src/util/elf2efi.c b/roms/ipxe/src/util/elf2efi.c
index e68fa5d142b8ab42b137724c24e7..aaf47ce03f601e723e98f5081265 100644
--- a/roms/ipxe/src/util/elf2efi.c
+++ b/roms/ipxe/src/util/elf2efi.c
@@ -334,7 +334,7 @@ static struct pe_section * process_section ( bfd *bfd,
 	struct pe_section *new;
 	size_t section_memsz;
 	size_t section_filesz;
-	unsigned long flags = bfd_get_section_flags ( bfd, section );
+	unsigned long flags = bfd_section_flags ( section );
 	unsigned long code_start;
 	unsigned long code_end;
 	unsigned long data_start;
@@ -359,7 +359,7 @@ static struct pe_section * process_section ( bfd *bfd,
 		     pe_header->nt.OptionalHeader.SizeOfUninitializedData );
 
 	/* Allocate PE section */
-	section_memsz = bfd_section_size ( bfd, section );
+	section_memsz = bfd_section_size ( section );
 	section_filesz = ( ( flags & SEC_LOAD ) ?
 			   efi_file_align ( section_memsz ) : 0 );
 	new = xmalloc ( sizeof ( *new ) + section_filesz );
@@ -369,7 +369,7 @@ static struct pe_section * process_section ( bfd *bfd,
 	strncpy ( ( char * ) new->hdr.Name, section->name,
 		  sizeof ( new->hdr.Name ) );
 	new->hdr.Misc.VirtualSize = section_memsz;
-	new->hdr.VirtualAddress = bfd_get_section_vma ( bfd, section );
+	new->hdr.VirtualAddress = bfd_section_vma ( section );
 	new->hdr.SizeOfRawData = section_filesz;
 
 	/* Fill in section characteristics and update RVA limits */
@@ -471,7 +471,7 @@ static void process_reloc ( bfd *bfd __attribute__ (( unused )),
 			    struct pe_relocs **pe_reltab ) {
 	reloc_howto_type *howto = rel->howto;
 	asymbol *sym = *(rel->sym_ptr_ptr);
-	unsigned long offset = ( bfd_get_section_vma ( bfd, section ) +
+	unsigned long offset = ( bfd_section_vma ( section ) +
 				 rel->address );
 
 	if ( bfd_is_abs_section ( sym->section ) ) {
@@ -703,7 +703,7 @@ static void elf2pe ( const char *elf_name, const char *pe_name,
 	 */
 	for ( section = bfd->sections ; section ; section = section->next ) {
 		/* Discard non-allocatable sections */
-		if ( ! ( bfd_get_section_flags ( bfd, section ) & SEC_ALLOC ) )
+		if ( ! ( bfd_section_flags ( section ) & SEC_ALLOC ) )
 			continue;
 		/* Create output section */
 		*(next_pe_section) = process_section ( bfd, &pe_header,
openSUSE Build Service is sponsored by