Skip to content

Commit

Permalink
NaCl: Use allocate_code_data after dyncode_create
Browse files Browse the repository at this point in the history
  • Loading branch information
frobtech committed Nov 21, 2015
1 parent 2d2c271 commit f549f0b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2015-11-20 Roland McGrath <[email protected]>

* sysdeps/nacl/dl-map-segments.h (_dl_map_segments): Use
__glibc_likely instead of __builtin_expect. After falling back to
dyncode_create in a non-ET_DYN case, use the allocate_code_data
system interface to register the code pages as occupied.

2015-11-20 Joseph Myers <[email protected]>

* sysdeps/arm/math_private.h [!_MATH_PRIVATE_H]: Change guard to
Expand Down
28 changes: 27 additions & 1 deletion sysdeps/nacl/dl-map-segments.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ _dl_map_segments (struct link_map *l, int fd,
const size_t maplength, bool has_holes,
struct link_map *loader)
{
if (__builtin_expect (type, ET_DYN) == ET_DYN)
if (__glibc_likely (type == ET_DYN))
{
/* This is a position-independent shared object. Let the system
choose where to place it.
Expand Down Expand Up @@ -165,6 +165,32 @@ _dl_map_segments (struct link_map *l, int fd,
errno = error;
return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
}
if (__glibc_unlikely (type != ET_DYN))
{
/* A successful PROT_EXEC mmap would have implicitly
updated the bookkeeping so that a future
allocate_code_data call would know that this range
of the address space is already occupied. That
doesn't happen implicitly with dyncode_create, so
it's necessary to do an explicit call to update the
bookkeeping. */
uintptr_t allocated_address;
error = __nacl_irt_code_data_alloc.allocate_code_data
(l->l_addr + c->mapstart, len, 0, 0, &allocated_address);
if (__glibc_unlikely (error))
{
errno = error;
return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
}
if (__glibc_unlikely
(allocated_address != l->l_addr + c->mapstart))
{
/* This is not a very helpful error for this case,
but there isn't really anything better to use. */
errno = ENOMEM;
return DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT;
}
}
}
else
{
Expand Down

0 comments on commit f549f0b

Please sign in to comment.