diff options
-rw-r--r-- | ld/ChangeLog | 23 | ||||
-rw-r--r-- | ld/Makefile.am | 4 | ||||
-rw-r--r-- | ld/Makefile.in | 4 | ||||
-rw-r--r-- | ld/deffile.h | 5 | ||||
-rw-r--r-- | ld/deffilep.y | 1 | ||||
-rw-r--r-- | ld/emultempl/pe.em | 16 | ||||
-rw-r--r-- | ld/pe-dll.c | 25 | ||||
-rw-r--r-- | ld/pe-dll.h | 46 |
8 files changed, 98 insertions, 26 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index bda109b..66bf46e 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,26 @@ +1999-09-12 Ian Lance Taylor <ian@zembu.com> + + * pe-dll.h: New file. + * pe-dll.c: Include "pe-dll.h". Mark unused arguments as needed + to avoid warnings. + (edata_sz, reloc_sz): Change from int to size_t. + (pe_details_type): Change type of imagebase_reloc from int to + unsigned int. + (pe_detail_list): Fully initialize last entry. + (pe_dll_id_target): Change parameter to const. + (pe_dll_generate_def_file): Likewise. + (pe_dll_generate_implib): Likewise. + (pe_implied_import_dll): Likewise. Change dll_name to const. + * emultempl/pe.em: Include "pe-dll.h". Remove declarations now in + pe-dll.h. + (init): Fully initialize __dll__ entry. + (gld_${EMULATION_NAME}_after_open): Remove unused variables + sequence, elt, and i. + * deffile.h: Add preprocessor guard. + * deffilep.y (def_debug): Remove. + * Makefile.am: Rebuild dependencies. + (HFILES): Add pe-dll.h. + 1999-09-12 Donn Terry <donn@interix.com> * emultempl/pe.em (PE_DEF_SECTION_ALIGNMENT): If diff --git a/ld/Makefile.am b/ld/Makefile.am index 19153a5..7623edd 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -225,7 +225,7 @@ CFILES = ldctor.c ldemul.c ldexp.c ldfile.c ldlang.c \ HFILES = ld.h ldctor.h ldemul.h ldexp.h ldfile.h \ ldlang.h ldlex.h ldmain.h ldmisc.h ldver.h \ - ldwrite.h mri.h deffile.h + ldwrite.h mri.h deffile.h pe-dll.h GENERATED_CFILES = ldgram.c ldlex.c deffilep.c GENERATED_HFILES = ldgram.h ldemul-list.h deffilep.h @@ -883,7 +883,7 @@ pe-dll.o: pe-dll.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ $(INCDIR)/libiberty.h ld.h ldexp.h ldlang.h ldwrite.h \ ldmisc.h ldgram.h ldmain.h ldemul.h $(INCDIR)/coff/internal.h \ - ../bfd/libcoff.h deffile.h + ../bfd/libcoff.h deffile.h pe-dll.h ldgram.o: ldgram.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ ld.h ldexp.h ldver.h ldlang.h ldemul.h ldfile.h ldmisc.h \ diff --git a/ld/Makefile.in b/ld/Makefile.in index e82d6a4..48ad819 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -334,7 +334,7 @@ CFILES = ldctor.c ldemul.c ldexp.c ldfile.c ldlang.c \ HFILES = ld.h ldctor.h ldemul.h ldexp.h ldfile.h \ ldlang.h ldlex.h ldmain.h ldmisc.h ldver.h \ - ldwrite.h mri.h deffile.h + ldwrite.h mri.h deffile.h pe-dll.h GENERATED_CFILES = ldgram.c ldlex.c deffilep.c @@ -1564,7 +1564,7 @@ pe-dll.o: pe-dll.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ $(INCDIR)/libiberty.h ld.h ldexp.h ldlang.h ldwrite.h \ ldmisc.h ldgram.h ldmain.h ldemul.h $(INCDIR)/coff/internal.h \ - ../bfd/libcoff.h deffile.h + ../bfd/libcoff.h deffile.h pe-dll.h ldgram.o: ldgram.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ ld.h ldexp.h ldver.h ldlang.h ldemul.h ldfile.h ldmisc.h \ diff --git a/ld/deffile.h b/ld/deffile.h index 3c6c1ce..e2c710d 100644 --- a/ld/deffile.h +++ b/ld/deffile.h @@ -19,6 +19,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef DEFFILE_H +#define DEFFILE_H + #include "ansidecl.h" /* DEF storage definitions. Note that any ordinal may be zero, and @@ -121,3 +124,5 @@ extern void def_file_add_directive PARAMS ((def_file * _def, extern void def_file_print PARAMS ((FILE * _file, def_file * _def)); #endif + +#endif /* DEFFILE_H */ diff --git a/ld/deffilep.y b/ld/deffilep.y index aacde6b..70e517c 100644 --- a/ld/deffilep.y +++ b/ld/deffilep.y @@ -93,7 +93,6 @@ static void def_version PARAMS ((int, int)); static void def_directive PARAMS ((char *)); static int def_parse PARAMS ((void)); static int def_error PARAMS ((const char *)); -static int def_debug; static int def_lex PARAMS ((void)); static int lex_forced_token = 0; diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 019c41d..db2a5ee 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -45,6 +45,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "../bfd/libcoff.h" #include "../bfd/libbfd.h" #include "deffile.h" +#include "pe-dll.h" #define TARGET_IS_${EMULATION_NAME} @@ -89,13 +90,9 @@ static struct internal_extra_pe_aouthdr pe; static int dll; static int support_old_code = 0; static char * thumb_entry_symbol = NULL; -extern def_file *pe_def_file; static lang_assignment_statement_type *image_base_statement = 0; static char *pe_out_def_filename = 0; -extern int pe_dll_export_everything; -extern int pe_dll_kill_ats; -extern int pe_dll_stdcall_aliases; static int pe_enable_stdcall_fixup = -1; /* 0=disable 1=enable */ static char *pe_implib_filename = 0; @@ -195,7 +192,7 @@ static definfo init[] = #define IMAGEBASEOFF 0 D(ImageBase,"__image_base__", NT_EXE_IMAGE_BASE), #define DLLOFF 1 - {&dll, sizeof(dll), 0, "__dll__"}, + {&dll, sizeof(dll), 0, "__dll__", 0}, D(SectionAlignment,"__section_alignment__", PE_DEF_SECTION_ALIGNMENT), D(FileAlignment,"__file_alignment__", PE_DEF_FILE_ALIGNMENT), D(MajorOperatingSystemVersion,"__major_os_version__", 4), @@ -701,10 +698,10 @@ gld_${EMULATION_NAME}_after_open () #endif { - static int sequence = 0; int is_ms_arch; - bfd *cur_arch = 0, *elt; + bfd *cur_arch = 0; lang_input_statement_type *is2; + /* Careful - this is a shell script. Watch those dollar signs! */ /* Microsoft import libraries have every member named the same, and not in the right order for us to link them correctly. We @@ -713,7 +710,7 @@ gld_${EMULATION_NAME}_after_open () thunks, and the sentinel(s). The head is easy; it's the one with idata2. We assume that the sentinels won't have relocs, and the thunks will. It's easier than checking the symbol - table for external references. */ + table for external references. */ LANG_FOR_EACH_INPUT_STATEMENT (is) { if (is->the_bfd->my_archive) @@ -734,9 +731,10 @@ gld_${EMULATION_NAME}_after_open () if (is_ms_arch) { - int idata2 = 0, i, reloc_count=0; + int idata2 = 0, reloc_count=0; asection *sec; char *new_name, seq; + for (sec = is->the_bfd->sections; sec; sec = sec->next) { if (strcmp (sec->name, ".idata\$2") == 0) diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 1752d66..5afdfbb 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -38,6 +38,7 @@ #include "coff/internal.h" #include "../bfd/libcoff.h" #include "deffile.h" +#include "pe-dll.h" /************************************************************************ @@ -71,12 +72,12 @@ static bfd_vma image_base; static bfd *filler_bfd; static struct sec *edata_s, *reloc_s; static unsigned char *edata_d, *reloc_d; -static int edata_sz, reloc_sz; +static size_t edata_sz, reloc_sz; typedef struct { char *target_name; char *object_target; - int imagebase_reloc; + unsigned int imagebase_reloc; int pe_arch; int bfd_arch; int underscored; @@ -93,7 +94,7 @@ static pe_details_type pe_detail_list[] = { bfd_arch_i386, 1 }, - { 0 } + { NULL, NULL, 0, 0, 0, 0 } }; static pe_details_type *pe_details; @@ -102,7 +103,7 @@ static pe_details_type *pe_details; void pe_dll_id_target (target) - char *target; + const char *target; { int i; for (i=0; pe_detail_list[i].target_name; i++) @@ -227,7 +228,7 @@ auto_export (d, n) static void process_def_file (abfd, info) - bfd *abfd; + bfd *abfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; { int i, j; @@ -489,7 +490,7 @@ build_filler_bfd (include_edata) static void generate_edata (abfd, info) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; { int i, next_ordinal; int name_table_size = 0; @@ -574,7 +575,7 @@ generate_edata (abfd, info) static void fill_edata (abfd, info) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; { int i, hint; unsigned char *edirectory; @@ -844,7 +845,7 @@ quoteput (s, f, needs_quotes) void pe_dll_generate_def_file (pe_out_def_filename) - char *pe_out_def_filename; + const char *pe_out_def_filename; { int i; FILE *out = fopen (pe_out_def_filename, "w"); @@ -1397,7 +1398,7 @@ make_one (exp, parent) void pe_dll_generate_implib (def, impfilename) def_file *def; - char *impfilename; + const char *impfilename; { int i; bfd *ar_head; @@ -1611,14 +1612,14 @@ pe_as32 (ptr) boolean pe_implied_import_dll (filename) - char *filename; + const char *filename; { bfd *dll; unsigned long pe_header_offset, opthdr_ofs, num_entries, i; unsigned long export_rva, export_size, nsections, secptr, expptr; unsigned char *expdata, *erva; unsigned long name_rvas, ordinals, nexp, ordbase; - char *dll_name; + const char *dll_name; /* No, I can't use bfd here. kernel32.dll puts its export table in the middle of the .rdata section. */ @@ -1717,7 +1718,7 @@ pe_dll_build_sections (abfd, info) void pe_exe_build_sections (abfd, info) bfd *abfd; - struct bfd_link_info *info; + struct bfd_link_info *info ATTRIBUTE_UNUSED; { pe_dll_id_target (bfd_get_target (abfd)); build_filler_bfd (0); diff --git a/ld/pe-dll.h b/ld/pe-dll.h new file mode 100644 index 0000000..b33a378 --- /dev/null +++ b/ld/pe-dll.h @@ -0,0 +1,46 @@ +/* pe-dll.h: Header file for routines used to build Windows DLLs. + Copyright (C) 1999 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#ifndef PE_DLL_H +#define PE_DLL_H + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "deffile.h" + +extern def_file *pe_def_file; +extern int pe_dll_export_everything; +extern int pe_dll_do_default_excludes; +extern int pe_dll_kill_ats; +extern int pe_dll_stdcall_aliases; + +extern void pe_dll_id_target PARAMS ((const char *)); +extern void pe_dll_add_excludes PARAMS ((const char *)); +extern void pe_dll_generate_def_file PARAMS ((const char *)); +extern void pe_dll_generate_implib PARAMS ((def_file *, const char *)); +extern void pe_process_import_defs PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean pe_implied_import_dll PARAMS ((const char *)); +extern void pe_dll_build_sections PARAMS ((bfd *, struct bfd_link_info *)); +extern void pe_exe_build_sections PARAMS ((bfd *, struct bfd_link_info *)); +extern void pe_dll_fill_sections PARAMS ((bfd *, struct bfd_link_info *)); +extern void pe_exe_fill_sections PARAMS ((bfd *, struct bfd_link_info *)); + +#endif /* PE_DLL_H */ |