Page MenuHomeFreeBSD

D31538.diff
No OneTemporary

D31538.diff

diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c
--- a/libexec/rtld-elf/amd64/reloc.c
+++ b/libexec/rtld-elf/amd64/reloc.c
@@ -548,29 +548,26 @@
}
size_t
-calculate_first_tls_offset(size_t size, size_t align, size_t offset)
+calculate_tls_offset(size_t prev_offset, size_t prev_size __unused,
+ size_t size, size_t align, size_t offset)
{
size_t res;
- res = roundup(size, align);
- offset &= align - 1;
- if (offset != 0)
- res += align - offset;
- return (res);
+ /*
+ * res is the smallest integer satisfying res - prev_offset >= size
+ * and (-res) % p_align = p_vaddr % p_align (= p_offset % p_align).
+ */
+ res = prev_offset + size + align - 1;
+ res -= (res + offset) & (align - 1);
+ return (res);
}
size_t
-calculate_tls_offset(size_t prev_offset, size_t prev_size __unused, size_t size,
- size_t align, size_t offset)
+calculate_first_tls_offset(size_t size, size_t align, size_t offset)
{
- size_t res;
-
- res = roundup(prev_offset + size, align);
- offset &= align - 1;
- if (offset != 0)
- res += align - offset;
- return (res);
+ return (calculate_tls_offset(0, 0, size, align, offset));
}
+
size_t
calculate_tls_end(size_t off, size_t size __unused)
{
diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c
--- a/libexec/rtld-elf/i386/reloc.c
+++ b/libexec/rtld-elf/i386/reloc.c
@@ -539,29 +539,26 @@
}
size_t
-calculate_first_tls_offset(size_t size, size_t align, size_t offset)
+calculate_tls_offset(size_t prev_offset, size_t prev_size __unused,
+ size_t size, size_t align, size_t offset)
{
size_t res;
- res = roundup(size, align);
- offset &= align - 1;
- if (offset != 0)
- res += align - offset;
- return (res);
+ /*
+ * res is the smallest integer satisfying res - prev_offset >= size
+ * and (-res) % p_align = p_vaddr % p_align (= p_offset % p_align).
+ */
+ res = prev_offset + size + align - 1;
+ res -= (res + offset) & (align - 1);
+ return (res);
}
size_t
-calculate_tls_offset(size_t prev_offset, size_t prev_size __unused, size_t size,
- size_t align, size_t offset)
+calculate_first_tls_offset(size_t size, size_t align, size_t offset)
{
- size_t res;
-
- res = roundup(prev_offset + size, align);
- offset &= align - 1;
- if (offset != 0)
- res += align - offset;
- return (res);
+ return (calculate_tls_offset(0, 0, size, align, offset));
}
+
size_t
calculate_tls_end(size_t off, size_t size __unused)
{

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 11, 2:55 AM (17 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15749309
Default Alt Text
D31538.diff (2 KB)

Event Timeline