Ejemplo n.º 1
0
static char *tp_from_combined_area(const struct tls_info *info,
                                   void *combined_area, size_t tdb_size) {
  size_t tls_size = info->tdata_size + info->tbss_size;
  ptrdiff_t tdboff = __nacl_tp_tdb_offset(tdb_size);
  if (tdboff < 0) {
    /*
     * The combined area is big enough to hold the TDB and then be aligned
     * up to the $tp alignment requirement.  If the whole area is aligned
     * to the $tp requirement, then aligning the beginning of the area
     * would give us the beginning unchanged, which is not what we need.
     * Instead, align from the putative end of the TDB, to decide where
     * $tp--the true end of the TDB--should actually lie.
     */
    return aligned_addr((char *) combined_area + tdb_size, info->tls_alignment);
  } else {
    /*
     * The linker increases the size of the TLS block up to its alignment
     * requirement, and that total is subtracted from the $tp address to
     * access the TLS area.  To keep that final address properly aligned,
     * we need to align up from the allocated space and then add the
     * aligned size.
     */
    tls_size = aligned_size(tls_size, info->tls_alignment);
    return aligned_addr((char *) combined_area, info->tls_alignment) + tls_size;
  }
}
Ejemplo n.º 2
0
int
is_addr_aligned(
    vmi_instance_t vmi,
    addr_t addr)
{
    return (addr == aligned_addr(vmi, addr));
}
Ejemplo n.º 3
0
void *__nacl_tls_data_bss_initialize_from_template(void *combined_area,
                                                   size_t tdb_size) {
  if (__nacl_tp_tdb_offset(tdb_size) != 0) {
    /*
     * This needs more work for ARM.
     * For now abort via null pointer dereference.
     */
    while (1) *(volatile int *) 0;
  } else {
    void *tdb = aligned_addr(((char *) combined_area) + tls_size +
                             SAFETY_PADDING , tls_align);
    return _dl_allocate_tls(tdb);
  }
}