aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorDavid Edelsohn <dje.gcc@gmail.com>1995-09-13 21:16:11 +0000
committerDavid Edelsohn <dje.gcc@gmail.com>1995-09-13 21:16:11 +0000
commit199f521718ba2f50a183280d0f56bc0bb58b6ef9 (patch)
treeba92453ac4911f3431ebe252127fffe2f27e9005 /binutils
parent0fc4bbe3cc20d906fbc552a57698f0ce901162fe (diff)
downloadgdb-199f521718ba2f50a183280d0f56bc0bb58b6ef9.zip
gdb-199f521718ba2f50a183280d0f56bc0bb58b6ef9.tar.gz
gdb-199f521718ba2f50a183280d0f56bc0bb58b6ef9.tar.bz2
Fix .drectve spelling (was .drective) in several comments.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/dlltool.c127
1 files changed, 80 insertions, 47 deletions
diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 7b2e36d..2b18bef 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -29,7 +29,7 @@
The export table is generated by this program by reading
in a .DEF file or scanning the .a and .o files which will be in the
- DLL. A .o file can contain information in special ".drective" sections
+ DLL. A .o file can contain information in special ".drectve" sections
with export information.
A DEF file contains any number of the following commands:
@@ -53,18 +53,18 @@
[STACKSIZE|HEAPSIZE] <number-reserve> [ , <number-commit> ]
Generates --stack|--heap <number-reserve>,<number-commit>
- in the output .drective section. The linker will
+ in the output .drectve section. The linker will
see this and act upon it.
[CODE|DATA] <attr>+
SECTIONS ( <sectionname> <attr>+ )*
<attr> = READ | WRITE | EXECUTE | SHARED
Generates --attr <sectionname> <attr> in the output
- .drective section. The linker will see this and act
+ .drectve section. The linker will see this and act
upon it.
- A -export:<name> in a .drective section in an input .o or .a
+ A -export:<name> in a .drectve section in an input .o or .a
file to this program is equivalent to a EXPORTS <name>
in a .DEF file.
@@ -175,6 +175,8 @@ char *exp_name;
char *imp_name;
char *dll_name;
+int add_indirect = 0;
+
int dontdeltemps = 0;
int yydebug;
@@ -218,17 +220,15 @@ mtable[]
{
{
#define MARM 0
-
"arm", ".byte", ".short", ".long", ".asciz", "@", "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", ".global", ".space", ".align\t2",
}
,
{
#define M386 1
"i386", ".byte", ".short", ".long", ".asciz", "#", "jmp *", ".global", ".space", ".align\t2",
-
}
,
- 0
+ 0
};
@@ -255,6 +255,17 @@ int machine;
return ".rva\t";
}
}
+
+char *asm_prefix (machine)
+{
+ switch (machine)
+ {
+ case MARM:
+ return "";
+ case M386:
+ return "_";
+ }
+}
#define ASM_BYTE mtable[machine].how_byte
#define ASM_SHORT mtable[machine].how_short
#define ASM_LONG mtable[machine].how_long
@@ -266,7 +277,7 @@ int machine;
#define ASM_ALIGN_SHORT mtable[machine].how_align_short
#define ASM_RVA_BEFORE rvabefore(machine)
#define ASM_RVA_AFTER rvaafter(machine)
-
+#define ASM_PREFIX asm_prefix(machine)
static char **oav;
int i;
@@ -567,7 +578,7 @@ void
scan_open_obj_file (abfd)
bfd *abfd;
{
- /* Look for .drectives */
+ /* Look for .drectve's */
asection *s = bfd_get_section_by_name (abfd, ".drectve");
if (s)
{
@@ -758,9 +769,9 @@ gen_exp_file ()
if (d_exports) {
fprintf (f, "\t.section .edata\n\n");
fprintf (f, "\t%s 0 %s Allways 0\n", ASM_LONG, ASM_C);
- fprintf (f, "\t%s %d %s Time and date\n", ASM_LONG, time (0), ASM_C);
+ fprintf (f, "\t%s 0 %s Time and date\n", ASM_LONG, ASM_C);
fprintf (f, "\t%s 0 %s Major and Minor version\n", ASM_LONG, ASM_C);
- fprintf (f, "\t%sname%s%s Ptr to name of dll\n", ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C);
+ fprintf (f, "\t%sname%s %s Ptr to name of dll\n", ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C);
fprintf (f, "\t%s %d %s Starting ordinal of exports\n", ASM_LONG, d_ord, ASM_C);
fprintf (f, "\t%s The next field is documented as being the number of functions\n", ASM_C);
fprintf (f, "\t%s yet it doesn't look like that in real PE dlls\n", ASM_C);
@@ -789,7 +800,8 @@ gen_exp_file ()
i = exp->ordinal;
}
#endif
- fprintf (f, "\t%s%s%s%s %d\n",ASM_RVA_BEFORE,
+ fprintf (f, "\t%s%s%s%s\t%s %d\n",ASM_RVA_BEFORE,
+ ASM_PREFIX,
exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal);
i++;
}
@@ -861,8 +873,22 @@ gen_exp_file ()
}
}
}
-
}
+
+
+ /* Add to the output file a way of getting to the exported names
+ without using the import library. */
+ if (add_indirect)
+ {
+ fprintf (f,"\t.section\t.rdata\n");
+ for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
+ if (!exp->noname) {
+ fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name);
+ fprintf (f, "__imp_%s:\n", exp->name);
+ fprintf (f,"\t%s\t%s\n", ASM_LONG, exp->name);
+ }
+ }
+
/* Dump the reloc section if a base file is provided */
if (base_file)
{
@@ -876,7 +902,7 @@ gen_exp_file ()
int on_page;
fprintf (f,"\t.section\t.init\n");
fprintf (f,"lab:\n");
- fprintf (f, "\t.section\t.reloc\n");
+
fseek (base_file, 0, SEEK_END);
numbytes = ftell (base_file);
fseek (base_file, 0, SEEK_SET);
@@ -884,25 +910,28 @@ gen_exp_file ()
fread (copy, 1, numbytes, base_file);
num_entries = numbytes / sizeof (long);
- qsort (copy, num_entries, sizeof (long), sfunc);
+ if (num_entries) {
+ fprintf (f, "\t.section\t.reloc\n");
+ qsort (copy, num_entries, sizeof (long), sfunc);
- addr = copy[0];
- page_addr = addr & PAGE_MASK; /* work out the page addr */
- on_page = 0;
- for (j = 0; j < num_entries; j++)
- {
- addr = copy[j];
- if ((addr & PAGE_MASK) != page_addr)
- {
- flush_page (f, need, page_addr, on_page);
- on_page = 0;
- page_addr = addr & PAGE_MASK;
- }
- need[on_page++] = addr;
- }
- flush_page (f, need, page_addr, on_page);
+ addr = copy[0];
+ page_addr = addr & PAGE_MASK; /* work out the page addr */
+ on_page = 0;
+ for (j = 0; j < num_entries; j++)
+ {
+ addr = copy[j];
+ if ((addr & PAGE_MASK) != page_addr)
+ {
+ flush_page (f, need, page_addr, on_page);
+ on_page = 0;
+ page_addr = addr & PAGE_MASK;
+ }
+ need[on_page++] = addr;
+ }
+ flush_page (f, need, page_addr, on_page);
- fprintf (f, "\t%s\t0,0\t%s End\n", ASM_LONG, ASM_C);
+ fprintf (f, "\t%s\t0,0\t%s End\n", ASM_LONG, ASM_C);
+ }
}
fclose (f);
@@ -936,8 +965,8 @@ xlate (char *name)
return name;
}
-
/**********************************************************************/
+static void
gen_lib_file ()
{
int i;
@@ -965,9 +994,10 @@ gen_lib_file ()
fprintf (f, "\t%shname%s\t%sPtr to image import by name list\n",
ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C);
+
fprintf (f, "\t%sthis should be the timestamp, but NT sometimes\n", ASM_C);
fprintf (f, "\t%sdoesn't load DLLs when this is set.\n", ASM_C);
- fprintf (f, "\t%s\t0\t%s time\n", ASM_LONG, ASM_C);
+ fprintf (f, "\t%s\t0\t%s loaded time\n", ASM_LONG, ASM_C);
fprintf (f, "\t%s\t0\t%s Forwarder chain\n", ASM_LONG, ASM_C);
fprintf (f, "\t%s__%s_iname%s\t%s imported dll's name\n",
ASM_RVA_BEFORE,
@@ -996,11 +1026,11 @@ gen_lib_file ()
{
sprintf (outfile, "%ss%d.s", prefix, i);
f = fopen (outfile, "w");
- fprintf (f, "\n\n\n%s ********************* \n", ASM_C);
fprintf (f, "\t.text\n");
- fprintf (f, "\t%s\t%s\n", ASM_GLOBAL, exp->name);
+ fprintf (f, "\t%s\t%s%s\n", ASM_GLOBAL, ASM_PREFIX, exp->name);
fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name);
- fprintf (f, "%s:\n\t%s\t__imp_%s\n", exp->name, ASM_JUMP, exp->name);
+ fprintf (f, "%s%s:\n\t%s\t__imp_%s\n", ASM_PREFIX,
+ exp->name, ASM_JUMP, exp->name);
fprintf (f, "\t.section\t.idata$7\t%s To force loading of head\n", ASM_C);
fprintf (f, "\t%s\t__%s_head\n", ASM_LONG, imp_name);
@@ -1091,14 +1121,14 @@ gen_lib_file ()
unlink (outfile);
}
-if (dontdeltemps < 2)
- for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
- {
- sprintf (outfile, "%ss%d.o", prefix, i);
- unlink (outfile);
- sprintf (outfile, "%ss%d.s", prefix, i);
- unlink (outfile);
- }
+ if (dontdeltemps < 2)
+ for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
+ {
+ sprintf (outfile, "%ss%d.o", prefix, i);
+ unlink (outfile);
+ sprintf (outfile, "%ss%d.s", prefix, i);
+ unlink (outfile);
+ }
}
/**********************************************************************/
@@ -1385,6 +1415,7 @@ usage (file, status)
fprintf (file, " --machine <machine>\n");
fprintf (file, " --output-exp <outname> Generate export file.\n");
fprintf (file, " --output-lib <outname> Generate input library.\n");
+ fprintf (file, " --add-indirect Add dll indirects to export file.\n");
fprintf (file, " --dllname <name> Name of input dll to put into output lib.\n");
fprintf (file, " --def <deffile> Name input .def file\n");
fprintf (file, " --base-file <basefile> Read linker generated base file\n");
@@ -1406,8 +1437,7 @@ static struct option long_options[] =
{"killat", no_argument, NULL, 'k'},
{"help", no_argument, NULL, 'h'},
{"machine", required_argument, NULL, 'm'},
- {"rva", required_argument, NULL, 'r'},
-/* {"image-base", required_argument, NULL, 'i'},*/
+ {"add-indirect", no_argument, NULL, 'a'},
{"base-file", required_argument, NULL, 'b'},
0
};
@@ -1424,10 +1454,13 @@ main (ac, av)
program_name = av[0];
oav = av;
- while ((c = getopt_long (ac, av, "D:l:e:nr:kvbuh?m:yd:", long_options, 0)) != EOF)
+ while ((c = getopt_long (ac, av, "aD:l:e:nkvbuh?m:yd:", long_options, 0)) != EOF)
{
switch (c)
{
+ case 'a':
+ add_indirect = 1;
+ break;
case 'D':
dll_name = optarg;
break;