[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] suggestion: accept def file in compatible way
From: |
lifenjoiner |
Subject: |
Re: [Tinycc-devel] suggestion: accept def file in compatible way |
Date: |
Fri, 20 Jun 2014 13:16:58 +0800 |
Hi,
If you have interest, here is my patch.
-------------------------------- tccpe.c ------------------------------------
static int pe_load_def(TCCState *s1, int fd)
{
int state = 0, ret = -1, dllindex = 0, ord;
char line[400], dllname[80], *p, *x;
FILE *fp;
fp = fdopen(dup(fd), "rb");
while (fgets(line, sizeof line, fp))
{
p = trimfront(trimback(line, strchr(line, 0)));
if (0 == *p || ';' == *p)
continue;
switch (state) {
case 0:
if (0 != strnicmp(p, "LIBRARY", 7))
goto quit;
pstrcpy(dllname, sizeof dllname, trimfront(p+7));
++state;
continue;
case 1:
if (0 != stricmp(p, "EXPORTS"))
goto quit;
++state;
continue;
case 2:
dllindex = add_dllref(s1, dllname);
++state;
/* fall through */
default:
/* get ordinal and will store in sym->st_value */
ord = 0;
x = strchr(p, ' ');
if (x) {
*x = 0, x = strrchr(x + 1, '@');
if (x) {
char *d;
ord = (int)strtol(x + 1, &d, 10);
if (*d)
ord = 0;
}
}
/*+*/ /* strip param bytes number */
/*+*/ if (*p != '?') {
/*+*/ x = strrchr(p, '@');
/*+*/ if (x) {
/*+*/ char *d;
/*+*/ strtol(x + 1, &d, 10);
/*+*/ if (*d == 0)
/*+*/ *x = 0;
/*+*/ }
/*+*/ }
pe_putimport(s1, dllindex, p, ord);
continue;
}
}
ret = 0;
quit:
fclose(fp);
return ret;
}
---------------------------------------------------------------------------
>
> Hi grischka and there,
>
> It is all about on windows.
>
> We know that TCC accept def file generated by tiny_impdef with a simplest
> format.
>
> When using 'w32api', its def file is also valuable as there are comments
> sometime. But its format is redundant, and couldn't be understood by TCC. I
> find out 3 styles:
> address@hidden
> function DATA
> C++ decorated function starts with "?"
>
> To use the def file,
>
> One way is reproduce them all by tiny_impdef or don't use them but produce the
> one when needed. It's OK.
>
> The other way I am wondering is adding a side-way pre-process, which works
> when
> needed (if condition is true). Of course it will cost time. And its benefit
> is compatibility. We don't need 2 sets of def files.
>
> What do you think?
>
tccpe.c-patch.txt
Description: Text document