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

    <tr>
        <th>Summary</th>
        <td>
            mmap() addr error through orc jit
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    for an example code:
```
#include <stdint.h>
#include <cstdio>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
int main(){
  uint64_t* p;
  p = (uint64_t*)0x750000;
  printf("p addr: %p\n", p);
  uint64_t* ptr = static_cast<uint64_t*>(mmap((void*)p, 8192, PROT_READ | PROT_WRITE,
                   MAP_PRIVATE | MAP_ANON, -1, 0));
  printf("ptr addr: %p\n", ptr);
  printf("%d\n",ptr==p);
  munmap((void*)ptr, 8192);
  return 0;
}
```
if compile through clang/gcc and run it, it will show the output
```
p addr: 0x750000
ptr addr: 0x750000
1
```
but when run it through orcjit (just like [KaleidoscopeJIT.h](https://github.com/llvm/llvm-project/blob/main/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h) and llvm version >=13), output is like
```
p addr: 0x750000
ptr addr: 0xffff74380000
0
```
for given addr for mmap(), the return addr should be the same. But seems in orcjit, the mmap() work at a random address but not the given address.
if this is a bug?and whether there are solutions to fixed it or other alternative solutions. I'm trying to use the code to implement brk(), and error occurs on both x86_64 and aarch64. Hope for help



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVclu4zgQ_Rr5UmhBplYfdHDsBJ0ZTHcQBDNHg6JoiwklClyc5O-nSG9Kj30YtCDJKNWr_RXdqPaz3ioNdAD-QftRcmCq5VG6jJJ1lCyjIjneB5GkYmDStRyidGVsKwYbd1F6f03NvF7dULpBoPqmrfk0EXnoezrchGzZYOVEi6lAT8UQkSoii6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