Index: pe-dll.c =================================================================== RCS file: /cvs/src/src/ld/pe-dll.c,v retrieving revision 1.26 diff -u -r1.26 pe-dll.c --- pe-dll.c 2001/08/21 11:42:57 1.26 +++ pe-dll.c 2001/09/08 20:56:57 @@ -982,10 +982,10 @@ pe_walk_relocs_of_symbol (info, name, cb) struct bfd_link_info *info; CONST char *name; - int (*cb) (arelent *); + int (*cb) (arelent *, asection *); { bfd *b; - struct sec *s; + asection *s; for (b = info->input_bfds; b; b = b->link_next) { @@ -1003,7 +1003,7 @@ && s->output_section == bfd_abs_section_ptr) continue; - current_sec=s; + current_sec = s; symsize = bfd_get_symtab_upper_bound (b); symbols = (asymbol **) xmalloc (symsize); @@ -1016,7 +1016,7 @@ for (i = 0; i < nrelocs; i++) { struct symbol_cache_entry *sym = *relocs[i]->sym_ptr_ptr; - if (!strcmp(name,sym->name)) cb(relocs[i]); + if (!strcmp(name,sym->name)) cb(relocs[i], s); } free (relocs); /* Warning: the allocated symbols are remembered in BFD and reused @@ -1908,7 +1908,7 @@ /* we convert reloc to symbol, for later reference */ static int counter; static char *fixup_name = NULL; - static int buffer_len = 0; + static unsigned int buffer_len = 0; struct symbol_cache_entry *sym = *rel->sym_ptr_ptr; Index: pe-dll.h =================================================================== RCS file: /cvs/src/src/ld/pe-dll.h,v retrieving revision 1.4 diff -u -r1.4 pe-dll.h --- pe-dll.h 2001/08/02 23:12:02 1.4 +++ pe-dll.h 2001/09/08 20:56:57 @@ -48,7 +48,7 @@ extern void pe_walk_relocs_of_symbol PARAMS ((struct bfd_link_info * info, CONST char *name, - int (*cb) (arelent *))); + int (*cb) (arelent *, asection *))); extern void pe_create_import_fixup PARAMS ((arelent * rel)); #endif /* PE_DLL_H */ Index: emultempl/pe.em =================================================================== RCS file: /cvs/src/src/ld/emultempl/pe.em,v retrieving revision 1.50 diff -u -r1.50 pe.em --- pe.em 2001/08/31 13:30:12 1.50 +++ pe.em 2001/09/08 20:57:12 @@ -127,7 +127,7 @@ static boolean pe_undef_cdecl_match PARAMS ((struct bfd_link_hash_entry *, PTR)); static void pe_fixup_stdcalls PARAMS ((void)); -static int make_import_fixup PARAMS ((arelent *)); +static int make_import_fixup PARAMS ((arelent *, asection *)); static void pe_find_data_imports PARAMS ((void)); #endif @@ -845,20 +845,36 @@ } static int -make_import_fixup (rel) +make_import_fixup (rel, s) arelent *rel; + asection *s; { struct symbol_cache_entry *sym = *rel->sym_ptr_ptr; -/* - bfd *b; -*/ if (pe_dll_extra_pe_debug) { printf ("arelent: %s@%#x: add=%li\n", sym->name, (int) rel->address, rel->addend); } - pe_create_import_fixup (rel); + + { + int addend = 0; + if (!bfd_get_section_contents(s->owner, s, &addend, rel->address, sizeof(addend))) + { + einfo (_("%C: Cannot get section contents - auto-import exception\n"), + s->owner, s, rel->address); + } + + if (addend == 0) + pe_create_import_fixup (rel); + else + { + einfo (_("%C: aggregate '%T' is referenced in direct addressing mode with constant offset - auto-import failed. Workarounds: a) mark the symbol with __declspec(dllimport); b) use auxiliary variable\n"), + s->owner, s, rel->address, sym->name); + einfo ("%X"); + } + } + return 1; } @@ -931,6 +947,8 @@ struct bfd_hash_entry *h; PTR string ATTRIBUTE_UNUSED; { + (void)string; + if (pe_dll_extra_pe_debug) { printf("+%s\n",h->string);