aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Gingold <tristan.gingold@adacore.com>2014-04-09 10:15:50 +0200
committerTristan Gingold <tristan.gingold@adacore.com>2014-04-18 12:23:31 +0200
commit4525c51ab02e6fdd29017d353e5decaceaeb1000 (patch)
tree7b3e70582273b1dae5063ce58b875a0de781b45c
parent51d481464ec03be1f5479ed648cc38fb944d7fc0 (diff)
downloadgdb-4525c51ab02e6fdd29017d353e5decaceaeb1000.zip
gdb-4525c51ab02e6fdd29017d353e5decaceaeb1000.tar.gz
gdb-4525c51ab02e6fdd29017d353e5decaceaeb1000.tar.bz2
mach-o: remove name_len field.
bfd/ * mach-o.h (bfd_mach_o_dylinker_command) (bfd_mach_o_dylib_command, bfd_mach_o_fvmlib_command): Remove name_len field. * mach-o.c (bfd_mach_o_read_dylinker, bfd_mach_o_read_dylib) (bfd_mach_o_read_fvmlib): Adjust after name_len removal.
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/mach-o.c26
-rw-r--r--bfd/mach-o.h7
3 files changed, 25 insertions, 16 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ce7cff5..750f88d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,13 @@
2014-04-18 Tristan Gingold <gingold@adacore.com>
+ * mach-o.h (bfd_mach_o_dylinker_command)
+ (bfd_mach_o_dylib_command, bfd_mach_o_fvmlib_command): Remove
+ name_len field.
+ * mach-o.c (bfd_mach_o_read_dylinker, bfd_mach_o_read_dylib)
+ (bfd_mach_o_read_fvmlib): Adjust after name_len removal.
+
+2014-04-18 Tristan Gingold <gingold@adacore.com>
+
* mach-o.h (bfd_mach_o_backend_data): Add page_size field.
* mach-o-target.c: Check TARGET_PAGESIZE is defined.
(TARGET_NAME_BACKEND): Add TARGET_PAGESIZE.
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index ab2af7c..c0cead7 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -3155,6 +3155,7 @@ bfd_mach_o_read_dylinker (bfd *abfd, bfd_mach_o_load_command *command)
bfd_mach_o_dylinker_command *cmd = &command->command.dylinker;
struct mach_o_str_command_external raw;
unsigned int nameoff;
+ unsigned int namelen;
if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0
|| bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw))
@@ -3162,13 +3163,14 @@ bfd_mach_o_read_dylinker (bfd *abfd, bfd_mach_o_load_command *command)
nameoff = bfd_h_get_32 (abfd, raw.str);
- cmd->name_offset = command->offset + nameoff;
- cmd->name_len = command->len - nameoff;
- cmd->name_str = bfd_alloc (abfd, cmd->name_len);
+ cmd->name_offset = nameoff;
+ namelen = command->len - nameoff;
+ nameoff += command->offset;
+ cmd->name_str = bfd_alloc (abfd, namelen);
if (cmd->name_str == NULL)
return FALSE;
- if (bfd_seek (abfd, cmd->name_offset, SEEK_SET) != 0
- || bfd_bread (cmd->name_str, cmd->name_len, abfd) != cmd->name_len)
+ if (bfd_seek (abfd, nameoff, SEEK_SET) != 0
+ || bfd_bread (cmd->name_str, namelen, abfd) != namelen)
return FALSE;
return TRUE;
}
@@ -3179,6 +3181,7 @@ bfd_mach_o_read_dylib (bfd *abfd, bfd_mach_o_load_command *command)
bfd_mach_o_dylib_command *cmd = &command->command.dylib;
struct mach_o_dylib_command_external raw;
unsigned int nameoff;
+ unsigned int namelen;
switch (command->type)
{
@@ -3204,12 +3207,12 @@ bfd_mach_o_read_dylib (bfd *abfd, bfd_mach_o_load_command *command)
cmd->compatibility_version = bfd_h_get_32 (abfd, raw.compatibility_version);
cmd->name_offset = command->offset + nameoff;
- cmd->name_len = command->len - nameoff;
- cmd->name_str = bfd_alloc (abfd, cmd->name_len);
+ namelen = command->len - nameoff;
+ cmd->name_str = bfd_alloc (abfd, namelen);
if (cmd->name_str == NULL)
return FALSE;
if (bfd_seek (abfd, cmd->name_offset, SEEK_SET) != 0
- || bfd_bread (cmd->name_str, cmd->name_len, abfd) != cmd->name_len)
+ || bfd_bread (cmd->name_str, namelen, abfd) != namelen)
return FALSE;
return TRUE;
}
@@ -3287,6 +3290,7 @@ bfd_mach_o_read_fvmlib (bfd *abfd, bfd_mach_o_load_command *command)
bfd_mach_o_fvmlib_command *fvm = &command->command.fvmlib;
struct mach_o_fvmlib_command_external raw;
unsigned int nameoff;
+ unsigned int namelen;
if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0
|| bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw))
@@ -3297,12 +3301,12 @@ bfd_mach_o_read_fvmlib (bfd *abfd, bfd_mach_o_load_command *command)
fvm->header_addr = bfd_h_get_32 (abfd, raw.header_addr);
fvm->name_offset = command->offset + nameoff;
- fvm->name_len = command->len - nameoff;
- fvm->name_str = bfd_alloc (abfd, fvm->name_len);
+ namelen = command->len - nameoff;
+ fvm->name_str = bfd_alloc (abfd, namelen);
if (fvm->name_str == NULL)
return FALSE;
if (bfd_seek (abfd, fvm->name_offset, SEEK_SET) != 0
- || bfd_bread (fvm->name_str, fvm->name_len, abfd) != fvm->name_len)
+ || bfd_bread (fvm->name_str, namelen, abfd) != namelen)
return FALSE;
return TRUE;
}
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index 95827e8..47b1bc5 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -418,8 +418,7 @@ bfd_mach_o_thread_command;
typedef struct bfd_mach_o_dylinker_command
{
- unsigned long name_offset; /* Offset to library's path name. */
- unsigned long name_len; /* Offset to library's path name. */
+ unsigned int name_offset; /* Offset to library's path name. */
char *name_str;
}
bfd_mach_o_dylinker_command;
@@ -429,8 +428,7 @@ bfd_mach_o_dylinker_command;
typedef struct bfd_mach_o_dylib_command
{
- unsigned long name_offset; /* Offset to library's path name. */
- unsigned long name_len; /* Offset to library's path name. */
+ unsigned int name_offset; /* Offset to library's path name. */
unsigned long timestamp; /* Library's build time stamp. */
unsigned long current_version; /* Library's current version number. */
unsigned long compatibility_version; /* Library's compatibility vers number. */
@@ -479,7 +477,6 @@ bfd_mach_o_str_command;
typedef struct bfd_mach_o_fvmlib_command
{
unsigned int name_offset;
- unsigned int name_len;
char *name_str;
unsigned int minor_version;
unsigned int header_addr;