summaryrefslogtreecommitdiff
path: root/ldso/ldso/nios2/dl-startup.h
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2016-05-28 18:12:58 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-11-04 00:03:07 +0100
commitb8fcdddcbb192fc367ff04bbd753b9deb69b09f3 (patch)
tree8febdb9d4e3d090e9273c29df9ff06116196c8e4 /ldso/ldso/nios2/dl-startup.h
parent191739597c6d380692885cfdd8dd8aa4f31f029d (diff)
nios2: sync support with glibc
Only static linking is supported for now. More debugging and analyzing for ld.so, TLS and NPTL is required. But at least you can bootup a static root fileystem in Qemu.
Diffstat (limited to 'ldso/ldso/nios2/dl-startup.h')
-rw-r--r--ldso/ldso/nios2/dl-startup.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/ldso/ldso/nios2/dl-startup.h b/ldso/ldso/nios2/dl-startup.h
new file mode 100644
index 000000000..982e55532
--- /dev/null
+++ b/ldso/ldso/nios2/dl-startup.h
@@ -0,0 +1,34 @@
+__asm__ ("\
+ .text\n\
+ .globl _start\n\
+ .type _start, %function\n\
+_start:\n\
+ mov r4, sp\n\
+ br _dl_start\n\
+ mov r16, r4\n\
+ jmp r16\n\
+");
+
+/*
+ * Get a pointer to the argv array. On many platforms this can be just
+ * the address of the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS)+1)
+
+/* The ld.so library requires relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
+static __always_inline
+void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
+ unsigned long symbol_addr, unsigned long load_addr, attribute_unused Elf32_Sym *symtab)
+{
+ switch (ELF_R_TYPE(rpnt->r_info)) {
+ case R_NIOS2_RELATIVE:
+ *reloc_addr = load_addr + rpnt->r_addend;
+ break;
+ default:
+ _dl_exit(1);
+ break;
+ }
+}