X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fread.c;h=8f93c2ba2b461a22440889e67875fb40a34275f4;hb=423054beadf317757d43aefb9eddfe711a42e3e1;hp=f011149bb36392fbb7c1fae5054ddce457e3f382;hpb=9dcbfff1e02778bac6fb723640724c38001a8f0a;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/read.c b/gas/read.c index f011149bb3..8f93c2ba2b 100644 --- a/gas/read.c +++ b/gas/read.c @@ -1,5 +1,5 @@ /* read.c - read a source file - - Copyright (C) 1986-2018 Free Software Foundation, Inc. + Copyright (C) 1986-2020 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -742,7 +742,7 @@ assemble_one (char *line) static bfd_boolean in_bss (void) { - flagword flags = bfd_get_section_flags (stdoutput, now_seg); + flagword flags = bfd_section_flags (now_seg); return (flags & SEC_ALLOC) && !(flags & (SEC_LOAD | SEC_HAS_CONTENTS)); } @@ -1052,7 +1052,8 @@ read_a_source_file (const char *name) { char *s2 = s; - strncpy (original_case_string, s2, sizeof (original_case_string)); + strncpy (original_case_string, s2, + sizeof (original_case_string) - 1); original_case_string[sizeof (original_case_string) - 1] = 0; while (*s2) @@ -1331,8 +1332,7 @@ read_a_source_file (const char *name) new_length += 100; } - if (tmp_buf) - free (tmp_buf); + free (tmp_buf); /* We've "scrubbed" input to the preferred format. In the process we may have consumed the whole of the remaining @@ -1800,8 +1800,7 @@ s_comm_internal (int param, out: if (flag_mri) mri_comment_end (stop, stopc); - if (name != NULL) - free (name); + free (name); return symbolP; } @@ -1861,8 +1860,7 @@ s_mri_common (int small ATTRIBUTE_UNUSED) sym = symbol_find_or_make (name); c = restore_line_pointer (c); - if (alc != NULL) - free (alc); + free (alc); if (*input_line_pointer != ',') align = 0; @@ -2419,7 +2417,7 @@ s_linkonce (int ignore ATTRIBUTE_UNUSED) if ((bfd_applicable_section_flags (stdoutput) & SEC_LINK_ONCE) == 0) as_warn (_(".linkonce is not supported for this object file format")); - flags = bfd_get_section_flags (stdoutput, now_seg); + flags = bfd_section_flags (now_seg); flags |= SEC_LINK_ONCE; switch (type) { @@ -2438,7 +2436,7 @@ s_linkonce (int ignore ATTRIBUTE_UNUSED) flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; break; } - if (!bfd_set_section_flags (stdoutput, now_seg, flags)) + if (!bfd_set_section_flags (now_seg, flags)) as_bad (_("bfd_set_section_flags: %s"), bfd_errmsg (bfd_get_error ())); } @@ -2464,7 +2462,7 @@ bss_alloc (symbolS *symbolP, addressT size, unsigned int align) { bss_seg = subseg_new (".sbss", 1); seg_info (bss_seg)->bss = 1; - if (!bfd_set_section_flags (stdoutput, bss_seg, SEC_ALLOC)) + if (!bfd_set_section_flags (bss_seg, SEC_ALLOC | SEC_SMALL_DATA)) as_warn (_("error setting flags for \".sbss\": %s"), bfd_errmsg (bfd_get_error ())); } @@ -2957,9 +2955,9 @@ s_mri_sect (char *type ATTRIBUTE_UNUSED) flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY | SEC_ROM; if (flags != SEC_NO_FLAGS) { - if (!bfd_set_section_flags (stdoutput, seg, flags)) + if (!bfd_set_section_flags (seg, flags)) as_warn (_("error setting flags for \"%s\": %s"), - bfd_section_name (stdoutput, seg), + bfd_section_name (seg), bfd_errmsg (bfd_get_error ())); } } @@ -3760,7 +3758,8 @@ ignore_rest_of_line (void) input_line_pointer++; /* Return pointing just after end-of-line. */ - know (is_end_of_line[(unsigned char) input_line_pointer[-1]]); + if (input_line_pointer <= buffer_limit) + know (is_end_of_line[(unsigned char) input_line_pointer[-1]]); } /* Sets frag for given symbol to zero_address_frag, except when the @@ -5252,7 +5251,7 @@ s_leb128 (int sign) do { - deferred_expression (&exp); + expression (&exp); emit_leb128_expr (&exp, sign); } while (*input_line_pointer++ == ','); @@ -5364,8 +5363,6 @@ stringer (int bits_appendzero) if (append_zero) stringer_append_char (0, bitsize); - know (input_line_pointer[-1] == '\"'); - #if !defined(NO_LISTING) && defined (OBJ_ELF) /* In ELF, when gcc is emitting DWARF 1 debugging output, it will emit .string with a filename in the .debug section @@ -5390,8 +5387,11 @@ stringer (int bits_appendzero) c = get_single_number (); stringer_append_char (c, bitsize); if (*input_line_pointer != '>') - as_bad (_("expected ")); - + { + as_bad (_("expected ")); + ignore_rest_of_line (); + return; + } input_line_pointer++; break; case ',': @@ -5433,8 +5433,9 @@ next_char_of_string (void) bump_line_counters (); break; -#ifndef NO_STRING_ESCAPES case '\\': + if (!TC_STRING_ESCAPES) + break; switch (c = *input_line_pointer++ & CHAR_MASK) { case 'b': @@ -5536,7 +5537,6 @@ next_char_of_string (void) break; } break; -#endif /* ! defined (NO_STRING_ESCAPES) */ default: break; @@ -5808,11 +5808,10 @@ s_incbin (int x ATTRIBUTE_UNUSED) as_warn (_("truncated file `%s', %ld of %ld bytes read"), path, bytes, count); } -done: + done: if (binfile != NULL) fclose (binfile); - if (path) - free (path); + free (path); } /* .include -- include a file at this point. */ @@ -5872,7 +5871,7 @@ s_include (int arg ATTRIBUTE_UNUSED) free (path); path = filename; -gotit: + gotit: /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */ register_dependency (path); input_scrub_insert_file (path); @@ -6212,10 +6211,7 @@ static char *saved_limit; overruns should not occur. Saves the current input line pointer so that it can be restored by calling restore_ilp(). - Does not support recursion. - - FIXME: This function is currently only used by stabs.c but that - should be extended to other files in the gas source directory. */ + Does not support recursion. */ void temp_ilp (char *buf)