aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-01-04 12:18:36 +1030
committerAlan Modra <amodra@gmail.com>2019-01-04 12:23:56 +1030
commit677bd4c69d0eda4f2ae635d793f23c0b1413a9e9 (patch)
tree71a89df9551df3978e49e34c705a2c011efb0226 /bfd
parent8261e52d1b8381252ede6754ea6cd1ba18810f1d (diff)
downloadgdb-677bd4c69d0eda4f2ae635d793f23c0b1413a9e9.zip
gdb-677bd4c69d0eda4f2ae635d793f23c0b1413a9e9.tar.gz
gdb-677bd4c69d0eda4f2ae635d793f23c0b1413a9e9.tar.bz2
PR24061, powerpc-ibm-aix-ar sets bogus file permissions when extracting
Mode field should be read in octal, all the rest in decimal. Do so. PR 24061 PR 21786 * coff-rs6000.c (GET_VALUE_IN_FIELD): Add base parameter and adjust all callers. (EQ_VALUE_IN_FIELD): Likewise. * coff64-rs6000.c (GET_VALUE_IN_FIELD): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/coff-rs6000.c72
-rw-r--r--bfd/coff64-rs6000.c16
3 files changed, 53 insertions, 44 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3fc4606..fc6782f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2019-01-04 Alan Modra <amodra@gmail.com>
+
+ PR 24061
+ PR 21786
+ * coff-rs6000.c (GET_VALUE_IN_FIELD): Add base parameter and
+ adjust all callers.
+ (EQ_VALUE_IN_FIELD): Likewise.
+ * coff64-rs6000.c (GET_VALUE_IN_FIELD): Likewise.
+
2019-01-01 Alan Modra <amodra@gmail.com>
Update year range in copyright notice of all files.
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 7f72f8c..85e90a0 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -1214,19 +1214,19 @@ _bfd_strntoll (const char * nptr, int base, unsigned int maxlen)
}
/* Macro to read an ASCII value stored in an archive header field. */
-#define GET_VALUE_IN_FIELD(VAR, FIELD) \
- do \
- { \
- (VAR) = sizeof (VAR) > sizeof (long) \
- ? _bfd_strntoll (FIELD, 10, sizeof FIELD) \
- : _bfd_strntol (FIELD, 10, sizeof FIELD); \
- } \
+#define GET_VALUE_IN_FIELD(VAR, FIELD, BASE) \
+ do \
+ { \
+ (VAR) = (sizeof (VAR) > sizeof (long) \
+ ? _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
+ : _bfd_strntol (FIELD, BASE, sizeof FIELD)); \
+ } \
while (0)
-#define EQ_VALUE_IN_FIELD(VAR, FIELD) \
- (sizeof (VAR) > sizeof (long) \
- ? (VAR) ==_bfd_strntoll (FIELD, 10, sizeof FIELD) \
- : (VAR) == _bfd_strntol (FIELD, 10, sizeof FIELD))
+#define EQ_VALUE_IN_FIELD(VAR, FIELD, BASE) \
+ (sizeof (VAR) > sizeof (long) \
+ ? (VAR) == _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
+ : (VAR) == _bfd_strntol (FIELD, BASE, sizeof FIELD))
/* Read in the armap of an XCOFF archive. */
@@ -1252,7 +1252,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd)
/* This is for the old format. */
struct xcoff_ar_hdr hdr;
- GET_VALUE_IN_FIELD (off, xcoff_ardata (abfd)->symoff);
+ GET_VALUE_IN_FIELD (off, xcoff_ardata (abfd)->symoff, 10);
if (off == 0)
{
bfd_has_map (abfd) = FALSE;
@@ -1268,12 +1268,12 @@ _bfd_xcoff_slurp_armap (bfd *abfd)
return FALSE;
/* Skip the name (normally empty). */
- GET_VALUE_IN_FIELD (namlen, hdr.namlen);
+ GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;
if (bfd_seek (abfd, off, SEEK_CUR) != 0)
return FALSE;
- GET_VALUE_IN_FIELD (sz, hdr.size);
+ GET_VALUE_IN_FIELD (sz, hdr.size, 10);
/* Read in the entire symbol table. */
contents = (bfd_byte *) bfd_alloc (abfd, sz);
@@ -1307,7 +1307,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd)
/* This is for the new format. */
struct xcoff_ar_hdr_big hdr;
- GET_VALUE_IN_FIELD (off, xcoff_ardata_big (abfd)->symoff);
+ GET_VALUE_IN_FIELD (off, xcoff_ardata_big (abfd)->symoff, 10);
if (off == 0)
{
bfd_has_map (abfd) = FALSE;
@@ -1323,12 +1323,12 @@ _bfd_xcoff_slurp_armap (bfd *abfd)
return FALSE;
/* Skip the name (normally empty). */
- GET_VALUE_IN_FIELD (namlen, hdr.namlen);
+ GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;
if (bfd_seek (abfd, off, SEEK_CUR) != 0)
return FALSE;
- GET_VALUE_IN_FIELD (sz, hdr.size);
+ GET_VALUE_IN_FIELD (sz, hdr.size, 10);
/* Read in the entire symbol table. */
contents = (bfd_byte *) bfd_alloc (abfd, sz);
@@ -1434,7 +1434,7 @@ _bfd_xcoff_archive_p (bfd *abfd)
}
GET_VALUE_IN_FIELD (bfd_ardata (abfd)->first_file_filepos,
- hdr.firstmemoff);
+ hdr.firstmemoff, 10);
amt = SIZEOF_AR_FILE_HDR;
bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
@@ -1509,7 +1509,7 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd)
return NULL;
}
- GET_VALUE_IN_FIELD (namlen, hdr.namlen);
+ GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
amt = SIZEOF_AR_HDR + namlen + 1;
hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd, amt);
if (hdrp == NULL)
@@ -1526,7 +1526,7 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd)
((char *) hdrp)[SIZEOF_AR_HDR + namlen] = '\0';
ret->arch_header = (char *) hdrp;
- GET_VALUE_IN_FIELD (ret->parsed_size, hdr.size);
+ GET_VALUE_IN_FIELD (ret->parsed_size, hdr.size, 10);
ret->filename = (char *) hdrp + SIZEOF_AR_HDR;
}
else
@@ -1541,7 +1541,7 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd)
return NULL;
}
- GET_VALUE_IN_FIELD (namlen, hdr.namlen);
+ GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
amt = SIZEOF_AR_HDR_BIG + namlen + 1;
hdrp = (struct xcoff_ar_hdr_big *) bfd_alloc (abfd, amt);
if (hdrp == NULL)
@@ -1558,7 +1558,7 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd)
((char *) hdrp)[SIZEOF_AR_HDR_BIG + namlen] = '\0';
ret->arch_header = (char *) hdrp;
- GET_VALUE_IN_FIELD (ret->parsed_size, hdr.size);
+ GET_VALUE_IN_FIELD (ret->parsed_size, hdr.size, 10);
ret->filename = (char *) hdrp + SIZEOF_AR_HDR_BIG;
}
@@ -1587,11 +1587,11 @@ _bfd_xcoff_openr_next_archived_file (bfd *archive, bfd *last_file)
if (last_file == NULL)
filestart = bfd_ardata (archive)->first_file_filepos;
else
- GET_VALUE_IN_FIELD (filestart, arch_xhdr (last_file)->nextoff);
+ GET_VALUE_IN_FIELD (filestart, arch_xhdr (last_file)->nextoff, 10);
if (filestart == 0
- || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata (archive)->memoff)
- || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata (archive)->symoff))
+ || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata (archive)->memoff, 10)
+ || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata (archive)->symoff, 10))
{
bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
@@ -1602,11 +1602,11 @@ _bfd_xcoff_openr_next_archived_file (bfd *archive, bfd *last_file)
if (last_file == NULL)
filestart = bfd_ardata (archive)->first_file_filepos;
else
- GET_VALUE_IN_FIELD (filestart, arch_xhdr_big (last_file)->nextoff);
+ GET_VALUE_IN_FIELD (filestart, arch_xhdr_big (last_file)->nextoff, 10);
if (filestart == 0
- || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata_big (archive)->memoff)
- || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata_big (archive)->symoff))
+ || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata_big (archive)->memoff, 10)
+ || EQ_VALUE_IN_FIELD (filestart, xcoff_ardata_big (archive)->symoff, 10))
{
bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
@@ -1631,20 +1631,20 @@ _bfd_xcoff_stat_arch_elt (bfd *abfd, struct stat *s)
{
struct xcoff_ar_hdr *hdrp = arch_xhdr (abfd);
- GET_VALUE_IN_FIELD (s->st_mtime, hdrp->date);
- GET_VALUE_IN_FIELD (s->st_uid, hdrp->uid);
- GET_VALUE_IN_FIELD (s->st_gid, hdrp->gid);
- GET_VALUE_IN_FIELD (s->st_mode, hdrp->mode);
+ GET_VALUE_IN_FIELD (s->st_mtime, hdrp->date, 10);
+ GET_VALUE_IN_FIELD (s->st_uid, hdrp->uid, 10);
+ GET_VALUE_IN_FIELD (s->st_gid, hdrp->gid, 10);
+ GET_VALUE_IN_FIELD (s->st_mode, hdrp->mode, 8);
s->st_size = arch_eltdata (abfd)->parsed_size;
}
else
{
struct xcoff_ar_hdr_big *hdrp = arch_xhdr_big (abfd);
- GET_VALUE_IN_FIELD (s->st_mtime, hdrp->date);
- GET_VALUE_IN_FIELD (s->st_uid, hdrp->uid);
- GET_VALUE_IN_FIELD (s->st_gid, hdrp->gid);
- GET_VALUE_IN_FIELD (s->st_mode, hdrp->mode);
+ GET_VALUE_IN_FIELD (s->st_mtime, hdrp->date, 10);
+ GET_VALUE_IN_FIELD (s->st_uid, hdrp->uid, 10);
+ GET_VALUE_IN_FIELD (s->st_gid, hdrp->gid, 10);
+ GET_VALUE_IN_FIELD (s->st_mode, hdrp->mode, 8);
s->st_size = arch_eltdata (abfd)->parsed_size;
}
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index f78afd1..6f0e358 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -1878,13 +1878,13 @@ _bfd_strntoll (const char * nptr, int base, unsigned int maxlen)
}
/* Macro to read an ASCII value stored in an archive header field. */
-#define GET_VALUE_IN_FIELD(VAR, FIELD) \
- do \
- { \
- (VAR) = sizeof (VAR) > sizeof (long) \
- ? _bfd_strntoll (FIELD, 10, sizeof FIELD) \
- : _bfd_strntol (FIELD, 10, sizeof FIELD); \
- } \
+#define GET_VALUE_IN_FIELD(VAR, FIELD, BASE) \
+ do \
+ { \
+ (VAR) = (sizeof (VAR) > sizeof (long) \
+ ? _bfd_strntoll (FIELD, BASE, sizeof FIELD) \
+ : _bfd_strntol (FIELD, BASE, sizeof FIELD)); \
+ } \
while (0)
/* Read in the armap of an XCOFF archive. */
@@ -1927,7 +1927,7 @@ xcoff64_slurp_armap (bfd *abfd)
return FALSE;
/* Skip the name (normally empty). */
- GET_VALUE_IN_FIELD (namlen, hdr.namlen);
+ GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
pos = ((namlen + 1) & ~(size_t) 1) + SXCOFFARFMAG;
if (bfd_seek (abfd, pos, SEEK_CUR) != 0)
return FALSE;