From: Stafford Horne <shorne@gmail.com>
To: openrisc@lists.librecores.org
Subject: [OpenRISC] [PATCH 5/8] or1k: TLS offset to use tcb size and section alignment
Date: Fri, 15 May 2020 06:00:15 +0900 [thread overview]
Message-ID: <20200514210018.2749462-6-shorne@gmail.com> (raw)
In-Reply-To: <20200514210018.2749462-1-shorne@gmail.com>
The offset was wrong and causing issues when the TLS section alignment
is larger than TCB_SIZE.
In or1k we have:
/- TP
V
[ Pthread | TCB 0x0 0x0 0x0 | TDATA , TBSS ]
Here TDATA is not at TP, but TDATA is offset by the alignment. TP points
to just after the TCB. With this patch I adjust for that TCB padding
due to alignment which was not being properly accounted for before.
This allows glibc nptl and elf tests to pass.
bfd/ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* elf32-or1k.c (TCB_SIZE): New macro.
(tpoff): Use TCB_SIZE and alignment to calculate offset.
---
bfd/elf32-or1k.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index eee418c558..ca1b61fe1c 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -884,6 +884,9 @@ static const struct or1k_reloc_map or1k_reloc_map[] =
#define TLS_IE 8
#define TLS_LE 16
+/* The size of the TLS thread control block, used to offset LE access. */
+#define TCB_SIZE 16
+
/* ELF linker hash entry. */
struct elf_or1k_link_hash_entry
{
@@ -1052,14 +1055,22 @@ or1k_info_to_howto_rela (bfd * abfd,
static bfd_vma
tpoff (struct bfd_link_info *info, bfd_vma address)
{
+ struct elf_link_hash_table *htab = elf_hash_table (info);
+ bfd_vma base;
+
/* If tls_sec is NULL, we should have signalled an error already. */
- if (elf_hash_table (info)->tls_sec == NULL)
+ if (htab->tls_sec == NULL)
return 0;
+ /* On or1k, the tp points to just after the tcb, if we have an alignment
+ greater than the tcb size we need to offset by the alignment difference. */
+ base = align_power ((bfd_vma) TCB_SIZE, htab->tls_sec->alignment_power)
+ - TCB_SIZE;
+
/* The thread pointer on or1k stores the address after the TCB where
the data is, just compute the difference. No need to compensate
for the size of TCB. */
- return (address - elf_hash_table (info)->tls_sec->vma);
+ return address - htab->tls_sec->vma + base;
}
/* If we have both IE and GD accesses to a symbol the IE relocations should be
--
2.26.2
next prev parent reply other threads:[~2020-05-14 21:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-14 21:00 [OpenRISC] [PATCH 0/8] OpenRISC BFD fixups for Glibc Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 1/8] or1k: Fix static linking when with .rela.got relocations Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 2/8] or1k: Fix dynamic TLS symbol flag Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 3/8] or1k: Add TLS mask to handle multiple model access Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 4/8] or1k: Fix issue with multiple PCREL relocations Stafford Horne
2020-05-14 21:00 ` Stafford Horne [this message]
2020-05-14 21:00 ` [OpenRISC] [PATCH 6/8] or1k: refactor: Rename p to sec_relocs Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 7/8] or1k: refactor: Rename s to sgot and splt Stafford Horne
2020-05-14 21:00 ` [OpenRISC] [PATCH 8/8] or1k: Add dynamic flag to tpoff Stafford Horne
2020-05-19 13:30 ` [OpenRISC] [PATCH 0/8] OpenRISC BFD fixups for Glibc Nick Clifton
2020-05-19 20:42 ` Stafford Horne
2020-05-20 10:41 ` Nick Clifton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200514210018.2749462-6-shorne@gmail.com \
--to=shorne@gmail.com \
--cc=openrisc@lists.librecores.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox