Browse Source

[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 years ago
parent
commit
bbd274a1d6
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      src/util/elf2efi.c

+ 6
- 1
src/util/elf2efi.c View File

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

Loading…
Cancel
Save