{
const mach_o_section_name_xlat *xlat;
char *res;
- unsigned int len;
+ size_t len;
const char *pfx = "";
*name = NULL;
res = bfd_alloc (abfd, len + 1);
if (res == NULL)
return;
- memcpy (res, xlat->bfd_name, len+1);
+ memcpy (res, xlat->bfd_name, len + 1);
*name = res;
*flags = xlat->bfd_flags;
return;
const char *name = bfd_section_name (sect);
const char *segname;
const char *dot;
- unsigned int len;
- unsigned int seglen;
- unsigned int seclen;
+ size_t len;
+ size_t seglen;
+ size_t seclen;
memset (section->segname, 0, BFD_MACH_O_SEGNAME_SIZE + 1);
memset (section->sectname, 0, BFD_MACH_O_SECTNAME_SIZE + 1);
bfd_mach_o_section *sec = mdata->sections[i];
unsigned int first, last;
bfd_vma addr;
- bfd_vma entry_size;
+ unsigned int entry_size;
switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
{
number of bytes written or -1 in case of error. */
static int
-bfd_mach_o_pad4 (bfd *abfd, unsigned int len)
+bfd_mach_o_pad4 (bfd *abfd, size_t len)
{
if (len % 4 != 0)
{
/* Likewise, but for a command. */
static int
-bfd_mach_o_pad_command (bfd *abfd, unsigned int len)
+bfd_mach_o_pad_command (bfd *abfd, size_t len)
{
- unsigned int align = bfd_mach_o_wide_p (abfd) ? 8 : 4;
+ size_t align = bfd_mach_o_wide_p (abfd) ? 8 : 4;
if (len % align != 0)
{
char pad[8] = {0};
- unsigned int padlen = align - (len % align);
+ size_t padlen = align - (len % align);
if (bfd_bwrite (pad, padlen, abfd) != padlen)
return -1;
bfd_mach_o_write_header (bfd *abfd, bfd_mach_o_header *header)
{
struct mach_o_header_external raw;
- unsigned int size;
+ size_t size;
size = mach_o_wide_p (header) ?
BFD_MACH_O_HEADER_64_SIZE : BFD_MACH_O_HEADER_SIZE;
bfd_mach_o_thread_command *cmd = &command->command.thread;
unsigned int i;
struct mach_o_thread_command_external raw;
- unsigned int offset;
+ size_t offset;
BFD_ASSERT ((command->type == BFD_MACH_O_LC_THREAD)
|| (command->type == BFD_MACH_O_LC_UNIXTHREAD));
for (i = 0; i < cmd->nflavours; i++)
{
BFD_ASSERT ((cmd->flavours[i].size % 4) == 0);
- BFD_ASSERT (cmd->flavours[i].offset ==
- (command->offset + offset + BFD_MACH_O_LC_SIZE));
+ BFD_ASSERT (cmd->flavours[i].offset
+ == command->offset + offset + BFD_MACH_O_LC_SIZE);
bfd_h_put_32 (abfd, cmd->flavours[i].flavour, raw.flavour);
bfd_h_put_32 (abfd, (cmd->flavours[i].size / 4), raw.count);
{
bfd_mach_o_dylinker_command *cmd = &command->command.dylinker;
struct mach_o_str_command_external raw;
- unsigned int namelen;
+ size_t namelen;
bfd_h_put_32 (abfd, cmd->name_offset, raw.str);
{
bfd_mach_o_dylib_command *cmd = &command->command.dylib;
struct mach_o_dylib_command_external raw;
- unsigned int namelen;
+ size_t namelen;
bfd_h_put_32 (abfd, cmd->name_offset, raw.name);
bfd_h_put_32 (abfd, cmd->timestamp, raw.timestamp);
}
static unsigned char *
-bfd_mach_o_alloc_and_read (bfd *abfd, file_ptr filepos, size_t size)
+bfd_mach_o_alloc_and_read (bfd *abfd, file_ptr filepos,
+ size_t size, size_t extra)
{
if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
return NULL;
- return _bfd_alloc_and_read (abfd, size, size);
+ unsigned char *ret = _bfd_alloc_and_read (abfd, size + extra, size);
+ if (ret && extra != 0)
+ memset (ret + size, 0, extra);
+ return ret;
}
static bool
bfd_mach_o_dylinker_command *cmd = &command->command.dylinker;
struct mach_o_str_command_external raw;
unsigned int nameoff;
- unsigned int namelen;
+ size_t namelen;
if (command->len < sizeof (raw) + 8)
return false;
cmd->name_offset = nameoff;
namelen = command->len - nameoff;
nameoff += command->offset;
- cmd->name_str = (char *) bfd_mach_o_alloc_and_read (abfd, nameoff, namelen);
+ cmd->name_str = (char *) bfd_mach_o_alloc_and_read (abfd, nameoff,
+ namelen, 1);
return cmd->name_str != NULL;
}
bfd_mach_o_dylib_command *cmd = &command->command.dylib;
struct mach_o_dylib_command_external raw;
unsigned int nameoff;
- unsigned int namelen;
+ size_t namelen;
file_ptr pos;
if (command->len < sizeof (raw) + 8)
cmd->name_offset = command->offset + nameoff;
namelen = command->len - nameoff;
pos = mdata->hdr_offset + cmd->name_offset;
- cmd->name_str = (char *) bfd_mach_o_alloc_and_read (abfd, pos, namelen);
+ cmd->name_str = (char *) bfd_mach_o_alloc_and_read (abfd, pos, namelen, 1);
return cmd->name_str != NULL;
}
bfd_mach_o_fvmlib_command *fvm = &command->command.fvmlib;
struct mach_o_fvmlib_command_external raw;
unsigned int nameoff;
- unsigned int namelen;
+ size_t namelen;
if (command->len < sizeof (raw) + 8)
return false;
fvm->name_offset = command->offset + nameoff;
namelen = command->len - nameoff;
fvm->name_str = (char *) bfd_mach_o_alloc_and_read (abfd, fvm->name_offset,
- namelen);
+ namelen, 1);
return fvm->name_str != NULL;
}
for (i = 0; i < nflavours; i++)
{
asection *bfdsec;
- unsigned int snamelen;
+ size_t snamelen;
char *sname;
const char *flavourstr;
const char *prefix = "LC_THREAD";
cmd->stroff = command->offset + off;
cmd->str_len = command->len - off;
cmd->str = (char *) bfd_mach_o_alloc_and_read (abfd, cmd->stroff,
- cmd->str_len);
+ cmd->str_len, 1);
return cmd->str != NULL;
}
if (cmd->rebase_content == NULL && cmd->rebase_size != 0)
{
cmd->rebase_content
- = bfd_mach_o_alloc_and_read (abfd, cmd->rebase_off, cmd->rebase_size);
+ = bfd_mach_o_alloc_and_read (abfd, cmd->rebase_off,
+ cmd->rebase_size, 0);
if (cmd->rebase_content == NULL)
return false;
}
if (cmd->bind_content == NULL && cmd->bind_size != 0)
{
cmd->bind_content
- = bfd_mach_o_alloc_and_read (abfd, cmd->bind_off, cmd->bind_size);
+ = bfd_mach_o_alloc_and_read (abfd, cmd->bind_off,
+ cmd->bind_size, 0);
if (cmd->bind_content == NULL)
return false;
}
/* Read weak bind content. */
if (cmd->weak_bind_content == NULL && cmd->weak_bind_size != 0)
{
- cmd->weak_bind_content = bfd_mach_o_alloc_and_read
- (abfd, cmd->weak_bind_off, cmd->weak_bind_size);
+ cmd->weak_bind_content
+ = bfd_mach_o_alloc_and_read (abfd, cmd->weak_bind_off,
+ cmd->weak_bind_size, 0);
if (cmd->weak_bind_content == NULL)
return false;
}
/* Read lazy bind content. */
if (cmd->lazy_bind_content == NULL && cmd->lazy_bind_size != 0)
{
- cmd->lazy_bind_content = bfd_mach_o_alloc_and_read
- (abfd, cmd->lazy_bind_off, cmd->lazy_bind_size);
+ cmd->lazy_bind_content
+ = bfd_mach_o_alloc_and_read (abfd, cmd->lazy_bind_off,
+ cmd->lazy_bind_size, 0);
if (cmd->lazy_bind_content == NULL)
return false;
}
/* Read export content. */
if (cmd->export_content == NULL && cmd->export_size != 0)
{
- cmd->export_content = bfd_mach_o_alloc_and_read
- (abfd, cmd->export_off, cmd->export_size);
+ cmd->export_content
+ = bfd_mach_o_alloc_and_read (abfd, cmd->export_off,
+ cmd->export_size, 0);
if (cmd->export_content == NULL)
return false;
}