<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59167>59167</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            ifunc does not require resolver function to have no arguments
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          arsenm
      </td>
    </tr>
</table>

<pre>
    For some reason, both clang and gcc seem to not perform any verification on ifunc resolver functions. Both accept resolver functions taking arguments and produce code. As far as I can tell, this is totally invalid. The GCC documentation states "the resolver's declaration is be a function returning pointer to void function returning void". 

[My skimming of the glibc sources suggests nothing can ever be passed here](https://sourceware.org/git?p=glibc.git;a=blob;f=sysdeps/x86_64/dl-irel.h;h=412bf18de3dc422659e5b11d75ce3de455cb705f;hb=HEAD#l32) for x86.

However, [AArch64's elf_ifunc_invoke has a little more going on](https://sourceware.org/git?p=glibc.git;a=blob;f=sysdeps/aarch64/dl-irel.h;h=88a45abeff338f756f9c35a43e2d20378f197026;hb=HEAD#l33). I'm not sure if user functions should/need to be looking for this hwcap argument.

```
int foo(int x) {
    return x + 1;
}

int bar(int x) {
    return x + 2;
}

// These arguments should not be allowed
extern "C" void *resolver(int x, int y) {
    return x ? (void*)foo : (void*) bar;
}

__attribute__((ifunc("resolver")))
extern int call_ifunc(int x, int y);


int caller() {
    return call_ifunc(3, 9) + 4;
}

```

I was looking into adding an IR verifier check for ifunc types, but a frontend error is probably needed before doing that.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VUtz4zYM_jXyBbMai7JeBx0ce93NoZdO7x6KhCxuKNElqST-9wUpO4mbTaeXemibDxD48OHBzshLezAWnBkRLHJnpoTtoDN-AKH5dAI-STgJAQ5xBG9gMh7OaHtjRzq7wDNa1SvBvTIT0FD9PAlS5YymIwircORSeAhKuRB49r84B8-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