* app.c (do_scrub_chars): Do not UNGET an EOF value.

* ti.h (GET_SCNHDR_NLNNO): Provide an alternative version of this
        macro which does not trigger an array bounds warning in gcc.
        (PUT_SCNHDR_NLNNO): Likewise.
        (GET_SCNHDR_FLAGS): Likewise.
        (PUT_SCNHDR_FLAGS): Likewise.
        (GET_SCNHDR_PAGE): Likewise.
        (PUT_SCNHDR_PAGE): Likewise.
This commit is contained in:
Nick Clifton 2008-06-17 16:01:28 +00:00
parent e7ddc19715
commit 0146fc9d1e
4 changed files with 94 additions and 8 deletions

View file

@ -1,3 +1,7 @@
2008-06-17 Nick Clifton <nickc@redhat.com>
* app.c (do_scrub_chars): Do not UNGET an EOF value.
2008-06-16 Hans-Peter Nilsson <hp@bitrange.com> 2008-06-16 Hans-Peter Nilsson <hp@bitrange.com>
PR gas/6607 PR gas/6607

View file

@ -676,7 +676,7 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
if (ch == '\'') if (ch == '\'')
/* Change to avoid warning about unclosed string. */ /* Change to avoid warning about unclosed string. */
PUT ('`'); PUT ('`');
else else if (ch != EOF)
UNGET (ch); UNGET (ch);
break; break;
#endif #endif
@ -1097,7 +1097,8 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
ch2 = GET (); ch2 = GET ();
if (ch2 != '-') if (ch2 != '-')
{ {
UNGET (ch2); if (ch2 != EOF)
UNGET (ch2);
goto de_fault; goto de_fault;
} }
/* Read and skip to end of line. */ /* Read and skip to end of line. */
@ -1283,7 +1284,8 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
state = 9; state = 9;
if (!IS_SYMBOL_COMPONENT (ch)) if (!IS_SYMBOL_COMPONENT (ch))
{ {
UNGET (ch); if (ch != EOF)
UNGET (ch);
break; break;
} }
} }
@ -1407,4 +1409,3 @@ do_scrub_chars (int (*get) (char *, int), char *tostart, int tolen)
return to - tostart; return to - tostart;
} }

View file

@ -1,3 +1,13 @@
2008-06-17 Nick Clifton <nickc@redhat.com>
* ti.h (GET_SCNHDR_NLNNO): Provide an alternative version of this
macro which does not trigger an array bounds warning in gcc.
(PUT_SCNHDR_NLNNO): Likewise.
(GET_SCNHDR_FLAGS): Likewise.
(PUT_SCNHDR_FLAGS): Likewise.
(GET_SCNHDR_PAGE): Likewise.
(PUT_SCNHDR_PAGE): Likewise.
2007-11-05 Danny Smith <dannysmith@users.sourceforge.net> 2007-11-05 Danny Smith <dannysmith@users.sourceforge.net>
* pe.h (COFF_ENCODE_ALIGNMENT) Define. * pe.h (COFF_ENCODE_ALIGNMENT) Define.

View file

@ -2,7 +2,7 @@
customized in a target-specific file, and then this file included (see customized in a target-specific file, and then this file included (see
tic54x.h for an example). tic54x.h for an example).
Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Copyright 2000, 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -213,12 +213,81 @@ struct external_scnhdr {
/* COFF2 changes the offsets and sizes of these fields /* COFF2 changes the offsets and sizes of these fields
Assume we're dealing with the COFF2 scnhdr structure, and adjust Assume we're dealing with the COFF2 scnhdr structure, and adjust
accordingly accordingly. Note: The GNU C versions of some of these macros
*/ are necessary in order to avoid compile time warnings triggered
gcc's array bounds checking. The PUT_SCNHDR_PAGE macro also has
the advantage on not evaluating LOC twice. */
#define GET_SCNHDR_NRELOC(ABFD, LOC) \ #define GET_SCNHDR_NRELOC(ABFD, LOC) \
(COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, LOC)) (COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, LOC))
#define PUT_SCNHDR_NRELOC(ABFD, VAL, LOC) \ #define PUT_SCNHDR_NRELOC(ABFD, VAL, LOC) \
(COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, LOC)) (COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, LOC))
#ifdef __GNUC__
#define GET_SCNHDR_NLNNO(ABFD, LOC) \
({ \
int nlnno; \
char * ptr = (LOC); \
if (COFF2_P (ABFD)) \
nlnno = H_GET_32 (ABFD, ptr); \
else \
nlnno = H_GET_16 (ABFD, ptr - 2); \
nlnno; \
})
#define PUT_SCNHDR_NLNNO(ABFD, VAL, LOC) \
do \
{ \
char * ptr = (LOC); \
if (COFF2_P (ABFD)) \
H_PUT_32 (ABFD, VAL, ptr); \
else \
H_PUT_16 (ABFD, VAL, ptr - 2); \
} \
while (0)
#define GET_SCNHDR_FLAGS(ABFD, LOC) \
({ \
int flags; \
char * ptr = (LOC); \
if (COFF2_P (ABFD)) \
flags = H_GET_32 (ABFD, ptr); \
else \
flags = H_GET_16 (ABFD, ptr - 4); \
flags; \
})
#define PUT_SCNHDR_FLAGS(ABFD, VAL, LOC) \
do \
{ \
char * ptr = (LOC); \
if (COFF2_P (ABFD)) \
H_PUT_32 (ABFD, VAL, ptr); \
else \
H_PUT_16 (ABFD, VAL, ptr - 4); \
} \
while (0)
#define GET_SCNHDR_PAGE(ABFD, LOC) \
({ \
unsigned page; \
char * ptr = (LOC); \
if (COFF2_P (ABFD)) \
page = H_GET_16 (ABFD, ptr); \
else \
page = (unsigned) H_GET_8 (ABFD, ptr - 7); \
page; \
})
/* On output, make sure that the "reserved" field is zero. */
#define PUT_SCNHDR_PAGE(ABFD, VAL, LOC) \
do \
{ \
char * ptr = (LOC); \
if (COFF2_P (ABFD)) \
H_PUT_16 (ABFD, VAL, ptr); \
else \
{ \
H_PUT_8 (ABFD, VAL, ptr - 7); \
H_PUT_8 (ABFD, 0, ptr - 8); \
} \
} \
while (0)
#else
#define GET_SCNHDR_NLNNO(ABFD, LOC) \ #define GET_SCNHDR_NLNNO(ABFD, LOC) \
(COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, (LOC) - 2)) (COFF2_P (ABFD) ? H_GET_32 (ABFD, LOC) : H_GET_16 (ABFD, (LOC) - 2))
#define PUT_SCNHDR_NLNNO(ABFD, VAL, LOC) \ #define PUT_SCNHDR_NLNNO(ABFD, VAL, LOC) \
@ -229,11 +298,13 @@ struct external_scnhdr {
(COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, (LOC) - 4)) (COFF2_P (ABFD) ? H_PUT_32 (ABFD, VAL, LOC) : H_PUT_16 (ABFD, VAL, (LOC) - 4))
#define GET_SCNHDR_PAGE(ABFD, LOC) \ #define GET_SCNHDR_PAGE(ABFD, LOC) \
(COFF2_P (ABFD) ? H_GET_16 (ABFD, LOC) : (unsigned) H_GET_8 (ABFD, (LOC) - 7)) (COFF2_P (ABFD) ? H_GET_16 (ABFD, LOC) : (unsigned) H_GET_8 (ABFD, (LOC) - 7))
/* on output, make sure that the "reserved" field is zero */ /* On output, make sure that the "reserved" field is zero. */
#define PUT_SCNHDR_PAGE(ABFD, VAL, LOC) \ #define PUT_SCNHDR_PAGE(ABFD, VAL, LOC) \
(COFF2_P (ABFD) \ (COFF2_P (ABFD) \
? H_PUT_16 (ABFD, VAL, LOC) \ ? H_PUT_16 (ABFD, VAL, LOC) \
: H_PUT_8 (ABFD, VAL, (LOC) - 7), H_PUT_8 (ABFD, 0, (LOC) - 8)) : H_PUT_8 (ABFD, VAL, (LOC) - 7), H_PUT_8 (ABFD, 0, (LOC) - 8))
#endif
/* TI COFF stores section size as number of bytes (address units, not octets), /* TI COFF stores section size as number of bytes (address units, not octets),
so adjust to be number of octets, which is what BFD expects */ so adjust to be number of octets, which is what BFD expects */