Skip to content

Commit 34d3bd8

Browse files
committed
Document the mmap(...) failed runtime error
Fixes a usability issue. Some users miss the warning message. So now the runtime loader will tell the user to check the manpage & the manpage now documents the fix.
1 parent edd845b commit 34d3bd8

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

doc/e9patch.1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,19 @@ Default: \fBfalse\fR (disabled)
194194
.TP
195195
\fB\-\-version\fR
196196
Print the version and exit.
197+
.SH "TROUBLESHOOTING"
198+
The instrumented binary may sometimes fail to run properly.
199+
See below for solutions to common problems.
200+
.TP
201+
\fBe9patch loader error: mmap(...) failed (errno=12)\fR
202+
This occurs when the instrumented binary uses too many mappings.
203+
This can usually be fixed by lowering the compression level,
204+
see the \fB--compression\fR option for E9Tool (see \fBman e9tool\fR).
205+
.TP
206+
\fBTrace/breakpoint trap\fR
207+
If using Control Flow Recovery (CFR) mode, the input binary may be
208+
incompatible.
209+
Disable CFR to resolve the issue.
197210
.SH "SEE ALSO"
198211
\fIe9tool\fR(1), \fIe9compile\fR(1), \fIe9afl\fR(1), \fIredfat\fR(1)
199212
.SH AUTHOR

src/e9patch/e9loader_elf.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,22 @@ static NO_INLINE void e9load_maps(const e9_map_s *maps, uint32_t num_maps,
147147
int prot = (maps[i].r? PROT_READ: 0x0) |
148148
(maps[i].w? PROT_WRITE: 0x0) |
149149
(maps[i].x? PROT_EXEC: 0x0);
150+
int flags = MAP_FIXED | MAP_PRIVATE;
150151
#if 0
151152
e9debug("mmap(addr=%p,size=%U,offset=+%U,prot=%c%c%c)",
152153
addr, len, offset,
153154
(maps[i].r? 'r': '-'), (maps[i].w? 'w': '-'),
154155
(maps[i].x? 'x': '-'));
155156
#endif
156-
intptr_t result = mmap((void *)addr, len, prot, MAP_FIXED | MAP_PRIVATE,
157-
fd, offset);
157+
intptr_t result = mmap((void *)addr, len, prot, flags, fd, offset);
158158
if (result < 0)
159159
e9panic("mmap(addr=%p,size=%U,offset=+%U,prot=%c%c%c) failed "
160-
"(errno=%u)", addr, len, offset,
160+
"(errno=%u)%s", addr, len, offset,
161161
(maps[i].r? 'r': '-'), (maps[i].w? 'w': '-'),
162-
(maps[i].x? 'x': '-'), -(int)result);
162+
(maps[i].x? 'x': '-'), -(int)result,
163+
(-(int)result == ENOMEM?
164+
"\nhint: see the e9patch manpage for more information.":
165+
""));
163166
}
164167
}
165168

0 commit comments

Comments
 (0)