/* libbfd.h -- Declarations used by bfd library *implementation*.
(This include file is not for users of the library.)
- Copyright (C) 1990-2022 Free Software Foundation, Inc.
+ Copyright (C) 1990-2024 Free Software Foundation, Inc.
Written by Cygnus Support.
extern "C" {
#endif
-/* If you want to read and write large blocks, you might want to do it
- in quanta of this amount */
-#define DEFAULT_BUFFERSIZE 8192
-
/* Set a tdata field. Can't use the other macros for this, since they
do casts, and casting to the left of assignment isn't portable. */
#define set_tdata(bfd, v) ((bfd)->tdata.any = (v))
struct artdata
{
- file_ptr first_file_filepos;
+ ufile_ptr first_file_filepos;
/* Speed up searching the armap */
htab_t cache;
- bfd *archive_head; /* Only interesting in output routines. */
carsym *symdefs; /* The symdef entries. */
symindex symdef_count; /* How many there are. */
char *extended_names; /* Clever intel extension. */
memcpy (buf, str, len);
return buf;
}
-/* These routines allocate and free things on the BFD's objalloc. */
-
-extern void bfd_release
- (bfd *, void *) ATTRIBUTE_HIDDEN;
extern bfd * _bfd_create_empty_archive_element_shell
(bfd *) ATTRIBUTE_HIDDEN;
extern bool _bfd_compute_and_write_armap
(bfd *, unsigned int) ATTRIBUTE_HIDDEN;
extern bfd *_bfd_get_elt_at_filepos
- (bfd *, file_ptr) ATTRIBUTE_HIDDEN;
+ (bfd *, file_ptr, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
extern bfd *_bfd_generic_get_elt_at_index
(bfd *, symindex) ATTRIBUTE_HIDDEN;
-extern bfd * _bfd_new_bfd
- (void) ATTRIBUTE_HIDDEN;
-extern bool _bfd_free_cached_info
- (bfd *) ATTRIBUTE_HIDDEN;
extern bool _bfd_bool_bfd_false
(bfd *) ATTRIBUTE_HIDDEN;
extern void _bfd_void_bfd_asection
(bfd *, asection *) ATTRIBUTE_HIDDEN;
-extern bfd *_bfd_new_bfd_contained_in
- (bfd *) ATTRIBUTE_HIDDEN;
extern bfd_cleanup _bfd_dummy_target
(bfd *) ATTRIBUTE_HIDDEN;
#define _bfd_no_cleanup _bfd_void_bfd
extern bool _bfd_archive_close_and_cleanup
(bfd *) ATTRIBUTE_HIDDEN;
extern void _bfd_unlink_from_archive_parent (bfd *) ATTRIBUTE_HIDDEN;
-#define _bfd_generic_bfd_free_cached_info _bfd_bool_bfd_true
+#define _bfd_generic_bfd_free_cached_info _bfd_free_cached_info
extern bool _bfd_generic_new_section_hook
(bfd *, asection *) ATTRIBUTE_HIDDEN;
extern bool _bfd_generic_get_section_contents
(bfd *, asection *, void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
-extern bool _bfd_generic_get_section_contents_in_window
- (bfd *, asection *, bfd_window *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN;
/* Generic routines to use for BFD_JUMP_TABLE_COPY. Use
BFD_JUMP_TABLE_COPY (_bfd_generic). */
(bfd *, asymbol **, asection *, bfd_vma,
const char **, const char **, unsigned int *, unsigned int *)
ATTRIBUTE_HIDDEN;
+extern bool _bfd_nosymbols_find_nearest_line_with_alt
+ (bfd *, const char *, asymbol **, asection *, bfd_vma,
+ const char **, const char **, unsigned int *, unsigned int *)
+ ATTRIBUTE_HIDDEN;
extern bool _bfd_nosymbols_find_line
(bfd *, asymbol **, asymbol *, const char **, unsigned int *)
ATTRIBUTE_HIDDEN;
extern bool _bfd_nosymbols_find_inliner_info
(bfd *, const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
extern asymbol *_bfd_nosymbols_bfd_make_debug_symbol
- (bfd *, void *, unsigned long) ATTRIBUTE_HIDDEN;
+ (bfd *) ATTRIBUTE_HIDDEN;
extern long _bfd_nosymbols_read_minisymbols
(bfd *, bool, void **, unsigned int *) ATTRIBUTE_HIDDEN;
extern asymbol *_bfd_nosymbols_minisymbol_to_symbol
(bfd *, asymbol **, asection *, bfd_vma,
const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN;
+/* Clean up the data used to handle DWARF 1 debugging information. */
+extern void _bfd_dwarf1_cleanup_debug_info
+ (bfd *, void **) ATTRIBUTE_HIDDEN;
+
struct dwarf_debug_section
{
const char * uncompressed_name;
const char **, const char **, unsigned int *, unsigned int *,
const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN;
+/* Find the nearest line using DWARF 2 debugging information, with
+ the option of specifying a .gnu_debugaltlink file. */
+extern int _bfd_dwarf2_find_nearest_line_with_alt
+ (bfd *, const char *, asymbol **, asymbol *, asection *, bfd_vma,
+ const char **, const char **, unsigned int *, unsigned int *,
+ const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN;
+
/* Find the bias between DWARF addresses and real addresses. */
extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias
(asymbol **, void **) ATTRIBUTE_HIDDEN;
extern void _bfd_dwarf2_cleanup_debug_info
(bfd *, void **) ATTRIBUTE_HIDDEN;
+extern void _bfd_stab_cleanup
+ (bfd *, void **) ATTRIBUTE_HIDDEN;
+
/* Create a new section entry. */
extern struct bfd_hash_entry *bfd_section_hash_newfunc
(struct bfd_hash_entry *, struct bfd_hash_table *, const char *)
extern bfd_reloc_status_type _bfd_clear_contents
(reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
-/* Link stabs in sections in the first pass. */
-
-extern bool _bfd_link_section_stabs
- (bfd *, struct stab_info *, asection *, asection *, void **,
- bfd_size_type *) ATTRIBUTE_HIDDEN;
-
-/* Eliminate stabs for discarded functions and symbols. */
-extern bool _bfd_discard_section_stabs
- (bfd *, asection *, void *, bool (*) (bfd_vma, void *), void *)
- ATTRIBUTE_HIDDEN;
-
-/* Write out the .stab section when linking stabs in sections. */
-
-extern bool _bfd_write_section_stabs
- (bfd *, struct stab_info *, asection *, void **, bfd_byte *)
- ATTRIBUTE_HIDDEN;
-
-/* Write out the .stabstr string table when linking stabs in sections. */
-
-extern bool _bfd_write_stab_strings
- (bfd *, struct stab_info *) ATTRIBUTE_HIDDEN;
-
-/* Find an offset within a .stab section when linking stabs in
- sections. */
-
-extern bfd_vma _bfd_stab_section_offset
- (asection *, void *, bfd_vma) ATTRIBUTE_HIDDEN;
-
/* Register a SEC_MERGE section as a candidate for merging. */
extern bool _bfd_add_merge_section
extern void _bfd_merge_sections_free (void *) ATTRIBUTE_HIDDEN;
-/* Create a string table. */
-extern struct bfd_strtab_hash *_bfd_stringtab_init
- (void) ATTRIBUTE_HIDDEN;
-
-/* Create an XCOFF .debug section style string table. */
-extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init
- (bool isxcoff64) ATTRIBUTE_HIDDEN;
-
-/* Free a string table. */
-extern void _bfd_stringtab_free
- (struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN;
-
-/* Get the size of a string table. */
-extern bfd_size_type _bfd_stringtab_size
- (struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN;
-
-/* Add a string to a string table. */
-extern bfd_size_type _bfd_stringtab_add
- (struct bfd_strtab_hash *, const char *, bool hash, bool copy)
- ATTRIBUTE_HIDDEN;
-
-/* Write out a string table. */
-extern bool _bfd_stringtab_emit
- (bfd *, struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN;
-\f
/* Macros to tell if bfds are read or write enabled.
Note that bfds open for read may be scribbled into if the fd passed
/* Functions shared by the ECOFF and MIPS ELF backends, which have no
other common header files. */
-#if defined(__STDC__) || defined(ALMOST_STDC)
+struct ecoff_debug_info;
+struct ecoff_debug_swap;
+struct ecoff_extr;
struct ecoff_find_line;
-#endif
+extern void _bfd_ecoff_free_ecoff_debug_info
+ (struct ecoff_debug_info *debug);
extern bool _bfd_ecoff_locate_line
(bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
const struct ecoff_debug_swap * const, struct ecoff_find_line *,
extern bfd_byte * _bfd_write_unsigned_leb128
(bfd_byte *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
-extern struct bfd_link_info *_bfd_get_link_info (bfd *);
-
-extern bool _bfd_link_keep_memory (struct bfd_link_info *)
+extern struct bfd_link_info *_bfd_get_link_info (bfd *)
ATTRIBUTE_HIDDEN;
+#ifdef HAVE_MMAP
+extern uintptr_t _bfd_pagesize ATTRIBUTE_HIDDEN;
+extern uintptr_t _bfd_pagesize_m1 ATTRIBUTE_HIDDEN;
+extern uintptr_t _bfd_minimum_mmap_size ATTRIBUTE_HIDDEN;
+#endif
+
#if GCC_VERSION >= 7000
#define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res)
#else
#define _bfd_constant_p(v) 0
#endif
-static inline bfd_byte *
+static inline void *
_bfd_alloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
{
- bfd_byte *mem;
+ void *mem;
if (!_bfd_constant_p (rsize))
{
ufile_ptr filesize = bfd_get_file_size (abfd);
mem = bfd_alloc (abfd, asize);
if (mem != NULL)
{
- if (bfd_bread (mem, rsize, abfd) == rsize)
+ if (bfd_read (mem, rsize, abfd) == rsize)
return mem;
bfd_release (abfd, mem);
}
return NULL;
}
-static inline bfd_byte *
+#ifdef USE_MMAP
+extern void *_bfd_mmap_readonly_persistent
+ (bfd *, size_t) ATTRIBUTE_HIDDEN;
+extern void *_bfd_mmap_readonly_temporary
+ (bfd *, size_t, void **, size_t *) ATTRIBUTE_HIDDEN;
+extern void _bfd_munmap_readonly_temporary
+ (void *, size_t) ATTRIBUTE_HIDDEN;
+#else
+#define _bfd_mmap_readonly_persistent(abfd, rsize) \
+ _bfd_alloc_and_read (abfd, rsize, rsize)
+#define _bfd_munmap_readonly_temporary(ptr, rsize) free (ptr)
+#endif
+
+extern bool _bfd_mmap_read_temporary
+ (void **, size_t *, void **, bfd *, bool) ATTRIBUTE_HIDDEN;
+
+static inline void *
_bfd_malloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
{
- bfd_byte *mem;
+ void *mem;
if (!_bfd_constant_p (rsize))
{
ufile_ptr filesize = bfd_get_file_size (abfd);
mem = bfd_malloc (asize);
if (mem != NULL)
{
- if (bfd_bread (mem, rsize, abfd) == rsize)
+ if (bfd_read (mem, rsize, abfd) == rsize)
return mem;
free (mem);
}
return NULL;
}
+
+#ifndef USE_MMAP
+static inline void *
+_bfd_mmap_readonly_temporary (bfd *abfd, size_t rsize, void **map_addr,
+ size_t *map_size)
+{
+ void *mem = _bfd_malloc_and_read (abfd, rsize, rsize);
+ *map_addr = mem;
+ *map_size = rsize;
+ return mem;
+}
+#endif