rm -f e${EMULATION_NAME}.c
(echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
fragment <<EOF
-/* Copyright (C) 2006-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2018 Free Software Foundation, Inc.
Written by Kai Tietz, OneVision Software GmbH&CoKg.
This file is part of the GNU Binutils.
#define GET_INIT_SYMBOL_NAME(IDX) \
(init[(IDX)].symbol \
- + ((init[(IDX)].is_c_symbol == FALSE || (is_underscoring () == 1)) ? 0 : 1))
+ + ((!init[(IDX)].is_c_symbol || is_underscoring () == 1) ? 0 : 1))
/* Decorates the C visible symbol by underscore, if target requires. */
#define U(CSTR) \
int i;
static const struct
- {
- const int value;
- const char *entry;
- }
+ {
+ const int value;
+ const char *entry;
+ }
v[] =
{
{ 1, "NtProcessStartup" },
else
{
for (i = 0; v[i].entry; i++)
- if (v[i].value == pep_subsystem)
- break;
+ if (v[i].value == pep_subsystem)
+ break;
/* If no match, use the default. */
if (v[i].entry != NULL)
- entry = v[i].entry;
+ entry = v[i].entry;
else
- entry = default_entry;
+ entry = default_entry;
}
/* Now we check target's default for getting proper symbol_char. */
}
static int
-make_import_fixup (arelent *rel, asection *s)
+make_import_fixup (arelent *rel, asection *s, char *name)
{
struct bfd_symbol *sym = *rel->sym_ptr_ptr;
char addend[8];
memset (addend, 0, sizeof (addend));
switch ((rel->howto->bitsize))
{
- case 8:
- suc = bfd_get_section_contents (s->owner, s, addend, rel->address, 1);
- if (suc && rel->howto->pc_relative)
- _addend = (bfd_vma) ((bfd_signed_vma) ((char) bfd_get_8 (s->owner, addend)));
- else if (suc)
- _addend = ((bfd_vma) bfd_get_8 (s->owner, addend)) & 0xff;
- break;
- case 16:
- suc = bfd_get_section_contents (s->owner, s, addend, rel->address, 2);
- if (suc && rel->howto->pc_relative)
- _addend = (bfd_vma) ((bfd_signed_vma) ((short) bfd_get_16 (s->owner, addend)));
- else if (suc)
- _addend = ((bfd_vma) bfd_get_16 (s->owner, addend)) & 0xffff;
- break;
- case 32:
- suc = bfd_get_section_contents (s->owner, s, addend, rel->address, 4);
- if (suc && rel->howto->pc_relative)
- _addend = (bfd_vma) ((bfd_signed_vma) ((int) bfd_get_32 (s->owner, addend)));
- else if (suc)
- _addend = ((bfd_vma) bfd_get_32 (s->owner, addend)) & 0xffffffff;
- break;
- case 64:
- suc = bfd_get_section_contents (s->owner, s, addend, rel->address, 8);
- if (suc)
- _addend = ((bfd_vma) bfd_get_64 (s->owner, addend));
- break;
+ case 8:
+ suc = bfd_get_section_contents (s->owner, s, addend, rel->address, 1);
+ if (suc && rel->howto->pc_relative)
+ _addend = bfd_get_signed_8 (s->owner, addend);
+ else if (suc)
+ _addend = bfd_get_8 (s->owner, addend);
+ break;
+ case 16:
+ suc = bfd_get_section_contents (s->owner, s, addend, rel->address, 2);
+ if (suc && rel->howto->pc_relative)
+ _addend = bfd_get_signed_16 (s->owner, addend);
+ else if (suc)
+ _addend = bfd_get_16 (s->owner, addend);
+ break;
+ case 32:
+ suc = bfd_get_section_contents (s->owner, s, addend, rel->address, 4);
+ if (suc && rel->howto->pc_relative)
+ _addend = bfd_get_signed_32 (s->owner, addend);
+ else if (suc)
+ _addend = bfd_get_32 (s->owner, addend);
+ break;
+ case 64:
+ suc = bfd_get_section_contents (s->owner, s, addend, rel->address, 8);
+ if (suc)
+ _addend = bfd_get_64 (s->owner, addend);
+ break;
}
if (! suc)
einfo (_("%C: Cannot get section contents - auto-import exception\n"),
if (pep_dll_extra_pe_debug)
{
- printf ("import of 0x%lx(0x%lx) sec_addr=0x%lx", (long) _addend, (long) rel->addend, (long) rel->address);
- if (rel->howto->pc_relative) printf (" pcrel");
- printf (" %d bit rel.\n",(int) rel->howto->bitsize);
- }
- pep_create_import_fixup (rel, s, _addend);
+ printf ("import of 0x%lx(0x%lx) sec_addr=0x%lx",
+ (long) _addend, (long) rel->addend, (long) rel->address);
+ if (rel->howto->pc_relative)
+ printf (" pcrel");
+ printf (" %d bit rel.\n", (int) rel->howto->bitsize);
+ }
+ pep_create_import_fixup (rel, s, _addend, name);
return 1;
}
pep_find_data_imports (void)
{
struct bfd_link_hash_entry *undef, *sym;
+ size_t namelen;
+ char *buf, *name;
if (link_info.pei386_auto_import == 0)
return;
- for (undef = link_info.hash->undefs; undef; undef=undef->u.undef.next)
+ namelen = 0;
+ for (undef = link_info.hash->undefs; undef; undef = undef->u.undef.next)
{
if (undef->type == bfd_link_hash_undefined)
{
- /* C++ symbols are *long*. */
-#define BUF_SIZE 4096
- char buf[BUF_SIZE];
+ size_t len = strlen (undef->root.string);
+ if (namelen < len)
+ namelen = len;
+ }
+ }
+ if (namelen == 0)
+ return;
+
+ /* We are being a bit cunning here. The buffer will have space for
+ prefixes at the beginning. The prefix is modified here and in a
+ number of functions called from this function. */
+#define PREFIX_LEN 32
+ buf = xmalloc (PREFIX_LEN + namelen + 1);
+ name = buf + PREFIX_LEN;
+
+ for (undef = link_info.hash->undefs; undef; undef = undef->u.undef.next)
+ {
+ if (undef->type == bfd_link_hash_undefined)
+ {
+ char *impname;
if (pep_dll_extra_pe_debug)
printf ("%s:%s\n", __FUNCTION__, undef->root.string);
- if (strlen (undef->root.string) > (BUF_SIZE - 6))
- {
- /* PR linker/18466. */
- einfo (_("%P: internal error: symbol too long: %s\n"),
- undef->root.string);
- return;
- }
+ strcpy (name, undef->root.string);
+ impname = name - (sizeof "__imp_" - 1);
+ memcpy (impname, "__imp_", sizeof "__imp_" - 1);
- sprintf (buf, "__imp_%s", undef->root.string);
-
- sym = bfd_link_hash_lookup (link_info.hash, buf, 0, 0, 1);
+ sym = bfd_link_hash_lookup (link_info.hash, impname, 0, 0, 1);
if (sym && sym->type == bfd_link_hash_defined)
{
if (pep_dll_extra_pe_debug)
printf ("->%s\n", symbols[i]->name);
- pep_data_import_dll = (char*) (symbols[i]->name +
- U_SIZE ("_head_") - 1);
+ pep_data_import_dll = (char *) (symbols[i]->name
+ + U_SIZE ("_head_") - 1);
break;
}
- pep_walk_relocs_of_symbol (&link_info, undef->root.string,
- make_import_fixup);
+ pep_walk_relocs_of_symbol (&link_info, name, make_import_fixup);
/* Let's differentiate it somehow from defined. */
undef->type = bfd_link_hash_defweak;
/* We replace original name with __imp_ prefixed, this
1) may trash memory 2) leads to duplicate symbol generation.
- Still, IMHO it's better than having name poluted. */
+ Still, IMHO it's better than having name polluted. */
undef->root.string = sym->root.string;
undef->u.def.value = sym->u.def.value;
undef->u.def.section = sym->u.def.section;
}
}
}
+ free (buf);
}
static bfd_boolean
status = bfd_bread (&b, (bfd_size_type) 1, abfd);
if (status < 1)
- {
- break;
- }
+ {
+ break;
+ }
(*process) (&b, 1, arg);
filepos += 1;
{
struct bfd_link_order *l = NULL;
for (l = asec->map_head.link_order; l != NULL; l = l->next)
- {
- if (l->type == bfd_indirect_link_order)
- {
- if (l->u.indirect.section == t->build_id.sec)
- {
- link_order = l;
- break;
- }
- }
- }
+ {
+ if (l->type == bfd_indirect_link_order)
+ {
+ if (l->u.indirect.section == t->build_id.sec)
+ {
+ link_order = l;
+ break;
+ }
+ }
+ }
if (link_order)
- break;
+ break;
}
if (!link_order)
{
einfo (_("%P: warning: .buildid section discarded,"
- " --build-id ignored.\n"));
+ " --build-id ignored.\n"));
return TRUE;
}
if (!validate_build_id_style (emit_build_id))
{
- einfo ("%P: warning: unrecognized --build-id style ignored.\n");
+ einfo (_("%P: warning: unrecognized --build-id style ignored.\n"));
return FALSE;
}
return TRUE;
}
- einfo ("%P: warning: Cannot create .buildid section,"
- " --build-id ignored.\n");
+ einfo (_("%P: warning: Cannot create .buildid section,"
+ " --build-id ignored.\n"));
return FALSE;
}
if (nrelocs < 0)
{
free (relocs);
- einfo ("%X%P: unable to process relocs: %E\n");
+ einfo (_("%X%P: unable to process relocs: %E\n"));
return;
}
/* Alternate explicit import library for dll's. */
{ "%s.dll.a", FALSE },
/* "libfoo.a" could be either an import lib or a static lib.
- For backwards compatibility, libfoo.a needs to precede
- libfoo.dll and foo.dll in the search. */
+ For backwards compatibility, libfoo.a needs to precede
+ libfoo.dll and foo.dll in the search. */
{ "lib%s.a", FALSE },
/* The 'native' spelling of an import lib name is "foo.lib". */
{ "%s.lib", FALSE },
hll_default,
gld_${EMULATION_NAME}_after_parse,
gld_${EMULATION_NAME}_after_open,
+ after_check_relocs_default,
after_allocation_default,
set_output_arch_default,
ldemul_default_target,