Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
Cannot mmap after switching to 64 bit mode in a Linux user-space process that started as 32-bit

I tried to do an mmap syscall after switching to 64 bit mode on x86 Linux (Linux version 5.15.6), but the syscall returns ENOMEM. A minimal reproducible example is given by the following assembly code:

.text
.global _start

_start:
.code32

jmp $0x33, $start64 // jmp to start64 and change mode to 64 bit

.code64
start64:

mov $9, %rax // mmap
mov $0, %rdi // NULL
mov $0x1000, %rsi // size
mov $1, %rdx // PROT_READ
mov $0x22, %r10
mov $0, %r8
mov $0, %r9
syscall

mov $60, %rax // 64 bit style exit
mov $0, %rdi
syscall

The corresponding output of strace is:

execve("./mmap_test32", ["./mmap_test32"], 0x7ffe0ccd7920 /* 60 vars */) = 0
mmap(NULL, 4096, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0) = -1 ENOMEM (Cannot allocate memory)
exit(0)                                 = ?
+++ exited with 0 +++

Does anyone have an idea why this is not working?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!