Re: [PATCH v4 03/15] ARC: startup and dynamic linking code

2020-03-25 Thread Vineet Gupta
On 3/25/20 6:55 PM, Joseph Myers wrote:
> Do you mean DTPOFF?  Otherwise I'm not sure what DTSOFF is.

Fixed.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v4 03/15] ARC: startup and dynamic linking code

2020-03-25 Thread Joseph Myers
On Thu, 12 Mar 2020, Vineet Gupta via Libc-alpha wrote:

> +case R_ARC_TLS_DTPOFF:
> +  if (sym != NULL)
> +/* Offset set by the linker in the GOT entry would be overwritten
> +   by dynamic loader instead of added to the symbol location.
> +   Other target have the same approach on DTSOFF relocs.  */

Do you mean DTPOFF?  Otherwise I'm not sure what DTSOFF is.

-- 
Joseph S. Myers
jos...@codesourcery.com

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v4 03/15] ARC: startup and dynamic linking code

2020-03-12 Thread Vineet Gupta
Code for C runtime startup and dynamic loading including PLT layout.

Signed-off-by: Vineet Gupta 
---
 sysdeps/arc/bits/link.h   |  52 ++
 sysdeps/arc/dl-machine.h  | 340 ++
 sysdeps/arc/entry.h   |   5 +
 sysdeps/arc/ldsodefs.h|  43 +
 sysdeps/arc/sotruss-lib.c |  51 ++
 sysdeps/arc/start.S   |  71 
 sysdeps/arc/tst-audit.h   |  23 +++
 7 files changed, 585 insertions(+)
 create mode 100644 sysdeps/arc/bits/link.h
 create mode 100644 sysdeps/arc/dl-machine.h
 create mode 100644 sysdeps/arc/entry.h
 create mode 100644 sysdeps/arc/ldsodefs.h
 create mode 100644 sysdeps/arc/sotruss-lib.c
 create mode 100644 sysdeps/arc/start.S
 create mode 100644 sysdeps/arc/tst-audit.h

diff --git a/sysdeps/arc/bits/link.h b/sysdeps/arc/bits/link.h
new file mode 100644
index ..0acbc1349e08
--- /dev/null
+++ b/sysdeps/arc/bits/link.h
@@ -0,0 +1,52 @@
+/* Machine-specific declarations for dynamic linker interface, ARC version.
+   Copyright (C) 2009-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef_LINK_H
+# error "Never include  directly; use  instead."
+#endif
+
+/* Registers for entry into PLT on ARC.  */
+typedef struct La_arc_regs
+{
+  uint32_t lr_reg[8]; /* r0 through r7 (upto 8 args).  */
+} La_arc_regs;
+
+/* Return values for calls from PLT on ARC.  */
+typedef struct La_arc_retval
+{
+  /* For ARCv2, a 64-bit integer return value can use 2 regs.  */
+  uint32_t lrv_reg[2];
+} La_arc_retval;
+
+__BEGIN_DECLS
+
+extern ElfW(Addr) la_arc_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
+uintptr_t *__refcook,
+uintptr_t *__defcook,
+La_arc_regs *__regs,
+unsigned int *__flags,
+const char *__symname,
+long int *__framesizep);
+extern unsigned int la_arc_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_arc_regs *__inregs,
+ La_arc_retval *__outregs,
+ const char *symname);
+
+__END_DECLS
diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h
new file mode 100644
index ..610401f8336d
--- /dev/null
+++ b/sysdeps/arc/dl-machine.h
@@ -0,0 +1,340 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  ARC version.
+   Copyright (C) 1995-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "arc"
+
+#include 
+
+#ifndef ENTRY_POINT
+# error ENTRY_POINT needs to be defined for ARC
+#endif
+
+#include 
+#include 
+#include 
+
+/* Dynamic Linking ABI for ARCv2 ISA.
+
+PLT
+   < DT_PLTGOT
+  |  ld r11, [pcl, off-to-GOT[1] |  0
+  |  |  4
+   plt0   |  ld r10, [pcl, off-to-GOT[2] |  8
+  |  | 12
+  |  j [r10] | 16
+  
+  |Base address of GOT   | 20
+  
+  |  ld r12, [pcl, off-to-GOT[3] | 24
+   plt1   |