Managed to construct simple compiler - which pick up function
prototypes on entry and produces a wrappers for function calls.

E.g. like this:

typedef void (*pPointerToFunction_fancy_abort) (const char* a, int b,
const char* c);

void  fancy_abort(const char* a, int b, const char* c)
{
    ((pPointerToFunction_fancy_abort) g_jumpTable_gcc_wrapped[3])(a,
b, c);
} //fancy_abort

...
typedef struct pointer_set_t* (*pPointerToFunction_pointer_set_create)
(void );

struct pointer_set_t*  pointer_set_create(void )
{
    return ((pPointerToFunction_pointer_set_create)
g_jumpTable_gcc_wrapped[7])();
} //pointer_set_create

And number of unresolved functions decreased. But - then I've came
accross
functions having a prototype void error (const char *, ...) - with
varying amount of arguments.

http://stackoverflow.com/questions/150543/forward-an-invocation-of-a-variadic-function-in-c
http://c-faq.com/varargs/handoff.html

However forwading calls with ... requires similar functions with
va_list instead of "...".
During my hardvesting on internet I have found libffi - see
http://en.wikipedia.org/wiki/Libffi
http://sourceware.org/libffi/

which turns out to be quite intresting library just for what I would
like to achieve.
However one of missing features of libffi is:

   * There is no support for calling varargs functions.  This may work
     on some platforms, depending on how the ABI is defined, but it is
     not reliable.

So - the same wall.

Gonna think something about overriding with defines
#define error(format, ...)
(pPointerToFunction_error) g_jumpTable_gcc_wrapped[7]) (format,
##__VA_ARGS__)

or even
#define error (pPointerToFunction_error) g_jumpTable_gcc_wrapped[7])

last one might produce more problems.

If I recall correctly '...' is not supported by $m compiler, but
should be supported by gcc.

Best way probably would be to try to identify what functions from gcc
are actually needed
and try to retune interfaces so that you would not need a huge list of
all possible helper functions
in gcc. E.g. pointer_set functionality could be simply copied into
dehydra can recompiled in dehydra
as built in functionality.

_______________________________________________
dev-static-analysis mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-static-analysis

Reply via email to