OLD | NEW |
1 /* BFD library -- caching of file descriptors. | 1 /* BFD library -- caching of file descriptors. |
2 | 2 |
3 Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002, | 3 Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002, |
4 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. | 4 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. |
5 | 5 |
6 Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com). | 6 Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com). |
7 | 7 |
8 This file is part of BFD, the Binary File Descriptor library. | 8 This file is part of BFD, the Binary File Descriptor library. |
9 | 9 |
10 This program is free software; you can redistribute it and/or modify | 10 This program is free software; you can redistribute it and/or modify |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 However, gcc 2.95 will create temporary files using | 558 However, gcc 2.95 will create temporary files using |
559 O_EXCL and tight permissions to prevent other users from | 559 O_EXCL and tight permissions to prevent other users from |
560 substituting other .o files during the compilation. gcc | 560 substituting other .o files during the compilation. gcc |
561 will then tell the assembler to use the newly created | 561 will then tell the assembler to use the newly created |
562 file as an output file. If we unlink the file here, we | 562 file as an output file. If we unlink the file here, we |
563 open a brief window when another user could still | 563 open a brief window when another user could still |
564 substitute a file. | 564 substitute a file. |
565 | 565 |
566 So we unlink the output file if and only if it has | 566 So we unlink the output file if and only if it has |
567 non-zero size. */ | 567 non-zero size. */ |
568 #ifndef __MSDOS__ | 568 #if !defined __MSDOS__ && !defined __native_client__ |
569 /* Don't do this for MSDOS: it doesn't care about overwriting | 569 /* Don't do this for MSDOS: it doesn't care about overwriting |
570 a running binary, but if this file is already open by | 570 a running binary, but if this file is already open by |
571 another BFD, we will be in deep trouble if we delete an | 571 another BFD, we will be in deep trouble if we delete an |
572 open file. In fact, objdump does just that if invoked with | 572 open file. In fact, objdump does just that if invoked with |
573 the --info option. */ | 573 the --info option. */ |
574 struct stat s; | 574 struct stat s; |
575 | 575 |
576 if (stat (abfd->filename, &s) == 0 && s.st_size != 0) | 576 if (stat (abfd->filename, &s) == 0 && s.st_size != 0) |
577 unlink_if_ordinary (abfd->filename); | 577 unlink_if_ordinary (abfd->filename); |
578 #endif | 578 #endif |
579 abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB); | 579 abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB); |
580 abfd->opened_once = TRUE; | 580 abfd->opened_once = TRUE; |
581 } | 581 } |
582 break; | 582 break; |
583 } | 583 } |
584 | 584 |
585 if (abfd->iostream == NULL) | 585 if (abfd->iostream == NULL) |
586 bfd_set_error (bfd_error_system_call); | 586 bfd_set_error (bfd_error_system_call); |
587 else | 587 else |
588 { | 588 { |
589 if (! bfd_cache_init (abfd)) | 589 if (! bfd_cache_init (abfd)) |
590 return NULL; | 590 return NULL; |
591 } | 591 } |
592 | 592 |
593 return (FILE *) abfd->iostream; | 593 return (FILE *) abfd->iostream; |
594 } | 594 } |
OLD | NEW |