/* Generic BFD library interface and support routines.
- Copyright (C) 1990-2020 Free Software Foundation, Inc.
+ Copyright (C) 1990-2021 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
. {* Set if this is a slim LTO object not loaded with a compiler plugin. *}
. unsigned int lto_slim_object : 1;
.
+. {* Do not attempt to modify this file. Set when detecting errors
+. that BFD is not prepared to handle for objcopy/strip. *}
+. unsigned int read_only : 1;
+.
. {* Set to dummy BFD created when claimed by a compiler plug-in
. library. *}
. bfd *plugin_dummy_bfd;
char *buf;
const char *msg = bfd_errmsg (input_error);
- if (asprintf (&buf, _(bfd_errmsgs [error_tag]), input_bfd->filename, msg)
- != -1)
+ if (asprintf (&buf, _(bfd_errmsgs [error_tag]),
+ bfd_get_filename (input_bfd), msg) != -1)
return buf;
/* Ick, what to do on out of memory? */
else if (abfd->my_archive
&& !bfd_is_thin_archive (abfd->my_archive))
result = fprintf (stream, "%s(%s)",
- abfd->my_archive->filename,
- abfd->filename);
+ bfd_get_filename (abfd->my_archive),
+ bfd_get_filename (abfd));
else
- result = fprintf (stream, "%s", abfd->filename);
+ result = fprintf (stream, "%s", bfd_get_filename (abfd));
}
else
PRINT_TYPE (void *, p);
no place to store this information in the COFF back end.
Should enough other COFF targets add support for DWARF2,
a place will have to be found. Until then, this hack will do. */
- if (CONST_STRNEQ (name, "coff-go32")
+ if (startswith (name, "coff-go32")
|| strcmp (name, "pe-i386") == 0
|| strcmp (name, "pei-i386") == 0
|| strcmp (name, "pe-x86-64") == 0
|| strcmp (name, "aix5coff64-rs6000") == 0)
return 1;
- if (CONST_STRNEQ (name, "mach-o"))
+ if (startswith (name, "mach-o"))
return 0;
bfd_set_error (bfd_error_wrong_format);
return 0;
}
-static void
-bfd_elf_set_pagesize (const bfd_target *target, bfd_vma size,
- int offset, const bfd_target *orig_target)
-{
- if (target->flavour == bfd_target_elf_flavour)
- {
- const struct elf_backend_data *bed;
-
- bed = xvec_get_elf_backend_data (target);
- *((bfd_vma *) ((char *) bed + offset)) = size;
- }
-
- if (target->alternative_target
- && target->alternative_target != orig_target)
- bfd_elf_set_pagesize (target->alternative_target, size, offset,
- orig_target);
-}
-
-/*
-FUNCTION
- bfd_emul_set_maxpagesize
-
-SYNOPSIS
- void bfd_emul_set_maxpagesize (const char *, bfd_vma);
-
-DESCRIPTION
- For ELF, set the maximum page size for the emulation. It is
- a no-op for other formats.
-
-*/
-
-void
-bfd_emul_set_maxpagesize (const char *emul, bfd_vma size)
-{
- const bfd_target *target;
-
- target = bfd_find_target (emul, NULL);
- if (target)
- bfd_elf_set_pagesize (target, size,
- offsetof (struct elf_backend_data,
- maxpagesize), target);
-}
-
/*
FUNCTION
bfd_emul_get_commonpagesize
return 0;
}
-/*
-FUNCTION
- bfd_emul_set_commonpagesize
-
-SYNOPSIS
- void bfd_emul_set_commonpagesize (const char *, bfd_vma);
-
-DESCRIPTION
- For ELF, set the common page size for the emulation. It is
- a no-op for other formats.
-
-*/
-
-void
-bfd_emul_set_commonpagesize (const char *emul, bfd_vma size)
-{
- const bfd_target *target;
-
- target = bfd_find_target (emul, NULL);
- if (target)
- bfd_elf_set_pagesize (target, size,
- offsetof (struct elf_backend_data,
- commonpagesize), target);
-}
-
/*
FUNCTION
bfd_demangle
res = cplus_demangle (name, options);
- if (alloc != NULL)
- free (alloc);
+ free (alloc);
if (res == NULL)
{
if ((abfd->flags & BFD_COMPRESS_GABI) != 0)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ struct bfd_elf_section_data * esd = elf_section_data (sec);
/* Set the SHF_COMPRESSED bit. */
elf_section_flags (sec) |= SHF_COMPRESSED;
&echdr->ch_addralign);
/* bfd_log2 (alignof (Elf32_Chdr)) */
bfd_set_section_alignment (sec, 2);
+ esd->this_hdr.sh_addralign = 4;
}
else
{
&echdr->ch_addralign);
/* bfd_log2 (alignof (Elf64_Chdr)) */
bfd_set_section_alignment (sec, 3);
+ esd->this_hdr.sh_addralign = 8;
}
break;
}
return size;
/* Convert GNU property size. */
- if (CONST_STRNEQ (isec->name, NOTE_GNU_PROPERTY_SECTION_NAME))
+ if (startswith (isec->name, NOTE_GNU_PROPERTY_SECTION_NAME))
return _bfd_elf_convert_gnu_property_size (ibfd, obfd);
/* Do nothing if input file will be decompressed. */
return TRUE;
/* Convert GNU properties. */
- if (CONST_STRNEQ (isec->name, NOTE_GNU_PROPERTY_SECTION_NAME))
+ if (startswith (isec->name, NOTE_GNU_PROPERTY_SECTION_NAME))
return _bfd_elf_convert_gnu_properties (ibfd, isec, obfd, ptr,
ptr_size);
*ptr_size = size;
return TRUE;
}
+
+/* Get the linker information. */
+
+struct bfd_link_info *
+_bfd_get_link_info (bfd *abfd)
+{
+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+ return NULL;
+
+ return elf_link_info (abfd);
+}