jserv / amacc

Small C Compiler generating ELF executable Arm architecture, supporting JIT execution
Other
1.01k stars 161 forks source link

After bsearch #7

Closed lecopzer closed 8 years ago

lecopzer commented 8 years ago

7094c3f

res = bsearch(&sym, sym, 2, 1, (void*) _start); // hack to jump into a function pointer
if (((void*) 0) != res)
    return retval;
else {
    printf("Error: can't find the function pointer\n");
    exit(0);
}

If return value from _start is not equal to 0, res will be NULL

In some test: tests/ptr.c tests/shift.c tests/arginc.c ... main() returns non-zero or have no return, and print the Error.

It's pretty weird to the error message "can't find the function pointer". Can't find what pointer? At this state the program finishes executing jit-progrom, if pointer means _start, "can't find" is really meaningless. Is it better message for "main function return for non-zero value: %d" or something else to let some test file (ex: tests/arginc.c only return argc + 2) make sense?

jserv commented 8 years ago

@lecopzer : Thanks for pointing the misleading messages while merging the changes done by @gapry . In fact, using bsearch is a hack to implement the semantics of jumping into specific function pointer, and it is meaningless to check its return value.

jserv commented 8 years ago

resolved in commit ba36d3f77c475c46fdd4a32deba67116545dcb24.