/* Routines to help build PEI-format DLLs (Win32 etc)
- Copyright (C) 1998-2020 Free Software Foundation, Inc.
+ Copyright (C) 1998-2021 Free Software Foundation, Inc.
Written by DJ Delorie <dj@cygnus.com>
This file is part of the GNU Binutils.
int pe_use_nul_prefixed_import_tables = 0;
int pe_use_coff_long_section_names = -1;
int pe_leading_underscore = -1;
-int pe_dll_enable_reloc_section = 0;
+int pe_dll_enable_reloc_section = 1;
/* Static variables and types. */
static bfd_boolean
is_import (const char* n)
{
- return (CONST_STRNEQ (n, "__imp_"));
+ return (startswith (n, "__imp_"));
}
/* abfd is a bfd containing n (or NULL)
static void
generate_reloc (bfd *abfd, struct bfd_link_info *info)
{
-
/* For .reloc stuff. */
reloc_data_type *reloc_data;
int total_relocs = 0;
bfd *b;
struct bfd_section *s;
+ if (reloc_s == NULL)
+ return;
total_relocs = 0;
for (b = info->input_bfds; b; b = b->link.next)
for (s = b->sections; s; s = s->next)
if (s->output_section->vma == 0)
{
/* Huh? Shouldn't happen, but punt if it does. */
+#if 0 /* This happens when linking with --just-symbols=<file>, so do not generate an error. */
einfo (_("%P: zero vma section reloc detected: `%s' #%d f=%d\n"),
s->output_section->name, s->output_section->index,
s->output_section->flags);
+#endif
continue;
}
&& relocs[i]->howto->type != pe_details->imagebase_reloc)
{
struct bfd_symbol *sym = *relocs[i]->sym_ptr_ptr;
+ const struct bfd_link_hash_entry *blhe
+ = bfd_wrapped_link_hash_lookup (abfd, info, sym->name,
+ FALSE, FALSE, FALSE);
/* Don't create relocs for undefined weak symbols. */
if (sym->flags == BSF_WEAK)
{
- struct bfd_link_hash_entry *blhe
- = bfd_wrapped_link_hash_lookup (abfd, info, sym->name,
- FALSE, FALSE, FALSE);
if (blhe && blhe->type == bfd_link_hash_undefweak)
{
/* Check aux sym and see if it is defined or not. */
if (!strcmp (s->name, ".eh_frame"))
continue;
}
+ /* Nor for absolute symbols. */
+ else if (blhe && ldexp_is_final_sym_absolute (blhe)
+ && (!blhe->linker_def
+ || (strcmp (sym->name, "__image_base__")
+ && strcmp (sym->name, U ("__ImageBase")))))
+ continue;
reloc_data[total_relocs].vma = sec_vma + relocs[i]->address;
reloc_data[total_relocs].idx = total_relocs;
if (page_ptr != (bfd_vma) -1)
bfd_put_32 (abfd, reloc_sz - page_ptr, reloc_d + page_ptr + 4);
-
- while (reloc_sz < reloc_s->size)
- reloc_d[reloc_sz++] = 0;
}
/* Given the exiting def_file structure, print out a .DEF file that
if (pe_details->underscored)
lname[0] = '_';
else
- strcpy (lname, lname + 1);
+ /* Use memmove rather than strcpy as that
+ can handle overlapping buffers. */
+ memmove (lname, lname + 1, strlen (lname));
key.key = lname;
kv = bsearch (&key, udef_table, undef_count,
sizeof (struct key_value), undef_sort_cmp);
/* Skip unwanted symbols, which are
exported in buggy auto-import releases. */
- if (! CONST_STRNEQ (erva + name_rva, "__nm_"))
+ if (! startswith (erva + name_rva, "__nm_"))
{
int is_dup = 0;
/* is_data is true if the address is in the data, rdata or bss
/* Do the assignments again. */
lang_do_assignments (lang_final_phase_enum);
}
- reloc_s->contents = reloc_d;
+ if (reloc_s)
+ reloc_s->contents = reloc_d;
}
bfd_boolean