* [PATCH 3/3] AArch64: Reformat inline-asm in elf_machine_load_address
2014-11-18 16:43 [PATCH 0/3] Rework a few of the AArch64 ILP32 patches Will Newton
2014-11-18 16:43 ` [PATCH 2/3] AArch64: Use ELF macros rather than Elf64 throughout Will Newton
2014-11-18 16:43 ` [PATCH 1/3] AArch64: Update relocations for ILP32 Will Newton
@ 2014-11-18 16:43 ` Will Newton
2014-11-21 14:39 ` Marcus Shawcroft
2 siblings, 1 reply; 7+ messages in thread
From: Will Newton @ 2014-11-18 16:43 UTC (permalink / raw)
To: libc-alpha
From: Andrew Pinski <apinski@cavium.com>
This patch reformats the inline-asm in elf_machine_load_address so it is
easier to change only part of the inline-asm. That is using string
concatenating instead of string continuation.
Also document why this inline-asm works - it depends on the 32bit
relocation being resolved at link time.
ChangeLog:
2014-11-18 Will Newton <will.newton@linaro.org>
Andrew Pinski <andrew.pinski@caviumnetworks.com>
* sysdeps/aarch64/dl-machine.h (elf_machine_load_address):
Refactor inline-asm. Also add comment.
---
sysdeps/aarch64/dl-machine.h | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index 7f5ce2b..1294369 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -52,19 +52,22 @@ elf_machine_load_address (void)
The choice of symbol is arbitrary. The static address we obtain
by constructing a non GOT reference to the symbol, the dynamic
address of the symbol we compute using adrp/add to compute the
- symbol's address relative to the PC. */
+ symbol's address relative to the PC.
+ This depends on 32bit relocations being resolved at link time
+ and that the static address fits in the 32bits. */
ElfW(Addr) static_addr;
ElfW(Addr) dynamic_addr;
- asm (" \n\
- adrp %1, _dl_start; \n\
- add %1, %1, #:lo12:_dl_start \n\
- ldr %w0, 1f \n\
- b 2f \n\
-1: .word _dl_start \n\
-2: \n\
- " : "=r" (static_addr), "=r" (dynamic_addr));
+ asm (" \n"
+" adrp %1, _dl_start; \n"
+" add %1, %1, #:lo12:_dl_start \n"
+" ldr %w0, 1f \n"
+" b 2f \n"
+"1: \n"
+" .word _dl_start \n"
+"2: \n"
+ : "=r" (static_addr), "=r" (dynamic_addr));
return dynamic_addr - static_addr;
}
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] AArch64: Update relocations for ILP32
2014-11-18 16:43 [PATCH 0/3] Rework a few of the AArch64 ILP32 patches Will Newton
2014-11-18 16:43 ` [PATCH 2/3] AArch64: Use ELF macros rather than Elf64 throughout Will Newton
@ 2014-11-18 16:43 ` Will Newton
2014-11-21 14:32 ` Marcus Shawcroft
2014-11-18 16:43 ` [PATCH 3/3] AArch64: Reformat inline-asm in elf_machine_load_address Will Newton
2 siblings, 1 reply; 7+ messages in thread
From: Will Newton @ 2014-11-18 16:43 UTC (permalink / raw)
To: libc-alpha
The latest version of the binutils ELF header defines a new set of
dynamic relocations for ILP32 and renames some to make the naming
more uniform.
ChangeLog:
2014-11-18 Will Newton <will.newton@linaro.org>
Andrew Pinski <andrew.pinski@caviumnetworks.com>
* elf/elf.h (R_AARCH64_P32_ABS32, R_AARCH64_P32_COPY,
R_AARCH64_P32_GLOB_DAT, R_AARCH64_P32_JUMP_SLOT,
R_AARCH64_P32_RELATIVE, R_AARCH64_P32_TLS_DTPMOD,
R_AARCH64_P32_TLS_DTPREL, R_AARCH64_P32_TLS_TPREL,
R_AARCH64_P32_TLSDESC, R_AARCH64_P32_IRELATIVE): Define.
(R_AARCH64_TLS_DTPMOD64): Rename to ..
(R_AARCH64_TLS_DTPMOD): This.
(R_AARCH64_TLS_DTPREL64): Rename to ...
(R_AARCH64_TLS_DTPREL): This.
(R_AARCH64_TLS_TPREL64): Rename to ...
(R_AARCH64_TLS_TPREL): This.
* sysdeps/aarch64/dl-machine.h (elf_machine_type_class): Update
R_AARCH64_TLS_DTPMOD64, R_AARCH64_TLS_DTPREL64, and
R_AARCH64_TLS_TPREL64.
(elf_machine_rela): Likewise.
---
elf/elf.h | 20 +++++++++++++++++---
sysdeps/aarch64/dl-machine.h | 12 ++++++------
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/elf/elf.h b/elf/elf.h
index 78815e8..d752343 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -2362,6 +2362,20 @@ typedef Elf32_Addr Elf32_Conflict;
/* AArch64 relocs. */
#define R_AARCH64_NONE 0 /* No relocation. */
+
+/* ILP32 AARCH64 relocs. */
+#define R_AARCH64_P32_ABS32 1 /* Direct 32 bit. */
+#define R_AARCH64_P32_COPY 180 /* Copy symbol at runtime. */
+#define R_AARCH64_P32_GLOB_DAT 181 /* Create GOT entry. */
+#define R_AARCH64_P32_JUMP_SLOT 182 /* Create PLT entry. */
+#define R_AARCH64_P32_RELATIVE 183 /* Adjust by program base. */
+#define R_AARCH64_P32_TLS_DTPMOD 184 /* Module number, 32 bit. */
+#define R_AARCH64_P32_TLS_DTPREL 185 /* Module-relative offset, 32 bit. */
+#define R_AARCH64_P32_TLS_TPREL 186 /* TP-relative offset, 32 bit. */
+#define R_AARCH64_P32_TLSDESC 187 /* TLS Descriptor. */
+#define R_AARCH64_P32_IRELATIVE 188 /* STT_GNU_IFUNC relocation. */
+
+/* LP64 AARCH64 relocs. */
#define R_AARCH64_ABS64 257 /* Direct 64 bit. */
#define R_AARCH64_ABS32 258 /* Direct 32 bit. */
#define R_AARCH64_ABS16 259 /* Direct 16-bit. */
@@ -2479,9 +2493,9 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_AARCH64_GLOB_DAT 1025 /* Create GOT entry. */
#define R_AARCH64_JUMP_SLOT 1026 /* Create PLT entry. */
#define R_AARCH64_RELATIVE 1027 /* Adjust by program base. */
-#define R_AARCH64_TLS_DTPMOD64 1028 /* Module number, 64 bit. */
-#define R_AARCH64_TLS_DTPREL64 1029 /* Module-relative offset, 64 bit. */
-#define R_AARCH64_TLS_TPREL64 1030 /* TP-relative offset, 64 bit. */
+#define R_AARCH64_TLS_DTPMOD 1028 /* Module number, 64 bit. */
+#define R_AARCH64_TLS_DTPREL 1029 /* Module-relative offset, 64 bit. */
+#define R_AARCH64_TLS_TPREL 1030 /* TP-relative offset, 64 bit. */
#define R_AARCH64_TLSDESC 1031 /* TLS Descriptor. */
#define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index 6746437..acb090d 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -188,9 +188,9 @@ _dl_start_user: \n\
#define elf_machine_type_class(type) \
((((type) == R_AARCH64_JUMP_SLOT || \
- (type) == R_AARCH64_TLS_DTPMOD64 || \
- (type) == R_AARCH64_TLS_DTPREL64 || \
- (type) == R_AARCH64_TLS_TPREL64 || \
+ (type) == R_AARCH64_TLS_DTPMOD || \
+ (type) == R_AARCH64_TLS_DTPREL || \
+ (type) == R_AARCH64_TLS_TPREL || \
(type) == R_AARCH64_TLSDESC) * ELF_RTYPE_CLASS_PLT) \
| (((type) == R_AARCH64_COPY) * ELF_RTYPE_CLASS_COPY))
@@ -314,7 +314,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
break;
}
- case R_AARCH64_TLS_DTPMOD64:
+ case R_AARCH64_TLS_DTPMOD:
#ifdef RTLD_BOOTSTRAP
*reloc_addr = 1;
#else
@@ -325,12 +325,12 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
#endif
break;
- case R_AARCH64_TLS_DTPREL64:
+ case R_AARCH64_TLS_DTPREL:
if (sym)
*reloc_addr = sym->st_value + reloc->r_addend;
break;
- case R_AARCH64_TLS_TPREL64:
+ case R_AARCH64_TLS_TPREL:
if (sym)
{
CHECK_STATIC_TLS (map, sym_map);
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 0/3] Rework a few of the AArch64 ILP32 patches
@ 2014-11-18 16:43 Will Newton
2014-11-18 16:43 ` [PATCH 2/3] AArch64: Use ELF macros rather than Elf64 throughout Will Newton
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Will Newton @ 2014-11-18 16:43 UTC (permalink / raw)
To: libc-alpha
These three patches break out some of the easier bits of the AArch64
ILP32 work from Andrew Pinksi with the intention that they can go in
relatively quickly while the rest of the series is reviewed and reworked.
Andrew Pinski (1):
AArch64: Reformat inline-asm in elf_machine_load_address
Will Newton (2):
AArch64: Update relocations for ILP32
AArch64: Use ELF macros rather than Elf64 throughout
elf/elf.h | 20 +++++++++++++++++---
sysdeps/aarch64/bits/link.h | 6 +++---
sysdeps/aarch64/dl-machine.h | 37 ++++++++++++++++++++-----------------
3 files changed, 40 insertions(+), 23 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] AArch64: Use ELF macros rather than Elf64 throughout
2014-11-18 16:43 [PATCH 0/3] Rework a few of the AArch64 ILP32 patches Will Newton
@ 2014-11-18 16:43 ` Will Newton
2014-11-21 14:37 ` Marcus Shawcroft
2014-11-18 16:43 ` [PATCH 1/3] AArch64: Update relocations for ILP32 Will Newton
2014-11-18 16:43 ` [PATCH 3/3] AArch64: Reformat inline-asm in elf_machine_load_address Will Newton
2 siblings, 1 reply; 7+ messages in thread
From: Will Newton @ 2014-11-18 16:43 UTC (permalink / raw)
To: libc-alpha
Using the macros for ELF types is required for adding ILP32 support.
In the standard AArch64 configuration this makes no difference to
the types used.
ChangeLog:
2014-11-18 Will Newton <will.newton@linaro.org>
Andrew Pinski <andrew.pinski@caviumnetworks.com>
* sysdeps/aarch64/bits/link.h (la_aarch64_gnu_pltenter): Use
ElfW macro instead of hardcoded Elf64 types.
(la_aarch64_gnu_pltenter): Likewise.
* sysdeps/aarch64/dl-machine.h
(elf_machine_runtime_setup): Use ElfW(Addr).
---
sysdeps/aarch64/bits/link.h | 6 +++---
sysdeps/aarch64/dl-machine.h | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/sysdeps/aarch64/bits/link.h b/sysdeps/aarch64/bits/link.h
index fe06827..3a84a18 100644
--- a/sysdeps/aarch64/bits/link.h
+++ b/sysdeps/aarch64/bits/link.h
@@ -40,8 +40,8 @@ typedef struct La_aarch64_retval
} La_aarch64_retval;
__BEGIN_DECLS
-extern Elf64_Addr
-la_aarch64_gnu_pltenter (Elf64_Sym *__sym, unsigned int __ndx,
+extern ElfW(Addr)
+la_aarch64_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
uintptr_t *__refcook,
uintptr_t *__defcook,
La_aarch64_regs *__regs,
@@ -50,7 +50,7 @@ la_aarch64_gnu_pltenter (Elf64_Sym *__sym, unsigned int __ndx,
long int *__framesizep);
extern unsigned int
-la_aarch64_gnu_pltexit (Elf64_Sym *__sym, unsigned int __ndx,
+la_aarch64_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
uintptr_t *__refcook,
uintptr_t *__defcook,
const La_aarch64_regs *__inregs,
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index acb090d..7f5ce2b 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -113,8 +113,8 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
}
if (l->l_info[ADDRIDX (DT_TLSDESC_GOT)] && lazy)
- *(Elf64_Addr*)(D_PTR (l, l_info[ADDRIDX (DT_TLSDESC_GOT)]) + l->l_addr)
- = (Elf64_Addr) &_dl_tlsdesc_resolve_rela;
+ *(ElfW(Addr)*)(D_PTR (l, l_info[ADDRIDX (DT_TLSDESC_GOT)]) + l->l_addr)
+ = (ElfW(Addr)) &_dl_tlsdesc_resolve_rela;
return lazy;
}
--
1.9.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] AArch64: Update relocations for ILP32
2014-11-18 16:43 ` [PATCH 1/3] AArch64: Update relocations for ILP32 Will Newton
@ 2014-11-21 14:32 ` Marcus Shawcroft
0 siblings, 0 replies; 7+ messages in thread
From: Marcus Shawcroft @ 2014-11-21 14:32 UTC (permalink / raw)
To: Will Newton; +Cc: GNU C Library
On 18 November 2014 16:43, Will Newton <will.newton@linaro.org> wrote:
> The latest version of the binutils ELF header defines a new set of
> dynamic relocations for ILP32 and renames some to make the naming
> more uniform.
>
> ChangeLog:
>
> 2014-11-18 Will Newton <will.newton@linaro.org>
> Andrew Pinski <andrew.pinski@caviumnetworks.com>
>
> * elf/elf.h (R_AARCH64_P32_ABS32, R_AARCH64_P32_COPY,
> R_AARCH64_P32_GLOB_DAT, R_AARCH64_P32_JUMP_SLOT,
> R_AARCH64_P32_RELATIVE, R_AARCH64_P32_TLS_DTPMOD,
> R_AARCH64_P32_TLS_DTPREL, R_AARCH64_P32_TLS_TPREL,
> R_AARCH64_P32_TLSDESC, R_AARCH64_P32_IRELATIVE): Define.
> (R_AARCH64_TLS_DTPMOD64): Rename to ..
> (R_AARCH64_TLS_DTPMOD): This.
> (R_AARCH64_TLS_DTPREL64): Rename to ...
> (R_AARCH64_TLS_DTPREL): This.
> (R_AARCH64_TLS_TPREL64): Rename to ...
> (R_AARCH64_TLS_TPREL): This.
> * sysdeps/aarch64/dl-machine.h (elf_machine_type_class): Update
> R_AARCH64_TLS_DTPMOD64, R_AARCH64_TLS_DTPREL64, and
> R_AARCH64_TLS_TPREL64.
> (elf_machine_rela): Likewise.
> ---
> elf/elf.h | 20 +++++++++++++++++---
> sysdeps/aarch64/dl-machine.h | 12 ++++++------
> 2 files changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/elf/elf.h b/elf/elf.h
> index 78815e8..d752343 100644
> --- a/elf/elf.h
> +++ b/elf/elf.h
> @@ -2362,6 +2362,20 @@ typedef Elf32_Addr Elf32_Conflict;
> /* AArch64 relocs. */
>
> #define R_AARCH64_NONE 0 /* No relocation. */
> +
> +/* ILP32 AARCH64 relocs. */
Nit, AArch32 and double space after period.
> +#define R_AARCH64_P32_ABS32 1 /* Direct 32 bit. */
> +#define R_AARCH64_P32_COPY 180 /* Copy symbol at runtime. */
> +#define R_AARCH64_P32_GLOB_DAT 181 /* Create GOT entry. */
> +#define R_AARCH64_P32_JUMP_SLOT 182 /* Create PLT entry. */
> +#define R_AARCH64_P32_RELATIVE 183 /* Adjust by program base. */
> +#define R_AARCH64_P32_TLS_DTPMOD 184 /* Module number, 32 bit. */
> +#define R_AARCH64_P32_TLS_DTPREL 185 /* Module-relative offset, 32 bit. */
> +#define R_AARCH64_P32_TLS_TPREL 186 /* TP-relative offset, 32 bit. */
> +#define R_AARCH64_P32_TLSDESC 187 /* TLS Descriptor. */
> +#define R_AARCH64_P32_IRELATIVE 188 /* STT_GNU_IFUNC relocation. */
> +
> +/* LP64 AARCH64 relocs. */
Nit AArch64 and double space after period.
Oherwise OK /Marcus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] AArch64: Use ELF macros rather than Elf64 throughout
2014-11-18 16:43 ` [PATCH 2/3] AArch64: Use ELF macros rather than Elf64 throughout Will Newton
@ 2014-11-21 14:37 ` Marcus Shawcroft
0 siblings, 0 replies; 7+ messages in thread
From: Marcus Shawcroft @ 2014-11-21 14:37 UTC (permalink / raw)
To: Will Newton; +Cc: GNU C Library
On 18 November 2014 16:43, Will Newton <will.newton@linaro.org> wrote:
> Using the macros for ELF types is required for adding ILP32 support.
> In the standard AArch64 configuration this makes no difference to
> the types used.
>
> ChangeLog:
>
> 2014-11-18 Will Newton <will.newton@linaro.org>
> Andrew Pinski <andrew.pinski@caviumnetworks.com>
>
> * sysdeps/aarch64/bits/link.h (la_aarch64_gnu_pltenter): Use
> ElfW macro instead of hardcoded Elf64 types.
> (la_aarch64_gnu_pltenter): Likewise.
> * sysdeps/aarch64/dl-machine.h
> (elf_machine_runtime_setup): Use ElfW(Addr).
OK /Marcus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] AArch64: Reformat inline-asm in elf_machine_load_address
2014-11-18 16:43 ` [PATCH 3/3] AArch64: Reformat inline-asm in elf_machine_load_address Will Newton
@ 2014-11-21 14:39 ` Marcus Shawcroft
0 siblings, 0 replies; 7+ messages in thread
From: Marcus Shawcroft @ 2014-11-21 14:39 UTC (permalink / raw)
To: Will Newton; +Cc: GNU C Library
On 18 November 2014 16:43, Will Newton <will.newton@linaro.org> wrote:
> From: Andrew Pinski <apinski@cavium.com>
>
> This patch reformats the inline-asm in elf_machine_load_address so it is
> easier to change only part of the inline-asm. That is using string
> concatenating instead of string continuation.
>
> Also document why this inline-asm works - it depends on the 32bit
> relocation being resolved at link time.
>
> ChangeLog:
>
> 2014-11-18 Will Newton <will.newton@linaro.org>
> Andrew Pinski <andrew.pinski@caviumnetworks.com>
>
> * sysdeps/aarch64/dl-machine.h (elf_machine_load_address):
> Refactor inline-asm. Also add comment.
OK /Marcus
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-11-21 14:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18 16:43 [PATCH 0/3] Rework a few of the AArch64 ILP32 patches Will Newton
2014-11-18 16:43 ` [PATCH 2/3] AArch64: Use ELF macros rather than Elf64 throughout Will Newton
2014-11-21 14:37 ` Marcus Shawcroft
2014-11-18 16:43 ` [PATCH 1/3] AArch64: Update relocations for ILP32 Will Newton
2014-11-21 14:32 ` Marcus Shawcroft
2014-11-18 16:43 ` [PATCH 3/3] AArch64: Reformat inline-asm in elf_machine_load_address Will Newton
2014-11-21 14:39 ` Marcus Shawcroft
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).