Executable shared object in rust

Hi everyone, I feel like this is not the right place to ask that question, though I can't really find anything more suitable.

I'm relatively new to rust and I was wondering if it's possible to rewrite my C code in rust:

#include <stdio.h>
#include <dlfcn.h>

int hello() {
  return 42;
}

void main(int _, char* argv[]) {
  printf("%s\n", argv[0]);
  void* me = dlopen(argv[0], 0x2);
  printf("%p\n", me);
  int (*hello_fn)();
  hello_fn = dlsym(me, "hello");
  printf("%p\n", hello_fn);
  printf("%d\n", hello_fn());
}

If you compile it like this: gcc -Wl,-E -fPIC -pie -ldl file.c
You will get a shared object, that is also an executable.

Example output:

./a.out
0x564b934c0290
0x7f084529e165
42

I tried rewriting it in rust already, but it seems like it's more of linking/compiling problem rather than the code itself.