Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107099873
D31538.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D31538.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D31538: rtld: Fix i386/amd64 TP offset when p_vaddr % p_align != 0
Attached
Detach File
Event Timeline
Log In to Comment