/* objcopy.c -- copy object file from input to output, optionally massaging it.
- Copyright (C) 1991-2019 Free Software Foundation, Inc.
+ Copyright (C) 1991-2020 Free Software Foundation, Inc.
This file is part of GNU Binutils.
long symval;
flagword flags;
char * section;
- char * othersym;
+ const char * othersym;
};
typedef struct section_rename
string can't be parsed. */
static flagword
-parse_symflags (const char *s, char **other)
+parse_symflags (const char *s, const char **other)
{
flagword ret;
const char *snext;
return FALSE;
}
+/* Empty name is hopefully never a valid symbol name. */
+static const char * empty_name = "";
+
static bfd_boolean
need_sym_before (struct addsym_node **node, const char *sym)
{
{
if (!ptr->othersym)
break;
+ if (ptr->othersym == empty_name)
+ continue;
else if (strcmp (ptr->othersym, sym) == 0)
{
- free (ptr->othersym);
- ptr->othersym = ""; /* Empty name is hopefully never a valid symbol name. */
+ free ((char *) ptr->othersym);
+ ptr->othersym = empty_name;
*node = ptr;
return TRUE;
}
{
if (ptr->othersym)
{
- if (strcmp (ptr->othersym, ""))
+ if (ptr->othersym != empty_name)
fatal (_("'before=%s' not found"), ptr->othersym);
}
else
bfd_vma prev_start = 0;
bfd_vma prev_end = 0;
- new = new_contents = xmalloc (size);
+ /* Not sure how, but the notes might grow in size.
+ (eg see PR 1774507). Allow for this here. */
+ new = new_contents = xmalloc (size * 2);
for (pnote = pnotes, old = contents;
pnote < pnotes_end;
pnote ++)
#endif
new_size = new - new_contents;
- memcpy (contents, new_contents, new_size);
- size = new_size;
+ if (new_size < size)
+ {
+ memcpy (contents, new_contents, new_size);
+ size = new_size;
+ }
free (new_contents);
done:
imach = bfd_get_mach (ibfd);
if (input_arch)
{
- if (bfd_get_arch_info (ibfd) == NULL
- || bfd_get_arch_info (ibfd)->arch == bfd_arch_unknown)
+ if (iarch == bfd_arch_unknown)
{
iarch = input_arch->arch;
imach = input_arch->mach;
non_fatal (_("Input file `%s' ignores binary architecture parameter."),
bfd_get_archive_filename (ibfd));
}
+ if (iarch == bfd_arch_unknown
+ && bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ && bfd_get_flavour (obfd) == bfd_target_elf_flavour)
+ {
+ const struct elf_backend_data *bed = get_elf_backend_data (obfd);
+ iarch = bed->arch;
+ imach = 0;
+ }
if (!bfd_set_arch_mach (obfd, iarch, imach)
&& (ibfd->target_defaulted
|| bfd_get_arch (ibfd) != bfd_get_arch (obfd)))
status = 1;
return;
}
+
+ if (gnu_debuglink_filename != NULL)
+ {
+ non_fatal (_("--add-gnu-debuglink ignored for archive %s"),
+ bfd_get_filename (ibfd));
+ gnu_debuglink_filename = NULL;
+ }
+
/* This is a no-op on non-Coff targets. */
set_long_section_mode (obfd, ibfd, long_section_names);