Przeglądaj źródła

[efi] Use POSIX version of basename() in elf2efi.c

This is required in order to build on Mac OS X.

Suggested-by: Joshua Oreman <oremanj@rwcr.net>
tags/v0.9.8
Michael Brown 15 lat temu
rodzic
commit
bbd274a1d6
1 zmienionych plików z 6 dodań i 1 usunięć
  1. 6
    1
      src/util/elf2efi.c

+ 6
- 1
src/util/elf2efi.c Wyświetl plik

@@ -29,6 +29,7 @@
29 29
 #include <bfd.h>
30 30
 #include <gpxe/efi/efi.h>
31 31
 #include <gpxe/efi/IndustryStandard/PeImage.h>
32
+#include <libgen.h>
32 33
 
33 34
 #define eprintf(...) fprintf ( stderr, __VA_ARGS__ )
34 35
 
@@ -658,6 +659,7 @@ static void write_pe_file ( struct pe_header *pe_header,
658 659
  */
659 660
 static void elf2pe ( const char *elf_name, const char *pe_name,
660 661
 		     struct options *opts ) {
662
+	char pe_name_tmp[ strlen ( pe_name ) + 1 ];
661 663
 	bfd *bfd;
662 664
 	asymbol **symtab;
663 665
 	asection *section;
@@ -669,6 +671,9 @@ static void elf2pe ( const char *elf_name, const char *pe_name,
669 671
 	struct pe_header pe_header;
670 672
 	FILE *pe;
671 673
 
674
+	/* Create a modifiable copy of the PE name */
675
+	memcpy ( pe_name_tmp, pe_name, sizeof ( pe_name_tmp ) );
676
+
672 677
 	/* Open the file */
673 678
 	bfd = open_input_bfd ( elf_name );
674 679
 	symtab = read_symtab ( bfd );
@@ -703,7 +708,7 @@ static void elf2pe ( const char *elf_name, const char *pe_name,
703 708
 
704 709
 	/* Create the .reloc section */
705 710
 	*(next_pe_section) = create_debug_section ( &pe_header,
706
-						    basename ( pe_name ) );
711
+						    basename ( pe_name_tmp ) );
707 712
 	next_pe_section = &(*next_pe_section)->next;
708 713
 
709 714
 	/* Write out PE file */

Ładowanie…
Anuluj
Zapisz