| 102 |
} |
} |
| 103 |
else |
else |
| 104 |
{ |
{ |
| 105 |
/* Attribute found - rebuild modes. */ |
/* Attributes found. Split. */ |
| 106 |
size_t modes_len = vms_attr - modes; |
size_t modes_len = strlen (modes) + 1; |
| 107 |
|
char attrs[modes_len + 1]; |
| 108 |
BFD_ASSERT (modes_len < sizeof (vms_modes)); |
char *at[3]; |
| 109 |
memcpy (vms_modes, modes, modes_len); |
int i; |
| 110 |
vms_modes[modes_len] = 0; |
|
| 111 |
return close_on_exec (fopen (filename, vms_modes, vms_attr + 1)); |
memcpy (attrs, modes, modes_len); |
| 112 |
|
at[0] = attrs; |
| 113 |
|
for (i = 0; i < 2; i++) |
| 114 |
|
{ |
| 115 |
|
at[i + 1] = strchr (at[i], ','); |
| 116 |
|
BFD_ASSERT (at[i + 1] != NULL); |
| 117 |
|
*(at[i + 1]++) = 0; /* Replace ',' with a nul, and skip it. */ |
| 118 |
|
} |
| 119 |
|
return close_on_exec (fopen (filename, at[0], at[1], at[2])); |
| 120 |
} |
} |
| 121 |
#else /* !VMS */ |
#else /* !VMS */ |
| 122 |
#if defined (HAVE_FOPEN64) |
#if defined (HAVE_FOPEN64) |
| 158 |
. int (*bclose) (struct bfd *abfd); |
. int (*bclose) (struct bfd *abfd); |
| 159 |
. int (*bflush) (struct bfd *abfd); |
. int (*bflush) (struct bfd *abfd); |
| 160 |
. int (*bstat) (struct bfd *abfd, struct stat *sb); |
. int (*bstat) (struct bfd *abfd, struct stat *sb); |
| 161 |
|
. {* Just like mmap: (void*)-1 on failure, mmapped address on success. *} |
| 162 |
|
. void *(*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len, |
| 163 |
|
. int prot, int flags, file_ptr offset); |
| 164 |
.}; |
.}; |
| 165 |
|
|
| 166 |
*/ |
*/ |
| 238 |
bim->size = 0; |
bim->size = 0; |
| 239 |
return 0; |
return 0; |
| 240 |
} |
} |
| 241 |
|
if (newsize > bim->size) |
| 242 |
|
memset (bim->buffer + bim->size, 0, newsize - bim->size); |
| 243 |
} |
} |
| 244 |
} |
} |
| 245 |
memcpy (bim->buffer + abfd->where, ptr, (size_t) size); |
memcpy (bim->buffer + abfd->where, ptr, (size_t) size); |
| 347 |
|
|
| 348 |
if (abfd->where > bim->size) |
if (abfd->where > bim->size) |
| 349 |
{ |
{ |
| 350 |
if ((abfd->direction == write_direction) || |
if (abfd->direction == write_direction |
| 351 |
(abfd->direction == both_direction)) |
|| abfd->direction == both_direction) |
| 352 |
{ |
{ |
| 353 |
bfd_size_type newsize, oldsize; |
bfd_size_type newsize, oldsize; |
| 354 |
|
|
| 364 |
bim->size = 0; |
bim->size = 0; |
| 365 |
return -1; |
return -1; |
| 366 |
} |
} |
| 367 |
|
memset (bim->buffer + oldsize, 0, newsize - oldsize); |
| 368 |
} |
} |
| 369 |
} |
} |
| 370 |
else |
else |
| 514 |
|
|
| 515 |
return buf.st_size; |
return buf.st_size; |
| 516 |
} |
} |
| 517 |
|
|
| 518 |
|
|
| 519 |
|
/* |
| 520 |
|
FUNCTION |
| 521 |
|
bfd_mmap |
| 522 |
|
|
| 523 |
|
SYNOPSIS |
| 524 |
|
void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len, |
| 525 |
|
int prot, int flags, file_ptr offset); |
| 526 |
|
|
| 527 |
|
DESCRIPTION |
| 528 |
|
Return mmap()ed region of the file, if possible and implemented. |
| 529 |
|
|
| 530 |
|
*/ |
| 531 |
|
|
| 532 |
|
void * |
| 533 |
|
bfd_mmap (bfd *abfd, void *addr, bfd_size_type len, |
| 534 |
|
int prot, int flags, file_ptr offset) |
| 535 |
|
{ |
| 536 |
|
void *ret = (void *)-1; |
| 537 |
|
if ((abfd->flags & BFD_IN_MEMORY) != 0) |
| 538 |
|
return ret; |
| 539 |
|
|
| 540 |
|
if (abfd->iovec == NULL) |
| 541 |
|
return ret; |
| 542 |
|
|
| 543 |
|
return abfd->iovec->bmmap (abfd, addr, len, prot, flags, offset); |
| 544 |
|
} |