- stroff = get_stab_string_offset (string, stabstr_secname);
- if (what == 's')
- {
- /* Release the string, if nobody else has used the obstack. */
- if (saved_string_obstack_end == notes.next_free)
- obstack_free (¬es, string);
- }
+ stroff = get_stab_string_offset (string, stabstr_secname,
+ stab_secname_obstack_end != NULL);
+
+ /* Release the string, if nobody else has used the obstack. */
+ if (saved_string_obstack_end != NULL
+ && saved_string_obstack_end == obstack_next_free (¬es))
+ obstack_free (¬es, string);
+ /* Similarly for the section name. This must be done before
+ creating symbols below, which uses the notes obstack. */
+ if (seg->name != stab_secname
+ && stab_secname_obstack_end != NULL
+ && stab_secname_obstack_end == obstack_next_free (¬es))
+ obstack_free (¬es, stab_secname);