* [PATCH roland/arm-elf_machine_dynamic] ARM: Rewrite elf_machine_dynamic in pure C.
@ 2013-05-06 21:14 Roland McGrath
2013-05-07 15:30 ` Joseph S. Myers
0 siblings, 1 reply; 2+ messages in thread
From: Roland McGrath @ 2013-05-06 21:14 UTC (permalink / raw)
To: libc-ports
I don't know the history of why it was ever anything but this.
Today, the compiler produces code for both -marm and -mthumb that is
just about identical to what we had hand-written here. Perhaps it
dates from a time when attribute_hidden wasn't available or wasn't
reliable?
For new variants like arm-nacl, using C leverages the compiler's
knowledge of special requirements and avoids having to get another
variant defined by hand. Is there any reason not to use C everywhere?
Thanks,
Roland
ports/ChangeLog.arm
* sysdeps/arm/dl-machine.h (elf_machine_dynamic): Use a plain C
reference to _GLOBAL_OFFSET_TABLE_ with an STV_HIDDEN declaration.
--- a/ports/sysdeps/arm/dl-machine.h
+++ b/ports/sysdeps/arm/dl-machine.h
@@ -39,30 +39,13 @@ elf_machine_matches_host (const Elf32_Ehdr *ehdr)
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
- first element of the GOT. We used to use the PIC register to do this
- without a constant pool reference, but GCC 4.2 will use a pseudo-register
- for the PIC base, so it may not be in r10. */
+ first element of the GOT. */
static inline Elf32_Addr __attribute__ ((unused))
elf_machine_dynamic (void)
{
- Elf32_Addr dynamic;
-#ifdef __thumb2__
- long tmp;
- asm ("ldr\t%0, 1f\n\t"
- "adr\t%1, 1f\n\t"
- "ldr\t%0, [%0, %1]\n\t"
- "b 2f\n"
- ".align 2\n"
- "1: .word _GLOBAL_OFFSET_TABLE_ - 1b\n"
- "2:" : "=r" (dynamic), "=r"(tmp));
-#else
- asm ("ldr %0, 2f\n"
- "1: ldr %0, [pc, %0]\n"
- "b 3f\n"
- "2: .word _GLOBAL_OFFSET_TABLE_ - (1b+8)\n"
- "3:" : "=r" (dynamic));
-#endif
- return dynamic;
+ /* Declaring this hidden ensures that a PC-relative reference is used. */
+ extern const Elf32_Addr _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
+ return _GLOBAL_OFFSET_TABLE_[0];
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH roland/arm-elf_machine_dynamic] ARM: Rewrite elf_machine_dynamic in pure C.
2013-05-06 21:14 [PATCH roland/arm-elf_machine_dynamic] ARM: Rewrite elf_machine_dynamic in pure C Roland McGrath
@ 2013-05-07 15:30 ` Joseph S. Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph S. Myers @ 2013-05-07 15:30 UTC (permalink / raw)
To: Roland McGrath; +Cc: libc-ports
On Mon, 6 May 2013, Roland McGrath wrote:
> * sysdeps/arm/dl-machine.h (elf_machine_dynamic): Use a plain C
> reference to _GLOBAL_OFFSET_TABLE_ with an STV_HIDDEN declaration.
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-07 15:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-06 21:14 [PATCH roland/arm-elf_machine_dynamic] ARM: Rewrite elf_machine_dynamic in pure C Roland McGrath
2013-05-07 15:30 ` Joseph S. Myers
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).