Fix .drectve spelling (was .drective) in several comments.
This commit is contained in:
parent
0fc4bbe3cc
commit
199f521718
1 changed files with 80 additions and 47 deletions
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
The export table is generated by this program by reading
|
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
|
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.
|
with export information.
|
||||||
|
|
||||||
A DEF file contains any number of the following commands:
|
A DEF file contains any number of the following commands:
|
||||||
|
@ -53,18 +53,18 @@
|
||||||
|
|
||||||
[STACKSIZE|HEAPSIZE] <number-reserve> [ , <number-commit> ]
|
[STACKSIZE|HEAPSIZE] <number-reserve> [ , <number-commit> ]
|
||||||
Generates --stack|--heap <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.
|
see this and act upon it.
|
||||||
|
|
||||||
[CODE|DATA] <attr>+
|
[CODE|DATA] <attr>+
|
||||||
SECTIONS ( <sectionname> <attr>+ )*
|
SECTIONS ( <sectionname> <attr>+ )*
|
||||||
<attr> = READ | WRITE | EXECUTE | SHARED
|
<attr> = READ | WRITE | EXECUTE | SHARED
|
||||||
Generates --attr <sectionname> <attr> in the output
|
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.
|
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>
|
file to this program is equivalent to a EXPORTS <name>
|
||||||
in a .DEF file.
|
in a .DEF file.
|
||||||
|
|
||||||
|
@ -175,6 +175,8 @@ char *exp_name;
|
||||||
char *imp_name;
|
char *imp_name;
|
||||||
char *dll_name;
|
char *dll_name;
|
||||||
|
|
||||||
|
int add_indirect = 0;
|
||||||
|
|
||||||
int dontdeltemps = 0;
|
int dontdeltemps = 0;
|
||||||
|
|
||||||
int yydebug;
|
int yydebug;
|
||||||
|
@ -218,14 +220,12 @@ mtable[]
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
#define MARM 0
|
#define MARM 0
|
||||||
|
|
||||||
"arm", ".byte", ".short", ".long", ".asciz", "@", "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", ".global", ".space", ".align\t2",
|
"arm", ".byte", ".short", ".long", ".asciz", "@", "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", ".global", ".space", ".align\t2",
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
{
|
{
|
||||||
#define M386 1
|
#define M386 1
|
||||||
"i386", ".byte", ".short", ".long", ".asciz", "#", "jmp *", ".global", ".space", ".align\t2",
|
"i386", ".byte", ".short", ".long", ".asciz", "#", "jmp *", ".global", ".space", ".align\t2",
|
||||||
|
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
0
|
0
|
||||||
|
@ -255,6 +255,17 @@ int machine;
|
||||||
return ".rva\t";
|
return ".rva\t";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *asm_prefix (machine)
|
||||||
|
{
|
||||||
|
switch (machine)
|
||||||
|
{
|
||||||
|
case MARM:
|
||||||
|
return "";
|
||||||
|
case M386:
|
||||||
|
return "_";
|
||||||
|
}
|
||||||
|
}
|
||||||
#define ASM_BYTE mtable[machine].how_byte
|
#define ASM_BYTE mtable[machine].how_byte
|
||||||
#define ASM_SHORT mtable[machine].how_short
|
#define ASM_SHORT mtable[machine].how_short
|
||||||
#define ASM_LONG mtable[machine].how_long
|
#define ASM_LONG mtable[machine].how_long
|
||||||
|
@ -266,7 +277,7 @@ int machine;
|
||||||
#define ASM_ALIGN_SHORT mtable[machine].how_align_short
|
#define ASM_ALIGN_SHORT mtable[machine].how_align_short
|
||||||
#define ASM_RVA_BEFORE rvabefore(machine)
|
#define ASM_RVA_BEFORE rvabefore(machine)
|
||||||
#define ASM_RVA_AFTER rvaafter(machine)
|
#define ASM_RVA_AFTER rvaafter(machine)
|
||||||
|
#define ASM_PREFIX asm_prefix(machine)
|
||||||
static char **oav;
|
static char **oav;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
@ -567,7 +578,7 @@ void
|
||||||
scan_open_obj_file (abfd)
|
scan_open_obj_file (abfd)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
{
|
{
|
||||||
/* Look for .drectives */
|
/* Look for .drectve's */
|
||||||
asection *s = bfd_get_section_by_name (abfd, ".drectve");
|
asection *s = bfd_get_section_by_name (abfd, ".drectve");
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
|
@ -758,7 +769,7 @@ gen_exp_file ()
|
||||||
if (d_exports) {
|
if (d_exports) {
|
||||||
fprintf (f, "\t.section .edata\n\n");
|
fprintf (f, "\t.section .edata\n\n");
|
||||||
fprintf (f, "\t%s 0 %s Allways 0\n", ASM_LONG, ASM_C);
|
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%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 %d %s Starting ordinal of exports\n", ASM_LONG, d_ord, ASM_C);
|
||||||
|
@ -789,7 +800,8 @@ gen_exp_file ()
|
||||||
i = exp->ordinal;
|
i = exp->ordinal;
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
exp->internal_name, ASM_RVA_AFTER, ASM_C, exp->ordinal);
|
||||||
i++;
|
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 */
|
/* Dump the reloc section if a base file is provided */
|
||||||
if (base_file)
|
if (base_file)
|
||||||
{
|
{
|
||||||
|
@ -876,7 +902,7 @@ gen_exp_file ()
|
||||||
int on_page;
|
int on_page;
|
||||||
fprintf (f,"\t.section\t.init\n");
|
fprintf (f,"\t.section\t.init\n");
|
||||||
fprintf (f,"lab:\n");
|
fprintf (f,"lab:\n");
|
||||||
fprintf (f, "\t.section\t.reloc\n");
|
|
||||||
fseek (base_file, 0, SEEK_END);
|
fseek (base_file, 0, SEEK_END);
|
||||||
numbytes = ftell (base_file);
|
numbytes = ftell (base_file);
|
||||||
fseek (base_file, 0, SEEK_SET);
|
fseek (base_file, 0, SEEK_SET);
|
||||||
|
@ -884,6 +910,8 @@ gen_exp_file ()
|
||||||
fread (copy, 1, numbytes, base_file);
|
fread (copy, 1, numbytes, base_file);
|
||||||
num_entries = numbytes / sizeof (long);
|
num_entries = numbytes / sizeof (long);
|
||||||
|
|
||||||
|
if (num_entries) {
|
||||||
|
fprintf (f, "\t.section\t.reloc\n");
|
||||||
qsort (copy, num_entries, sizeof (long), sfunc);
|
qsort (copy, num_entries, sizeof (long), sfunc);
|
||||||
|
|
||||||
addr = copy[0];
|
addr = copy[0];
|
||||||
|
@ -904,6 +932,7 @@ gen_exp_file ()
|
||||||
|
|
||||||
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);
|
fclose (f);
|
||||||
|
|
||||||
|
@ -936,8 +965,8 @@ xlate (char *name)
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
static void
|
||||||
gen_lib_file ()
|
gen_lib_file ()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -965,9 +994,10 @@ gen_lib_file ()
|
||||||
|
|
||||||
fprintf (f, "\t%shname%s\t%sPtr to image import by name list\n",
|
fprintf (f, "\t%shname%s\t%sPtr to image import by name list\n",
|
||||||
ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C);
|
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%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%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\t0\t%s Forwarder chain\n", ASM_LONG, ASM_C);
|
||||||
fprintf (f, "\t%s__%s_iname%s\t%s imported dll's name\n",
|
fprintf (f, "\t%s__%s_iname%s\t%s imported dll's name\n",
|
||||||
ASM_RVA_BEFORE,
|
ASM_RVA_BEFORE,
|
||||||
|
@ -996,11 +1026,11 @@ gen_lib_file ()
|
||||||
{
|
{
|
||||||
sprintf (outfile, "%ss%d.s", prefix, i);
|
sprintf (outfile, "%ss%d.s", prefix, i);
|
||||||
f = fopen (outfile, "w");
|
f = fopen (outfile, "w");
|
||||||
fprintf (f, "\n\n\n%s ********************* \n", ASM_C);
|
|
||||||
fprintf (f, "\t.text\n");
|
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, "\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.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);
|
fprintf (f, "\t%s\t__%s_head\n", ASM_LONG, imp_name);
|
||||||
|
@ -1385,6 +1415,7 @@ usage (file, status)
|
||||||
fprintf (file, " --machine <machine>\n");
|
fprintf (file, " --machine <machine>\n");
|
||||||
fprintf (file, " --output-exp <outname> Generate export file.\n");
|
fprintf (file, " --output-exp <outname> Generate export file.\n");
|
||||||
fprintf (file, " --output-lib <outname> Generate input library.\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, " --dllname <name> Name of input dll to put into output lib.\n");
|
||||||
fprintf (file, " --def <deffile> Name input .def file\n");
|
fprintf (file, " --def <deffile> Name input .def file\n");
|
||||||
fprintf (file, " --base-file <basefile> Read linker generated base 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'},
|
{"killat", no_argument, NULL, 'k'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"machine", required_argument, NULL, 'm'},
|
{"machine", required_argument, NULL, 'm'},
|
||||||
{"rva", required_argument, NULL, 'r'},
|
{"add-indirect", no_argument, NULL, 'a'},
|
||||||
/* {"image-base", required_argument, NULL, 'i'},*/
|
|
||||||
{"base-file", required_argument, NULL, 'b'},
|
{"base-file", required_argument, NULL, 'b'},
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
@ -1424,10 +1454,13 @@ main (ac, av)
|
||||||
program_name = av[0];
|
program_name = av[0];
|
||||||
oav = av;
|
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)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'a':
|
||||||
|
add_indirect = 1;
|
||||||
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
dll_name = optarg;
|
dll_name = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue